    [INACTIVE] Highlighted Cursorline

    This is Thorsten Haude's patch, modified from Fredrik Corneliusson's patch
    to provide a background color for the current line. You can find it here:

    http://sourceforge.net/tracker/index.php?func=detail&aid=683567&group_id=11005&atid=311005
	    [ 683567 ] Highlighted Cursorline
	    cursorline.ajbj.2004-03-28.1.diff 2004-03-28 05:52

    This coloring takes precedence over rangesets, syntax highlighting
    backgrounds (if specified) and backlighting, but not over parenthesis match
    highlighting nor selection.

    It still requires work, for example for turning the cursorline highlighting
    on and off through the GUI and through macros.

    Thorsten has taken over this patch, integrating it with other functionality.
    Check the patch page:

    http://sourceforge.net/tracker/index.php?func=detail&aid=1058246&group_id=11005&atid=311005
	    [ 1058246 ] Patch Collection

diff -aur nedit_official nedit_mod
diff -aur nedit_official/source/menu.c nedit_mod/source/menu.c
--- nedit_official/source/menu.c	2008-01-04 23:11:03.000000000 +0100
+++ nedit_mod/source/menu.c	2008-01-14 17:57:24.000000000 +0100
@@ -3933,7 +3933,7 @@
             newFocusPane = GetPaneByIndex(window, paneIndex);
         }
         if (newFocusPane != NULL) {
-            window->lastFocus = newFocusPane;
+            ChangeLastFocus(window, newFocusPane);
             XmProcessTraversal(window->lastFocus, XmTRAVERSE_CURRENT);
         }
         else {
diff -aur nedit_official/source/nedit.h nedit_mod/source/nedit.h
--- nedit_official/source/nedit.h	2008-01-04 23:11:03.000000000 +0100
+++ nedit_mod/source/nedit.h	2008-01-14 17:57:24.000000000 +0100
@@ -56,7 +56,7 @@
 #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 5119          /* Maximum length of search/replace strings */
@@ -193,6 +193,7 @@
     HILITE_BG_COLOR,
     LINENO_FG_COLOR,
     CURSOR_FG_COLOR,
+    CURSORLINE_BG_COLOR,
     NUM_COLORS
 };
 
diff -aur nedit_official/source/preferences.c nedit_mod/source/preferences.c
--- nedit_official/source/preferences.c	2008-01-13 13:04:35.000000000 +0100
+++ nedit_mod/source/preferences.c	2008-01-14 17:57:24.000000000 +0100
@@ -235,6 +235,8 @@
     Widget lineNoFgErrW;
     Widget cursorFgW;
     Widget cursorFgErrW;
+    Widget cursorlineBgW;
+    Widget cursorlineBgErrW;
     WindowInfo *window;
 } colorDialog;
 
@@ -320,6 +322,7 @@
     char colorNames[NUM_COLORS][MAX_COLOR_LEN];
     char tooltipBgColor[MAX_COLOR_LEN];
     int  undoModifiesSelection;
+    int showCursorline;         /* Wanna see where the cursor is? */
     int  focusOnRaise;
     Boolean honorSymlinks;
     int truncSubstitution;
@@ -1022,6 +1025,10 @@
     {"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},
@@ -1065,6 +1072,8 @@
 	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},
     {"focusOnRaise", "FocusOnRaise", PREF_BOOLEAN,
             "False", &PrefData.focusOnRaise, NULL, False},
     {"forceOSConversion", "ForceOSConversion", PREF_BOOLEAN, "True",
@@ -2164,6 +2173,16 @@
     return PrefData.honorSymlinks;
 }
 
+void SetPrefShowCursorline(Boolean value)
+{
+    setIntPref(&PrefData.showCursorline, (int) value);
+}
+
+Boolean GetPrefShowCursorline(void)
+{
+    return (Boolean) PrefData.showCursorline;
+}
+
 int GetPrefOverrideVirtKeyBindings(void)
 {
     return PrefData.virtKeyOverride;
@@ -5797,6 +5816,7 @@
 hiliteBg              HILITE_BG_COLOR
 lineNoFg              LINENO_FG_COLOR
 cursorFg              CURSOR_FG_COLOR
+cursorlineBg          CURSORLINE_BG_COLOR
 */
 
 #define MARGIN_SPACING 10
@@ -5860,6 +5880,13 @@
     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
@@ -5874,7 +5901,8 @@
             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 */
@@ -5913,12 +5941,13 @@
             *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  );
@@ -5929,6 +5958,7 @@
     SetPrefColorName(HILITE_BG_COLOR, hiliteBg);
     SetPrefColorName(LINENO_FG_COLOR, lineNoFg);
     SetPrefColorName(CURSOR_FG_COLOR, cursorFg);
