Index: doc/help.etx =================================================================== RCS file: /cvsroot/nedit/nedit/doc/help.etx,v retrieving revision 1.67 diff -U5 -r1.67 help.etx --- doc/help.etx 8 Jun 2004 15:36:15 -0000 1.67 +++ doc/help.etx 10 Jun 2004 12:30:50 -0000 @@ -5040,10 +5040,12 @@ .. .. You get a syntax/indent credit if your pattern is compiled into the .. binary. .. ====================================================================== + This is a patched version of NEdit. See below for details. + NEdit was written by Mark Edel, Joy Kyriakopulos, Christopher Conrad, Jim Clark, Arnulfo Zepeda-Navratil, Suresh Ravoor, Tony Balinski, Max Vohlken, Yunliang Yu, Donna Reid, Arne Førlie, Eddy De Greef, Steve LoBasso, Alexander Mai, Scott Tringali, Thorsten Haude, Steve Haehn, Andrew Hood, Nathaniel Gray, and TK Soh. @@ -5072,10 +5074,25 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License in the Help section "Distribution_Policy_" for more details. + + This version of NEdit contains additional code written by Thorsten Haude + and Tony Balinski. This additional code is free software; you can + redistribute it and/or modify it under the terms of the GNU General + Public License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. In + addition, as a special exception, the authors of this additional code + give permission to link their code with the Motif and Open Motif + libraries (or with modified versions of these that use the same licence), + and distribute linked combinations including the two. You must obey the + GNU General Public Licence in all respects for all of the code used + other than Motif/Open Motif. If you modify this additional code, you may + extend this exception to your version of the file, but you are not + obligated to do so. If you do not wish to do so, delete this exception + statement from your version. ---------------------------------------------------------------------- Distribution Policy ------------------- Index: source/help_data.h =================================================================== RCS file: /cvsroot/nedit/nedit/source/help_data.h,v retrieving revision 1.62 diff -U5 -r1.62 help_data.h --- source/help_data.h 8 Jun 2004 15:36:15 -0000 1.62 +++ source/help_data.h 10 Jun 2004 12:31:27 -0000 @@ -4799,10 +4799,12 @@ }; static char * htxt_version [] = { "\01A%s\n", "\01I\n", +"This is a patched version of NEdit. See below for details. ", +"\n\n", "NEdit was written by Mark Edel, Joy Kyriakopulos, Christopher Conrad, ", "Jim Clark, Arnulfo Zepeda-Navratil, Suresh Ravoor, Tony Balinski, Max ", "Vohlken, Yunliang Yu, Donna Reid, Arne Førlie, Eddy De Greef, Steve ", "LoBasso, Alexander Mai, Scott Tringali, Thorsten Haude, Steve Haehn, ", "Andrew Hood, Nathaniel Gray, and TK Soh. ", @@ -4831,10 +4833,25 @@ "This program is distributed in the hope that it will be useful, ", "but WITHOUT ANY WARRANTY; without even the implied warranty of ", "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ", "GNU General Public License in the Help section \"\01QDistribution Policy\01I\" ", "for more details. ", +"\n\n", +"This version of NEdit contains additional code written by Thorsten Haude ", +"and Tony Balinski. This additional code is free software; you can ", +"redistribute it and/or modify it under the terms of the GNU General ", +"Public License as published by the Free Software Foundation; either ", +"version 2 of the License, or (at your option) any later version. In ", +"addition, as a special exception, the authors of this additional code ", +"give permission to link their code with the Motif and Open Motif ", +"libraries (or with modified versions of these that use the same licence), ", +"and distribute linked combinations including the two. You must obey the ", +"GNU General Public Licence in all respects for all of the code used ", +"other than Motif/Open Motif. If you modify this additional code, you may ", +"extend this exception to your version of the file, but you are not ", +"obligated to do so. If you do not wish to do so, delete this exception ", +"statement from your version. ", NULL }; static char * htxt_distribution [] = { "\01IGNU GENERAL PUBLIC LICENSE ", Index: source/menu.c =================================================================== RCS file: /cvsroot/nedit/nedit/source/menu.c,v retrieving revision 1.104 diff -U5 -r1.104 menu.c --- source/menu.c 6 May 2004 08:39:56 -0000 1.104 +++ source/menu.c 10 Jun 2004 12:32:14 -0000 @@ -3848,11 +3848,11 @@ } if (paneIndex >= 0 && paneIndex <= window->nPanes) { newFocusPane = GetPaneByIndex(window, paneIndex); } if (newFocusPane != NULL) { - window->lastFocus = newFocusPane; + ChangeLastFocus(window, newFocusPane); XmProcessTraversal(window->lastFocus, XmTRAVERSE_CURRENT); } else { XBell(TheDisplay, 0); } Index: source/nedit.h =================================================================== RCS file: /cvsroot/nedit/nedit/source/nedit.h,v retrieving revision 1.55 diff -U5 -r1.55 nedit.h --- source/nedit.h 28 Apr 2004 01:54:19 -0000 1.55 +++ source/nedit.h 10 Jun 2004 12:32:20 -0000 @@ -31,11 +31,11 @@ #define NEDIT_DEFAULT_HI_BG "red" /* matching parens. */ #define NEDIT_DEFAULT_LINENO_FG "black" #define NEDIT_DEFAULT_CURSOR_FG "black" #define NEDIT_DEFAULT_HELP_FG "black" #define NEDIT_DEFAULT_HELP_BG "rgb:cc/cc/cc" - +#define NEDIT_DEFAULT_CURSORLINE_BG "LightSkyBlue" /* Tuning parameters */ #define SEARCHMAX 511 /* Maximum length of search/replace strings */ #define MAX_SEARCH_HISTORY 100 /* Maximum length of search string history */ #define MAX_PANES 6 /* Max # of ADDITIONAL text editing panes @@ -168,10 +168,11 @@ SELECT_BG_COLOR, HILITE_FG_COLOR, HILITE_BG_COLOR, LINENO_FG_COLOR, CURSOR_FG_COLOR, + CURSORLINE_BG_COLOR, NUM_COLORS }; /* cache user menus: manage mode of user menu list element */ typedef enum { Index: source/preferences.c =================================================================== RCS file: /cvsroot/nedit/nedit/source/preferences.c,v retrieving revision 1.119 diff -U5 -r1.119 preferences.c --- source/preferences.c 27 Apr 2004 01:35:28 -0000 1.119 +++ source/preferences.c 10 Jun 2004 12:32:39 -0000 @@ -225,10 +225,12 @@ Widget hiliteBgErrW; Widget lineNoFgW; Widget lineNoFgErrW; Widget cursorFgW; Widget cursorFgErrW; + Widget cursorlineBgW; + Widget cursorlineBgErrW; WindowInfo *window; } colorDialog; /* Repository for simple preferences settings */ static struct prefData { @@ -310,10 +312,11 @@ char helpFontNames[NUM_HELP_FONTS][MAX_FONT_LEN];/* fonts for help system */ char helpLinkColor[MAX_COLOR_LEN]; /* Color for hyperlinks in the help system */ char colorNames[NUM_COLORS][MAX_COLOR_LEN]; char tooltipBgColor[MAX_COLOR_LEN]; int undoModifiesSelection; + int showCursorline; /* Wanna see where the cursor is? */ } PrefData; /* Temporary storage for preferences strings which are discarded after being read */ static struct { @@ -918,10 +921,14 @@ PrefData.colorNames[LINENO_FG_COLOR], (void *)sizeof(PrefData.colorNames[LINENO_FG_COLOR]), True}, {"cursorFgColor", "CursorFgColor", PREF_STRING, NEDIT_DEFAULT_CURSOR_FG, PrefData.colorNames[CURSOR_FG_COLOR], (void *)sizeof(PrefData.colorNames[CURSOR_FG_COLOR]), True}, + {"cursorlineBGColor", "CursorlineBGColor", PREF_STRING, + NEDIT_DEFAULT_CURSORLINE_BG, + PrefData.colorNames[CURSORLINE_BG_COLOR], + (void *)sizeof(PrefData.colorNames[CURSORLINE_BG_COLOR]), True}, {"tooltipBgColor", "TooltipBgColor", PREF_STRING, "LemonChiffon1", PrefData.tooltipBgColor, (void *)sizeof(PrefData.tooltipBgColor), False}, {"shell", "Shell", PREF_STRING, @@ -967,10 +974,12 @@ PREF_ENUM, "Auto", &PrefData.virtKeyOverride, VirtKeyOverrideModes, False}, {"titleFormat", "TitleFormat", PREF_STRING, "{%c} [%s] %f (%S) - %d", PrefData.titleFormat, (void *)sizeof(PrefData.titleFormat), True}, {"undoModifiesSelection", "UndoModifiesSelection", PREF_BOOLEAN, "True", &PrefData.undoModifiesSelection, NULL, False}, + {"showCursorline", "ShowCursorline", PREF_BOOLEAN, "True", + &PrefData.showCursorline, NULL, True}, }; static XrmOptionDescRec OpTable[] = { {"-wrap", ".autoWrap", XrmoptionNoArg, (caddr_t)"Continuous"}, {"-nowrap", ".autoWrap", XrmoptionNoArg, (caddr_t)"None"}, @@ -2046,10 +2055,20 @@ Boolean GetPrefUndoModifiesSelection(void) { return (Boolean)PrefData.undoModifiesSelection; } +void SetPrefShowCursorline(Boolean value) +{ + setIntPref(&PrefData.showCursorline, (int) value); +} + +Boolean GetPrefShowCursorline(void) +{ + return (Boolean) PrefData.showCursorline; +} + int GetPrefOverrideVirtKeyBindings(void) { return PrefData.virtKeyOverride; } @@ -5620,10 +5639,11 @@ selectBg SELECT_BG_COLOR hiliteFg HILITE_FG_COLOR hiliteBg HILITE_BG_COLOR lineNoFg LINENO_FG_COLOR cursorFg CURSOR_FG_COLOR +cursorlineBg CURSORLINE_BG_COLOR */ #define MARGIN_SPACING 10 /* @@ -5683,10 +5703,17 @@ { colorDialog *cd = (colorDialog *)clientData; showColorStatus(cd, cd->cursorFgW, cd->cursorFgErrW); } +static void cursorlineBgModifiedCB(Widget w, XtPointer clientData, + XtPointer callData) +{ + colorDialog *cd = (colorDialog *)clientData; + showColorStatus(cd, cd->cursorlineBgW, cd->cursorlineBgErrW); +} + /* * Helper functions for validating colors */ static int verifyAllColors(colorDialog *cd) { @@ -5696,11 +5723,12 @@ checkColorStatus(cd, cd->selectFgW) && checkColorStatus(cd, cd->selectBgW) && checkColorStatus(cd, cd->hiliteFgW) && checkColorStatus(cd, cd->hiliteBgW) && checkColorStatus(cd, cd->lineNoFgW) && - checkColorStatus(cd, cd->cursorFgW) ); + checkColorStatus(cd, cd->cursorFgW) && + checkColorStatus(cd, cd->cursorlineBgW)); } /* Returns True if the color is valid, False if it's not */ static Boolean checkColorStatus(colorDialog *cd, Widget colorFieldW) { @@ -5735,35 +5763,38 @@ *selectFg = XmTextGetString(cd->selectFgW), *selectBg = XmTextGetString(cd->selectBgW), *hiliteFg = XmTextGetString(cd->hiliteFgW), *hiliteBg = XmTextGetString(cd->hiliteBgW), *lineNoFg = XmTextGetString(cd->lineNoFgW), - *cursorFg = XmTextGetString(cd->cursorFgW); + *cursorFg = XmTextGetString(cd->cursorFgW), + *cursorlineBg = XmTextGetString(cd->cursorlineBgW); for (window = WindowList; window != NULL; window = window->next) { SetColors(window, textFg, textBg, selectFg, selectBg, hiliteFg, - hiliteBg, lineNoFg, cursorFg); + hiliteBg, lineNoFg, cursorFg, cursorlineBg); } SetPrefColorName(TEXT_FG_COLOR , textFg ); SetPrefColorName(TEXT_BG_COLOR , textBg ); SetPrefColorName(SELECT_FG_COLOR, selectFg); SetPrefColorName(SELECT_BG_COLOR, selectBg); SetPrefColorName(HILITE_FG_COLOR, hiliteFg); SetPrefColorName(HILITE_BG_COLOR, hiliteBg); SetPrefColorName(LINENO_FG_COLOR, lineNoFg); SetPrefColorName(CURSOR_FG_COLOR, cursorFg); + SetPrefColorName(CURSORLINE_BG_COLOR, cursorlineBg); XtFree(textFg); XtFree(textBg); XtFree(selectFg); XtFree(selectBg); XtFree(hiliteFg); XtFree(hiliteBg); XtFree(lineNoFg); XtFree(cursorFg); + XtFree(cursorlineBg); } /* * Dialog button callbacks @@ -5929,38 +5960,41 @@ NULL); XmStringFree(s1); topW = infoLbl; + /* The right column (backgrounds) */ + tmpW = addColorGroup( form, "textBg", 'T', "Text Area Background", + &(cd->textBgW), &(cd->textBgErrW), topW, 51, 99, + textBgModifiedCB, cd ); + tmpW = addColorGroup( form, "selectBg", 'B', "Selection Background", + &(cd->selectBgW), &(cd->selectBgErrW), tmpW, 51, 99, + selectBgModifiedCB, cd ); + tmpW = addColorGroup( form, "hiliteBg", 'h', "Matching (..) Background", + &(cd->hiliteBgW), &(cd->hiliteBgErrW), tmpW, 51, 99, + hiliteBgModifiedCB, cd ); + tmpW = addColorGroup( form, "cursorlineBg", 'r', "Cursorline Highlighting", + &(cd->cursorlineBgW), &(cd->cursorlineBgErrW), tmpW, 51, 99, + cursorlineBgModifiedCB, cd ); + /* The left column (foregrounds) of color entry groups */ tmpW = addColorGroup( form, "textFg", 'P', "Plain Text Foreground", &(cd->textFgW), &(cd->textFgErrW), topW, 1, 49, textFgModifiedCB, cd ); tmpW = addColorGroup( form, "selectFg", 'S', "Selection Foreground", &(cd->selectFgW), &(cd->selectFgErrW), tmpW, 1, 49, selectFgModifiedCB, cd ); tmpW = addColorGroup( form, "hiliteFg", 'M', "Matching (..) Foreground", &(cd->hiliteFgW), &(cd->hiliteFgErrW), tmpW, 1, 49, hiliteFgModifiedCB, cd ); + tmpW = addColorGroup( form, "cursorFg", 'C', "Cursor Color", + &(cd->cursorFgW), &(cd->cursorFgErrW), tmpW, 1, 49, + cursorFgModifiedCB, cd ); tmpW = addColorGroup( form, "lineNoFg", 'L', "Line Numbers", &(cd->lineNoFgW), &(cd->lineNoFgErrW), tmpW, 1, 49, lineNoFgModifiedCB, cd ); - /* The right column (backgrounds) */ - tmpW = addColorGroup( form, "textBg", 'T', "Text Area Background", - &(cd->textBgW), &(cd->textBgErrW), topW, 51, 99, - textBgModifiedCB, cd ); - tmpW = addColorGroup( form, "selectBg", 'B', "Selection Background", - &(cd->selectBgW), &(cd->selectBgErrW), tmpW, 51, 99, - selectBgModifiedCB, cd ); - tmpW = addColorGroup( form, "hiliteBg", 'h', "Matching (..) Background", - &(cd->hiliteBgW), &(cd->hiliteBgErrW), tmpW, 51, 99, - hiliteBgModifiedCB, cd ); - tmpW = addColorGroup( form, "cursorFg", 'C', "Cursor Color", - &(cd->cursorFgW), &(cd->cursorFgErrW), tmpW, 51, 99, - cursorFgModifiedCB, cd ); - tmpW = XtVaCreateManagedWidget("infoLbl", xmLabelGadgetClass, form, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, tmpW, XmNtopOffset, MARGIN_SPACING, @@ -6033,10 +6067,11 @@ XmTextSetString(cd->selectBgW, GetPrefColorName(SELECT_BG_COLOR)); XmTextSetString(cd->hiliteFgW, GetPrefColorName(HILITE_FG_COLOR)); XmTextSetString(cd->hiliteBgW, GetPrefColorName(HILITE_BG_COLOR)); XmTextSetString(cd->lineNoFgW, GetPrefColorName(LINENO_FG_COLOR)); XmTextSetString(cd->cursorFgW, GetPrefColorName(CURSOR_FG_COLOR)); + XmTextSetString(cd->cursorlineBgW, GetPrefColorName(CURSORLINE_BG_COLOR)); /* Handle mnemonic selection of buttons and focus to dialog */ AddDialogMnemonicHandler(form, FALSE); /* put up dialog */ Index: source/preferences.h =================================================================== RCS file: /cvsroot/nedit/nedit/source/preferences.h,v retrieving revision 1.41 diff -U5 -r1.41 preferences.h --- source/preferences.h 15 Apr 2004 22:32:31 -0000 1.41 +++ source/preferences.h 10 Jun 2004 12:32:40 -0000 @@ -187,8 +187,10 @@ void SetPrefOpenInTab(int state); int GetPrefOpenInTab(void); void SetPrefOpenInTab(int state); int GetPrefOpenInTab(void); Boolean GetPrefUndoModifiesSelection(void); +void SetPrefShowCursorline(Boolean value); +Boolean GetPrefShowCursorline(void); int GetPrefOverrideVirtKeyBindings(void); #endif /* NEDIT_PREFERENCES_H_INCLUDED */ Index: source/text.c =================================================================== RCS file: /cvsroot/nedit/nedit/source/text.c,v retrieving revision 1.46 diff -U5 -r1.46 text.c --- source/text.c 29 Apr 2004 02:34:01 -0000 1.46 +++ source/text.c 10 Jun 2004 12:33:35 -0000 @@ -626,10 +626,16 @@ XtOffset(TextWidget, text.highlightFGPixel), XmRString, NEDIT_DEFAULT_HI_FG}, {textNhighlightBackground, textCHighlightBackground, XmRPixel,sizeof(Pixel), XtOffset(TextWidget, text.highlightBGPixel), XmRString, NEDIT_DEFAULT_HI_BG}, + {textNcursorlineBackground, textCCursorlineBackground, XmRPixel,sizeof(Pixel), + XtOffset(TextWidget, text.cursorlineBGPixel), XmRString, + NEDIT_DEFAULT_CURSORLINE_BG}, + {textNshowCursorline, textCshowCursorline, XmRBoolean, sizeof(Boolean), + XtOffset(TextWidget, text.showCursorline), XmRString, "False"}, + {textNlineNumForeground, textCLineNumForeground, XmRPixel,sizeof(Pixel), XtOffset(TextWidget, text.lineNumFGPixel), XmRString, NEDIT_DEFAULT_LINENO_FG}, {textNcursorForeground, textCCursorForeground, XmRPixel,sizeof(Pixel), XtOffset(TextWidget, text.cursorFGPixel), XmRString, @@ -818,10 +824,11 @@ buf, new->text.fontStruct, new->core.background_pixel, new->primitive.foreground, new->text.selectFGPixel, new->text.selectBGPixel, new->text.highlightFGPixel, new->text.highlightBGPixel, new->text.cursorFGPixel, new->text.lineNumFGPixel, + new->text.cursorlineBGPixel, new->text.showCursorline, new->text.continuousWrap, new->text.wrapMargin, new->text.backlightCharTypes, new->text.calltipFGPixel, new->text.calltipBGPixel); /* Add mandatory delimiters blank, tab, and newline to the list of @@ -1118,10 +1125,18 @@ if (new->text.wrapMargin != current->text.wrapMargin || new->text.continuousWrap != current->text.continuousWrap) TextDSetWrapMode(current->text.textD, new->text.continuousWrap, new->text.wrapMargin); + if (new->text.showCursorline != current->text.showCursorline) { + current->text.showCursorline = new->text.showCursorline; + if (current->text.textD) + current->text.textD->showCursorline = new->text.showCursorline; + redraw = True; + /* TextDSetShowCursorline(current->text.textD, new->text.showCursorline); */ + } + /* When delimiters are changed, copy the memory, so that the caller doesn't have to manage it, and add mandatory delimiters blank, tab, and newline to the list */ if (new->text.delimiters != current->text.delimiters) { char *delimiters = XtMalloc(strlen(new->text.delimiters) + 4); Index: source/text.h =================================================================== RCS file: /cvsroot/nedit/nedit/source/text.h,v retrieving revision 1.18 diff -U5 -r1.18 text.h --- source/text.h 25 Dec 2003 06:55:08 -0000 1.18 +++ source/text.h 10 Jun 2004 12:33:35 -0000 @@ -26,10 +26,22 @@ #define textCSelectBackground "SelectBackground" #define textNhighlightForeground "highlightForeground" #define textCHighlightForeground "HighlightForeground" #define textNhighlightBackground "highlightBackground" #define textCHighlightBackground "HighlightBackground" + +/* added by latrin */ +#define textNcursorlineForeground "cursorlineForeground" +#define textCCursorlineForeground "CursorlineForeground" +#define textNcursorlineBackground "cursorlineBackground" +#define textCCursorlineBackground "CursorlineBackground" + +#define textNshowCursorline "showCursorline" +#define textCshowCursorline "ShowCursorline" +/******************/ + + #define textNcursorForeground "cursorForeground" #define textCCursorForeground "CursorForeground" #define textNlineNumForeground "lineNumForeground" #define textCLineNumForeground "LineNumForeground" #define textNcalltipForeground "calltipForeground" Index: source/textDisp.c =================================================================== RCS file: /cvsroot/nedit/nedit/source/textDisp.c,v retrieving revision 1.56 diff -U5 -r1.56 textDisp.c --- source/textDisp.c 1 Apr 2004 02:50:29 -0000 1.56 +++ source/textDisp.c 10 Jun 2004 12:33:50 -0000 @@ -66,41 +66,44 @@ #define LEFT_MARGIN 3 #define RIGHT_MARGIN 3 /* Masks for text drawing methods. These are or'd together to form an integer which describes what drawing calls to use to draw a string */ +#define STYLE_LOOKUP_SHIFT 0 #define FILL_SHIFT 8 #define SECONDARY_SHIFT 9 #define PRIMARY_SHIFT 10 #define HIGHLIGHT_SHIFT 11 -#define STYLE_LOOKUP_SHIFT 0 #define BACKLIGHT_SHIFT 12 +#define RANGESET_SHIFT 20 +#define CURSORLINE_SHIFT 26 #define FILL_MASK (1 << FILL_SHIFT) #define SECONDARY_MASK (1 << SECONDARY_SHIFT) #define PRIMARY_MASK (1 << PRIMARY_SHIFT) #define HIGHLIGHT_MASK (1 << HIGHLIGHT_SHIFT) #define STYLE_LOOKUP_MASK (0xff << STYLE_LOOKUP_SHIFT) #define BACKLIGHT_MASK (0xff << BACKLIGHT_SHIFT) - -#define RANGESET_SHIFT (20) #define RANGESET_MASK (0x3F << RANGESET_SHIFT) +#define CURSORLINE_MASK (1 << CURSORLINE_SHIFT) /* If you use both 32-Bit Style mask layout: Bits +----------------+----------------+----------------+----------------+ hex |1F1E1D1C1B1A1918|1716151413121110| F E D C B A 9 8| 7 6 5 4 3 2 1 0| dec |3130292827262524|2322212019181716|151413121110 9 8| 7 6 5 4 3 2 1 0| +----------------+----------------+----------------+----------------+ - 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| + 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| +----------------+----------------+----------------+----------------+ - where: s - style lookup value (8 bits) + where: + s - style lookup value (8 bits) F - fill (1 bit) 2 - secondary selection (1 bit) 1 - primary selection (1 bit) H - highlight (1 bit) b - backlighting index (8 bits) r - rangeset index (6 bits) + c - cursorline coloring (1 bit) This leaves 6 "unused" bits */ /* Maximum displayable line length (how many characters will fit across the widest window). This amount of memory is temporarily allocated from the stack in the redisplayLine routine for drawing strings */ @@ -117,10 +120,12 @@ static void calcLineStarts(textDisp *textD, int startLine, int endLine); static void calcLastChar(textDisp *textD); static int posToVisibleLineNum(textDisp *textD, int pos, int *lineNum); static void redisplayLine(textDisp *textD, int visLineNum, int leftClip, int rightClip, int leftCharIndex, int rightCharIndex); +static void redisplayLineCur(textDisp *textD, int visLineNum, int leftClip, + int rightClip, int leftCharIndex, int rightCharIndex, Boolean curLine); static void drawString(textDisp *textD, int style, int x, int y, int toX, char *string, int nChars); static void clearRect(textDisp *textD, GC gc, int x, int y, int width, int height); static void drawCursor(textDisp *textD, int x, int y); @@ -150,11 +155,12 @@ static int measureVisLine(textDisp *textD, int visLineNum); static int emptyLinesVisible(textDisp *textD); static void blankCursorProtrusions(textDisp *textD); static void allocateFixedFontGCs(textDisp *textD, XFontStruct *fontStruct, Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel, - Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel); + Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel, + Pixel cursorlineBGPixel); static GC allocateGC(Widget w, unsigned long valueMask, unsigned long foreground, unsigned long background, Font font, unsigned long dynamicMask, unsigned long dontCareMask); static void releaseGC(Widget w, GC gc); static void resetClipRectangles(textDisp *textD); @@ -184,12 +190,13 @@ Position left, Position top, Position width, Position height, Position lineNumLeft, Position lineNumWidth, textBuffer *buffer, XFontStruct *fontStruct, Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel, Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel cursorFGPixel, Pixel lineNumFGPixel, - int continuousWrap, int wrapMargin, XmString bgClassString, - Pixel calltipFGPixel, Pixel calltipBGPixel) + Pixel cursorlineBGPixel, Boolean showCursorline, int continuousWrap, + int wrapMargin, XmString bgClassString, Pixel calltipFGPixel, + Pixel calltipBGPixel) { textDisp *textD; XGCValues gcValues; int i; @@ -230,15 +237,17 @@ textD->selectFGPixel = selectFGPixel; textD->highlightFGPixel = highlightFGPixel; textD->selectBGPixel = selectBGPixel; textD->highlightBGPixel = highlightBGPixel; textD->lineNumFGPixel = lineNumFGPixel; + textD->cursorlineBGPixel = cursorlineBGPixel; /* added by latrin */ textD->cursorFGPixel = cursorFGPixel; textD->wrapMargin = wrapMargin; textD->continuousWrap = continuousWrap; allocateFixedFontGCs(textD, fontStruct, bgPixel, fgPixel, selectFGPixel, - selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel); + selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel, + cursorlineBGPixel); textD->styleGC = allocateGC(textD->w, 0, 0, 0, fontStruct->fid, GCClipMask|GCForeground|GCBackground, GCArcMode); textD->lineNumLeft = lineNumLeft; textD->lineNumWidth = lineNumWidth; textD->nVisibleLines = (height - 1) / (textD->ascent + textD->descent) + 1; @@ -260,10 +269,13 @@ textD->suppressResync = 0; textD->nLinesDeleted = 0; textD->modifyingTabDist = 0; textD->pointerHidden = False; textD->graphicsExposeQueue = NULL; + textD->showCursorline = showCursorline; + textD->oldCursorPos = 0; + textD->oldLineStart = 0; /* Attach an event handler to the widget so we can know the visibility (used for choosing the fastest drawing method) */ XtAddEventHandler(widget, VisibilityChangeMask, False, visibilityEH, textD); @@ -388,11 +400,11 @@ /* Change the (non syntax-highlit) colors */ void TextDSetColors(textDisp *textD, Pixel textFgP, Pixel textBgP, Pixel selectFgP, Pixel selectBgP, Pixel hiliteFgP, Pixel hiliteBgP, - Pixel lineNoFgP, Pixel cursorFgP) + Pixel lineNoFgP, Pixel cursorFgP, Pixel cursorlineBgP) { XGCValues values; Display *d = XtDisplay(textD->w); /* Update the stored pixels */ @@ -402,19 +414,21 @@ textD->selectBGPixel = selectBgP; textD->highlightFGPixel = hiliteFgP; textD->highlightBGPixel = hiliteBgP; textD->lineNumFGPixel = lineNoFgP; textD->cursorFGPixel = cursorFgP; + textD->cursorlineBGPixel = cursorlineBgP; releaseGC(textD->w, textD->gc); releaseGC(textD->w, textD->selectGC); releaseGC(textD->w, textD->selectBGGC); releaseGC(textD->w, textD->highlightGC); releaseGC(textD->w, textD->highlightBGGC); releaseGC(textD->w, textD->lineNumGC); + releaseGC(textD->w, textD->cursorlineBGGC); allocateFixedFontGCs(textD, textD->fontStruct, textBgP, textFgP, selectFgP, - selectBgP, hiliteFgP, hiliteBgP, lineNoFgP); + selectBgP, hiliteFgP, hiliteBgP, lineNoFgP, cursorlineBgP); /* Change the cursor GC (the cursor GC is not shared). */ values.foreground = cursorFgP; XChangeGC( d, textD->cursorFGGC, GCForeground, &values ); @@ -422,20 +436,30 @@ TextDRedisplayRect(textD, textD->left, textD->top, textD->width, textD->height); redrawLineNumbers(textD, True); } +void TextDSetShowCursorline(textDisp *textD, Boolean showCursorline) +{ + textD->showCursorline = showCursorline; + + /* Redisplay */ + TextDRedisplayRect(textD, textD->left, textD->top, textD->width, + textD->height); + redrawLineNumbers(textD, True); +} + /* ** Change the (non highlight) font */ void TextDSetFont(textDisp *textD, XFontStruct *fontStruct) { Display *display = XtDisplay(textD->w); int i, maxAscent = fontStruct->ascent, maxDescent = fontStruct->descent; int width, height, fontWidth; Pixel bgPixel, fgPixel, selectFGPixel, selectBGPixel; - Pixel highlightFGPixel, highlightBGPixel, lineNumFGPixel; + Pixel highlightFGPixel, highlightBGPixel, cursorlineBGPixel, lineNumFGPixel; XGCValues values; XFontStruct *styleFont; /* If font size changes, cursor will be redrawn in a new position */ blankCursorProtrusions(textD); @@ -483,20 +507,25 @@ selectFGPixel = values.foreground; selectBGPixel = values.background; XGetGCValues(display, textD->highlightGC,GCForeground|GCBackground,&values); highlightFGPixel = values.foreground; highlightBGPixel = values.background; + XGetGCValues(display, textD->cursorlineGC,GCForeground|GCBackground,&values); + cursorlineBGPixel = values.background; XGetGCValues(display, textD->lineNumGC, GCForeground, &values); lineNumFGPixel = values.foreground; releaseGC(textD->w, textD->gc); releaseGC(textD->w, textD->selectGC); releaseGC(textD->w, textD->highlightGC); + releaseGC(textD->w, textD->cursorlineGC); /* added by latrin */ releaseGC(textD->w, textD->selectBGGC); releaseGC(textD->w, textD->highlightBGGC); + releaseGC(textD->w, textD->cursorlineBGGC); /* added by latrin */ releaseGC(textD->w, textD->lineNumGC); allocateFixedFontGCs(textD, fontStruct, bgPixel, fgPixel, selectFGPixel, - selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel); + selectBGPixel, highlightFGPixel, highlightBGPixel, lineNumFGPixel, + cursorlineBGPixel); XSetFont(display, textD->styleGC, fontStruct->fid); /* Do a full resize to force recalculation of font related parameters */ width = textD->width; height = textD->height; @@ -777,37 +806,37 @@ TextDBlankCursor(textD); /* draw it at its new position */ textD->cursorPos = newPos; textD->cursorOn = True; - TextDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos + 1); + TextDRedisplayRange(textD, textD->cursorPos, textD->cursorPos); } void TextDBlankCursor(textDisp *textD) { if (!textD->cursorOn) return; blankCursorProtrusions(textD); textD->cursorOn = False; - TextDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos+1); + TextDRedisplayRange(textD, textD->cursorPos, textD->cursorPos); } void TextDUnblankCursor(textDisp *textD) { if (!textD->cursorOn) { textD->cursorOn = True; - TextDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos+1); + TextDRedisplayRange(textD, textD->cursorPos, textD->cursorPos); } } void TextDSetCursorStyle(textDisp *textD, int style) { textD->cursorStyle = style; blankCursorProtrusions(textD); if (textD->cursorOn) - TextDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos + 1); + TextDRedisplayRange(textD, textD->cursorPos, textD->cursorPos); } void TextDSetWrapMode(textDisp *textD, int wrap, int wrapMargin) { textD->wrapMargin = wrapMargin; @@ -1723,14 +1752,29 @@ ** "leftClip" and "rightClip" window coordinates and "leftCharIndex" and ** "rightCharIndex" character positions (not including the character at ** position "rightCharIndex"). ** ** The cursor is also drawn if it appears on the line. +** +** The function actually forwards to redisplayLineCur(), passing the +** showCursorline setting as appropriate. */ static void redisplayLine(textDisp *textD, int visLineNum, int leftClip, int rightClip, int leftCharIndex, int rightCharIndex) { + redisplayLineCur(textD, visLineNum, leftClip, rightClip, leftCharIndex, + rightCharIndex, textD->showCursorline); +} + +/* +** The meat of redisplayLine() is handled here. The extra curLine parameter +** tells redisplayLineCur() whether it should attempt to reset the previous +** "current line" to a non-current line state. +*/ +static void redisplayLineCur(textDisp *textD, int visLineNum, int leftClip, + int rightClip, int leftCharIndex, int rightCharIndex, Boolean curLine) +{ textBuffer *buf = textD->buffer; int i, x, y, startX, charIndex, lineStartPos, lineLen, fontHeight; int stdCharWidth, charWidth, startIndex, charStyle, style; int charLen, outStartIndex, outIndex, cursorX = 0, hasCursor = False; int dispIndexOffset, cursorPos = textD->cursorPos, y_orig; @@ -1762,10 +1806,92 @@ } else { lineLen = visLineLength(textD, visLineNum); lineStr = BufGetRange(buf, lineStartPos, lineStartPos + lineLen); } + /* handle case of leftCharIndex == rightCharIndex */ + if (leftCharIndex == rightCharIndex) { + if (lineStartPos + leftCharIndex == cursorPos) + { + /* we're at the cursor position */ + if (leftCharIndex > 0) + --leftCharIndex; + if (rightCharIndex < lineLen) + ++rightCharIndex; + if (rightCharIndex >= lineLen) + rightCharIndex = INT_MAX; + } + else { + /* hmm: not sure what gets us here, but it happens - redraw line */ + leftCharIndex = 0; + rightCharIndex = INT_MAX; + return; + } + } + + /* for cursorline tracking, if this is the current line, check it against + the last cursorline - if different, we need to display the whole line + plus anything to the extreme right */ + if (curLine && + (textD->oldCursorPos != cursorPos || + textD->oldLineStart != lineStartPos)) { + int oldCursor = textD->oldCursorPos; + int lineEndPos = lineStartPos + lineLen; + int oldLineStart = textD->oldLineStart; + int gotLineCurdiff = -1; + /* store new values if we need to call redisplayLine() again */ + textD->oldCursorPos = cursorPos; + + if (lineStartPos <= cursorPos && cursorPos <= lineEndPos && + !(lineStartPos <= oldCursor && oldCursor <= lineEndPos)) { + /* find visible line number for oldCursor */ + int lineNum, startPos = -1, oldLen, endPos; + int gotLine = -1; + + for (lineNum = 0; lineNum < textD->nVisibleLines; lineNum++) { + startPos = textD->lineStarts[lineNum]; + if (startPos >= 0) { + oldLen = visLineLength(textD, lineNum); + endPos = startPos + oldLen; + if (startPos >= 0 && + startPos <= oldCursor && oldCursor <= endPos) { + gotLine = lineNum; + break; + } + } + } + if (gotLine >= 0 && gotLine != visLineNum) { + redisplayLineCur(textD, gotLine, 0, INT_MAX, 0, INT_MAX, False); + gotLineCurdiff = gotLine; + } + /* right: that was the old line done - now the current line */ + leftCharIndex = 0; + rightCharIndex = INT_MAX; + /* only update oldLineStart i fcursor has moved */ + textD->oldLineStart = lineStartPos; + } + if (lineStartPos != oldLineStart) { + /* find visible line number for oldLineStart */ + int lineNum; + int gotLine = -1; + for (lineNum = 0; lineNum < textD->nVisibleLines; lineNum++) { + if (textD->lineStarts[lineNum] == oldLineStart) { + gotLine = lineNum; + break; + } + } + if (gotLine >= 0 && + gotLine != visLineNum && + gotLineCurdiff != gotLine) { + redisplayLineCur(textD, gotLine, 0, INT_MAX, 0, INT_MAX, False); + } + /* right: that was the old line done - now the current line */ + leftCharIndex = 0; + rightCharIndex = INT_MAX; + } + } + /* Space beyond the end of the line is still counted in units of characters of a standardized character width (this is done mostly because style changes based on character position can still occur in this region due to rectangular selections). stdCharWidth must be non-zero to prevent a potential infinite loop if x does not advance */ @@ -1910,10 +2036,11 @@ XGCValues gcValues; XFontStruct *fs = textD->fontStruct; Pixel bground = textD->bgPixel; Pixel fground = textD->fgPixel; int underlineStyle = FALSE; + int cursorline_mask = textD->showCursorline ? CURSORLINE_MASK : 0; /* Don't draw if widget isn't realized */ if (XtWindow(textD->w) == 0) return; @@ -1923,10 +2050,14 @@ } else if (style & HIGHLIGHT_MASK) { gc = textD->highlightGC; bgGC = textD->highlightBGGC; } + else if (style & cursorline_mask) { + gc = textD->cursorlineGC; + bgGC = textD->cursorlineBGGC; + } else if (style & PRIMARY_MASK) { gc = textD->selectGC; bgGC = textD->selectBGGC; } else { @@ -1958,10 +2089,11 @@ 3 Rangeset, 4 SyntaxHighlightStyle, 5 Backlight (if NOT fill), 6 DefaultBackground */ bground = style & PRIMARY_MASK ? textD->selectBGPixel : style & HIGHLIGHT_MASK ? textD->highlightBGPixel : + style & cursorline_mask ? textD->cursorlineBGPixel : style & RANGESET_MASK ? getRangesetColor(textD, (style&RANGESET_MASK)>>RANGESET_SHIFT, bground) : styleRec && styleRec->bgColorName ? styleRec->bgColor : @@ -2120,10 +2252,11 @@ static int styleOfPos(textDisp *textD, int lineStartPos, int lineLen, int lineIndex, int dispIndex, int thisChar) { textBuffer *buf = textD->buffer; textBuffer *styleBuf = textD->styleBuffer; + int cursorPos = textD->cursorPos; int pos, style = 0; if (lineStartPos == -1 || buf == NULL) return FILL_MASK; @@ -2141,10 +2274,12 @@ } if (inSelection(&buf->primary, pos, lineStartPos, dispIndex)) style |= PRIMARY_MASK; if (inSelection(&buf->highlight, pos, lineStartPos, dispIndex)) style |= HIGHLIGHT_MASK; + if (lineStartPos <= cursorPos && cursorPos <= lineStartPos + lineLen) + style |= CURSORLINE_MASK; if (inSelection(&buf->secondary, pos, lineStartPos, dispIndex)) style |= SECONDARY_MASK; /* store in the RANGESET_MASK portion of style the rangeset index for pos */ if (buf->rangesetTable) { int rangesetIndex = RangesetIndex1ofPos(buf->rangesetTable, pos, True); @@ -2681,11 +2816,11 @@ else if (xOffset < 0) { TextDRedisplayRect(textD, textD->left + textD->width + xOffset, textD->top, -xOffset, textD->height); } /* Restore protruding parts of the cursor */ - TextDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos+1); + TextDRedisplayRange(textD, textD->cursorPos, textD->cursorPos); } /* Refresh line number/calltip display if its up and we've scrolled vertically */ if (lineDelta != 0) { @@ -2968,11 +3103,12 @@ ** Allocate shared graphics contexts used by the widget, which must be ** re-allocated on a font change. */ static void allocateFixedFontGCs(textDisp *textD, XFontStruct *fontStruct, Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel, - Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel) + Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel lineNumFGPixel, + Pixel cursorlineBGPixel) { textD->gc = allocateGC(textD->w, GCFont | GCForeground | GCBackground, fgPixel, bgPixel, fontStruct->fid, GCClipMask, GCArcMode); textD->selectGC = allocateGC(textD->w, GCFont | GCForeground | GCBackground, selectFGPixel, selectBGPixel, fontStruct->fid, GCClipMask, @@ -2982,10 +3118,15 @@ textD->highlightGC = allocateGC(textD->w, GCFont|GCForeground|GCBackground, highlightFGPixel, highlightBGPixel, fontStruct->fid, GCClipMask, GCArcMode); textD->highlightBGGC = allocateGC(textD->w, GCForeground, highlightBGPixel, 0, fontStruct->fid, GCClipMask, GCArcMode); + textD->cursorlineGC = allocateGC(textD->w, GCFont|GCForeground|GCBackground, + fgPixel, cursorlineBGPixel, fontStruct->fid, GCClipMask, + GCArcMode); + textD->cursorlineBGGC = allocateGC(textD->w, GCForeground, + cursorlineBGPixel, 0, fontStruct->fid, GCClipMask, GCArcMode); textD->lineNumGC = allocateGC(textD->w, GCFont | GCForeground | GCBackground, lineNumFGPixel, bgPixel, fontStruct->fid, GCClipMask, GCArcMode); } Index: source/textDisp.h =================================================================== RCS file: /cvsroot/nedit/nedit/source/textDisp.h,v retrieving revision 1.24 diff -U5 -r1.24 textDisp.h --- source/textDisp.h 22 Nov 2003 13:03:40 -0000 1.24 +++ source/textDisp.h 10 Jun 2004 12:33:51 -0000 @@ -102,12 +102,17 @@ int ascent, descent; /* Composite ascent and descent for primary font + all-highlight fonts */ int fixedFontWidth; /* Font width if all current fonts are fixed and match in width, else -1 */ Widget hScrollBar, vScrollBar; - GC gc, selectGC, highlightGC; /* GCs for drawing text */ - GC selectBGGC, highlightBGGC; /* GCs for erasing text */ + /* added by latrin */ + int oldCursorPos; + int oldLineStart; + Pixel cursorlineBGPixel; + GC gc, selectGC, highlightGC, cursorlineGC; /* GCs for drawing text */ + GC selectBGGC, highlightBGGC, cursorlineBGGC; /* GCs for erasing text */ + /******************/ GC cursorFGGC; /* GC for drawing the cursor */ GC lineNumGC; /* GC for drawing line numbers */ GC styleGC; /* GC with color and font unspecified for drawing colored/styled text */ Pixel fgPixel, bgPixel; /* Foreground/Background colors */ @@ -134,29 +139,31 @@ int modifyingTabDist; /* Whether tab distance is being modified */ Boolean pointerHidden; /* true if the mouse pointer is hidden */ graphicExposeTranslationEntry *graphicsExposeQueue; + Boolean showCursorline; } textDisp; textDisp *TextDCreate(Widget widget, Widget hScrollBar, Widget vScrollBar, Position left, Position top, Position width, Position height, Position lineNumLeft, Position lineNumWidth, textBuffer *buffer, XFontStruct *fontStruct, Pixel bgPixel, Pixel fgPixel, Pixel selectFGPixel, Pixel selectBGPixel, Pixel highlightFGPixel, Pixel highlightBGPixel, Pixel cursorFGPixel, Pixel lineNumFGPixel, - int continuousWrap, int wrapMargin, XmString bgClassString, - Pixel calltipFGPixel, Pixel calltipBGPixel); + Pixel cursorlineBGPixel, Boolean showCursorline, int continuousWrap, + int wrapMargin, XmString bgClassString, Pixel calltipFGPixel, + Pixel calltipBGPixel); void TextDFree(textDisp *textD); void TextDSetBuffer(textDisp *textD, textBuffer *buffer); textBuffer *TextDGetBuffer(textDisp *textD); void TextDAttachHighlightData(textDisp *textD, textBuffer *styleBuffer, styleTableEntry *styleTable, int nStyles, char unfinishedStyle, unfinishedStyleCBProc unfinishedHighlightCB, void *cbArg); void TextDSetColors(textDisp *textD, Pixel textFgP, Pixel textBgP, Pixel selectFgP, Pixel selectBgP, Pixel hiliteFgP, Pixel hiliteBgP, - Pixel lineNoFgP, Pixel cursorFgP); + Pixel lineNoFgP, Pixel cursorFgP, Pixel cursorlineBgPix); void TextDSetFont(textDisp *textD, XFontStruct *fontStruct); int TextDMinFontWidth(textDisp *textD, Boolean considerStyles); int TextDMaxFontWidth(textDisp *textD, Boolean considerStyles); void TextDResize(textDisp *textD, int width, int height); void TextDRedisplayRect(textDisp *textD, int left, int top, int width, Index: source/textP.h =================================================================== RCS file: /cvsroot/nedit/nedit/source/textP.h,v retrieving revision 1.8 diff -U5 -r1.8 textP.h --- source/textP.h 18 Apr 2003 01:07:39 -0000 1.8 +++ source/textP.h 10 Jun 2004 12:33:53 -0000 @@ -37,11 +37,12 @@ extern TextClassRec nTextClassRec; typedef struct _TextPart { /* resources */ Pixel selectFGPixel, selectBGPixel, highlightFGPixel, highlightBGPixel; - Pixel cursorFGPixel, lineNumFGPixel, calltipFGPixel, calltipBGPixel; + Pixel cursorFGPixel, lineNumFGPixel, calltipFGPixel, calltipBGPixel, + cursorlineBGPixel; /* added by latrin */ XFontStruct *fontStruct; Boolean pendingDelete; Boolean autoShowInsertPos; Boolean autoWrap; Boolean autoWrapPastedText; @@ -50,10 +51,11 @@ Boolean smartIndent; Boolean overstrike; Boolean heavyCursor; Boolean readOnly; Boolean hidePointer; + Boolean showCursorline; int rows, columns; int marginWidth, marginHeight; int cursorBlinkRate; int wrapMargin; int emulateTabs; Index: source/window.c =================================================================== RCS file: /cvsroot/nedit/nedit/source/window.c,v retrieving revision 1.158 diff -U5 -r1.158 window.c --- source/window.c 9 Jun 2004 17:52:58 -0000 1.158 +++ source/window.c 10 Jun 2004 12:34:14 -0000 @@ -264,10 +264,11 @@ window->fileMissing = True; strcpy(window->filename, name); window->undo = NULL; window->redo = NULL; window->nPanes = 0; + window->lastFocus = NULL; window->autoSaveCharCount = 0; window->autoSaveOpCount = 0; window->undoOpCount = 0; window->undoMemUsed = 0; CLEAR_ALL_LOCKS(window->lockReasons); @@ -700,22 +701,23 @@ text = createTextArea(pane, window, rows,cols, GetPrefEmTabDist(PLAIN_LANGUAGE_MODE), GetPrefDelimiters(), GetPrefWrapMargin(), window->showLineNumbers?MIN_LINE_NUM_COLS:0); XtManageChild(text); window->textArea = text; - window->lastFocus = text; + ChangeLastFocus(window, text); /* Set the initial colors from the globals. */ SetColors(window, GetPrefColorName(TEXT_FG_COLOR ), GetPrefColorName(TEXT_BG_COLOR ), GetPrefColorName(SELECT_FG_COLOR), GetPrefColorName(SELECT_BG_COLOR), GetPrefColorName(HILITE_FG_COLOR), GetPrefColorName(HILITE_BG_COLOR), GetPrefColorName(LINENO_FG_COLOR), - GetPrefColorName(CURSOR_FG_COLOR)); + GetPrefColorName(CURSOR_FG_COLOR), + GetPrefColorName(CURSORLINE_BG_COLOR)); /* Create the right button popup menu (note: order is important here, since the translation for popping up this menu was probably already added in createTextArea, but CreateBGMenu requires window->textArea to be set so it can attach the menu to it (because menu shells are @@ -1184,11 +1186,11 @@ XmNbackground, textD->bgPixel, NULL); TextDSetColors( newTextD, textD->fgPixel, textD->bgPixel, textD->selectFGPixel, textD->selectBGPixel, textD->highlightFGPixel, textD->highlightBGPixel, textD->lineNumFGPixel, - textD->cursorFGPixel ); + textD->cursorFGPixel, textD->cursorlineBGPixel); /* Set the minimum pane height in the new pane */ UpdateMinPaneHeights(window); /* adjust the heights, scroll positions, etc., to split the focus pane */ @@ -1291,13 +1293,15 @@ window->nPanes--; XtUnmanageChild(containingPane(window->textPanes[window->nPanes])); XtDestroyWidget(containingPane(window->textPanes[window->nPanes])); if (window->nPanes == 0) - window->lastFocus = window->textArea; + text = window->textArea; else if (focusPane > window->nPanes) - window->lastFocus = window->textPanes[window->nPanes-1]; + text = window->textPanes[window->nPanes-1]; + + ChangeLastFocus(window, text); /* adjust the heights, scroll positions, etc., to make it look like the pane with the input focus was closed */ for (i=focusPane; i<=window->nPanes; i++) { insertPositions[i] = insertPositions[i+1]; @@ -1805,11 +1809,12 @@ UpdateMinPaneHeights(window); } void SetColors(WindowInfo *window, const char *textFg, const char *textBg, const char *selectFg, const char *selectBg, const char *hiliteFg, - const char *hiliteBg, const char *lineNoFg, const char *cursorFg) + const char *hiliteBg, const char *lineNoFg, const char *cursorFg, + const char* cursorlineBg) { int i, dummy; Pixel textFgPix = AllocColor( window->textArea, textFg, &dummy, &dummy, &dummy), textBgPix = AllocColor( window->textArea, textBg, @@ -1823,30 +1828,34 @@ hiliteBgPix = AllocColor( window->textArea, hiliteBg, &dummy, &dummy, &dummy), lineNoFgPix = AllocColor( window->textArea, lineNoFg, &dummy, &dummy, &dummy), cursorFgPix = AllocColor( window->textArea, cursorFg, + &dummy, &dummy, &dummy), + cursorlineBgPix = AllocColor( window->textArea, cursorlineBg, &dummy, &dummy, &dummy); textDisp *textD; /* Update the main pane */ XtVaSetValues(window->textArea, XmNforeground, textFgPix, XmNbackground, textBgPix, NULL); textD = ((TextWidget)window->textArea)->text.textD; TextDSetColors( textD, textFgPix, textBgPix, selectFgPix, selectBgPix, - hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix ); + hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix, + cursorlineBgPix); /* Update any additional panes */ for (i=0; inPanes; i++) { XtVaSetValues(window->textPanes[i], XmNforeground, textFgPix, XmNbackground, textBgPix, NULL); textD = ((TextWidget)window->textPanes[i])->text.textD; TextDSetColors( textD, textFgPix, textBgPix, selectFgPix, selectBgPix, - hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix ); + hiliteFgPix, hiliteBgPix, lineNoFgPix, cursorFgPix, + cursorlineBgPix); } /* Redo any syntax highlighting */ if (window->highlightData != NULL) UpdateHighlightStyles(window); @@ -2215,10 +2224,11 @@ textNautoIndent, window->indentStyle == AUTO_INDENT, textNsmartIndent, window->indentStyle == SMART_INDENT, textNautoWrap, window->wrapMode == NEWLINE_WRAP, textNcontinuousWrap, window->wrapMode == CONTINUOUS_WRAP, textNoverstrike, window->overstrike, + textNshowCursorline, False, textNhidePointer, (Boolean) GetPrefTypingHidesPointer(), textNcursorVPadding, GetVerticalAutoScroll(), NULL); XtVaSetValues(sw, XmNworkWindow, frame, XmNhorizontalScrollBar, @@ -2339,11 +2349,11 @@ } static void focusCB(Widget w, WindowInfo *window, XtPointer callData) { /* record which window pane last had the keyboard focus */ - window->lastFocus = w; + ChangeLastFocus(window, w); /* update line number statistic to reflect current focus pane */ UpdateStatsLine(window); /* finish off the current incremental search */ @@ -3340,10 +3350,11 @@ window->lastModTime = 0; strcpy(window->filename, name); window->undo = NULL; window->redo = NULL; window->nPanes = 0; + window->lastFocus = NULL; window->autoSaveCharCount = 0; window->autoSaveOpCount = 0; window->undoOpCount = 0; window->undoMemUsed = 0; CLEAR_ALL_LOCKS(window->lockReasons); @@ -3440,22 +3451,23 @@ text = createTextArea(pane, window, nRows, nCols, GetPrefEmTabDist(PLAIN_LANGUAGE_MODE), GetPrefDelimiters(), GetPrefWrapMargin(), window->showLineNumbers?MIN_LINE_NUM_COLS:0); XtManageChild(text); window->textArea = text; - window->lastFocus = text; + ChangeLastFocus(window, text); /* Set the initial colors from the globals. */ SetColors(window, GetPrefColorName(TEXT_FG_COLOR ), GetPrefColorName(TEXT_BG_COLOR ), GetPrefColorName(SELECT_FG_COLOR), GetPrefColorName(SELECT_BG_COLOR), GetPrefColorName(HILITE_FG_COLOR), GetPrefColorName(HILITE_BG_COLOR), GetPrefColorName(LINENO_FG_COLOR), - GetPrefColorName(CURSOR_FG_COLOR)); + GetPrefColorName(CURSOR_FG_COLOR), + GetPrefColorName(CURSORLINE_BG_COLOR)); /* Create the right button popup menu (note: order is important here, since the translation for popping up this menu was probably already added in createTextArea, but CreateBGMenu requires window->textArea to be set so it can attach the menu to it (because menu shells are @@ -3830,11 +3842,11 @@ /* set the focus pane */ for (i=0; i<=window->nPanes; i++) { text = i==0 ? window->textArea : window->textPanes[i-1]; if(i == focusPane) { - window->lastFocus = text; + ChangeLastFocus(window, text); XmProcessTraversal(text, XmTRAVERSE_CURRENT); break; } } @@ -4709,10 +4721,25 @@ XtSetSensitive(w, sensitive); } } /* +** Track which text pane in this widget is/was last active (with focus). +** Also perform any tasks relating to changing pane focus. +*/ +void ChangeLastFocus(WindowInfo *window, Widget text) +{ + if (GetPrefShowCursorline()) { + if (window->lastFocus) { + XtVaSetValues(window->lastFocus, textNshowCursorline, False, NULL); + } + XtVaSetValues(text, textNshowCursorline, True, NULL); + } + window->lastFocus = text; +} + +/* ** Remove redundant expose events on tab bar. */ void CleanUpTabBarExposeQueue(WindowInfo *window) { XEvent event; Index: source/window.h =================================================================== RCS file: /cvsroot/nedit/nedit/source/window.h,v retrieving revision 1.23 diff -U5 -r1.23 window.h --- source/window.h 28 Apr 2004 01:54:20 -0000 1.23 +++ source/window.h 10 Jun 2004 12:34:14 -0000 @@ -28,11 +28,12 @@ void SetShowMatching(WindowInfo *window, int state); void SetFonts(WindowInfo *window, const char *fontName, const char *italicName, const char *boldName, const char *boldItalicName); void SetColors(WindowInfo *window, const char *textFg, const char *textBg, const char *selectFg, const char *selectBg, const char *hiliteFg, - const char *hiliteBg, const char *lineNoFg, const char *cursorFg); + const char *hiliteBg, const char *lineNoFg, const char *cursorFg, + const char* cursorlineBg); void SetOverstrike(WindowInfo *window, int overstrike); void SetAutoWrap(WindowInfo *window, int state); void SetWrapMargin(WindowInfo *window, int margin); void SetAutoScroll(WindowInfo *window, int margin); void SplitPane(WindowInfo *window); @@ -80,7 +81,8 @@ void SortTabBar(WindowInfo *window); void SetBacklightChars(WindowInfo *window, char *applyBacklightTypes); void SetToggleButtonState(WindowInfo *window, Widget w, Boolean state, Boolean notify); void SetSensitive(WindowInfo *window, Widget w, Boolean sensitive); +void ChangeLastFocus(WindowInfo *window, Widget text); void CleanUpTabBarExposeQueue(WindowInfo *window); #endif /* NEDIT_WINDOW_H_INCLUDED */