booleanize: try to convert string to int first
[nedit-bw.git] / HairlineMargin9.diff
blobad25f07a1b4d08703ec9c9210e73b6e326f79b45
1 From: Thorsten Haude <yoo@vranx.de>
2 Subject: Add a visual hairline to show any fixed wrap margin
4 This patch is based on:
6 http://www.vranx.de/nedit/hairline.2004-07-13.1.diff.gz
8 ---
10 doc/help.etx | 8 ++
11 source/menu.c | 16 ++++
12 source/nedit.h | 6 +
13 source/preferences.c | 128 ++++++++++++++++++++++++++++++++--
14 source/preferences.h | 2
15 source/text.c | 12 ++-
16 source/text.h | 4 +
17 source/textDisp.c | 188 ++++++++++++++++++++++++++++++++++++++++++++-------
18 source/textDisp.h | 9 +-
19 source/textP.h | 2
20 source/window.c | 63 +++++++++++++++--
21 source/window.h | 3
22 12 files changed, 398 insertions(+), 43 deletions(-)
24 diff --quilt old/doc/help.etx new/doc/help.etx
25 --- old/doc/help.etx
26 +++ new/doc/help.etx
27 @@ -3837,6 +3837,14 @@ Preferences
28 may, be wrapped at the right margin of the window, or the margin can be set
29 at a specific column.
31 +**Show Wrap Margin**
32 + Visually indicate which column is set as the wrap margin by drawing a vertical
33 + line. Choose between never, always and when wrap is enabled. "Never" turns
34 + this feature off. "Always" will show the wrap margin irrespecitive of the
35 + wrapping style. "When Wrap is Enabled" will show the wrap margin only if
36 + continuous or auto-newline wrap styles is choosen and does not show the wrap
37 + margin if wrapping is turned off.
39 **Tab Stops**
40 Set the tab distance (number of characters between tab stops) for tab
41 characters, and control tab emulation and use of tab characters in padding
42 diff --quilt old/source/menu.c new/source/menu.c
43 --- old/source/menu.c
44 +++ new/source/menu.c
45 @@ -396,6 +396,8 @@ static void setWrapTextAP(Widget w, XEve
46 Cardinal *nArgs);
47 static void setWrapMarginAP(Widget w, XEvent *event, String *args,
48 Cardinal *nArgs);
49 +static void setShowWrapMarginAP(Widget w, XEvent *event, String *args,
50 + Cardinal *nArgs);
51 static void setHighlightSyntaxAP(Widget w, XEvent *event, String *args,
52 Cardinal *nArgs);
53 static void setMakeBackupCopyAP(Widget w, XEvent *event, String *args,
54 @@ -570,6 +572,7 @@ static XtActionsRec Actions[] = {
55 {"set_auto_indent", setAutoIndentAP},
56 {"set_wrap_text", setWrapTextAP},
57 {"set_wrap_margin", setWrapMarginAP},
58 + {"set_show_wrap_margin", setShowWrapMarginAP},
59 {"set_highlight_syntax", setHighlightSyntaxAP},
60 #ifndef VMS
61 {"set_make_backup_copy", setMakeBackupCopyAP},
62 @@ -4113,6 +4116,19 @@ static void setWrapMarginAP(Widget w, XE
66 +static void setShowWrapMarginAP(Widget w, XEvent *event, String *args,
67 + Cardinal *nArgs)
69 + WindowInfo *window = WidgetToWindow(w);
70 + int showWrapMargin = 0;
72 + if (*nArgs > 0) {
73 + if (sscanf(args[0], "%d", &showWrapMargin) == 1) {
74 + SetShowWrapMargin(window, showWrapMargin);
75 + }
76 + }
79 static void setHighlightSyntaxAP(Widget w, XEvent *event, String *args,
80 Cardinal *nArgs)
82 diff --quilt old/source/nedit.h new/source/nedit.h
83 --- old/source/nedit.h
84 +++ new/source/nedit.h
85 @@ -57,6 +57,7 @@
86 #define NEDIT_DEFAULT_HELP_FG "black"
87 #define NEDIT_DEFAULT_HELP_BG "rgb:cc/cc/cc"
88 #define NEDIT_DEFAULT_CURSORLINE_BG "LightSkyBlue"
89 +#define NEDIT_DEFAULT_WRAPMARGIN_FG "black"
91 /* Tuning parameters */
92 #define SEARCHMAX 5119 /* Maximum length of search/replace strings */
93 @@ -105,6 +106,8 @@ enum wrapStyle {NO_WRAP, NEWLINE_WRAP, C
94 enum showMatchingStyle {NO_FLASH, FLASH_DELIMIT, FLASH_RANGE};
95 enum virtKeyOverride { VIRT_KEY_OVERRIDE_NEVER, VIRT_KEY_OVERRIDE_AUTO,
96 VIRT_KEY_OVERRIDE_ALWAYS };
97 +enum showWrapMarginEnums {SHOW_WRAP_MARGIN_NEVER, SHOW_WRAP_MARGIN_ALWAYS,
98 + SHOW_WRAP_MARGIN_ON_WRAP, N_SHOW_WRAP_MARGIN_STYLES};
100 /* This enum must be kept in parallel to the array TruncSubstitutionModes[]
101 in preferences.c */
102 @@ -194,6 +197,7 @@ enum colorTypes {
103 LINENO_FG_COLOR,
104 CURSOR_FG_COLOR,
105 CURSORLINE_BG_COLOR,
106 + WRAPMARGIN_FG_COLOR,
107 NUM_COLORS
110 @@ -499,6 +503,8 @@ typedef struct _WindowInfo {
111 char indentStyle; /* whether/how to auto indent */
112 char wrapMode; /* line wrap style: NO_WRAP,
113 NEWLINE_WRAP or CONTINUOUS_WRAP */
114 + int showWrapMargin; /* show wrap margin style: NEVER,
115 + ALWAYS, ON-WRAP as enums */
116 Boolean overstrike; /* is overstrike mode turned on ? */
117 char showMatchingStyle; /* How to show matching parens:
118 NO_FLASH, FLASH_DELIMIT, or
119 diff --quilt old/source/preferences.c new/source/preferences.c
120 --- old/source/preferences.c
121 +++ new/source/preferences.c
122 @@ -140,6 +140,9 @@ static char *AutoIndentTypes[N_INDENT_ST
123 #define N_VIRTKEY_OVERRIDE_MODES 3
124 static char *VirtKeyOverrideModes[N_VIRTKEY_OVERRIDE_MODES+1] = { "Never",
125 "Auto", "Always", NULL};
126 +#define N_SHOW_WRAP_MARGIN_STYLES 3
127 +static char *ShowWrapMarginStrings[N_SHOW_WRAP_MARGIN_STYLES+1] = { "Never",
128 + "Always", "When Wrap is Enabled", NULL};
130 #define N_SHOW_MATCHING_STYLES 3
131 /* For backward compatibility, "False" and "True" are still accepted.
132 @@ -237,6 +240,8 @@ typedef struct {
133 Widget cursorFgErrW;
134 Widget cursorlineBgW;
135 Widget cursorlineBgErrW;
136 + Widget wrapMarginFgW;
137 + Widget wrapMarginFgErrW;
138 WindowInfo *window;
139 } colorDialog;
141 @@ -245,6 +250,7 @@ static struct prefData {
142 int openInTab; /* open files in new tabs */
143 int wrapStyle; /* what kind of wrapping to do */
144 int wrapMargin; /* 0=wrap at window width, other=wrap margin */
145 + int showWrapMargin; /* whether to draw line at wrap margin */
146 int autoIndent; /* style for auto-indent */
147 int autoSave; /* whether automatic backup feature is on */
148 int saveOldVersion; /* whether to preserve a copy of last version */
149 @@ -850,6 +856,8 @@ static PrefDescripRec PrefDescrip[] = {
150 &PrefData.wrapStyle, AutoWrapTypes, True},
151 {"wrapMargin", "WrapMargin", PREF_INT, "0",
152 &PrefData.wrapMargin, NULL, True},
153 + {"showWrapMargin", "ShowWrapMargin", PREF_ENUM, "Never",
154 + &PrefData.showWrapMargin, ShowWrapMarginStrings, True},
155 {"autoIndent", "AutoIndent", PREF_ENUM, "Auto",
156 &PrefData.autoIndent, AutoIndentTypes, True},
157 {"autoSave", "AutoSave", PREF_BOOLEAN, "True",
158 @@ -1032,6 +1040,9 @@ static PrefDescripRec PrefDescrip[] = {
159 {"tooltipBgColor", "TooltipBgColor", PREF_STRING, "LemonChiffon1",
160 PrefData.tooltipBgColor,
161 (void *)sizeof(PrefData.tooltipBgColor), False},
162 + {"wrapMarginForeground", "WrapMarginForeground", PREF_STRING,
163 + NEDIT_DEFAULT_LINENO_FG, PrefData.colorNames[WRAPMARGIN_FG_COLOR],
164 + (void *)sizeof(PrefData.colorNames[WRAPMARGIN_FG_COLOR]), True},
165 {"shell", "Shell", PREF_STRING, "DEFAULT", PrefData.shell,
166 (void*) sizeof(PrefData.shell), True},
167 {"geometry", "Geometry", PREF_STRING, "",
168 @@ -1135,7 +1146,9 @@ static Widget TabDistText, EmTabText, Em
169 /* Module-global variables for Wrap Margin dialog */
170 static int DoneWithWrapDialog;
171 static WindowInfo *WrapDialogForWindow;
172 -static Widget WrapText, WrapTextLabel, WrapWindowToggle;
173 +static Widget WrapText, WrapTextLabel, WrapWindowToggle, ShowWrapMarginPulldown,
174 + ShowWrapMarginPulldownItems[N_SHOW_WRAP_MARGIN_STYLES],
175 + ShowWrapMarginOptMenu, ShowWrapMarginLabel;
177 /* Module-global variables for shell selection dialog */
178 static int DoneWithShellSelDialog = False;
179 @@ -1569,6 +1582,16 @@ int GetPrefWrapMargin(void)
180 return PrefData.wrapMargin;
183 +void SetPrefShowWrapMargin(int state)
185 + setIntPref(&PrefData.showWrapMargin, state);
188 +int GetPrefShowWrapMargin(void)
190 + return PrefData.showWrapMargin;
193 void SetPrefSearch(int searchType)
195 setIntPref(&PrefData.searchMethod, searchType);
196 @@ -2697,6 +2720,9 @@ void WrapMarginDialog(Widget parent, Win
197 Arg selBoxArgs[2];
198 XmString s1;
199 int margin;
200 + int showWrapMargin;
201 + int i, n;
202 + Arg args[20];
204 XtSetArg(selBoxArgs[0], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
205 XtSetArg(selBoxArgs[1], XmNautoUnmanage, False);
206 @@ -2739,16 +2765,69 @@ void WrapMarginDialog(Widget parent, Win
207 XmNbottomWidget, WrapText, NULL);
208 XmStringFree(s1);
210 + ShowWrapMarginPulldown = CreatePulldownMenu(form,
211 + "ShowWrapMarginPulldown", NULL, 0);
212 + for(i = 0; i < N_SHOW_WRAP_MARGIN_STYLES; i++) {
213 + s1 = XmStringCreateSimple(ShowWrapMarginStrings[i]);
214 + ShowWrapMarginPulldownItems[i] = XtVaCreateManagedWidget(
215 + "ShowWrapMarginPulldown",
216 + xmPushButtonWidgetClass, ShowWrapMarginPulldown,
217 + XmNlabelString, s1,
218 + XmNmarginHeight, 0,
219 + XmNuserData, (XtPointer)(long)i,
220 + NULL);
221 + XmStringFree(s1);
223 + n = 0;
224 + XtSetArg(args[n], XmNspacing, 0); n++;
225 + XtSetArg(args[n], XmNmarginWidth, 0); n++;
226 + XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
227 + XtSetArg(args[n], XmNtopWidget, WrapText); n++;
228 + XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
229 + XtSetArg(args[n], XmNsubMenuId, ShowWrapMarginPulldown); n++;
230 + ShowWrapMarginOptMenu = XmCreateOptionMenu(form,
231 + "ShowWrapMarginOptMenu", args, n);
232 + XtManageChild(ShowWrapMarginOptMenu);
234 + ShowWrapMarginLabel = XtVaCreateManagedWidget("ShowWrapMarginLabel",
235 + xmLabelGadgetClass, form,
236 + XmNlabelString, s1=XmStringCreateSimple("Show Wrap Margin"),
237 + XmNmnemonic, 'S',
238 + XmNuserData, XtParent(ShowWrapMarginOptMenu),
239 + XmNalignment, XmALIGNMENT_END,
240 + XmNtopAttachment, XmATTACH_WIDGET,
241 + XmNtopWidget, WrapText,
242 + XmNleftAttachment, XmATTACH_FORM,
243 + XmNrightAttachment, XmATTACH_WIDGET,
244 + XmNrightWidget, ShowWrapMarginOptMenu,
245 + XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
246 + XmNbottomWidget, ShowWrapMarginOptMenu,
247 + NULL);
248 + XmStringFree(s1);
250 /* Set default value */
251 - if (forWindow == NULL)
252 + if (forWindow == NULL) {
253 margin = GetPrefWrapMargin();
254 - else
255 + showWrapMargin = GetPrefShowWrapMargin();
256 + } else {
257 XtVaGetValues(forWindow->textArea, textNwrapMargin, &margin, NULL);
258 + showWrapMargin = forWindow->showWrapMargin;
261 + if (showWrapMargin > N_SHOW_WRAP_MARGIN_STYLES || showWrapMargin < 0) {
262 + fprintf(stderr, "NEdit: internal error: illegal value for showWrapMargin: %d\n", showWrapMargin);
263 + showWrapMargin = SHOW_WRAP_MARGIN_NEVER;
266 XmToggleButtonSetState(WrapWindowToggle, margin==0, True);
267 + XtVaSetValues(ShowWrapMarginOptMenu, XmNmenuHistory,
268 + ShowWrapMarginPulldownItems[showWrapMargin], NULL);
269 if (margin != 0)
270 SetIntText(WrapText, margin);
271 XtSetSensitive(WrapText, margin!=0);
272 XtSetSensitive(WrapTextLabel, margin!=0);
273 + XtSetSensitive(ShowWrapMarginOptMenu, margin!=0);
274 + XtSetSensitive(ShowWrapMarginLabel, margin!=0);
276 /* Handle mnemonic selection of buttons and focus to dialog */
277 AddDialogMnemonicHandler(form, FALSE);
278 @@ -2771,6 +2850,9 @@ static void wrapOKCB(Widget w, XtPointer
280 int wrapAtWindow, margin, stat;
281 WindowInfo *window = WrapDialogForWindow;
282 + int showWrapMargin;
283 + Widget showWrapMarginSelectedItem;
284 + XtPointer userData;
286 /* get the values that the user entered and make sure they're ok */
287 wrapAtWindow = XmToggleButtonGetState(WrapWindowToggle);
288 @@ -2790,6 +2872,14 @@ static void wrapOKCB(Widget w, XtPointer
292 + XtVaGetValues(ShowWrapMarginOptMenu, XmNmenuHistory,
293 + &showWrapMarginSelectedItem, NULL);
294 + XtVaGetValues(showWrapMarginSelectedItem, XmNuserData, &userData, NULL);
295 + showWrapMargin = (int)(long)userData;
296 + if (showWrapMargin > N_SHOW_WRAP_MARGIN_STYLES || showWrapMargin < 0) {
297 + showWrapMargin = SHOW_WRAP_MARGIN_NEVER;
300 #ifdef SGI_CUSTOM
301 /* Ask the user about saving as a default preference */
302 if (WrapDialogForWindow != NULL) {
303 @@ -2801,20 +2891,25 @@ static void wrapOKCB(Widget w, XtPointer
305 if (setDefault) {
306 SetPrefWrapMargin(margin);
307 + SetPrefShowWrapMargin(showWrapMargin);
308 SaveNEditPrefs(window->shell, GetPrefShortMenus());
311 #endif
313 /* Set the value in either the requested window or default preferences */
314 - if (WrapDialogForWindow == NULL)
315 + if (WrapDialogForWindow == NULL) {
316 SetPrefWrapMargin(margin);
317 - else {
318 + SetPrefShowWrapMargin(showWrapMargin);
319 + } else {
320 char *params[1];
321 char marginStr[25];
322 sprintf(marginStr, "%d", margin);
323 params[0] = marginStr;
324 XtCallActionProc(window->textArea, "set_wrap_margin", NULL, params, 1);
325 + sprintf(marginStr, "%d", showWrapMargin);
326 + params[0] = marginStr;
327 + XtCallActionProc(window->textArea, "set_show_wrap_margin", NULL, params, 1);
329 DoneWithWrapDialog = True;
331 @@ -2830,6 +2925,8 @@ static void wrapWindowCB(Widget w, XtPoi
333 XtSetSensitive(WrapTextLabel, !wrapAtWindow);
334 XtSetSensitive(WrapText, !wrapAtWindow);
335 + XtSetSensitive(ShowWrapMarginOptMenu, !wrapAtWindow);
336 + XtSetSensitive(ShowWrapMarginLabel, !wrapAtWindow);
340 @@ -6164,6 +6261,13 @@ static void cursorlineBgModifiedCB(Widge
341 showColorStatus(cd, cd->cursorlineBgW, cd->cursorlineBgErrW);
344 +static void wrapMarginFgModifiedCB(Widget w, XtPointer clientData,
345 + XtPointer callData)
347 + colorDialog *cd = (colorDialog *)clientData;
348 + showColorStatus(cd, cd->wrapMarginFgW, cd->wrapMarginFgErrW);
353 * Helper functions for validating colors
354 @@ -6179,7 +6283,8 @@ static int verifyAllColors(colorDialog *
355 checkColorStatus(cd, cd->hiliteBgW) &&
356 checkColorStatus(cd, cd->lineNoFgW) &&
357 checkColorStatus(cd, cd->cursorFgW) &&
358 - checkColorStatus(cd, cd->cursorlineBgW));
359 + checkColorStatus(cd, cd->cursorlineBgW) &&
360 + checkColorStatus(cd, cd->wrapMarginFgW));
363 /* Returns True if the color is valid, False if it's not */
364 @@ -6219,12 +6324,13 @@ static void updateColors(colorDialog *cd
365 *hiliteBg = XmTextGetString(cd->hiliteBgW),
366 *lineNoFg = XmTextGetString(cd->lineNoFgW),
367 *cursorFg = XmTextGetString(cd->cursorFgW),
368 - *cursorlineBg = XmTextGetString(cd->cursorlineBgW);
369 + *cursorlineBg = XmTextGetString(cd->cursorlineBgW),
370 + *wrapMarginFg = XmTextGetString(cd->wrapMarginFgW);
372 for (window = WindowList; window != NULL; window = window->next)
374 SetColors(window, textFg, textBg, selectFg, selectBg, hiliteFg,
375 - hiliteBg, lineNoFg, cursorFg, cursorlineBg);
376 + hiliteBg, lineNoFg, cursorFg, cursorlineBg, wrapMarginFg);
379 SetPrefColorName(TEXT_FG_COLOR , textFg );
380 @@ -6236,6 +6342,7 @@ static void updateColors(colorDialog *cd
381 SetPrefColorName(LINENO_FG_COLOR, lineNoFg);
382 SetPrefColorName(CURSOR_FG_COLOR, cursorFg);
383 SetPrefColorName(CURSORLINE_BG_COLOR, cursorlineBg);
384 + SetPrefColorName(WRAPMARGIN_FG_COLOR, wrapMarginFg);
386 XtFree(textFg);
387 XtFree(textBg);
388 @@ -6246,6 +6353,7 @@ static void updateColors(colorDialog *cd
389 XtFree(lineNoFg);
390 XtFree(cursorFg);
391 XtFree(cursorlineBg);
392 + XtFree(wrapMarginFg);
396 @@ -6428,6 +6536,9 @@ void ChooseColors(WindowInfo *window)
397 tmpW = addColorGroup( form, "cursorlineBg", 'r', "Cursorline Highlighting",
398 &(cd->cursorlineBgW), &(cd->cursorlineBgErrW), tmpW, 51, 99,
399 cursorlineBgModifiedCB, cd );
400 + tmpW = addColorGroup( form, "wrapMarginFg", 'w', "Wrap Margin Color",
401 + &(cd->wrapMarginFgW), &(cd->wrapMarginFgErrW), tmpW, 51, 99,
402 + wrapMarginFgModifiedCB, cd );
404 /* The left column (foregrounds) of color entry groups */
405 tmpW = addColorGroup( form, "textFg", 'P', "Plain Text Foreground",
406 @@ -6527,6 +6638,7 @@ void ChooseColors(WindowInfo *window)
407 XmTextSetString(cd->lineNoFgW, GetPrefColorName(LINENO_FG_COLOR));
408 XmTextSetString(cd->cursorFgW, GetPrefColorName(CURSOR_FG_COLOR));
409 XmTextSetString(cd->cursorlineBgW, GetPrefColorName(CURSORLINE_BG_COLOR));
410 + XmTextSetString(cd->wrapMarginFgW, GetPrefColorName(WRAPMARGIN_FG_COLOR));
412 /* Handle mnemonic selection of buttons and focus to dialog */
413 AddDialogMnemonicHandler(form, FALSE);
414 diff --quilt old/source/preferences.h new/source/preferences.h
415 --- old/source/preferences.h
416 +++ new/source/preferences.h
417 @@ -59,6 +59,8 @@ void SetPrefWrap(int state);
418 int GetPrefWrap(int langMode);
419 void SetPrefWrapMargin(int margin);
420 int GetPrefWrapMargin(void);
421 +void SetPrefShowWrapMargin(int state);
422 +int GetPrefShowWrapMargin(void);
423 void SetPrefSearchDlogs(int state);
424 int GetPrefSearchDlogs(void);
425 void SetPrefKeepSearchDlogs(int state);
426 diff --quilt old/source/text.c new/source/text.c
427 --- old/source/text.c
428 +++ new/source/text.c
429 @@ -646,6 +646,9 @@ static XtResource resources[] = {
430 {textNcursorlineBackground, textCCursorlineBackground, XmRPixel,sizeof(Pixel),
431 XtOffset(TextWidget, text.cursorlineBGPixel), XmRString,
432 NEDIT_DEFAULT_CURSORLINE_BG},
433 + {textNwrapMarginForeground, textCWrapMarginForeground, XmRPixel,sizeof(Pixel),
434 + XtOffset(TextWidget, text.wrapMarginFGPixel), XmRString,
435 + NEDIT_DEFAULT_WRAPMARGIN_FG},
436 {textNbacklightCharTypes,textCBacklightCharTypes,XmRString,sizeof(XmString),
437 XtOffset(TextWidget, text.backlightCharTypes), XmRString, NULL},
438 {textNrows, textCRows, XmRInt,sizeof(int),
439 @@ -676,6 +679,8 @@ static XtResource resources[] = {
440 XtOffset(TextWidget, text.hidePointer), XmRString, "False"},
441 {textNwrapMargin, textCWrapMargin, XmRInt, sizeof(int),
442 XtOffset(TextWidget, text.wrapMargin), XmRString, "0"},
443 + {textNshowWrapMargin, textCShowWrapMargin, XmRBoolean, sizeof(Boolean),
444 + XtOffset(TextWidget, text.showWrapMargin), XmRString, "True"},
445 {textNhScrollBar, textCHScrollBar, XmRWidget, sizeof(Widget),
446 XtOffset(TextWidget, text.hScrollBar), XmRString, ""},
447 {textNvScrollBar, textCVScrollBar, XmRWidget, sizeof(Widget),
448 @@ -831,7 +836,8 @@ static void initialize(TextWidget reques
449 new->text.continuousWrap, new->text.wrapMargin,
450 new->text.backlightCharTypes, new->text.calltipFGPixel,
451 new->text.calltipBGPixel,
452 - new->text.cursorlineBGPixel, new->text.showCursorline);
453 + new->text.cursorlineBGPixel, new->text.showCursorline,
454 + new->text.wrapMarginFGPixel, new->text.showWrapMargin);
456 /* Add mandatory delimiters blank, tab, and newline to the list of
457 delimiters. The memory use scheme here is that new values are
458 @@ -1137,6 +1143,10 @@ static Boolean setValues(TextWidget curr
459 TextDSetShowCursorline(current->text.textD, new->text.showCursorline);
462 + if (new->text.showWrapMargin != current->text.showWrapMargin) {
463 + TextDSetShowWrapMargin(current->text.textD, new->text.showWrapMargin);
466 /* When delimiters are changed, copy the memory, so that the caller
467 doesn't have to manage it, and add mandatory delimiters blank,
468 tab, and newline to the list */
469 diff --quilt old/source/textDisp.c new/source/textDisp.c
470 --- old/source/textDisp.c
471 +++ new/source/textDisp.c
472 @@ -155,7 +155,7 @@ static void blankCursorProtrusions(textD
473 static void allocateFixedFontGCs(textDisp *textD, XFontStruct *fontStruct,
474 Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel,
475 Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel,
476 - Pixel cursorlineBGPixel);
477 + Pixel cursorlineBGPixel, Pixel wrapMarginFGPixel);
478 static GC allocateGC(Widget w, unsigned long valueMask,
479 unsigned long foreground, unsigned long background, Font font,
480 unsigned long dynamicMask, unsigned long dontCareMask);
481 @@ -185,6 +185,8 @@ static int measurePropChar(const textDis
482 static Pixel allocBGColor(Widget w, char *colorName, int *ok);
483 static Pixel getRangesetColor(textDisp *textD, int ind, Pixel bground);
484 static void textDRedisplayRange(textDisp *textD, int start, int end);
485 +static void drawWrapMargin(textDisp *textD);
486 +static void redisplayCursor(textDisp *textD);
488 textDisp *TextDCreate(Widget widget, Widget hScrollBar, Widget vScrollBar,
489 Position left, Position top, Position width, Position height,
490 @@ -194,7 +196,8 @@ textDisp *TextDCreate(Widget widget, Wid
491 Pixel highlightBGPixel, Pixel cursorFGPixel, Pixel lineNumFGPixel,
492 int continuousWrap, int wrapMargin, XmString bgClassString,
493 Pixel calltipFGPixel, Pixel calltipBGPixel,
494 - Pixel cursorlineBGPixel, Boolean showCursorline)
495 + Pixel cursorlineBGPixel, Boolean showCursorline,
496 + Pixel wrapMarginFGPixel, Boolean showWrapMargin)
498 textDisp *textD;
499 XGCValues gcValues;
500 @@ -241,11 +244,13 @@ textDisp *TextDCreate(Widget widget, Wid
501 textD->lineNumFGPixel = lineNumFGPixel;
502 textD->cursorFGPixel = cursorFGPixel;
503 textD->cursorlineBGPixel = cursorlineBGPixel;
504 + textD->wrapMarginFGPixel = wrapMarginFGPixel;
505 textD->wrapMargin = wrapMargin;
506 textD->continuousWrap = continuousWrap;
507 + textD->showWrapMargin = showWrapMargin;
508 allocateFixedFontGCs(textD, fontStruct, bgPixel, fgPixel, selectFGPixel,
509 selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel,
510 - cursorlineBGPixel);
511 + cursorlineBGPixel, wrapMarginFGPixel);
512 textD->styleGC = allocateGC(textD->w, 0, 0, 0, fontStruct->fid,
513 GCClipMask|GCForeground|GCBackground, GCArcMode);
514 textD->lineNumLeft = lineNumLeft;
515 @@ -332,6 +337,7 @@ void TextDFree(textDisp *textD)
516 releaseGC(textD->w, textD->lineNumGC);
517 releaseGC(textD->w, textD->cursorlineGC);
518 releaseGC(textD->w, textD->cursorlineBGGC);
519 + releaseGC(textD->w, textD->wrapMarginGC);
520 XtFree((char *)textD->lineStarts);
521 while (TextDPopGraphicExposeQueueEntry(textD)) {
523 @@ -397,7 +403,7 @@ void TextDAttachHighlightData(textDisp *
524 void TextDSetColors(textDisp *textD, Pixel textFgP, Pixel textBgP,
525 Pixel selectFgP, Pixel selectBgP, Pixel hiliteFgP, Pixel hiliteBgP,
526 Pixel lineNoFgP, Pixel cursorFgP,
527 - Pixel cursorlineBgP)
528 + Pixel cursorlineBgP, Pixel wrapMarginFgP)
530 XGCValues values;
531 Display *d = XtDisplay(textD->w);
532 @@ -412,6 +418,7 @@ void TextDSetColors(textDisp *textD, Pix
533 textD->lineNumFGPixel = lineNoFgP;
534 textD->cursorFGPixel = cursorFgP;
535 textD->cursorlineBGPixel = cursorlineBgP;
536 + textD->wrapMarginFGPixel = wrapMarginFgP;
538 releaseGC(textD->w, textD->gc);
539 releaseGC(textD->w, textD->selectGC);
540 @@ -421,9 +428,10 @@ void TextDSetColors(textDisp *textD, Pix
541 releaseGC(textD->w, textD->lineNumGC);
542 releaseGC(textD->w, textD->cursorlineGC);
543 releaseGC(textD->w, textD->cursorlineBGGC);
544 + releaseGC(textD->w, textD->wrapMarginGC);
545 allocateFixedFontGCs(textD, textD->fontStruct, textBgP, textFgP, selectFgP,
546 selectBgP, hiliteFgP, hiliteBgP, lineNoFgP,
547 - cursorlineBgP);
548 + cursorlineBgP, wrapMarginFgP);
550 /* Change the cursor GC (the cursor GC is not shared). */
551 values.foreground = cursorFgP;
552 @@ -456,6 +464,7 @@ void TextDSetFont(textDisp *textD, XFont
553 Pixel bgPixel, fgPixel, selectFGPixel, selectBGPixel;
554 Pixel highlightFGPixel, highlightBGPixel, lineNumFGPixel;
555 Pixel cursorlineBGPixel;
556 + Pixel wrapMarginFGPixel;
557 XGCValues values;
558 XFontStruct *styleFont;
560 @@ -511,6 +520,8 @@ void TextDSetFont(textDisp *textD, XFont
561 lineNumFGPixel = values.foreground;
562 XGetGCValues(display, textD->cursorlineGC,GCForeground|GCBackground,&values);
563 cursorlineBGPixel = values.background;
564 + XGetGCValues(display, textD->wrapMarginGC, GCForeground, &values);
565 + wrapMarginFGPixel = values.foreground;
567 releaseGC(textD->w, textD->gc);
568 releaseGC(textD->w, textD->selectGC);
569 @@ -520,10 +531,11 @@ void TextDSetFont(textDisp *textD, XFont
570 releaseGC(textD->w, textD->lineNumGC);
571 releaseGC(textD->w, textD->cursorlineGC);
572 releaseGC(textD->w, textD->cursorlineBGGC);
573 + releaseGC(textD->w, textD->wrapMarginGC);
575 allocateFixedFontGCs(textD, fontStruct, bgPixel, fgPixel, selectFGPixel,
576 selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel,
577 - cursorlineBGPixel);
578 + cursorlineBGPixel, wrapMarginFGPixel);
579 XSetFont(display, textD->styleGC, fontStruct->fid);
581 /* Do a full resize to force recalculation of font related parameters */
582 @@ -681,6 +693,9 @@ void TextDRedisplayRect(textDisp *textD,
583 /* draw the line numbers if exposed area includes them */
584 if (textD->lineNumWidth != 0 && left <= textD->lineNumLeft + textD->lineNumWidth)
585 redrawLineNumbers(textD, False);
587 + /* draw wrap margin incase it got erased */
588 + drawWrapMargin(textD);
592 @@ -752,19 +767,94 @@ static void textDRedisplayRange(textDisp
593 Add one to endIndex to catch the caret at the end of a range. */
594 if (startLine == lastLine) {
595 redisplayLine(textD, startLine, 0, INT_MAX, startIndex, endIndex);
596 - return;
598 + if (-1 != textD->lineStarts[startLine]
599 + || (textD->wrapMargin >= BufCountDispChars(
600 + textD->buffer, textD->lineStarts[startLine], start)
601 + && textD->wrapMargin <= BufCountDispChars(
602 + textD->buffer, textD->lineStarts[startLine], end))) {
603 + /* redraw wrap margin if it got erased */
604 + drawWrapMargin(textD);
606 + } else {
607 + /* Redisplay the first line from "start" */
608 + redisplayLine(textD, startLine, 0, INT_MAX, startIndex, INT_MAX);
610 + /* Redisplay the lines in between at their full width */
611 + for (i = startLine + 1; i < lastLine; i++) {
612 + redisplayLine(textD, i, 0, INT_MAX, 0, INT_MAX);
615 + /* Redisplay the last line to "end". Add one to the endIndex to catch
616 + the caret at the end of a range. */
617 + redisplayLine(textD, lastLine, 0, INT_MAX, 0, endIndex);
619 + /* redraw wrap margin */
620 + drawWrapMargin(textD);
623 - /* Redisplay the first line from "start" */
624 - redisplayLine(textD, startLine, 0, INT_MAX, startIndex, INT_MAX);
626 - /* Redisplay the lines in between at their full width */
627 - for (i=startLine+1; i<lastLine; i++)
628 - redisplayLine(textD, i, 0, INT_MAX, 0, INT_MAX);
630 - /* Redisplay the last line to "end". Add one to the endIndex to catch
631 - the caret at the end of a range. */
632 - redisplayLine(textD, lastLine, 0, INT_MAX, 0, endIndex);
636 +** Custom version of TextDRedisplayRange that only updates the area around
637 +** the cursor.
639 +static void redisplayCursor(textDisp *textD)
641 + int cursorLine, lineStart, start, end, startIndex, endIndex;
642 + int pos = textD->cursorPos;
643 + Boolean cursorLineChanged;
645 + /* If the cursor is outside of the displayed text, just return */
646 + if (pos + 1 < textD->firstChar || pos - 1 > textD->lastChar) {
647 + return;
650 + if (!posToVisibleLineNum(textD, pos, &cursorLine)) {
651 + /* At first sight, this can only be reached when redisplayCursor()
652 + is miscalled or when the catch above didn't work. There is at
653 + least one situation though which makes the catch helpless: If
654 + your caret is in the last line, column 1 and you move it down,
655 + textD->cursorPos will be changed *before* this function is
656 + called, the automatic scroll will be done after. */
657 + return;
660 + /* Find the position right before and after the cursor,
661 + but make sure that we stay on the same line. */
662 + lineStart = TextDStartOfLine(textD, pos);
663 + start = max(lineStart, pos - 1);
664 + end = min(pos + 1, TextDEndOfLine(textD, lineStart, True) + 1);
666 + /* Get the starting and ending positions within the line. */
667 + startIndex = start - lineStart;
668 + endIndex = end - lineStart;
670 + /* Reset the clipping rectangles for the drawing GCs which are shared
671 + using XtAllocateGC, and may have changed since the last use */
672 + resetClipRectangles(textD);
674 + cursorLineChanged = (textD->oldCursorPos != textD->cursorPos
675 + || textD->oldLineStart != lineStart);
677 + redisplayLine(textD, cursorLine, 0, INT_MAX, startIndex, endIndex);
679 + if (cursorLineChanged) {
680 + /* Hairline destroyed in old cursor line! Redraw neccessary. */
681 + drawWrapMargin(textD);
682 + return;
685 + if (BufCountDispChars(textD->buffer, lineStart, end) < textD->wrapMargin) {
686 + /* hairline is off-screen, most common case */
687 + return;
690 + if (BufCountDispChars(textD->buffer, lineStart, start)
691 + > textD->wrapMargin) {
692 + return;
695 + drawWrapMargin(textD);
699 @@ -824,7 +914,14 @@ void TextDSetInsertPosition(textDisp *te
700 /* draw it at its new position */
701 textD->cursorPos = newPos;
702 textD->cursorOn = True;
703 - textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
705 + redisplayCursor(textD);
707 + /* We have to force redraw of the hairline here: The hairline will be
708 + erased if the cursorline changes, but will not be redrawn by
709 + redisplayCursor() (only works on the area immedietely surrounding
710 + the cursor). */
711 + drawWrapMargin(textD);
714 void TextDBlankCursor(textDisp *textD)
715 @@ -834,14 +931,14 @@ void TextDBlankCursor(textDisp *textD)
717 blankCursorProtrusions(textD);
718 textD->cursorOn = False;
719 - textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
720 + redisplayCursor(textD);
723 void TextDUnblankCursor(textDisp *textD)
725 if (!textD->cursorOn) {
726 textD->cursorOn = True;
727 - textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
728 + redisplayCursor(textD);
732 @@ -850,7 +947,7 @@ void TextDSetCursorStyle(textDisp *textD
733 textD->cursorStyle = style;
734 blankCursorProtrusions(textD);
735 if (textD->cursorOn) {
736 - textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
737 + redisplayCursor(textD);
741 @@ -886,6 +983,15 @@ void TextDSetWrapMode(textDisp *textD, i
742 textD->height);
745 +void TextDSetShowWrapMargin(textDisp *textD, Boolean state)
747 + textD->showWrapMargin = state;
749 + /* Do a full redraw */
750 + TextDRedisplayRect(textD, 0, textD->top, textD->width + textD->left,
751 + textD->height);
754 int TextDGetInsertPosition(textDisp *textD)
756 return textD->cursorPos;
757 @@ -2882,7 +2988,7 @@ static void setScroll(textDisp *textD, i
758 textD->top, -xOffset, textD->height);
760 /* Restore protruding parts of the cursor */
761 - textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
762 + redisplayCursor(textD);
765 /* Refresh line number/calltip display if its up and we've scrolled
766 @@ -3170,7 +3276,7 @@ static void blankCursorProtrusions(textD
767 static void allocateFixedFontGCs(textDisp *textD, XFontStruct *fontStruct,
768 Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel,
769 Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel,
770 - Pixel cursorlineBGPixel)
771 + Pixel cursorlineBGPixel, Pixel wrapMarginFGPixel)
773 textD->gc = allocateGC(textD->w, GCFont | GCForeground | GCBackground,
774 fgPixel, bgPixel, fontStruct->fid, GCClipMask, GCArcMode);
775 @@ -3191,6 +3297,8 @@ static void allocateFixedFontGCs(textDis
776 fgPixel, cursorlineBGPixel, fontStruct->fid, GCClipMask, GCArcMode);
777 textD->cursorlineBGGC = allocateGC(textD->w, GCForeground,
778 cursorlineBGPixel, 0, fontStruct->fid, GCClipMask, GCArcMode);
779 + textD->wrapMarginGC = allocateGC(textD->w, GCForeground | GCBackground,
780 + wrapMarginFGPixel, bgPixel, fontStruct->fid, GCClipMask, GCArcMode);
784 @@ -3267,6 +3375,8 @@ static void resetClipRectangles(textDisp
785 &clipRect, 1, Unsorted);
786 XSetClipRectangles(display, textD->cursorlineBGGC, 0, 0,
787 &clipRect, 1, Unsorted);
788 + XSetClipRectangles(display, textD->wrapMarginGC, 0, 0,
789 + &clipRect, 1, Unsorted);
793 @@ -3970,3 +4080,33 @@ void TextDSetupBGClasses(Widget w, XmStr
794 memcpy(*pp_bgClass, bgClass, 256);
795 memcpy(*pp_bgClassPixel, bgClassPixel, class_no * sizeof (Pixel));
799 +** Draw wrap margin if requested
801 +static void drawWrapMargin(textDisp *textD)
803 + int fromX, fromY;
804 + int fontHeight, lineHeight;
806 + /* attempt to draw the wrap margin # only if
807 + - widget has been realized
808 + - font width is not -1, ie. not using different/proportional width fonts
809 + - show wrap margins is enabled */
810 + if (XtWindow(textD->w) != 0
811 + && textD->fixedFontWidth != -1
812 + && textD->showWrapMargin) {
813 + fromX = textD->left + (textD->fixedFontWidth * textD->wrapMargin)
814 + - textD->horizOffset - 1;
816 + /* compute rest of coordinates if line is to right of left margin */
817 + if (fromX > textD->left) {
818 + fromY = textD->top;
819 + fontHeight = textD->ascent + textD->descent;
820 + lineHeight = textD->nVisibleLines * fontHeight - 1;
821 + XDrawLine(XtDisplay(textD->w), XtWindow(textD->w),
822 + textD->wrapMarginGC, fromX, fromY, fromX,
823 + fromY + lineHeight);
827 diff --quilt old/source/textDisp.h new/source/textDisp.h
828 --- old/source/textDisp.h
829 +++ new/source/textDisp.h
830 @@ -103,6 +103,7 @@ typedef struct _textDisp {
831 int continuousWrap; /* Wrap long lines when displaying */
832 int wrapMargin; /* Margin in # of char positions for
833 wrapping in continuousWrap mode */
834 + Boolean showWrapMargin; /* draw line at wrap margin */
835 int *lineStarts;
836 int topLineNum; /* Line number of top displayed line
837 of file (first line of file is 1) */
838 @@ -151,6 +152,8 @@ typedef struct _textDisp {
839 calltipStruct calltip; /* The info for the calltip itself */
840 Pixel calltipFGPixel;
841 Pixel calltipBGPixel;
842 + Pixel wrapMarginFGPixel; /* color for drawing wrap margin */
843 + GC wrapMarginGC; /* GC for drawing wrap margin */
844 int suppressResync; /* Suppress resynchronization of line
845 starts during buffer updates */
846 int nLinesDeleted; /* Number of lines deleted during
847 @@ -175,7 +178,8 @@ textDisp *TextDCreate(Widget widget, Wid
848 Pixel highlightBGPixel, Pixel cursorFGPixel, Pixel lineNumFGPixel,
849 int continuousWrap, int wrapMargin, XmString bgClassString,
850 Pixel calltipFGPixel, Pixel calltipBGPixel,
851 - Pixel cursorlineBGPixel, Boolean showCursorline);
852 + Pixel cursorlineBGPixel, Boolean showCursorline,
853 + Pixel wrapMarginFGPixel, Boolean showWrapMargin);
854 void TextDFree(textDisp *textD);
855 void TextDSetBuffer(textDisp *textD, textBuffer *buffer);
856 void TextDAttachHighlightData(textDisp *textD, textBuffer *styleBuffer,
857 @@ -184,7 +188,7 @@ void TextDAttachHighlightData(textDisp *
858 void TextDSetColors(textDisp *textD, Pixel textFgP, Pixel textBgP,
859 Pixel selectFgP, Pixel selectBgP, Pixel hiliteFgP, Pixel hiliteBgP,
860 Pixel lineNoFgP, Pixel cursorFgP,
861 - Pixel cursorlineBgP);
862 + Pixel cursorlineBgP, Pixel wrapMarginFgP);
863 void TextDSetFont(textDisp *textD, XFontStruct *fontStruct);
864 int TextDMinFontWidth(textDisp *textD, Boolean considerStyles);
865 int TextDMaxFontWidth(textDisp *textD, Boolean considerStyles);
866 @@ -216,6 +220,7 @@ void TextDBlankCursor(textDisp *textD);
867 void TextDUnblankCursor(textDisp *textD);
868 void TextDSetCursorStyle(textDisp *textD, int style);
869 void TextDSetWrapMode(textDisp *textD, int wrap, int wrapMargin);
870 +void TextDSetShowWrapMargin(textDisp *textD, Boolean state);
871 int TextDEndOfLine(const textDisp* textD, const int pos,
872 const Boolean startPosIsLineStart);
873 int TextDStartOfLine(const textDisp* textD, const int pos);
874 diff --quilt old/source/text.h new/source/text.h
875 --- old/source/text.h
876 +++ new/source/text.h
877 @@ -63,6 +63,8 @@
878 #define textCcalltipBackground "CalltipBackground"
879 #define textNcursorlineBackground "cursorlineBackground"
880 #define textCCursorlineBackground "CursorlineBackground"
881 +#define textNwrapMarginForeground "wrapMarginForeground"
882 +#define textCWrapMarginForeground "WrapMarginForeground"
883 #define textNpendingDelete "pendingDelete"
884 #define textCPendingDelete "PendingDelete"
885 #define textNhScrollBar "hScrollBar"
886 @@ -97,6 +99,8 @@
887 #define textCContinuousWrap "ContinuousWrap"
888 #define textNwrapMargin "wrapMargin"
889 #define textCWrapMargin "WrapMargin"
890 +#define textNshowWrapMargin "showWrapMargin"
891 +#define textCShowWrapMargin "ShowWrapMargin"
892 #define textNautoIndent "autoIndent"
893 #define textCAutoIndent "AutoIndent"
894 #define textNsmartIndent "smartIndent"
895 diff --quilt old/source/textP.h new/source/textP.h
896 --- old/source/textP.h
897 +++ new/source/textP.h
898 @@ -60,6 +60,7 @@ typedef struct _TextPart {
899 Pixel selectFGPixel, selectBGPixel, highlightFGPixel, highlightBGPixel;
900 Pixel cursorFGPixel, lineNumFGPixel, calltipFGPixel, calltipBGPixel;
901 Pixel cursorlineBGPixel;
902 + Pixel wrapMarginFGPixel;
903 XFontStruct *fontStruct;
904 Boolean pendingDelete;
905 Boolean autoShowInsertPos;
906 @@ -77,6 +78,7 @@ typedef struct _TextPart {
907 int marginWidth, marginHeight;
908 int cursorBlinkRate;
909 int wrapMargin;
910 + Boolean showWrapMargin;
911 int emulateTabs;
912 int lineNumCols;
913 char *delimiters;
914 diff --quilt old/source/window.c new/source/window.c
915 --- old/source/window.c
916 +++ new/source/window.c
917 @@ -272,6 +272,7 @@ WindowInfo *CreateWindow(const char *nam
918 window->autoSave = GetPrefAutoSave();
919 window->saveOldVersion = GetPrefSaveOldVersion();
920 window->wrapMode = GetPrefWrap(PLAIN_LANGUAGE_MODE);
921 + window->showWrapMargin = GetPrefShowWrapMargin();
922 window->overstrike = False;
923 window->showMatchingStyle = GetPrefShowMatching();
924 window->matchSyntaxBased = GetPrefMatchSyntaxBased();
925 @@ -731,7 +732,8 @@ WindowInfo *CreateWindow(const char *nam
926 GetPrefColorName(HILITE_BG_COLOR),
927 GetPrefColorName(LINENO_FG_COLOR),
928 GetPrefColorName(CURSOR_FG_COLOR),
929 - GetPrefColorName(CURSORLINE_BG_COLOR));
930 + GetPrefColorName(CURSORLINE_BG_COLOR),
931 + GetPrefColorName(WRAPMARGIN_FG_COLOR));
933 /* Create the right button popup menu (note: order is important here,
934 since the translation for popping up this menu was probably already
935 @@ -1239,7 +1241,8 @@ void SplitPane(WindowInfo *window)
936 TextDSetColors( newTextD, textD->fgPixel, textD->bgPixel,
937 textD->selectFGPixel, textD->selectBGPixel, textD->highlightFGPixel,
938 textD->highlightBGPixel, textD->lineNumFGPixel,
939 - textD->cursorFGPixel, textD->cursorlineBGPixel );
940 + textD->cursorFGPixel, textD->cursorlineBGPixel,
941 + textD->wrapMarginFGPixel );
943 /* Set the minimum pane height in the new pane */
944 UpdateMinPaneHeights(window);
945 @@ -1880,7 +1883,7 @@ void SetFonts(WindowInfo *window, const
946 void SetColors(WindowInfo *window, const char *textFg, const char *textBg,
947 const char *selectFg, const char *selectBg, const char *hiliteFg,
948 const char *hiliteBg, const char *lineNoFg, const char *cursorFg,
949 - const char *cursorlineBg)
950 + const char *cursorlineBg, const char *wrapMarginFg)
952 int i, dummy;
953 Pixel textFgPix = AllocColor( window->textArea, textFg,
954 @@ -1900,6 +1903,8 @@ void SetColors(WindowInfo *window, const
955 cursorFgPix = AllocColor( window->textArea, cursorFg,
956 &dummy, &dummy, &dummy),
957 cursorlineBgPix = AllocColor( window->textArea, cursorlineBg,
958 + &dummy, &dummy, &dummy),
959 + wrapMarginFgPix = AllocColor( window->textArea, wrapMarginFg,
960 &dummy, &dummy, &dummy);
961 textDisp *textD;
963 @@ -1911,7 +1916,7 @@ void SetColors(WindowInfo *window, const
964 textD = ((TextWidget)window->textArea)->text.textD;
965 TextDSetColors( textD, textFgPix, textBgPix, selectFgPix, selectBgPix,
966 hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix,
967 - cursorlineBgPix );
968 + cursorlineBgPix, wrapMarginFgPix );
969 /* Update any additional panes */
970 for (i=0; i<window->nPanes; i++) {
971 XtVaSetValues(window->textPanes[i],
972 @@ -1921,7 +1926,7 @@ void SetColors(WindowInfo *window, const
973 textD = ((TextWidget)window->textPanes[i])->text.textD;
974 TextDSetColors( textD, textFgPix, textBgPix, selectFgPix, selectBgPix,
975 hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix,
976 - cursorlineBgPix );
977 + cursorlineBgPix, wrapMarginFgPix );
980 /* Redo any syntax highlighting */
981 @@ -1962,6 +1967,8 @@ void SetAutoWrap(WindowInfo *window, int
982 XmToggleButtonSetState(window->continuousWrapItem, contWrap, False);
983 XmToggleButtonSetState(window->noWrapItem, state == NO_WRAP, False);
986 + SetShowWrapMargin(window, window->showWrapMargin);
990 @@ -1977,6 +1984,36 @@ void SetAutoScroll(WindowInfo *window, i
994 +** Set show-wrap-margin style, one of NEVER, ALWAYS, ON-WRAP
996 +void SetShowWrapMargin(WindowInfo *window, int state)
998 + int i;
999 + Boolean alwaysShowWrapMargin = (state == SHOW_WRAP_MARGIN_ALWAYS);
1000 + Boolean onWrapShowWrapMargin = (state == SHOW_WRAP_MARGIN_ON_WRAP);
1001 + Boolean autoWrap = (window->wrapMode == NEWLINE_WRAP);
1002 + Boolean contWrap = (window->wrapMode == CONTINUOUS_WRAP);
1003 + /* true or false only. not never/always/on-wrap. text widget does need to know
1004 + exact details. it just needs to know that wrap margin should be shown */
1005 + Boolean showWrapMargin = (alwaysShowWrapMargin
1006 + || (onWrapShowWrapMargin && autoWrap)
1007 + || (onWrapShowWrapMargin && contWrap));
1009 + XtVaSetValues(window->textArea,
1010 + textNshowWrapMargin, showWrapMargin,
1011 + NULL);
1012 + for (i = 0; i < window->nPanes; i++) {
1013 + XtVaSetValues(window->textPanes[i],
1014 + textNshowWrapMargin, showWrapMargin,
1015 + NULL);
1018 + /* never/always/on-wrap needs to be stored in window settings, for generating
1019 + menu, etc */
1020 + window->showWrapMargin = state;
1024 ** Recover the window pointer from any widget in the window, by searching
1025 ** up the widget hierarcy for the top level container widget where the
1026 ** window pointer is stored in the userData field. In a tabbed window,
1027 @@ -2234,6 +2271,15 @@ static Widget createTextArea(Widget pare
1028 int lineNumCols)
1030 Widget text, sw, hScrollBar, vScrollBar, frame;
1031 + int alwaysShowWrapMargin = (window->showWrapMargin == SHOW_WRAP_MARGIN_ALWAYS);
1032 + int onWrapShowWrapMargin = (window->showWrapMargin == SHOW_WRAP_MARGIN_ON_WRAP);
1033 + int autoWrap = (window->wrapMode == NEWLINE_WRAP);
1034 + int contWrap = (window->wrapMode == CONTINUOUS_WRAP);
1035 + /* true or false only. not never/always/on-wrap. text widget does need to know
1036 + exact details. it just needs to know that wrap margin should be shown */
1037 + int showWrapMargin = (alwaysShowWrapMargin
1038 + || (onWrapShowWrapMargin && autoWrap)
1039 + || (onWrapShowWrapMargin && contWrap));
1041 /* Create a text widget inside of a scrolled window widget */
1042 sw = XtVaCreateManagedWidget("scrolledW", xmScrolledWindowWidgetClass,
1043 @@ -2257,6 +2303,7 @@ static Widget createTextArea(Widget pare
1044 textNreadOnly, IS_ANY_LOCKED(window->lockReasons),
1045 textNwordDelimiters, delimiters,
1046 textNwrapMargin, wrapMargin,
1047 + textNshowWrapMargin, showWrapMargin,
1048 textNautoIndent, window->indentStyle == AUTO_INDENT,
1049 textNsmartIndent, window->indentStyle == SMART_INDENT,
1050 textNautoWrap, window->wrapMode == NEWLINE_WRAP,
1051 @@ -3366,6 +3413,7 @@ WindowInfo* CreateDocument(WindowInfo* s
1052 window->autoSave = GetPrefAutoSave();
1053 window->saveOldVersion = GetPrefSaveOldVersion();
1054 window->wrapMode = GetPrefWrap(PLAIN_LANGUAGE_MODE);
1055 + window->showWrapMargin = GetPrefShowWrapMargin();
1056 window->overstrike = False;
1057 window->showMatchingStyle = GetPrefShowMatching();
1058 window->matchSyntaxBased = GetPrefMatchSyntaxBased();
1059 @@ -3471,7 +3519,8 @@ WindowInfo* CreateDocument(WindowInfo* s
1060 GetPrefColorName(HILITE_BG_COLOR),
1061 GetPrefColorName(LINENO_FG_COLOR),
1062 GetPrefColorName(CURSOR_FG_COLOR),
1063 - GetPrefColorName(CURSORLINE_BG_COLOR));
1064 + GetPrefColorName(CURSORLINE_BG_COLOR),
1065 + GetPrefColorName(WRAPMARGIN_FG_COLOR));
1067 /* Create the right button popup menu (note: order is important here,
1068 since the translation for popping up this menu was probably already
1069 @@ -4261,7 +4310,7 @@ static void cloneTextPanes(WindowInfo *w
1070 textD->selectFGPixel, textD->selectBGPixel,
1071 textD->highlightFGPixel,textD->highlightBGPixel,
1072 textD->lineNumFGPixel, textD->cursorFGPixel,
1073 - textD->cursorlineBGPixel);
1074 + textD->cursorlineBGPixel, textD->wrapMarginFGPixel);
1077 /* Set the minimum pane height in the new pane */
1078 diff --quilt old/source/window.h new/source/window.h
1079 --- old/source/window.h
1080 +++ new/source/window.h
1081 @@ -54,7 +54,7 @@ void SetFonts(WindowInfo *window, const
1082 void SetColors(WindowInfo *window, const char *textFg, const char *textBg,
1083 const char *selectFg, const char *selectBg, const char *hiliteFg,
1084 const char *hiliteBg, const char *lineNoFg, const char *cursorFg,
1085 - const char *cursorlineBg);
1086 + const char *cursorlineBg, const char *wrapMarginFg);
1087 void SetOverstrike(WindowInfo *window, int overstrike);
1088 void SetAutoWrap(WindowInfo *window, int state);
1089 void SetAutoScroll(WindowInfo *window, int margin);
1090 @@ -106,4 +106,5 @@ void SetToggleButtonState(WindowInfo *wi
1091 void SetSensitive(WindowInfo *window, Widget w, Boolean sensitive);
1092 void CleanUpTabBarExposeQueue(WindowInfo *window);
1093 void ChangeLastFocus(WindowInfo *window, Widget text);
1094 +void SetShowWrapMargin(WindowInfo *window, int state);
1095 #endif /* NEDIT_WINDOW_H_INCLUDED */