+    SetPrefColorName(CURSORLINE_BG_COLOR, cursorlineBg);
 
     XtFree(textFg);
     XtFree(textBg);
@@ -5938,6 +5968,7 @@
     XtFree(hiliteBg);
     XtFree(lineNoFg);
     XtFree(cursorFg);
+    XtFree(cursorlineBg);
 }
 
 
@@ -6107,6 +6138,20 @@
     
     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, 
@@ -6117,24 +6162,13 @@
     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,
@@ -6215,6 +6249,7 @@
     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);
diff -aur nedit_official/source/preferences.h nedit_mod/source/preferences.h
--- nedit_official/source/preferences.h	2008-01-04 23:11:03.000000000 +0100
+++ nedit_mod/source/preferences.h	2008-01-14 17:57:24.000000000 +0100
@@ -201,6 +201,7 @@
 #endif
 void SetPrefTitleFormat(const char* format);
 const char* GetPrefTitleFormat(void);
+Boolean GetPrefShowCursorline(void);
 int GetPrefOverrideVirtKeyBindings(void);
 int GetPrefTruncSubstitution(void);
 int GetPrefOpenInTab(void);
diff -aur nedit_official/source/text.c nedit_mod/source/text.c
--- nedit_official/source/text.c	2008-01-04 23:11:04.000000000 +0100
+++ nedit_mod/source/text.c	2008-01-14 17:57:24.000000000 +0100
@@ -631,6 +631,12 @@
     {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},
@@ -823,6 +829,7 @@
 	    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);
@@ -1123,6 +1130,14 @@
     	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 */
diff -aur nedit_official/source/textDisp.c nedit_mod/source/textDisp.c
--- nedit_official/source/textDisp.c	2008-01-04 23:31:48.000000000 +0100
+++ nedit_mod/source/textDisp.c	2008-01-14 17:57:24.000000000 +0100
@@ -64,12 +64,14 @@
 
 /* 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)
@@ -77,24 +79,25 @@
 #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
@@ -115,6 +118,8 @@
 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, 
@@ -149,7 +154,8 @@
 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);
@@ -186,8 +192,9 @@
         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;
@@ -232,11 +239,13 @@
     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;
@@ -262,6 +271,9 @@
     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) */
@@ -382,7 +394,7 @@
 /* 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);
@@ -396,6 +408,7 @@
     textD->highlightBGPixel = hiliteBgP;
     textD->lineNumFGPixel = lineNoFgP;
     textD->cursorFGPixel = cursorFgP;
+    textD->cursorlineBGPixel = cursorlineBgP;
 
     releaseGC(textD->w, textD->gc);
     releaseGC(textD->w, textD->selectGC);
@@ -403,8 +416,9 @@
     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;
@@ -416,6 +430,16 @@
     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
 */
@@ -425,7 +449,7 @@
     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;
     
@@ -477,16 +501,21 @@
     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 */
@@ -785,7 +814,7 @@
     /* 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)
@@ -795,14 +824,14 @@
     
     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);
     }
 }
 
@@ -811,7 +840,7 @@
     textD->cursorStyle = style;
     blankCursorProtrusions(textD);
     if (textD->cursorOn) {
-        textDRedisplayRange(textD, textD->cursorPos-1, textD->cursorPos + 1);
+        textDRedisplayRange(textD, textD->cursorPos, textD->cursorPos);
     }
 }
 
@@ -1747,10 +1776,25 @@
 ** 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;
@@ -1786,6 +1830,88 @@
 	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
@@ -1951,6 +2077,7 @@
     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)
@@ -1964,6 +2091,10 @@
         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;
@@ -1999,6 +2130,7 @@
         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,
@@ -2161,6 +2293,7 @@
 {
     textBuffer *buf = textD->buffer;
     textBuffer *styleBuf = textD->styleBuffer;
+    int cursorPos = textD->cursorPos;
     int pos, style = 0;
     
     if (lineStartPos == -1 || buf == NULL)
@@ -2182,6 +2315,8 @@
     	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 */
@@ -2723,7 +2858,7 @@
                     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 
@@ -3010,7 +3145,8 @@
 */
 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); 
@@ -3024,6 +3160,11 @@
             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);
diff -aur nedit_official/source/textDisp.h nedit_mod/source/textDisp.h
--- nedit_official/source/textDisp.h	2008-01-04 23:11:04.000000000 +0100
+++ nedit_mod/source/textDisp.h	2008-01-14 17:57:24.000000000 +0100
@@ -129,8 +129,13 @@
     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
@@ -161,6 +166,7 @@
     Boolean pointerHidden;              /* true if the mouse pointer is 
                                            hidden */
     graphicExposeTranslationEntry *graphicsExposeQueue;
