Allows styles to specify the underlining of text. This patch adds an "Underline" check box to the Text Drawing Styles dialog. If selected, it causes text of the corresponding style to be underlined. The position of the underline for underlining is determined differently from the underline used for secondary selection, so you can distinguish between the two. The text-style underline is at the bottom of the glyphs' descenders whereas the secondary select underline is just below their baseline. The underline flag is stored as the word "underline" in the nedit.rc saved preferences file. If missing, no underline attribute is registered. diff -ru nedit_official/source nedit_mod/source diff -ru nedit_official/source/highlight.c nedit_mod/source/highlight.c --- nedit_official/source/highlight.c 2008-01-04 23:11:03.000000000 +0100 +++ nedit_mod/source/highlight.c 2008-01-14 17:27:33.000000000 +0100 @@ -772,6 +772,7 @@ p->styleName = pat->style; \ p->colorName = ColorOfNamedStyle(pat->style); \ p->bgColorName = BgColorOfNamedStyle(pat->style); \ + p->underline = UnderlineOfNamedStyle(pat->style); \ p->isBold = FontOfNamedStyleIsBold(pat->style); \ p->isItalic = FontOfNamedStyleIsItalic(pat->style); \ /* And now for the more physical stuff */ \ diff -ru nedit_official/source/highlightData.c nedit_mod/source/highlightData.c --- nedit_official/source/highlightData.c 2008-01-04 23:11:03.000000000 +0100 +++ nedit_mod/source/highlightData.c 2008-01-14 17:23:08.000000000 +0100 @@ -89,6 +89,7 @@ char *color; char *bgColor; int font; + Boolean underline; } highlightStyleRec; static int styleError(const char *stringStart, const char *stoppedAt, @@ -168,6 +169,7 @@ Widget colorW; Widget bgColorW; Widget plainW, boldW, italicW, boldItalicW; + Widget underlineW; Widget managedListW; highlightStyleRec **highlightStyleList; int nHighlightStyles; @@ -1067,6 +1069,15 @@ } XtFree(fontStr); + hs->underline = False; + while (SkipOptSeparator(':', &inPtr)) { + char *wordStr = ReadSymbolicField(&inPtr); + if (wordStr && strcmp(wordStr, "underline") == 0) { + hs->underline = True; + } + XtFree(wordStr); + /* else if any other optional flags ... */ + } /* pattern set was read correctly, add/change it in the list */ for (i=0; iname, hs->name)) { @@ -1114,6 +1125,9 @@ } BufInsert(outBuf, outBuf->length, ":"); BufInsert(outBuf, outBuf->length, FontTypeNames[style->font]); + if (style->underline) { + BufInsert(outBuf, outBuf->length, ":underline"); + } BufInsert(outBuf, outBuf->length, "\\n\\\n"); } @@ -1336,6 +1350,18 @@ } /* +** Find whether a named style is underlined. +*/ +Boolean UnderlineOfNamedStyle(const char *styleName) +{ + int styleNo=lookupNamedStyle(styleName); + + if (styleNo<0) + return False; + return HighlightStyles[styleNo]->underline; +} + +/* ** Determine whether a named style exists */ int NamedStyleExists(const char *styleName) @@ -1865,7 +1891,18 @@ XmNlabelString, s1=XmStringCreateSimple("Bold Italic"), XmNmnemonic, 'o', NULL); XmStringFree(s1); - + + HSDialog.underlineW = XtVaCreateManagedWidget("underline", + xmToggleButtonWidgetClass, form, + XmNleftAttachment, XmATTACH_POSITION, + XmNleftPosition, HS_LIST_RIGHT, + XmNtopAttachment, XmATTACH_WIDGET, + XmNtopOffset, HS_H_MARGIN, + XmNtopWidget, fontBox, + XmNlabelString, s1=XmStringCreateSimple("Underlined"), + XmNmnemonic, 'U', NULL); + XmStringFree(s1); + okBtn = XtVaCreateManagedWidget("ok",xmPushButtonWidgetClass,form, XmNlabelString, s1=XmStringCreateSimple("OK"), XmNmarginWidth, BUTTON_WIDTH_MARGIN, @@ -1906,7 +1943,7 @@ sep1 = XtVaCreateManagedWidget("sep1", xmSeparatorGadgetClass, form, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, fontBox, + XmNtopWidget, /* fontBox, */ HSDialog.underlineW, XmNtopOffset, HS_H_MARGIN, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, @@ -2023,6 +2060,7 @@ RadioButtonChangeState(HSDialog.boldW, False, False); RadioButtonChangeState(HSDialog.italicW, False, False); RadioButtonChangeState(HSDialog.boldItalicW, False, False); + RadioButtonChangeState(HSDialog.underlineW, False, False); } else { if (strcmp(hs->name, "Plain") == 0) { /* you should not be able to delete the reserved style "Plain" */ @@ -2053,6 +2091,7 @@ RadioButtonChangeState(HSDialog.italicW, hs->font==ITALIC_FONT, False); RadioButtonChangeState(HSDialog.boldItalicW, hs->font==BOLD_ITALIC_FONT, False); + RadioButtonChangeState(HSDialog.underlineW, hs->underline, False); } } @@ -2168,6 +2207,8 @@ else hs->font = PLAIN_FONT; + /* and finally, do we underline? */ + hs->underline = XmToggleButtonGetState(HSDialog.underlineW); return hs; } @@ -2195,6 +2236,7 @@ strcpy(newHS->bgColor, hs->bgColor); } newHS->font = hs->font; + newHS->underline = hs->underline; return newHS; } @@ -2232,7 +2274,8 @@ { return TextWidgetIsBlank(HSDialog.nameW) && TextWidgetIsBlank(HSDialog.colorW) && - XmToggleButtonGetState(HSDialog.plainW); + XmToggleButtonGetState(HSDialog.plainW) && + !XmToggleButtonGetState(HSDialog.underlineW); } /* diff -ru nedit_official/source/highlightData.h nedit_mod/source/highlightData.h --- nedit_official/source/highlightData.h 2004-11-09 22:58:44.000000000 +0100 +++ nedit_mod/source/highlightData.h 2008-01-14 17:23:08.000000000 +0100 @@ -48,6 +48,7 @@ int FontOfNamedStyleIsItalic(char *styleName); char *ColorOfNamedStyle(const char *styleName); char *BgColorOfNamedStyle(const char *styleName); +Boolean UnderlineOfNamedStyle(const char *styleName); int IndexOfNamedStyle(const char *styleName); int NamedStyleExists(const char *styleName); void RenameHighlightPattern(const char *oldName, const char *newName); diff -ru nedit_official/source/macro.c nedit_mod/source/macro.c --- nedit_official/source/macro.c 2007-10-04 18:04:25.000000000 +0200 +++ nedit_mod/source/macro.c 2008-01-14 17:23:08.000000000 +0100 @@ -5337,7 +5337,8 @@ ** ["color"] Foreground color name of style ** ["background"] Background color name of style if specified ** ["bold"] '1' if style is bold, '0' otherwise -** ["italic"] '1' if style is italic, '0' otherwise +** ["italic"] '1' if style is italic, '0' otherwise +** ["underline"] '1' if style is underlined, '0' otherwise ** Given position and pattern code we obtain: ** ["rgb"] RGB representation of foreground color of style ** ["back_rgb"] RGB representation of background color of style @@ -5431,6 +5432,12 @@ M_ARRAY_INSERT_FAILURE(); } + /* Put underlining value in array */ + DV.val.n = UnderlineOfNamedStyle(styleName); + if (!ArrayInsert(result, PERM_ALLOC_STR("underline"), &DV)) { + M_ARRAY_INSERT_FAILURE(); + } + if (bufferPos >= 0) { /* insert extent */ const char *styleNameNotUsed = NULL; diff -ru 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:23:08.000000000 +0100 @@ -2044,16 +2044,20 @@ y + textD->ascent, string, nChars); /* Underline if style is secondary selection */ - if (style & SECONDARY_MASK || underlineStyle) + if (style & SECONDARY_MASK) { - /* restore foreground in GC (was set to background by clearRect()) */ - gcValues.foreground = fground; - XChangeGC(XtDisplay(textD->w), gc, - GCForeground, &gcValues); /* draw underline */ XDrawLine(XtDisplay(textD->w), XtWindow(textD->w), gc, x, y + textD->ascent, toX - 1, y + textD->ascent); } + /* Underline if style is underlined */ + if (underlineStyle) + { + int bottom = textD->ascent + textD->descent - 1; + /* draw underline - use textD->gc for the non-highlighted text color */ + XDrawLine(XtDisplay(textD->w), XtWindow(textD->w), gc, x, + y + bottom, toX - 1, y + bottom); + } } /*