From 92b4c75d9a045a87cc60901cabb53d4085c83bd7 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Sat, 2 Feb 2008 19:56:15 +0100 Subject: [PATCH] import RSunderlineStyle.diff from ajbj B.W. --- RSunderlineStyle.diff | 405 ++++++++++++++++++++++++++++++++++++++++++++++ fix_hide_hscrollbar.patch | 2 +- series | 1 + sh-bg-newline.diff | 2 +- 4 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 RSunderlineStyle.diff diff --git a/RSunderlineStyle.diff b/RSunderlineStyle.diff new file mode 100644 index 0000000..21f7ac9 --- /dev/null +++ b/RSunderlineStyle.diff @@ -0,0 +1,405 @@ + Allow rangesets to be displayed underlined. + + This patch depends on the UnderlineStyle.diff patch (or its derivative). + APPLY THAT PATCH FIRST! This patch uses the syntax highlighting style's + underlining mechanism (from the earlier patch) to provide an underline for a + rangeset. + + To apply underlining to a rangeset, use the following macro functioon: + rangeset_set_underline(id, mode) + where mode is one of "leave" (don't change underlining from syntax + highlighting's attributes), "remove" (don't show syntax highlighting + underlines for the ranges of the set, and "add" (make sure all text in + the rangeset is undelined). The ramgeset_info() function will return + the underline mode keyword for a set. + +--- + + doc/help.etx | 6 ++++ + source/macro.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++--- + source/rangeset.c | 38 +++++++++++++++++++++++++++- + source/rangeset.h | 5 +++ + source/textDisp.c | 28 +++++++++++++++++++++ + 5 files changed, 144 insertions(+), 5 deletions(-) + +diff --quilt old/doc/help.etx new/doc/help.etx +--- old/doc/help.etx ++++ new/doc/help.etx +@@ -3147,10 +3147,16 @@ Rangesets + Attempts to apply the color as a background color to the ranges of r. If + color is at empty string, removes the coloring of r. No check is made + regarding the validity of color: if the color is invalid (a bad name, + or not supported by the hardware) this has unpredictable effects. + ++**rangeset_set_underline( r, mode )** ++ Change whether text over which the rangeset is defined should be displayed ++ as underlined. **mode** can be "leave" (the text will show any underlining ++ according to syntax highlighting settings), "remove" (any underliining is ++ removed), or "add" (underlining is added to the text). ++ + **rangeset_set_name( r, name )** + Apply the name to the rangeset r. + + **rangeset_set_mode( r, type )** + Changes the behaviour of the rangeset r when modifications to the text +diff --quilt old/source/macro.c new/source/macro.c +--- old/source/macro.c ++++ new/source/macro.c +@@ -392,10 +392,12 @@ static int rangesetRangeMS(WindowInfo *w + DataValue *result, char **errMsg); + static int rangesetIncludesPosMS(WindowInfo *window, DataValue *argList, + int nArgs, DataValue *result, char **errMsg); + static int rangesetSetColorMS(WindowInfo *window, DataValue *argList, + int nArgs, DataValue *result, char **errMsg); ++static int rangesetSetUnderlineMS(WindowInfo *window, DataValue *argList, ++ int nArgs, DataValue *result, char **errMsg); + static int rangesetSetNameMS(WindowInfo *window, DataValue *argList, + int nArgs, DataValue *result, char **errMsg); + static int rangesetSetModeMS(WindowInfo *window, DataValue *argList, + int nArgs, DataValue *result, char **errMsg); + +@@ -506,10 +508,11 @@ static const BuiltInSubrName MacroSubrs[ + { "rangeset_invert", rangesetInvertMS }, + { "rangeset_info", rangesetInfoMS }, + { "rangeset_range", rangesetRangeMS }, + { "rangeset_includes", rangesetIncludesPosMS }, + { "rangeset_set_color", rangesetSetColorMS }, ++ { "rangeset_set_underline", rangesetSetUnderlineMS }, + { "rangeset_set_name", rangesetSetNameMS }, + { "rangeset_set_mode", rangesetSetModeMS }, + { "rangeset_get_by_name", rangesetGetByNameMS }, + { "get_pattern_by_name", getPatternByNameMS }, + { "get_pattern_at_pos", getPatternAtPosMS }, +@@ -5847,11 +5850,11 @@ static int rangesetInvertMS(WindowInfo * + static int rangesetInfoMS(WindowInfo *window, DataValue *argList, int nArgs, + DataValue *result, char **errMsg) + { + RangesetTable *rangesetTable = window->buffer->rangesetTable; + Rangeset *rangeset = NULL; +- int count, defined; ++ int count, defined, uline; + char *color, *name, *mode; + DataValue element; + int label = 0; + + if (nArgs != 1) +@@ -5864,11 +5867,12 @@ static int rangesetInfoMS(WindowInfo *wi + + if (rangesetTable != NULL) { + rangeset = RangesetFetch(rangesetTable, label); + } + +- RangesetGetInfo(rangeset, &defined, &label, &count, &color, &name, &mode); ++ RangesetGetInfo(rangeset, &defined, &label, &count, &uline, ++ &color, &name, &mode); + + /* set up result */ + result->tag = ARRAY_TAG; + result->val.arrayPtr = ArrayNew(); + +@@ -5898,11 +5902,19 @@ static int rangesetInfoMS(WindowInfo *wi + element.tag = STRING_TAG; + if (!AllocNStringCpy(&element.val.str, mode)) + M_FAILURE("Failed to allocate array value \"mode\" in %s"); + if (!ArrayInsert(result, PERM_ALLOC_STR("mode"), &element)) + M_FAILURE("Failed to insert array element \"mode\" in %s"); +- ++ ++ element.tag = STRING_TAG; ++ element.val.str.rep = (uline < 0) ? PERM_ALLOC_STR("remove") : ++ (uline > 0) ? PERM_ALLOC_STR("add") : ++ PERM_ALLOC_STR("leave"); ++ element.val.str.len = strlen(element.val.str.rep); ++ if (!ArrayInsert(result, PERM_ALLOC_STR("underline"), &element)) ++ M_FAILURE("Failed to insert array element \"count\" in %s"); ++ + return True; + } + + /* + ** Built-in macro subroutine for finding the extent of a range in a set. +@@ -6071,10 +6083,64 @@ static int rangesetSetColorMS(WindowInfo + result->tag = NO_TAG; + return True; + } + + /* ++** Set underline flag for a range set's ranges. Returns true if the rangeset ++** is valid. It takes two arguments: the id of the rangeset to change and ++** the underlineMode string, which should be specified as "leave" (let any ++** syntax highlighting underlines to appear as undisturbed), "add" or "remove". ++*/ ++static int rangesetSetUnderlineMS(WindowInfo *window, DataValue *argList, ++ int nArgs, DataValue *result, char **errMsg) ++{ ++ char stringStorage[1][TYPE_INT_STR_SIZE(int)]; ++ textBuffer *buffer = window->buffer; ++ RangesetTable *rangesetTable = buffer->rangesetTable; ++ Rangeset *rangeset; ++ int label = 0; ++ char *underlineMode; ++ ++ if (nArgs != 2) { ++ return wrongNArgsErr(errMsg); ++ } ++ ++ if (!readIntArg(argList[0], &label, errMsg) ++ || !RangesetLabelOK(label)) { ++ M_FAILURE("First parameter is an invalid rangeset label in %s"); ++ } ++ ++ if (rangesetTable == NULL) { ++ M_FAILURE("Rangeset does not exist in %s"); ++ } ++ ++ rangeset = RangesetFetch(rangesetTable, label); ++ if (rangeset == NULL) { ++ M_FAILURE("Rangeset does not exist in %s"); ++ } ++ ++ if (readStringArg(argList[1], &underlineMode, stringStorage[0], errMsg)) { ++ if (strcmp(underlineMode, "leave") == 0) ++ RangesetAssignUnderline(rangeset, 0); ++ else ++ if (strcmp(underlineMode, "remove") == 0) ++ RangesetAssignUnderline(rangeset, -1); ++ else ++ if (strcmp(underlineMode, "add") == 0) ++ RangesetAssignUnderline(rangeset, 1); ++ else ++ M_FAILURE("Second parameter must be \"leave\", \"remove\" or \"add\" in %s"); ++ } ++ else ++ M_FAILURE("Second parameter must be \"leave\", \"remove\" or \"add\" in %s"); ++ ++ /* set up result */ ++ result->tag = NO_TAG; ++ return True; ++} ++ ++/* + ** Set the name of a range set's ranges. Returns + ** true if the rangeset is valid. + */ + static int rangesetSetNameMS(WindowInfo *window, DataValue *argList, + int nArgs, DataValue *result, char **errMsg) +diff --quilt old/source/rangeset.c new/source/rangeset.c +--- old/source/rangeset.c ++++ new/source/rangeset.c +@@ -62,10 +62,11 @@ struct _Rangeset { + int n_ranges; /* how many ranges in ranges */ + Range *ranges; /* the ranges table */ + unsigned char label; /* a number 1-63 */ + + signed char color_set; /* 0: unset; 1: set; -1: invalid */ ++ signed char underline; /* underline it? */ + char *color_name; /* the name of an assigned color */ + Pixel color; /* the value of a particular color */ + textBuffer *buf; /* the text buffer of the rangeset */ + char *name; /* name of rangeset */ + }; +@@ -249,10 +250,11 @@ void RangesetInit(Rangeset *rangeset, in + rangeset->ranges = (Range *)0; /* the ranges table */ + + rangeset->color_name = (char *)0; + rangeset->name = (char *)0; + rangeset->color_set = 0; ++ rangeset->underline = 0; /* "no change" value */ + rangeset->buf = buf; + + rangeset->maxpos = buf->length; + + RangesetChangeModifyResponse(rangeset, DEFAULT_UPDATE_FN_NAME); +@@ -691,24 +693,26 @@ int RangesetGetNRanges(Rangeset *rangese + + /* + ** Get information about rangeset. + */ + void RangesetGetInfo(Rangeset *rangeset, int *defined, int *label, +- int *count, char **color, char **name, char **mode) ++ int *count, int *uline, char **color, char **name, char **mode) + { + if (rangeset == NULL) { + *defined = False; + *label = 0; + *count = 0; ++ *uline = 0; + *color = ""; + *name = ""; + *mode = ""; + } + else { + *defined = True; + *label = (int)rangeset->label; + *count = rangeset->n_ranges; ++ *uline = rangeset->underline; + *color = rangeset->color_name ? rangeset->color_name : ""; + *name = rangeset->name ? rangeset->name : ""; + *mode = rangeset->update_name; + } + } +@@ -774,10 +778,11 @@ static void rangesetClone(Rangeset *dest + destRangeset->update_name = srcRangeset->update_name; + destRangeset->maxpos = srcRangeset->maxpos; + destRangeset->last_index = srcRangeset->last_index; + destRangeset->n_ranges = srcRangeset->n_ranges; + destRangeset->color_set = srcRangeset->color_set; ++ destRangeset->underline = srcRangeset->underline; + destRangeset->color = srcRangeset->color; + + if (srcRangeset->color_name) { + destRangeset->color_name = XtMalloc(strlen(srcRangeset->color_name) +1); + strcpy(destRangeset->color_name, srcRangeset->color_name); +@@ -1107,10 +1112,31 @@ int RangesetAssignColorName(Rangeset *ra + rangesetRefreshAllRanges(rangeset); + return 1; + } + + /* ++** Assign the underline to a rangeset via the rangeset table. ++*/ ++ ++int RangesetAssignUnderline(Rangeset *rangeset, int under) ++{ ++ rangeset->underline = (0 < under) - (under < 0); ++ ++ rangesetRefreshAllRanges(rangeset); ++ return 1; ++} ++ ++/* ++** Fetch the underline mode value. ++*/ ++ ++int RangesetGetUnderline(Rangeset *rangeset) ++{ ++ return rangeset->underline; ++} ++ ++/* + ** Assign a name to a rangeset via the rangeset table. + */ + + int RangesetAssignName(Rangeset *rangeset, char *name) + { +@@ -1157,10 +1183,20 @@ char *RangesetGetName(Rangeset *rangeset + { + return rangeset->name; + } + + /* ++** Return the underlining mode. ++*/ ++ ++int RangesetTableGetUnderline(RangesetTable *table, int index) ++{ ++ Rangeset *rangeset = &table->set[index]; ++ return rangeset->underline; ++} ++ ++/* + ** Return the color validity, if any, and the value in *color. + */ + + int RangesetGetColorValid(Rangeset *rangeset, Pixel *color) + { +diff --quilt old/source/rangeset.h new/source/rangeset.h +--- old/source/rangeset.h ++++ new/source/rangeset.h +@@ -51,11 +51,11 @@ int RangesetAdd(Rangeset *origSet, Range + int RangesetAddBetween(Rangeset *rangeset, int start, int end); + int RangesetRemove(Rangeset *origSet, Rangeset *minusSet); + int RangesetRemoveBetween(Rangeset *rangeset, int start, int end); + int RangesetGetNRanges(Rangeset *rangeset); + void RangesetGetInfo(Rangeset *rangeset, int *defined, int *label, +- int *count, char **color, char **name, char **mode); ++ int *count, int *uline, char **color, char **name, char **mode); + RangesetTable *RangesetTableAlloc(textBuffer *buf); + RangesetTable *RangesetTableFree(RangesetTable *table); + RangesetTable *RangesetTableClone(RangesetTable *srcTable, + textBuffer *destBuffer); + int RangesetFindIndex(RangesetTable *table, int label, int must_be_active); +@@ -67,16 +67,19 @@ Rangeset *RangesetFetch(RangesetTable *t + unsigned char * RangesetGetList(RangesetTable *table); + void RangesetTableUpdatePos(RangesetTable *table, int pos, int n_ins, int n_del); + void RangesetBufModifiedCB(int pos, int nInserted, int nDeleted, int nRestyled, + const char *deletedText, void *cbArg); + int RangesetIndex1ofPos(RangesetTable *table, int pos, int needs_color); ++int RangesetAssignUnderline(Rangeset *rangeset, int under); ++int RangesetGetUnderline(Rangeset *rangeset); + int RangesetAssignColorName(Rangeset *rangeset, char *color_name); + int RangesetAssignColorPixel(Rangeset *rangeset, Pixel color, int ok); + char *RangesetGetName(Rangeset *rangeset); + int RangesetAssignName(Rangeset *rangeset, char *name); + int RangesetGetColorValid(Rangeset *rangeset, Pixel *color); + char *RangesetTableGetColorName(RangesetTable *table, int index); ++int RangesetTableGetUnderline(RangesetTable *table, int index); + int RangesetTableGetColorValid(RangesetTable *table, int index, Pixel *color); + int RangesetTableAssignColorPixel(RangesetTable *table, int index, Pixel color, + int ok); + + #endif /* rangeset_h_DEFINED */ +diff --quilt old/source/textDisp.c new/source/textDisp.c +--- old/source/textDisp.c ++++ new/source/textDisp.c +@@ -182,10 +182,11 @@ static int maintainingAbsTopLineNum(text + static void resetAbsLineNum(textDisp *textD); + static int measurePropChar(const textDisp* textD, const char c, + const int colNum, const int pos); + static Pixel allocBGColor(Widget w, char *colorName, int *ok); + static Pixel getRangesetColor(textDisp *textD, int ind, Pixel bground); ++static int getRangesetUnderline(textDisp *textD, int ind, int old); + static void textDRedisplayRange(textDisp *textD, int start, int end); + static void drawWrapMargin(textDisp* textD); + static void redisplayCursor(textDisp* textD); + + textDisp *TextDCreate(Widget widget, Widget hScrollBar, Widget vScrollBar, +@@ -2282,10 +2283,14 @@ static void drawString(textDisp *textD, + fground = textD->bgPixel; + /* set up gc for clearing using the foreground color entry */ + gcValues.foreground = gcValues.background = bground; + XChangeGC(XtDisplay(textD->w), gc, + GCFont | GCForeground | GCBackground, &gcValues); ++ /* adjust underline according to rangeset underline style */ ++ underlineStyle = getRangesetUnderline(textD, ++ (style&RANGESET_MASK)>>RANGESET_SHIFT, ++ underlineStyle); + } + + /* Draw blank area rather than text, if that was the request */ + if (style & FILL_MASK) { + /* wipes out to right hand edge of widget */ +@@ -4021,10 +4026,33 @@ static Pixel getRangesetColor(textDisp * + } + return bground; + } + + /* ++** Return an adjusted underline flag. The original flag value (true if needed ++** by the syntax highlighting style) is left alone if the rangeset's underline ++** mode is 0; cleared if the mode is less than 0, or set if greater. ++*/ ++static int getRangesetUnderline(textDisp *textD, int ind, int old) ++{ ++ textBuffer *buf; ++ RangesetTable *tab; ++ int under; ++ ++ if (ind > 0) { ++ ind--; ++ buf = textD->buffer; ++ tab = buf->rangesetTable; ++ ++ under = RangesetTableGetUnderline(tab, ind); ++ if (under != 0) ++ return under > 0; ++ } ++ return old; ++} ++ ++/* + ** Read the background color class specification string in str, allocating the + ** necessary colors, and allocating and setting up the character->class_no and + ** class_no->pixel map arrays, returned via *pp_bgClass and *pp_bgClassPixel + ** respectively. + ** Note: the allocation of class numbers could be more intelligent: there can diff --git a/fix_hide_hscrollbar.patch b/fix_hide_hscrollbar.patch index c95a502..d128c2b 100644 --- a/fix_hide_hscrollbar.patch +++ b/fix_hide_hscrollbar.patch @@ -6,7 +6,7 @@ diff --quilt old/source/textDisp.c new/source/textDisp.c --- old/source/textDisp.c +++ new/source/textDisp.c -@@ -3925,11 +3925,11 @@ static int wrapUsesCharacter(textDisp *t +@@ -3930,11 +3930,11 @@ static int wrapUsesCharacter(textDisp *t ** the longest possible line. */ static void hideOrShowHScrollBar(textDisp *textD) diff --git a/series b/series index 47d1555..27c6d34 100644 --- a/series +++ b/series @@ -86,6 +86,7 @@ radioOpenPrev.diff ForbackwardSame.diff relativeFileNormalization.diff relativeFileNormalization-fix.diff +RSunderlineStyle.diff close_shift_menu_entry.patch fix_hide_hscrollbar.patch dont-resize-window.patch diff --git a/sh-bg-newline.diff b/sh-bg-newline.diff index 889cf99..3f54bef 100644 --- a/sh-bg-newline.diff +++ b/sh-bg-newline.diff @@ -6,7 +6,7 @@ diff --quilt old/source/textDisp.c new/source/textDisp.c --- old/source/textDisp.c +++ new/source/textDisp.c -@@ -2448,17 +2448,18 @@ static int styleOfPos(textDisp *textD, i +@@ -2453,17 +2453,18 @@ static int styleOfPos(textDisp *textD, i pos = lineStartPos + min(lineIndex, lineLen); -- 2.11.4.GIT