+    Boolean showCursorline;
 } textDisp;
 
 textDisp *TextDCreate(Widget widget, Widget hScrollBar, Widget vScrollBar,
@@ -169,8 +175,9 @@
 	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);
 void TextDAttachHighlightData(textDisp *textD, textBuffer *styleBuffer,
@@ -178,7 +185,7 @@
     	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 cursorlineBgP);
 void TextDSetFont(textDisp *textD, XFontStruct *fontStruct);
 int TextDMinFontWidth(textDisp *textD, Boolean considerStyles);
 int TextDMaxFontWidth(textDisp *textD, Boolean considerStyles);
diff -aur nedit_official/source/text.h nedit_mod/source/text.h
--- nedit_official/source/text.h	2008-01-04 23:11:04.000000000 +0100
+++ nedit_mod/source/text.h	2008-01-14 17:57:24.000000000 +0100
@@ -53,6 +53,18 @@
 #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"
diff -aur nedit_official/source/textP.h nedit_mod/source/textP.h
--- nedit_official/source/textP.h	2004-11-09 22:58:45.000000000 +0100
+++ nedit_mod/source/textP.h	2008-01-14 17:57:24.000000000 +0100
@@ -58,7 +58,8 @@
 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;
@@ -71,6 +72,7 @@
     Boolean heavyCursor;
     Boolean readOnly;
     Boolean hidePointer;
+    Boolean showCursorline;
     int rows, columns;
     int marginWidth, marginHeight;
     int cursorBlinkRate;
diff -aur nedit_official/source/window.c nedit_mod/source/window.c
--- nedit_official/source/window.c	2008-01-05 03:24:13.000000000 +0100
+++ nedit_mod/source/window.c	2008-01-14 17:58:19.000000000 +0100
@@ -259,6 +259,7 @@
     window->undo = NULL;
     window->redo = NULL;
     window->nPanes = 0;
+    window->lastFocus = NULL;
     window->autoSaveCharCount = 0;
     window->autoSaveOpCount = 0;
     window->undoOpCount = 0;
@@ -697,7 +698,7 @@
             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,
@@ -708,7 +709,8 @@
               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
@@ -1219,7 +1221,7 @@
     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);
@@ -1325,9 +1327,11 @@
     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 */
@@ -1855,7 +1859,8 @@
 
 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, 
@@ -1873,6 +1878,8 @@
             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;
 
@@ -1883,7 +1890,8 @@
             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; i<window->nPanes; i++) {
         XtVaSetValues(window->textPanes[i],
@@ -1892,7 +1900,8 @@
                 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 */
@@ -2233,6 +2242,7 @@
             textNautoWrap, window->wrapMode == NEWLINE_WRAP,
             textNcontinuousWrap, window->wrapMode == CONTINUOUS_WRAP,
             textNoverstrike, window->overstrike,
+            textNshowCursorline, False,
             textNhidePointer, (Boolean) GetPrefTypingHidesPointer(),
             textNcursorVPadding, GetVerticalAutoScroll(),
             NULL);
@@ -2370,7 +2380,7 @@
 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);
@@ -3278,6 +3288,7 @@
     window->undo = NULL;
     window->redo = NULL;
     window->nPanes = 0;
+    window->lastFocus = NULL;
     window->autoSaveCharCount = 0;
     window->autoSaveOpCount = 0;
     window->undoOpCount = 0;
@@ -3380,7 +3391,7 @@
 	    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,
@@ -3391,7 +3402,8 @@
               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
@@ -4180,7 +4192,8 @@
             TextDSetColors(newTextD, textD->fgPixel, textD->bgPixel, 
                     textD->selectFGPixel, textD->selectBGPixel,
                     textD->highlightFGPixel,textD->highlightBGPixel,
-                    textD->lineNumFGPixel, textD->cursorFGPixel);
+                    textD->lineNumFGPixel, textD->cursorFGPixel,
+                    textD->cursorlineBGPixel);
 	}
         
 	/* Set the minimum pane height in the new pane */
@@ -4213,7 +4226,7 @@
     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;
 	}
@@ -4744,3 +4757,18 @@
 		ExposureMask, (XEvent *)&ev);
     }
 }    
+
+/*
+** 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;
+}
diff -aur nedit_official/source/window.h nedit_mod/source/window.h
--- nedit_official/source/window.h	2008-01-04 23:11:05.000000000 +0100
+++ nedit_mod/source/window.h	2008-01-14 17:57:24.000000000 +0100
@@ -53,7 +53,8 @@
 	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 SetAutoScroll(WindowInfo *window, int margin);
@@ -104,4 +105,5 @@
         Boolean notify);
 void SetSensitive(WindowInfo *window, Widget w, Boolean sensitive);
 void CleanUpTabBarExposeQueue(WindowInfo *window);
+void ChangeLastFocus(WindowInfo *window, Widget text);
 #endif /* NEDIT_WINDOW_H_INCLUDED */
