re-fresh
[nedit-bw.git] / CursorLine6.diff
blob506a178b7e85ba06a32c808a1bf5dc055e747677
1 From: Thorsten Haude <yoo@vranx.de>
2 From: Fredrik Corneliusson
3 Subject: Highlighted Cursorline
5 This is Thorsten Haude's patch, modified from Fredrik Corneliusson's patch
6 to provide a background color for the current line. You can find it here:
8 http://sourceforge.net/tracker/index.php?func=detail&aid=683567&group_id=11005&atid=311005
9 [ 683567 ] Highlighted Cursorline
10 cursorline.ajbj.2004-03-28.1.diff 2004-03-28 05:52
12 This coloring takes precedence over rangesets, syntax highlighting
13 backgrounds (if specified) and backlighting, but not over parenthesis match
14 highlighting nor selection.
16 It still requires work, for example for turning the cursorline highlighting
17 on and off through the GUI and through macros.
19 Thorsten has taken over this patch, integrating it with other functionality.
20 Check the patch page:
22 http://sourceforge.net/tracker/index.php?func=detail&aid=1058246&group_id=11005&atid=311005
23 [ 1058246 ] Patch Collection
25 ---
27 doc/help.etx | 4
28 source/menu.c | 28 ++++++
29 source/nedit.h | 4
30 source/preferences.c | 71 ++++++++++++----
31 source/preferences.h | 2
32 source/text.c | 18 +++-
33 source/text.h | 4
34 source/textDisp.c | 220 ++++++++++++++++++++++++++++++++++++++++++++-------
35 source/textDisp.h | 16 ++-
36 source/textP.h | 2
37 source/window.c | 62 ++++++++++----
38 source/window.h | 4
39 12 files changed, 367 insertions(+), 68 deletions(-)
41 diff --quilt old/doc/help.etx new/doc/help.etx
42 --- old/doc/help.etx
43 +++ new/doc/help.etx
44 @@ -3977,6 +3977,10 @@ Preferences
45 Show file name and path in a tooltip when moving the mouse pointer over a tab.
46 (See Tabbed_Editing_.)
48 +**Show Cursorline**
49 + Background the current line with a colored bar. Use the color dialog to
50 + change the background color.
52 **Terminate with Line Break on Save**
53 Some UNIX tools expect that files end with a line feed. If this option is
54 activated, NEdit will append one if required.
55 diff --quilt old/source/menu.c new/source/menu.c
56 --- old/source/menu.c
57 +++ new/source/menu.c
58 @@ -179,6 +179,8 @@ static void beepOnSearchWrapDefCB(Widget
59 static void keepSearchDlogsDefCB(Widget w, WindowInfo *window,
60 caddr_t callData);
61 static void searchWrapsDefCB(Widget w, WindowInfo *window, caddr_t callData);
62 +static void showCursorlineCB(Widget widget, WindowInfo *window,
63 + caddr_t callData);
64 static void appendLFCB(Widget w, WindowInfo* window, caddr_t callData);
65 static void sortOpenPrevDefCB(Widget w, WindowInfo *window, caddr_t callData);
66 static void reposDlogsDefCB(Widget w, WindowInfo *window, caddr_t callData);
67 @@ -1017,6 +1019,11 @@ Widget CreateMenuBar(Widget parent, Wind
68 "matchSyntax", "Syntax Based", 'S', matchSyntaxBasedDefCB, window,
69 GetPrefMatchSyntaxBased(), SHORT);
71 + /* Show Cursorline */
72 + window->showCursorlineItem = createMenuToggle(subPane,
73 + "showCursorlineItem", "Show Cursorline", 'x', showCursorlineCB,
74 + NULL, GetPrefShowCursorline(), FULL);
76 /* Append LF at end of files on save */
77 window->appendLFItem = createMenuToggle(subPane, "appendLFItem",
78 "Terminate with Line Break on Save", 'v', appendLFCB, NULL,
79 @@ -2177,6 +2184,25 @@ static void searchWrapsDefCB(Widget w, W
83 +static void showCursorlineCB(Widget widget, WindowInfo *unused,
84 + caddr_t callData)
86 + WindowInfo *window;
87 + Boolean state = XmToggleButtonGetState(widget);
89 + SetPrefShowCursorline(state);
90 + for (window = WindowList; window != NULL; window = window->next) {
91 + XmToggleButtonSetState(window->showCursorlineItem, state, False);
93 + if (IsTopDocument(window)) {
94 + Widget pane = (window->lastFocus
95 + ? window->lastFocus
96 + : window->textArea);
97 + XtVaSetValues(pane, textNshowCursorline, state, NULL);
98 + }
99 + }
102 static void appendLFCB(Widget w, WindowInfo* window, caddr_t callData)
104 WindowInfo *win;
105 @@ -3944,7 +3970,7 @@ static void focusPaneAP(Widget w, XEvent
106 newFocusPane = GetPaneByIndex(window, paneIndex);
108 if (newFocusPane != NULL) {
109 - window->lastFocus = newFocusPane;
110 + ChangeLastFocus(window, newFocusPane);
111 XmProcessTraversal(window->lastFocus, XmTRAVERSE_CURRENT);
113 else {
114 diff --quilt old/source/nedit.h new/source/nedit.h
115 --- old/source/nedit.h
116 +++ new/source/nedit.h
117 @@ -56,7 +56,7 @@
118 #define NEDIT_DEFAULT_CURSOR_FG "black"
119 #define NEDIT_DEFAULT_HELP_FG "black"
120 #define NEDIT_DEFAULT_HELP_BG "rgb:cc/cc/cc"
122 +#define NEDIT_DEFAULT_CURSORLINE_BG "LightSkyBlue"
124 /* Tuning parameters */
125 #define SEARCHMAX 5119 /* Maximum length of search/replace strings */
126 @@ -193,6 +193,7 @@ enum colorTypes {
127 HILITE_BG_COLOR,
128 LINENO_FG_COLOR,
129 CURSOR_FG_COLOR,
130 + CURSORLINE_BG_COLOR,
131 NUM_COLORS
134 @@ -395,6 +396,7 @@ typedef struct _WindowInfo {
135 Widget beepOnSearchWrapDefItem;
136 Widget keepSearchDlogsDefItem;
137 Widget searchWrapsDefItem;
138 + Widget showCursorlineItem;
139 Widget appendLFItem;
140 Widget sortOpenPrevDefItem;
141 Widget allTagsDefItem;
142 diff --quilt old/source/preferences.c new/source/preferences.c
143 --- old/source/preferences.c
144 +++ new/source/preferences.c
145 @@ -235,6 +235,8 @@ typedef struct {
146 Widget lineNoFgErrW;
147 Widget cursorFgW;
148 Widget cursorFgErrW;
149 + Widget cursorlineBgW;
150 + Widget cursorlineBgErrW;
151 WindowInfo *window;
152 } colorDialog;
154 @@ -320,6 +322,7 @@ static struct prefData {
155 char colorNames[NUM_COLORS][MAX_COLOR_LEN];
156 char tooltipBgColor[MAX_COLOR_LEN];
157 int undoModifiesSelection;
158 + int showCursorline;
159 int focusOnRaise;
160 Boolean honorSymlinks;
161 int truncSubstitution;
162 @@ -1022,6 +1025,10 @@ static PrefDescripRec PrefDescrip[] = {
163 {"cursorFgColor", "CursorFgColor", PREF_STRING, NEDIT_DEFAULT_CURSOR_FG,
164 PrefData.colorNames[CURSOR_FG_COLOR],
165 (void *)sizeof(PrefData.colorNames[CURSOR_FG_COLOR]), True},
166 + {"cursorlineBGColor", "CursorlineBGColor", PREF_STRING,
167 + NEDIT_DEFAULT_CURSORLINE_BG,
168 + PrefData.colorNames[CURSORLINE_BG_COLOR],
169 + (void *)sizeof(PrefData.colorNames[CURSORLINE_BG_COLOR]), True},
170 {"tooltipBgColor", "TooltipBgColor", PREF_STRING, "LemonChiffon1",
171 PrefData.tooltipBgColor,
172 (void *)sizeof(PrefData.tooltipBgColor), False},
173 @@ -1072,7 +1079,9 @@ static PrefDescripRec PrefDescrip[] = {
174 {"truncSubstitution", "TruncSubstitution", PREF_ENUM, "Fail",
175 &PrefData.truncSubstitution, TruncSubstitutionModes, False},
176 {"honorSymlinks", "HonorSymlinks", PREF_BOOLEAN, "True",
177 - &PrefData.honorSymlinks, NULL, False}
178 + &PrefData.honorSymlinks, NULL, False},
179 + {"showCursorline", "ShowCursorline", PREF_BOOLEAN, "True",
180 + &PrefData.showCursorline, NULL, True},
183 static XrmOptionDescRec OpTable[] = {
184 @@ -2194,6 +2203,16 @@ void MarkPrefsChanged(void)
185 PrefsHaveChanged = True;
188 +void SetPrefShowCursorline(Boolean value)
190 + setIntPref(&PrefData.showCursorline, (int)value);
193 +Boolean GetPrefShowCursorline(void)
195 + return PrefData.showCursorline;
199 ** Check if preferences have changed, and if so, ask the user if he wants
200 ** to re-save. Returns False if user requests cancelation of Exit (or whatever
201 @@ -6073,6 +6092,7 @@ hiliteFg HILITE_FG_COLOR
202 hiliteBg HILITE_BG_COLOR
203 lineNoFg LINENO_FG_COLOR
204 cursorFg CURSOR_FG_COLOR
205 +cursorlineBg CURSORLINE_BG_COLOR
208 #define MARGIN_SPACING 10
209 @@ -6136,6 +6156,13 @@ static void cursorFgModifiedCB(Widget w,
210 showColorStatus(cd, cd->cursorFgW, cd->cursorFgErrW);
213 +static void cursorlineBgModifiedCB(Widget w, XtPointer clientData,
214 + XtPointer callData)
216 + colorDialog *cd = (colorDialog *)clientData;
217 + showColorStatus(cd, cd->cursorlineBgW, cd->cursorlineBgErrW);
222 * Helper functions for validating colors
223 @@ -6150,7 +6177,8 @@ static int verifyAllColors(colorDialog *
224 checkColorStatus(cd, cd->hiliteFgW) &&
225 checkColorStatus(cd, cd->hiliteBgW) &&
226 checkColorStatus(cd, cd->lineNoFgW) &&
227 - checkColorStatus(cd, cd->cursorFgW) );
228 + checkColorStatus(cd, cd->cursorFgW) &&
229 + checkColorStatus(cd, cd->cursorlineBgW));
232 /* Returns True if the color is valid, False if it's not */
233 @@ -6189,12 +6217,13 @@ static void updateColors(colorDialog *cd
234 *hiliteFg = XmTextGetString(cd->hiliteFgW),
235 *hiliteBg = XmTextGetString(cd->hiliteBgW),
236 *lineNoFg = XmTextGetString(cd->lineNoFgW),
237 - *cursorFg = XmTextGetString(cd->cursorFgW);
238 + *cursorFg = XmTextGetString(cd->cursorFgW),
239 + *cursorlineBg = XmTextGetString(cd->cursorlineBgW);
241 for (window = WindowList; window != NULL; window = window->next)
243 SetColors(window, textFg, textBg, selectFg, selectBg, hiliteFg,
244 - hiliteBg, lineNoFg, cursorFg);
245 + hiliteBg, lineNoFg, cursorFg, cursorlineBg);
248 SetPrefColorName(TEXT_FG_COLOR , textFg );
249 @@ -6205,6 +6234,7 @@ static void updateColors(colorDialog *cd
250 SetPrefColorName(HILITE_BG_COLOR, hiliteBg);
251 SetPrefColorName(LINENO_FG_COLOR, lineNoFg);
252 SetPrefColorName(CURSOR_FG_COLOR, cursorFg);
253 + SetPrefColorName(CURSORLINE_BG_COLOR, cursorlineBg);
255 XtFree(textFg);
256 XtFree(textBg);
257 @@ -6214,6 +6244,7 @@ static void updateColors(colorDialog *cd
258 XtFree(hiliteBg);
259 XtFree(lineNoFg);
260 XtFree(cursorFg);
261 + XtFree(cursorlineBg);
265 @@ -6383,6 +6414,20 @@ void ChooseColors(WindowInfo *window)
267 topW = infoLbl;
269 + /* The right column (backgrounds) */
270 + tmpW = addColorGroup( form, "textBg", 'T', "Text Area Background",
271 + &(cd->textBgW), &(cd->textBgErrW), topW, 51, 99,
272 + textBgModifiedCB, cd );
273 + tmpW = addColorGroup( form, "selectBg", 'B', "Selection Background",
274 + &(cd->selectBgW), &(cd->selectBgErrW), tmpW, 51, 99,
275 + selectBgModifiedCB, cd );
276 + tmpW = addColorGroup( form, "hiliteBg", 'h', "Matching (..) Background",
277 + &(cd->hiliteBgW), &(cd->hiliteBgErrW), tmpW, 51, 99,
278 + hiliteBgModifiedCB, cd );
279 + tmpW = addColorGroup( form, "cursorlineBg", 'r', "Cursorline Highlighting",
280 + &(cd->cursorlineBgW), &(cd->cursorlineBgErrW), tmpW, 51, 99,
281 + cursorlineBgModifiedCB, cd );
283 /* The left column (foregrounds) of color entry groups */
284 tmpW = addColorGroup( form, "textFg", 'P', "Plain Text Foreground",
285 &(cd->textFgW), &(cd->textFgErrW), topW, 1, 49,
286 @@ -6393,24 +6438,13 @@ void ChooseColors(WindowInfo *window)
287 tmpW = addColorGroup( form, "hiliteFg", 'M', "Matching (..) Foreground",
288 &(cd->hiliteFgW), &(cd->hiliteFgErrW), tmpW, 1, 49,
289 hiliteFgModifiedCB, cd );
290 + tmpW = addColorGroup( form, "cursorFg", 'C', "Cursor Color",
291 + &(cd->cursorFgW), &(cd->cursorFgErrW), tmpW, 1, 49,
292 + cursorFgModifiedCB, cd );
293 tmpW = addColorGroup( form, "lineNoFg", 'L', "Line Numbers",
294 &(cd->lineNoFgW), &(cd->lineNoFgErrW), tmpW, 1, 49,
295 lineNoFgModifiedCB, cd );
297 - /* The right column (backgrounds) */
298 - tmpW = addColorGroup( form, "textBg", 'T', "Text Area Background",
299 - &(cd->textBgW), &(cd->textBgErrW), topW, 51, 99,
300 - textBgModifiedCB, cd );
301 - tmpW = addColorGroup( form, "selectBg", 'B', "Selection Background",
302 - &(cd->selectBgW), &(cd->selectBgErrW), tmpW, 51, 99,
303 - selectBgModifiedCB, cd );
304 - tmpW = addColorGroup( form, "hiliteBg", 'h', "Matching (..) Background",
305 - &(cd->hiliteBgW), &(cd->hiliteBgErrW), tmpW, 51, 99,
306 - hiliteBgModifiedCB, cd );
307 - tmpW = addColorGroup( form, "cursorFg", 'C', "Cursor Color",
308 - &(cd->cursorFgW), &(cd->cursorFgErrW), tmpW, 51, 99,
309 - cursorFgModifiedCB, cd );
311 tmpW = XtVaCreateManagedWidget("infoLbl",
312 xmLabelGadgetClass, form,
313 XmNtopAttachment, XmATTACH_WIDGET,
314 @@ -6491,6 +6525,7 @@ void ChooseColors(WindowInfo *window)
315 XmTextSetString(cd->hiliteBgW, GetPrefColorName(HILITE_BG_COLOR));
316 XmTextSetString(cd->lineNoFgW, GetPrefColorName(LINENO_FG_COLOR));
317 XmTextSetString(cd->cursorFgW, GetPrefColorName(CURSOR_FG_COLOR));
318 + XmTextSetString(cd->cursorlineBgW, GetPrefColorName(CURSORLINE_BG_COLOR));
320 /* Handle mnemonic selection of buttons and focus to dialog */
321 AddDialogMnemonicHandler(form, FALSE);
322 diff --quilt old/source/preferences.h new/source/preferences.h
323 --- old/source/preferences.h
324 +++ new/source/preferences.h
325 @@ -122,6 +122,8 @@ int GetPrefRepositionDialogs(void);
326 void SetPrefAutoScroll(int state);
327 int GetPrefAutoScroll(void);
328 int GetVerticalAutoScroll(void);
329 +void SetPrefShowCursorline(Boolean value);
330 +Boolean GetPrefShowCursorline(void);
331 void SetPrefAppendLF(int state);
332 int GetPrefAppendLF(void);
333 void SetPrefSortOpenPrevMenu(int state);
334 diff --quilt old/source/text.c new/source/text.c
335 --- old/source/text.c
336 +++ new/source/text.c
337 @@ -643,6 +643,9 @@ static XtResource resources[] = {
338 {textNcalltipBackground, textCcalltipBackground, XmRPixel,sizeof(Pixel),
339 XtOffset(TextWidget, text.calltipBGPixel), XmRString,
340 NEDIT_DEFAULT_CALLTIP_BG},
341 + {textNcursorlineBackground, textCCursorlineBackground, XmRPixel,sizeof(Pixel),
342 + XtOffset(TextWidget, text.cursorlineBGPixel), XmRString,
343 + NEDIT_DEFAULT_CURSORLINE_BG},
344 {textNbacklightCharTypes,textCBacklightCharTypes,XmRString,sizeof(XmString),
345 XtOffset(TextWidget, text.backlightCharTypes), XmRString, NULL},
346 {textNrows, textCRows, XmRInt,sizeof(int),
347 @@ -707,7 +710,9 @@ static XtResource resources[] = {
348 sizeof(caddr_t), XtOffset(TextWidget, text.smartIndentCB), XtRCallback,
349 NULL},
350 {textNcursorVPadding, textCCursorVPadding, XtRCardinal, sizeof(Cardinal),
351 - XtOffset(TextWidget, text.cursorVPadding), XmRString, "0"}
352 + XtOffset(TextWidget, text.cursorVPadding), XmRString, "0"},
353 + {textNshowCursorline, textCshowCursorline, XmRBoolean, sizeof(Boolean),
354 + XtOffset(TextWidget, text.showCursorline), XmRString, "False"},
357 static TextClassRec textClassRec = {
358 @@ -825,7 +830,8 @@ static void initialize(TextWidget reques
359 new->text.lineNumFGPixel,
360 new->text.continuousWrap, new->text.wrapMargin,
361 new->text.backlightCharTypes, new->text.calltipFGPixel,
362 - new->text.calltipBGPixel);
363 + new->text.calltipBGPixel,
364 + new->text.cursorlineBGPixel, new->text.showCursorline);
366 /* Add mandatory delimiters blank, tab, and newline to the list of
367 delimiters. The memory use scheme here is that new values are
368 @@ -1123,6 +1129,14 @@ static Boolean setValues(TextWidget curr
369 TextDSetWrapMode(current->text.textD, new->text.continuousWrap,
370 new->text.wrapMargin);
372 + if (new->text.showCursorline != current->text.showCursorline) {
373 + current->text.showCursorline = new->text.showCursorline;
374 + if (current->text.textD) {
375 + current->text.textD->showCursorline = new->text.showCursorline;
377 + TextDSetShowCursorline(current->text.textD, new->text.showCursorline);
380 /* When delimiters are changed, copy the memory, so that the caller
381 doesn't have to manage it, and add mandatory delimiters blank,
382 tab, and newline to the list */
383 diff --quilt old/source/text.h new/source/text.h
384 --- old/source/text.h
385 +++ new/source/text.h
386 @@ -61,6 +61,8 @@
387 #define textCcalltipForeground "CalltipForeground"
388 #define textNcalltipBackground "calltipBackground"
389 #define textCcalltipBackground "CalltipBackground"
390 +#define textNcursorlineBackground "cursorlineBackground"
391 +#define textCCursorlineBackground "CursorlineBackground"
392 #define textNpendingDelete "pendingDelete"
393 #define textCPendingDelete "PendingDelete"
394 #define textNhScrollBar "hScrollBar"
395 @@ -113,6 +115,8 @@
396 #define textCCursorVPadding "CursorVPadding"
397 #define textNbacklightCharTypes "backlightCharTypes"
398 #define textCBacklightCharTypes "BacklightCharTypes"
399 +#define textNshowCursorline "showCursorline"
400 +#define textCshowCursorline "ShowCursorline"
403 extern WidgetClass textWidgetClass;
404 diff --quilt old/source/textDisp.c new/source/textDisp.c
405 --- old/source/textDisp.c
406 +++ new/source/textDisp.c
407 @@ -64,12 +64,14 @@ static const char CVSID[] = "$Id: textDi
409 /* Masks for text drawing methods. These are or'd together to form an
410 integer which describes what drawing calls to use to draw a string */
411 +#define STYLE_LOOKUP_SHIFT 0
412 #define FILL_SHIFT 8
413 #define SECONDARY_SHIFT 9
414 #define PRIMARY_SHIFT 10
415 #define HIGHLIGHT_SHIFT 11
416 -#define STYLE_LOOKUP_SHIFT 0
417 #define BACKLIGHT_SHIFT 12
418 +#define RANGESET_SHIFT 20
419 +#define CURSORLINE_SHIFT 26
421 #define FILL_MASK (1 << FILL_SHIFT)
422 #define SECONDARY_MASK (1 << SECONDARY_SHIFT)
423 @@ -77,29 +79,30 @@ static const char CVSID[] = "$Id: textDi
424 #define HIGHLIGHT_MASK (1 << HIGHLIGHT_SHIFT)
425 #define STYLE_LOOKUP_MASK (0xff << STYLE_LOOKUP_SHIFT)
426 #define BACKLIGHT_MASK (0xff << BACKLIGHT_SHIFT)
428 -#define RANGESET_SHIFT (20)
429 #define RANGESET_MASK (0x3F << RANGESET_SHIFT)
430 +#define CURSORLINE_MASK (1 << CURSORLINE_SHIFT)
432 /* If you use both 32-Bit Style mask layout:
433 Bits +----------------+----------------+----------------+----------------+
434 hex |1F1E1D1C1B1A1918|1716151413121110| F E D C B A 9 8| 7 6 5 4 3 2 1 0|
435 dec |3130292827262524|2322212019181716|151413121110 9 8| 7 6 5 4 3 2 1 0|
436 +----------------+----------------+----------------+----------------+
437 - Type | r r| r r r r b b b b| b b b b H 1 2 F| s s s s s s s s|
438 + Type | c r r| r r r r b b b b| b b b b H 1 2 F| s s s s s s s s|
439 +----------------+----------------+----------------+----------------+
440 - where: s - style lookup value (8 bits)
441 + where:
442 + s - style lookup value (8 bits)
443 F - fill (1 bit)
444 2 - secondary selection (1 bit)
445 1 - primary selection (1 bit)
446 H - highlight (1 bit)
447 b - backlighting index (8 bits)
448 r - rangeset index (6 bits)
449 - This leaves 6 "unused" bits */
450 + c - cursorline coloring (1 bit)
451 + This leaves 5 "unused" bits */
453 /* Maximum displayable line length (how many characters will fit across the
454 widest window). This amount of memory is temporarily allocated from the
455 - stack in the redisplayLine routine for drawing strings */
456 + stack in the redisplayLineCur routine for drawing strings */
457 #define MAX_DISP_LINE_LEN 1000
459 /* Macro for getting the TextPart from a textD */
460 @@ -115,6 +118,8 @@ static void calcLastChar(textDisp *textD
461 static int posToVisibleLineNum(textDisp *textD, int pos, int *lineNum);
462 static void redisplayLine(textDisp *textD, int visLineNum, int leftClip,
463 int rightClip, int leftCharIndex, int rightCharIndex);
464 +static void redisplayLineCur(textDisp *textD, int visLineNum, int leftClip,
465 + int rightClip, int leftCharIndex, int rightCharIndex, Boolean curLine);
466 static void drawString(textDisp *textD, int style, int x, int y, int toX,
467 char *string, int nChars);
468 static void clearRect(textDisp *textD, GC gc, int x, int y,
469 @@ -149,7 +154,8 @@ static int emptyLinesVisible(textDisp *t
470 static void blankCursorProtrusions(textDisp *textD);
471 static void allocateFixedFontGCs(textDisp *textD, XFontStruct *fontStruct,
472 Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel,
473 - Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel);
474 + Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel,
475 + Pixel cursorlineBGPixel);
476 static GC allocateGC(Widget w, unsigned long valueMask,
477 unsigned long foreground, unsigned long background, Font font,
478 unsigned long dynamicMask, unsigned long dontCareMask);
479 @@ -187,7 +193,8 @@ textDisp *TextDCreate(Widget widget, Wid
480 Pixel selectFGPixel, Pixel selectBGPixel, Pixel highlightFGPixel,
481 Pixel highlightBGPixel, Pixel cursorFGPixel, Pixel lineNumFGPixel,
482 int continuousWrap, int wrapMargin, XmString bgClassString,
483 - Pixel calltipFGPixel, Pixel calltipBGPixel)
484 + Pixel calltipFGPixel, Pixel calltipBGPixel,
485 + Pixel cursorlineBGPixel, Boolean showCursorline)
487 textDisp *textD;
488 XGCValues gcValues;
489 @@ -233,10 +240,12 @@ textDisp *TextDCreate(Widget widget, Wid
490 textD->highlightBGPixel = highlightBGPixel;
491 textD->lineNumFGPixel = lineNumFGPixel;
492 textD->cursorFGPixel = cursorFGPixel;
493 + textD->cursorlineBGPixel = cursorlineBGPixel;
494 textD->wrapMargin = wrapMargin;
495 textD->continuousWrap = continuousWrap;
496 allocateFixedFontGCs(textD, fontStruct, bgPixel, fgPixel, selectFGPixel,
497 - selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel);
498 + selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel,
499 + cursorlineBGPixel);
500 textD->styleGC = allocateGC(textD->w, 0, 0, 0, fontStruct->fid,
501 GCClipMask|GCForeground|GCBackground, GCArcMode);
502 textD->lineNumLeft = lineNumLeft;
503 @@ -262,6 +271,9 @@ textDisp *TextDCreate(Widget widget, Wid
504 textD->modifyingTabDist = 0;
505 textD->pointerHidden = False;
506 textD->graphicsExposeQueue = NULL;
507 + textD->showCursorline = showCursorline;
508 + textD->oldCursorPos = 0;
509 + textD->oldLineStart = 0;
511 /* Attach an event handler to the widget so we can know the visibility
512 (used for choosing the fastest drawing method) */
513 @@ -318,6 +330,8 @@ void TextDFree(textDisp *textD)
514 releaseGC(textD->w, textD->highlightBGGC);
515 releaseGC(textD->w, textD->styleGC);
516 releaseGC(textD->w, textD->lineNumGC);
517 + releaseGC(textD->w, textD->cursorlineGC);
518 + releaseGC(textD->w, textD->cursorlineBGGC);
519 XtFree((char *)textD->lineStarts);
520 while (TextDPopGraphicExposeQueueEntry(textD)) {
522 @@ -382,7 +396,8 @@ void TextDAttachHighlightData(textDisp *
523 /* Change the (non syntax-highlit) colors */
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 lineNoFgP, Pixel cursorFgP,
528 + Pixel cursorlineBgP)
530 XGCValues values;
531 Display *d = XtDisplay(textD->w);
532 @@ -396,6 +411,7 @@ void TextDSetColors(textDisp *textD, Pix
533 textD->highlightBGPixel = hiliteBgP;
534 textD->lineNumFGPixel = lineNoFgP;
535 textD->cursorFGPixel = cursorFgP;
536 + textD->cursorlineBGPixel = cursorlineBgP;
538 releaseGC(textD->w, textD->gc);
539 releaseGC(textD->w, textD->selectGC);
540 @@ -403,8 +419,11 @@ void TextDSetColors(textDisp *textD, Pix
541 releaseGC(textD->w, textD->highlightGC);
542 releaseGC(textD->w, textD->highlightBGGC);
543 releaseGC(textD->w, textD->lineNumGC);
544 + releaseGC(textD->w, textD->cursorlineGC);
545 + releaseGC(textD->w, textD->cursorlineBGGC);
546 allocateFixedFontGCs(textD, textD->fontStruct, textBgP, textFgP, selectFgP,
547 - selectBgP, hiliteFgP, hiliteBgP, lineNoFgP);
548 + selectBgP, hiliteFgP, hiliteBgP, lineNoFgP,
549 + cursorlineBgP);
551 /* Change the cursor GC (the cursor GC is not shared). */
552 values.foreground = cursorFgP;
553 @@ -416,6 +435,16 @@ void TextDSetColors(textDisp *textD, Pix
554 redrawLineNumbers(textD, True);
557 +void TextDSetShowCursorline(textDisp *textD, Boolean showCursorline)
559 + textD->showCursorline = showCursorline;
561 + /* Redisplay */
562 + TextDRedisplayRect(textD, textD->left, textD->top,
563 + textD->width, textD->height);
564 + redrawLineNumbers(textD, True);
568 ** Change the (non highlight) font
570 @@ -426,6 +455,7 @@ void TextDSetFont(textDisp *textD, XFont
571 int width, height, fontWidth;
572 Pixel bgPixel, fgPixel, selectFGPixel, selectBGPixel;
573 Pixel highlightFGPixel, highlightBGPixel, lineNumFGPixel;
574 + Pixel cursorlineBGPixel;
575 XGCValues values;
576 XFontStruct *styleFont;
578 @@ -479,14 +509,21 @@ void TextDSetFont(textDisp *textD, XFont
579 highlightBGPixel = values.background;
580 XGetGCValues(display, textD->lineNumGC, GCForeground, &values);
581 lineNumFGPixel = values.foreground;
582 + XGetGCValues(display, textD->cursorlineGC,GCForeground|GCBackground,&values);
583 + cursorlineBGPixel = values.background;
585 releaseGC(textD->w, textD->gc);
586 releaseGC(textD->w, textD->selectGC);
587 releaseGC(textD->w, textD->highlightGC);
588 releaseGC(textD->w, textD->selectBGGC);
589 releaseGC(textD->w, textD->highlightBGGC);
590 releaseGC(textD->w, textD->lineNumGC);
591 + releaseGC(textD->w, textD->cursorlineGC);
592 + releaseGC(textD->w, textD->cursorlineBGGC);
594 allocateFixedFontGCs(textD, fontStruct, bgPixel, fgPixel, selectFGPixel,
595 - selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel);
596 + selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel,
597 + cursorlineBGPixel);
598 XSetFont(display, textD->styleGC, fontStruct->fid);
600 /* Do a full resize to force recalculation of font related parameters */
601 @@ -711,7 +748,8 @@ static void textDRedisplayRange(textDisp
602 resetClipRectangles(textD);
604 /* If the starting and ending lines are the same, redisplay the single
605 - line between "start" and "end" */
606 + line between "start" and "end".
607 + Add one to endIndex to catch the caret at the end of a range. */
608 if (startLine == lastLine) {
609 redisplayLine(textD, startLine, 0, INT_MAX, startIndex, endIndex);
610 return;
611 @@ -724,7 +762,8 @@ static void textDRedisplayRange(textDisp
612 for (i=startLine+1; i<lastLine; i++)
613 redisplayLine(textD, i, 0, INT_MAX, 0, INT_MAX);
615 - /* Redisplay the last line to "end" */
616 + /* Redisplay the last line to "end". Add one to the endIndex to catch
617 + the caret at the end of a range. */
618 redisplayLine(textD, lastLine, 0, INT_MAX, 0, endIndex);
621 @@ -785,7 +824,7 @@ void TextDSetInsertPosition(textDisp *te
622 /* draw it at its new position */
623 textD->cursorPos = newPos;
624 textD->cursorOn = True;
625 - textDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos + 1);
626 + textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
629 void TextDBlankCursor(textDisp *textD)
630 @@ -795,14 +834,14 @@ void TextDBlankCursor(textDisp *textD)
632 blankCursorProtrusions(textD);
633 textD->cursorOn = False;
634 - textDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos+1);
635 + textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
638 void TextDUnblankCursor(textDisp *textD)
640 if (!textD->cursorOn) {
641 textD->cursorOn = True;
642 - textDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos+1);
643 + textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
647 @@ -811,7 +850,7 @@ void TextDSetCursorStyle(textDisp *textD
648 textD->cursorStyle = style;
649 blankCursorProtrusions(textD);
650 if (textD->cursorOn) {
651 - textDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos + 1);
652 + textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
656 @@ -1747,9 +1786,24 @@ static int posToVisibleLineNum(textDisp
657 ** position "rightCharIndex").
659 ** The cursor is also drawn if it appears on the line.
661 +** The function actually forwards to redisplayLineCur(), passing the
662 +** showCursorline setting as appropriate.
664 static void redisplayLine(textDisp *textD, int visLineNum, int leftClip,
665 - int rightClip, int leftCharIndex, int rightCharIndex)
666 + int rightClip, int leftCharIndex, int rightCharIndex)
668 + redisplayLineCur(textD, visLineNum, leftClip, rightClip, leftCharIndex,
669 + rightCharIndex, textD->showCursorline);
673 +** The meat of redisplayLine() is handled here. The extra curLine parameter
674 +** tells redisplayLineCur() whether it should attempt to reset the previous
675 +** "current line" to a non-current line state.
677 +static void redisplayLineCur(textDisp *textD, int visLineNum, int leftClip,
678 + int rightClip, int leftCharIndex, int rightCharIndex, Boolean curLine)
680 textBuffer *buf = textD->buffer;
681 int i, x, y, startX, charIndex, lineStartPos, lineLen, fontHeight;
682 @@ -1786,6 +1840,98 @@ static void redisplayLine(textDisp *text
683 lineStr = BufGetRange(buf, lineStartPos, lineStartPos + lineLen);
686 + /* handle case of leftCharIndex == rightCharIndex */
687 + if (leftCharIndex == rightCharIndex) {
688 + if (lineStartPos + leftCharIndex == cursorPos) {
689 + /* we're at the cursor position */
690 + if (leftCharIndex > 0)
691 + --leftCharIndex;
692 + if (rightCharIndex < lineLen)
693 + ++rightCharIndex;
694 + if (rightCharIndex >= lineLen)
695 + rightCharIndex = INT_MAX;
696 + } else {
697 + /* hmm: not sure what gets us here, but it happens - redraw line */
698 + leftCharIndex = 0;
699 + rightCharIndex = INT_MAX;
700 + return;
704 + /* for cursorline tracking, if this is the current line, check it against
705 + the last cursorline - if different, we need to display the whole line
706 + plus anything to the extreme right */
707 + if (curLine
708 + && (textD->oldCursorPos != cursorPos
709 + || textD->oldLineStart != lineStartPos)) {
710 + int oldCursor = textD->oldCursorPos;
711 + int lineEndPos = lineStartPos + lineLen;
712 + int oldLineStart = textD->oldLineStart;
713 + int gotLineCurdiff = -1;
714 + /* store new values if we need to call redisplayLine() again */
715 + textD->oldCursorPos = cursorPos;
717 + if (lineStartPos <= cursorPos
718 + && cursorPos <= lineEndPos
719 + && !(lineStartPos <= oldCursor && oldCursor <= lineEndPos)) {
720 + /* find visible line number for oldCursor */
721 + int lineNum, startPos = -1, oldLen, endPos;
722 + int gotLine = -1;
724 + for (lineNum = 0; lineNum < textD->nVisibleLines; lineNum++) {
725 + startPos = textD->lineStarts[lineNum];
726 + if (startPos >= 0) {
727 + oldLen = visLineLength(textD, lineNum);
728 + endPos = startPos + oldLen;
729 + if (startPos >= 0
730 + && startPos <= oldCursor
731 + && oldCursor <= endPos) {
732 + gotLine = lineNum;
733 + break;
738 + if (gotLine >= 0 && gotLine != visLineNum) {
739 + redisplayLineCur(textD, gotLine, 0, INT_MAX, 0, INT_MAX, False);
740 + gotLineCurdiff = gotLine;
743 + /* right: that was the old line done - now the current line */
744 + leftCharIndex = 0;
745 + rightCharIndex = INT_MAX;
747 + /* only update oldLineStart if cursor has moved */
748 + textD->oldLineStart = lineStartPos;
751 + if (lineStartPos != oldLineStart) {
752 + /* find visible line number for oldLineStart */
753 + int lineNum;
754 + int gotLine = -1;
756 + for (lineNum = 0; lineNum < textD->nVisibleLines; lineNum++) {
757 + if (textD->lineStarts[lineNum] == oldLineStart) {
758 + gotLine = lineNum;
759 + break;
763 + if (gotLine >= 0
764 + && gotLine != visLineNum
765 + && gotLine != gotLineCurdiff) {
766 + redisplayLineCur(textD, gotLine, 0, INT_MAX, 0, INT_MAX, False);
769 + /* right: that was the old line done - now the current line */
770 + leftCharIndex = 0;
771 + rightCharIndex = INT_MAX;
773 + /* only update oldLineStart if cursor has moved */
774 + textD->oldLineStart = lineStartPos;
778 /* Space beyond the end of the line is still counted in units of characters
779 of a standardized character width (this is done mostly because style
780 changes based on character position can still occur in this region due
781 @@ -1951,6 +2097,7 @@ static void drawString(textDisp *textD,
782 Pixel bground = textD->bgPixel;
783 Pixel fground = textD->fgPixel;
784 int underlineStyle = FALSE;
785 + int cursorline_mask = textD->showCursorline ? CURSORLINE_MASK : 0;
787 /* Don't draw if widget isn't realized */
788 if (XtWindow(textD->w) == 0)
789 @@ -1968,6 +2115,10 @@ static void drawString(textDisp *textD,
790 gc = textD->selectGC;
791 bgGC = textD->selectBGGC;
793 + else if (style & cursorline_mask) {
794 + gc = textD->cursorlineGC;
795 + bgGC = textD->cursorlineBGGC;
797 else {
798 gc = bgGC = textD->gc;
800 @@ -1992,10 +2143,14 @@ static void drawString(textDisp *textD,
801 gcValues.font = fs->fid;
802 fground = textD->fgPixel;
804 - /* Background color priority order is:
805 - 1 Primary(Selection), 2 Highlight(Parens),
806 - 3 Rangeset, 4 SyntaxHighlightStyle,
807 - 5 Backlight (if NOT fill), 6 DefaultBackground */
808 + /* Background color priority order is:
809 + 1. PRIMARY (selection)
810 + 2. Highlight (flash matching parens)
811 + 3. Rangeset
812 + 4. SyntaxHighlightStyle
813 + 5. Cursorline
814 + 6. Backlight (if NOT fill)
815 + 7. DefaultBackground */
816 bground =
817 style & PRIMARY_MASK ? textD->selectBGPixel :
818 style & HIGHLIGHT_MASK ? textD->highlightBGPixel :
819 @@ -2004,6 +2159,7 @@ static void drawString(textDisp *textD,
820 (style&RANGESET_MASK)>>RANGESET_SHIFT,
821 bground) :
822 styleRec && styleRec->bgColorName ? styleRec->bgColor :
823 + style & cursorline_mask ? textD->cursorlineBGPixel :
824 (style & BACKLIGHT_MASK) && !(style & FILL_MASK) ?
825 textD->bgClassPixel[(style>>BACKLIGHT_SHIFT) & 0xff] :
826 textD->bgPixel;
827 @@ -2161,6 +2317,7 @@ static int styleOfPos(textDisp *textD, i
829 textBuffer *buf = textD->buffer;
830 textBuffer *styleBuf = textD->styleBuffer;
831 + int cursorPos = textD->cursorPos;
832 int pos, style = 0;
834 if (lineStartPos == -1 || buf == NULL)
835 @@ -2195,6 +2352,8 @@ static int styleOfPos(textDisp *textD, i
837 style |= (textD->bgClass[(unsigned char)thisChar]<<BACKLIGHT_SHIFT);
839 + if (lineStartPos <= cursorPos && cursorPos <= lineStartPos + lineLen)
840 + style |= CURSORLINE_MASK;
841 return style;
844 @@ -2723,7 +2882,7 @@ static void setScroll(textDisp *textD, i
845 textD->top, -xOffset, textD->height);
847 /* Restore protruding parts of the cursor */
848 - textDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos+1);
849 + textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
852 /* Refresh line number/calltip display if its up and we've scrolled
853 @@ -3010,7 +3169,8 @@ static void blankCursorProtrusions(textD
855 static void allocateFixedFontGCs(textDisp *textD, XFontStruct *fontStruct,
856 Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel,
857 - Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel)
858 + Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel,
859 + Pixel cursorlineBGPixel)
861 textD->gc = allocateGC(textD->w, GCFont | GCForeground | GCBackground,
862 fgPixel, bgPixel, fontStruct->fid, GCClipMask, GCArcMode);
863 @@ -3027,6 +3187,10 @@ static void allocateFixedFontGCs(textDis
864 textD->lineNumGC = allocateGC(textD->w, GCFont | GCForeground |
865 GCBackground, lineNumFGPixel, bgPixel, fontStruct->fid,
866 GCClipMask, GCArcMode);
867 + textD->cursorlineGC = allocateGC(textD->w, GCFont|GCForeground|GCBackground,
868 + fgPixel, cursorlineBGPixel, fontStruct->fid, GCClipMask, GCArcMode);
869 + textD->cursorlineBGGC = allocateGC(textD->w, GCForeground,
870 + cursorlineBGPixel, 0, fontStruct->fid, GCClipMask, GCArcMode);
874 @@ -3099,6 +3263,10 @@ static void resetClipRectangles(textDisp
875 &clipRect, 1, Unsorted);
876 XSetClipRectangles(display, textD->styleGC, 0, 0,
877 &clipRect, 1, Unsorted);
878 + XSetClipRectangles(display, textD->cursorlineGC, 0, 0,
879 + &clipRect, 1, Unsorted);
880 + XSetClipRectangles(display, textD->cursorlineBGGC, 0, 0,
881 + &clipRect, 1, Unsorted);
885 diff --quilt old/source/textDisp.h new/source/textDisp.h
886 --- old/source/textDisp.h
887 +++ new/source/textDisp.h
888 @@ -129,8 +129,8 @@ typedef struct _textDisp {
889 int fixedFontWidth; /* Font width if all current fonts are
890 fixed and match in width, else -1 */
891 Widget hScrollBar, vScrollBar;
892 - GC gc, selectGC, highlightGC; /* GCs for drawing text */
893 - GC selectBGGC, highlightBGGC; /* GCs for erasing text */
894 + GC gc, selectGC, highlightGC, cursorlineGC; /* GCs for drawing text */
895 + GC selectBGGC, highlightBGGC, cursorlineBGGC; /* GCs for erasing text */
896 GC cursorFGGC; /* GC for drawing the cursor */
897 GC lineNumGC; /* GC for drawing line numbers */
898 GC styleGC; /* GC with color and font unspecified
899 @@ -142,6 +142,7 @@ typedef struct _textDisp {
900 highlightBGPixel; /* flashing matching parens */
901 Pixel lineNumFGPixel; /* Color for drawing line numbers */
902 Pixel cursorFGPixel;
903 + Pixel cursorlineBGPixel;
904 Pixel *bgClassPixel; /* table of colors for each BG class */
905 unsigned char *bgClass; /* obtains index into bgClassPixel[] */
907 @@ -161,6 +162,9 @@ typedef struct _textDisp {
908 Boolean pointerHidden; /* true if the mouse pointer is
909 hidden */
910 graphicExposeTranslationEntry *graphicsExposeQueue;
911 + int oldCursorPos;
912 + int oldLineStart;
913 + Boolean showCursorline;
914 } textDisp;
916 textDisp *TextDCreate(Widget widget, Widget hScrollBar, Widget vScrollBar,
917 @@ -170,7 +174,8 @@ textDisp *TextDCreate(Widget widget, Wid
918 Pixel selectFGPixel, Pixel selectBGPixel, Pixel highlightFGPixel,
919 Pixel highlightBGPixel, Pixel cursorFGPixel, Pixel lineNumFGPixel,
920 int continuousWrap, int wrapMargin, XmString bgClassString,
921 - Pixel calltipFGPixel, Pixel calltipBGPixel);
922 + Pixel calltipFGPixel, Pixel calltipBGPixel,
923 + Pixel cursorlineBGPixel, Boolean showCursorline);
924 void TextDFree(textDisp *textD);
925 void TextDSetBuffer(textDisp *textD, textBuffer *buffer);
926 void TextDAttachHighlightData(textDisp *textD, textBuffer *styleBuffer,
927 @@ -178,7 +183,8 @@ void TextDAttachHighlightData(textDisp *
928 unfinishedStyleCBProc unfinishedHighlightCB, void *cbArg);
929 void TextDSetColors(textDisp *textD, Pixel textFgP, Pixel textBgP,
930 Pixel selectFgP, Pixel selectBgP, Pixel hiliteFgP, Pixel hiliteBgP,
931 - Pixel lineNoFgP, Pixel cursorFgP);
932 + Pixel lineNoFgP, Pixel cursorFgP,
933 + Pixel cursorlineBgP);
934 void TextDSetFont(textDisp *textD, XFontStruct *fontStruct);
935 int TextDMinFontWidth(textDisp *textD, Boolean considerStyles);
936 int TextDMaxFontWidth(textDisp *textD, Boolean considerStyles);
937 @@ -234,4 +240,6 @@ void TextDImposeGraphicsExposeTranslatio
938 Boolean TextDPopGraphicExposeQueueEntry(textDisp *textD);
939 void TextDTranlateGraphicExposeQueue(textDisp *textD, int xOffset, int yOffset, Boolean appendEntry);
941 +void TextDSetShowCursorline(textDisp *textD, Boolean showCursorline);
943 #endif /* NEDIT_TEXTDISP_H_INCLUDED */
944 diff --quilt old/source/textP.h new/source/textP.h
945 --- old/source/textP.h
946 +++ new/source/textP.h
947 @@ -59,6 +59,7 @@ typedef struct _TextPart {
948 /* resources */
949 Pixel selectFGPixel, selectBGPixel, highlightFGPixel, highlightBGPixel;
950 Pixel cursorFGPixel, lineNumFGPixel, calltipFGPixel, calltipBGPixel;
951 + Pixel cursorlineBGPixel;
952 XFontStruct *fontStruct;
953 Boolean pendingDelete;
954 Boolean autoShowInsertPos;
955 @@ -71,6 +72,7 @@ typedef struct _TextPart {
956 Boolean heavyCursor;
957 Boolean readOnly;
958 Boolean hidePointer;
959 + Boolean showCursorline;
960 int rows, columns;
961 int marginWidth, marginHeight;
962 int cursorBlinkRate;
963 diff --quilt old/source/window.c new/source/window.c
964 --- old/source/window.c
965 +++ new/source/window.c
966 @@ -262,6 +262,7 @@ WindowInfo *CreateWindow(const char *nam
967 window->undo = NULL;
968 window->redo = NULL;
969 window->nPanes = 0;
970 + window->lastFocus = NULL;
971 window->autoSaveCharCount = 0;
972 window->autoSaveOpCount = 0;
973 window->undoOpCount = 0;
974 @@ -718,7 +719,7 @@ WindowInfo *CreateWindow(const char *nam
975 GetPrefWrapMargin(), window->showLineNumbers?MIN_LINE_NUM_COLS:0);
976 XtManageChild(text);
977 window->textArea = text;
978 - window->lastFocus = text;
979 + ChangeLastFocus(window, text);
981 /* Set the initial colors from the globals. */
982 SetColors(window,
983 @@ -729,7 +730,8 @@ WindowInfo *CreateWindow(const char *nam
984 GetPrefColorName(HILITE_FG_COLOR),
985 GetPrefColorName(HILITE_BG_COLOR),
986 GetPrefColorName(LINENO_FG_COLOR),
987 - GetPrefColorName(CURSOR_FG_COLOR));
988 + GetPrefColorName(CURSOR_FG_COLOR),
989 + GetPrefColorName(CURSORLINE_BG_COLOR));
991 /* Create the right button popup menu (note: order is important here,
992 since the translation for popping up this menu was probably already
993 @@ -1237,7 +1239,7 @@ void SplitPane(WindowInfo *window)
994 TextDSetColors( newTextD, textD->fgPixel, textD->bgPixel,
995 textD->selectFGPixel, textD->selectBGPixel, textD->highlightFGPixel,
996 textD->highlightBGPixel, textD->lineNumFGPixel,
997 - textD->cursorFGPixel );
998 + textD->cursorFGPixel, textD->cursorlineBGPixel );
1000 /* Set the minimum pane height in the new pane */
1001 UpdateMinPaneHeights(window);
1002 @@ -1342,10 +1344,14 @@ void ClosePane(WindowInfo *window)
1003 XtUnmanageChild(containingPane(window->textPanes[window->nPanes]));
1004 XtDestroyWidget(containingPane(window->textPanes[window->nPanes]));
1006 - if (window->nPanes == 0)
1007 - window->lastFocus = window->textArea;
1008 - else if (focusPane > window->nPanes)
1009 - window->lastFocus = window->textPanes[window->nPanes-1];
1010 + if (window->nPanes == 0) {
1011 + text = window->textArea;
1012 + } else if (focusPane > window->nPanes) {
1013 + text = window->textPanes[window->nPanes - 1];
1014 + } else {
1015 + text = window->textPanes[focusPane - 1];
1017 + ChangeLastFocus(window, text);
1019 /* adjust the heights, scroll positions, etc., to make it look
1020 like the pane with the input focus was closed */
1021 @@ -1873,7 +1879,8 @@ void SetFonts(WindowInfo *window, const
1023 void SetColors(WindowInfo *window, const char *textFg, const char *textBg,
1024 const char *selectFg, const char *selectBg, const char *hiliteFg,
1025 - const char *hiliteBg, const char *lineNoFg, const char *cursorFg)
1026 + const char *hiliteBg, const char *lineNoFg, const char *cursorFg,
1027 + const char *cursorlineBg)
1029 int i, dummy;
1030 Pixel textFgPix = AllocColor( window->textArea, textFg,
1031 @@ -1891,6 +1898,8 @@ void SetColors(WindowInfo *window, const
1032 lineNoFgPix = AllocColor( window->textArea, lineNoFg,
1033 &dummy, &dummy, &dummy),
1034 cursorFgPix = AllocColor( window->textArea, cursorFg,
1035 + &dummy, &dummy, &dummy),
1036 + cursorlineBgPix = AllocColor( window->textArea, cursorlineBg,
1037 &dummy, &dummy, &dummy);
1038 textDisp *textD;
1040 @@ -1901,7 +1910,8 @@ void SetColors(WindowInfo *window, const
1041 NULL);
1042 textD = ((TextWidget)window->textArea)->text.textD;
1043 TextDSetColors( textD, textFgPix, textBgPix, selectFgPix, selectBgPix,
1044 - hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix );
1045 + hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix,
1046 + cursorlineBgPix );
1047 /* Update any additional panes */
1048 for (i=0; i<window->nPanes; i++) {
1049 XtVaSetValues(window->textPanes[i],
1050 @@ -1910,7 +1920,8 @@ void SetColors(WindowInfo *window, const
1051 NULL);
1052 textD = ((TextWidget)window->textPanes[i])->text.textD;
1053 TextDSetColors( textD, textFgPix, textBgPix, selectFgPix, selectBgPix,
1054 - hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix );
1055 + hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix,
1056 + cursorlineBgPix );
1059 /* Redo any syntax highlighting */
1060 @@ -2253,6 +2264,7 @@ static Widget createTextArea(Widget pare
1061 textNoverstrike, window->overstrike,
1062 textNhidePointer, (Boolean) GetPrefTypingHidesPointer(),
1063 textNcursorVPadding, GetVerticalAutoScroll(),
1064 + textNshowCursorline, False,
1065 NULL);
1067 XtVaSetValues(sw, XmNworkWindow, frame, XmNhorizontalScrollBar,
1068 @@ -2388,7 +2400,7 @@ static void modifiedCB(int pos, int nIns
1069 static void focusCB(Widget w, WindowInfo *window, XtPointer callData)
1071 /* record which window pane last had the keyboard focus */
1072 - window->lastFocus = w;
1073 + ChangeLastFocus(window, w);
1075 /* update line number statistic to reflect current focus pane */
1076 UpdateStatsLine(window);
1077 @@ -3344,6 +3356,7 @@ WindowInfo* CreateDocument(WindowInfo* s
1078 window->undo = NULL;
1079 window->redo = NULL;
1080 window->nPanes = 0;
1081 + window->lastFocus = NULL;
1082 window->autoSaveCharCount = 0;
1083 window->autoSaveOpCount = 0;
1084 window->undoOpCount = 0;
1085 @@ -3446,7 +3459,7 @@ WindowInfo* CreateDocument(WindowInfo* s
1086 GetPrefWrapMargin(), window->showLineNumbers?MIN_LINE_NUM_COLS:0);
1087 XtManageChild(text);
1088 window->textArea = text;
1089 - window->lastFocus = text;
1090 + ChangeLastFocus(window, text);
1092 /* Set the initial colors from the globals. */
1093 SetColors(window,
1094 @@ -3457,7 +3470,8 @@ WindowInfo* CreateDocument(WindowInfo* s
1095 GetPrefColorName(HILITE_FG_COLOR),
1096 GetPrefColorName(HILITE_BG_COLOR),
1097 GetPrefColorName(LINENO_FG_COLOR),
1098 - GetPrefColorName(CURSOR_FG_COLOR));
1099 + GetPrefColorName(CURSOR_FG_COLOR),
1100 + GetPrefColorName(CURSORLINE_BG_COLOR));
1102 /* Create the right button popup menu (note: order is important here,
1103 since the translation for popping up this menu was probably already
1104 @@ -4246,7 +4260,8 @@ static void cloneTextPanes(WindowInfo *w
1105 TextDSetColors(newTextD, textD->fgPixel, textD->bgPixel,
1106 textD->selectFGPixel, textD->selectBGPixel,
1107 textD->highlightFGPixel,textD->highlightBGPixel,
1108 - textD->lineNumFGPixel, textD->cursorFGPixel);
1109 + textD->lineNumFGPixel, textD->cursorFGPixel,
1110 + textD->cursorlineBGPixel);
1113 /* Set the minimum pane height in the new pane */
1114 @@ -4279,7 +4294,7 @@ static void cloneTextPanes(WindowInfo *w
1115 for (i=0; i<=window->nPanes; i++) {
1116 text = i==0 ? window->textArea : window->textPanes[i-1];
1117 if(i == focusPane) {
1118 - window->lastFocus = text;
1119 + ChangeLastFocus(window, text);
1120 XmProcessTraversal(text, XmTRAVERSE_CURRENT);
1121 break;
1123 @@ -4810,3 +4825,20 @@ void CleanUpTabBarExposeQueue(WindowInfo
1124 ExposureMask, (XEvent *)&ev);
1129 +** Track which text pane in this widget is/was last active (with focus).
1130 +** Also perform any tasks relating to changing pane focus.
1132 +void ChangeLastFocus(WindowInfo *window, Widget text)
1134 + Boolean showCursorline = GetPrefShowCursorline();
1136 + if (window->lastFocus) {
1137 + XtVaSetValues(window->lastFocus, textNshowCursorline, False, NULL);
1140 + XtVaSetValues(text, textNshowCursorline, showCursorline, NULL);
1142 + window->lastFocus = text;
1144 diff --quilt old/source/window.h new/source/window.h
1145 --- old/source/window.h
1146 +++ new/source/window.h
1147 @@ -53,7 +53,8 @@ void SetFonts(WindowInfo *window, const
1148 const char *boldName, const char *boldItalicName);
1149 void SetColors(WindowInfo *window, const char *textFg, const char *textBg,
1150 const char *selectFg, const char *selectBg, const char *hiliteFg,
1151 - const char *hiliteBg, const char *lineNoFg, const char *cursorFg);
1152 + const char *hiliteBg, const char *lineNoFg, const char *cursorFg,
1153 + const char *cursorlineBg);
1154 void SetOverstrike(WindowInfo *window, int overstrike);
1155 void SetAutoWrap(WindowInfo *window, int state);
1156 void SetAutoScroll(WindowInfo *window, int margin);
1157 @@ -104,4 +105,5 @@ void SetToggleButtonState(WindowInfo *wi
1158 Boolean notify);
1159 void SetSensitive(WindowInfo *window, Widget w, Boolean sensitive);
1160 void CleanUpTabBarExposeQueue(WindowInfo *window);
1161 +void ChangeLastFocus(WindowInfo *window, Widget text);
1162 #endif /* NEDIT_WINDOW_H_INCLUDED */