Index: source/menu.c =================================================================== retrieving revision 1.123 diff -u -r1.123 menu.c --- a/source/menu.c 5 Dec 2004 01:15:03 -0000 1.123 +++ b/source/menu.c 16 Dec 2004 23:14:47 -0000 @@ -170,6 +170,7 @@ static void macroDefCB(Widget w, WindowInfo *window, caddr_t callData); static void bgMenuDefCB(Widget w, WindowInfo *window, caddr_t callData); static void searchDlogsDefCB(Widget w, WindowInfo *window, caddr_t callData); +static void incrSearchHiliteDefCB(Widget w, WindowInfo *window, caddr_t callData); static void beepOnSearchWrapDefCB(Widget w, WindowInfo *window, caddr_t callData); static void keepSearchDlogsDefCB(Widget w, WindowInfo *window, caddr_t callData); @@ -920,6 +921,9 @@ window->searchRegexNoCaseDefItem = createMenuToggle(subSubSubPane, "regularExpressionNoCase", "Regular Expression, Case Insensitive", 'I', searchRegexNoCaseCB, window, GetPrefSearch() == SEARCH_REGEX_NOCASE, FULL); + window->incrSearchHiliteDefItem = createMenuToggle(subSubPane, "incrSearchHilite", + "Highlight Incremental Search", 'V', incrSearchHiliteDefCB, window, + GetPrefIncrSearchHilite(), SHORT); #ifdef REPLACE_SCOPE subSubSubPane = createMenu(subSubPane, "defaultReplaceScope", "Default Replace Scope", 'R', NULL, FULL); @@ -2117,6 +2121,19 @@ for (win=WindowList; win!=NULL; win=win->next) { if (IsTopDocument(win)) XmToggleButtonSetState(win->searchDlogsDefItem, state, False); + } +} + +static void incrSearchHiliteDefCB(Widget w, WindowInfo *window, caddr_t callData) +{ + WindowInfo *win; + int state = XmToggleButtonGetState(w); + + /* Set the preference and make the other windows' menus agree */ + SetPrefIncrSearchHilite(state); + for (win=WindowList; win!=NULL; win=win->next) { + if (IsTopDocument(win)) + XmToggleButtonSetState(win->incrSearchHiliteDefItem, state, False); } } Index: source/nedit.h =================================================================== retrieving revision 1.63 diff -u -r1.63 nedit.h --- a/source/nedit.h 9 Nov 2004 21:58:44 -0000 1.63 +++ b/source/nedit.h 16 Dec 2004 23:14:47 -0000 @@ -310,6 +310,7 @@ Widget findRegexToggle; Widget findRevToggle; Widget findKeepBtn; + Widget findHighlightAllBtn; Widget findBtns; Widget findBtn; Widget findSearchTypeBox; @@ -385,6 +386,7 @@ Widget backlightCharsItem; Widget backlightCharsDefItem; Widget searchDlogsDefItem; + Widget incrSearchHiliteDefItem; Widget beepOnSearchWrapDefItem; Widget keepSearchDlogsDefItem; Widget searchWrapsDefItem; @@ -536,6 +538,8 @@ Bool iSearchLastLiteralCase; /* idem, for literal mode */ Bool findLastRegexCase; /* idem, for regex mode in find dialog */ Bool findLastLiteralCase; /* idem, for literal mode */ + char *highlightSearchString; /* search string used in highlighting */ + int highlightSearchType; /* search type used in highlighting */ #ifdef REPLACE_SCOPE int replaceScope; /* Current scope for replace dialog */ Index: source/preferences.c =================================================================== retrieving revision 1.132 diff -u -r1.132 preferences.c --- a/source/preferences.c 26 Nov 2004 18:25:51 -0000 1.132 +++ b/source/preferences.c 16 Dec 2004 23:14:47 -0000 @@ -240,6 +240,7 @@ int autoSave; /* whether automatic backup feature is on */ int saveOldVersion; /* whether to preserve a copy of last version */ int searchDlogs; /* whether to show explanatory search dialogs */ + int incrSearchHilte; /* whether to hilite i-search matched strings */ int searchWrapBeep; /* 1=beep when search restarts at begin/end */ int keepSearchDlogs; /* whether to retain find and replace dialogs */ int searchWraps; /* whether to attempt search again if reach bof or eof */ @@ -312,6 +313,7 @@ char helpLinkColor[MAX_COLOR_LEN]; /* Color for hyperlinks in the help system */ char colorNames[NUM_COLORS][MAX_COLOR_LEN]; char tooltipBgColor[MAX_COLOR_LEN]; + char searchHiliteColor[MAX_COLOR_LEN]; /* color for highlighting search matches */ int undoModifiesSelection; } PrefData; @@ -766,6 +768,8 @@ "0-8,10-31,127:red;9:#dedede;32,160-255:#f0f0f0;128-159:orange", /* gray87 gray94 */ &PrefData.backlightCharTypes, NULL, False}, + {"incrSearchHilte", "IncrSearchHilte", PREF_BOOLEAN, "True", + &PrefData.incrSearchHilte, NULL, True}, {"searchDialogs", "SearchDialogs", PREF_BOOLEAN, "False", &PrefData.searchDlogs, NULL, True}, {"beepOnSearchWrap", "BeepOnSearchWrap", PREF_BOOLEAN, "False", @@ -924,6 +928,9 @@ {"tooltipBgColor", "TooltipBgColor", PREF_STRING, "LemonChiffon1", PrefData.tooltipBgColor, (void *)sizeof(PrefData.tooltipBgColor), False}, + {"searchHiliteColor", "SearchHiliteColor", PREF_STRING, "Yellow", + PrefData.searchHiliteColor, + (void *)sizeof(PrefData.searchHiliteColor), False}, {"shell", "Shell", PREF_STRING, #if defined(__MVS__) || defined(__EMX__) @@ -1480,6 +1487,16 @@ return PrefData.searchDlogs; } +void SetPrefIncrSearchHilite(int state) +{ + setIntPref(&PrefData.incrSearchHilte, state); +} + +int GetPrefIncrSearchHilite(void) +{ + return PrefData.incrSearchHilte; +} + void SetPrefBeepOnSearchWrap(int state) { setIntPref(&PrefData.searchWrapBeep, state); @@ -1967,6 +1984,11 @@ char *GetPrefTooltipBgColor(void) { return PrefData.tooltipBgColor; +} + +char *GetPrefSearchHiliteColor(void) +{ + return PrefData.searchHiliteColor; } void SetPrefShell(const char *shell) Index: source/preferences.h =================================================================== retrieving revision 1.47 diff -u -r1.47 preferences.h --- a/source/preferences.h 9 Nov 2004 21:58:44 -0000 1.47 +++ b/source/preferences.h 16 Dec 2004 23:14:47 -0000 @@ -59,6 +59,8 @@ int GetPrefWrap(int langMode); void SetPrefWrapMargin(int margin); int GetPrefWrapMargin(void); +void SetPrefIncrSearchHilite(int state); +int GetPrefIncrSearchHilite(void); void SetPrefSearchDlogs(int state); int GetPrefSearchDlogs(void); void SetPrefKeepSearchDlogs(int state); @@ -144,6 +146,7 @@ XFontStruct *GetPrefItalicFont(void); XFontStruct *GetPrefBoldItalicFont(void); char *GetPrefTooltipBgColor(void); +char *GetPrefSearchHiliteColor(void); char *GetPrefHelpFontName(int index); char *GetPrefHelpLinkColor(void); char *GetPrefColorName(int colorIndex); Index: source/rangeset.c =================================================================== retrieving revision 1.12 diff -u -r1.12 rangeset.c --- a/source/rangeset.c 18 Oct 2004 19:27:24 -0000 1.12 +++ b/source/rangeset.c 16 Dec 2004 23:12:15 -0000 @@ -68,6 +68,7 @@ Pixel color; /* the value of a particular color */ textBuffer *buf; /* the text buffer of the rangeset */ char *name; /* name of rangeset */ + int refresh; /* refresh ranges if this is true */ }; struct _RangesetTable { @@ -190,10 +191,18 @@ /* ** Refresh the given range on the screen. If the range indicated is null, we ** refresh the screen for the whole file. +** +** Refreshing can be suspended by setting 'refresh' to False. This is +** useful if a large number of ranges is to be added in one burst. +** Remember to restore the flag and call RangesetRefreshRange() on the +** while file to after all work is done. */ void RangesetRefreshRange(Rangeset *rangeset, int start, int end) { + if (!rangeset->refresh) + return; + if (rangeset->buf != NULL) BufCheckDisplay(rangeset->buf, start, end); } @@ -202,6 +211,9 @@ { int i; + if (!rangeset->refresh) + return; + for (i = 0; i < rangeset->n_ranges; i++) RangesetRefreshRange(rangeset, rangeset->ranges[i].start, rangeset->ranges[i].end); } @@ -240,6 +252,23 @@ rangeset->ranges = RangesFree(rangeset->ranges); } +/* +** suspend screen refreshing on ranges if 'flag' is set +** to False. +*/ +void RangesetSetRefresh(Rangeset *rangeset, int flag) +{ + rangeset->refresh = flag; +} + +/* +** query the screen refreshing status of the rangeset. +*/ +int RangesetGetRefresh(Rangeset *rangeset) +{ + return rangeset->refresh; +} + /* -------------------------------------------------------------------------- */ /* @@ -254,6 +283,7 @@ rangeset->n_ranges = 0; /* how many ranges in ranges */ rangeset->ranges = (Range *)0; /* the ranges table */ + rangeset->refresh = 1; rangeset->color_name = (char *)0; rangeset->name = (char *)0; rangeset->color_set = 0; @@ -700,20 +730,20 @@ int *count, char **color, char **name, char **mode) { if (rangeset == NULL) { - *defined = False; - *label = 0; - *count = 0; - *color = ""; - *name = ""; - *mode = ""; + if (defined) *defined = False; + if (label) *label = 0; + if (count) *count = 0; + if (color) *color = ""; + if (name) *name = ""; + if (mode) *mode = ""; } else { - *defined = True; - *label = (int)rangeset->label; - *count = rangeset->n_ranges; - *color = rangeset->color_name ? rangeset->color_name : ""; - *name = rangeset->name ? rangeset->name : ""; - *mode = rangeset->update_name; + if (defined) *defined = True; + if (label) *label = (int)rangeset->label; + if (count) *count = rangeset->n_ranges; + if (color) *color = rangeset->color_name ? rangeset->color_name : ""; + if (name) *name = rangeset->name ? rangeset->name : ""; + if (mode) *mode = rangeset->update_name; } } @@ -1124,6 +1154,31 @@ rangesetRefreshAllRanges(rangeset); return 1; } + +Rangeset *GetRangesetByName(RangesetTable *rangesetTable, const char *name) +{ + Rangeset *rangeset; + unsigned char *rangesetList; + int nRangesets, i; + char *rangeset_name; + int label; + + rangesetList = RangesetGetList(rangesetTable); + nRangesets = strlen((char *)rangesetList); + for (i = 0; i < nRangesets; ++i) { + label = rangesetList[i]; + rangeset = RangesetFetch(rangesetTable, label); + if (rangeset) { + rangeset_name = RangesetGetName(rangeset); + if (strcmp(name, rangeset_name ? rangeset_name : "") == 0) { + return rangeset; + } + } + } + + return NULL; +} + /* ** Assign a name to a rangeset via the rangeset table. Index: source/rangeset.h =================================================================== retrieving revision 1.6 diff -u -r1.6 rangeset.h --- a/source/rangeset.h 21 Jul 2004 11:32:05 -0000 1.6 +++ b/source/rangeset.h 16 Dec 2004 23:12:15 -0000 @@ -39,6 +39,8 @@ typedef struct _Range Range; typedef struct _Rangeset Rangeset; +void RangesetSetRefresh(Rangeset *rangeset, int flag); +int RangesetGetRefresh(Rangeset *rangeset); void RangesetRefreshRange(Rangeset *rangeset, int start, int end); void RangesetEmpty(Rangeset *rangeset); void RangesetInit(Rangeset *rangeset, int label, textBuffer *buf); @@ -74,6 +76,7 @@ int RangesetAssignColorPixel(Rangeset *rangeset, Pixel color, int ok); char *RangesetGetColorName(Rangeset *rangeset); char *RangesetGetName(Rangeset *rangeset); +Rangeset *GetRangesetByName(RangesetTable *rangesetTable, const char *name); int RangesetAssignName(Rangeset *rangeset, char *name); int RangesetGetColorValid(Rangeset *rangeset, Pixel *color); char *RangesetTableGetColorName(RangesetTable *table, int index); Index: source/search.c =================================================================== retrieving revision 1.74 diff -u -r1.74 search.c --- a/source/search.c 26 Nov 2004 18:25:51 -0000 1.74 +++ b/source/search.c 16 Dec 2004 23:56:05 -0000 @@ -32,12 +32,14 @@ #endif #include "search.h" +#include "rangeset.h" #include "regularExp.h" #include "textBuf.h" #include "text.h" #include "nedit.h" #include "server.h" #include "window.h" +#include "macro.h" #include "userCmds.h" #include "preferences.h" #include "file.h" @@ -100,6 +102,8 @@ int searchWrap; } SearchSelectedCallData; +const char *searchHiliteRangesetName = "_RANGESET_HILITE_SEARCH_"; + /* History mechanism for search and replace strings */ static char *SearchHistory[MAX_SEARCH_HISTORY]; static char *ReplaceHistory[MAX_SEARCH_HISTORY]; @@ -114,6 +118,7 @@ static void rFocusCB(Widget w, WindowInfo *window, caddr_t *callData); static void rKeepCB(Widget w, WindowInfo *window, caddr_t *callData); static void fKeepCB(Widget w, WindowInfo *window, caddr_t *callData); +static void fHighlightAllCB(Widget w, WindowInfo *window, caddr_t *callData); static void replaceCB(Widget w, WindowInfo *window, XmAnyCallbackStruct *callData); static void replaceAllCB(Widget w, WindowInfo *window, @@ -566,6 +571,7 @@ void DoFindDlog(WindowInfo *window, int direction, int keepDialogs, int searchType, Time time) { + Rangeset *hiliteRange; /* Create the dialog if it doesn't already exist */ if (window->findDlog == NULL) @@ -592,6 +598,12 @@ /* Set the state of the Keep Dialog Up button */ XmToggleButtonSetState(window->findKeepBtn, keepDialogs, True); + /* Set the state of the Highlight All button */ + hiliteRange = GetRangesetByName(window->buffer->rangesetTable, + searchHiliteRangesetName); + XmToggleButtonSetState(window->findHighlightAllBtn, + hiliteRange != NULL, False); + /* Set the state of the Find button */ fUpdateActionButtons(window); @@ -1166,7 +1178,7 @@ int argcnt, defaultBtnOffset; XmString st1; Widget form, btnForm, searchTypeBox; - Widget findText, label1, label2, cancelBtn, findBtn; + Widget findText, label1, label2, cancelBtn, findBtn, hiliteAllBtn; Widget searchDirBox, reverseBtn, keepBtn; char title[MAXPATHLEN + 11]; Dimension shadowThickness; @@ -1301,6 +1313,17 @@ argcnt = 0; XtSetArg(args[argcnt], XmNlabelString, + st1=MKSTRING("Highlight All")); argcnt++; + XtSetArg(args[argcnt], XmNmnemonic, 'l'); argcnt++; + hiliteAllBtn = XmCreateToggleButton(searchDirBox, "highlightAll", args, argcnt); + XtAddCallback(hiliteAllBtn, XmNvalueChangedCallback, + (XtCallbackProc)fHighlightAllCB, window); + XmStringFree(st1); + XtManageChild(hiliteAllBtn); + XmAddTabGroup(hiliteAllBtn); + + argcnt = 0; + XtSetArg(args[argcnt], XmNlabelString, st1=MKSTRING("Keep Dialog")); argcnt++; XtSetArg(args[argcnt], XmNmnemonic, 'K'); argcnt++; XtSetArg(args[argcnt], XmNtopAttachment, XmATTACH_WIDGET); argcnt++; @@ -1367,6 +1390,7 @@ window->findText = findText; window->findRevToggle = reverseBtn; window->findKeepBtn = keepBtn; + window->findHighlightAllBtn = hiliteAllBtn; window->findBtns = btnForm; window->findBtn = findBtn; window->findSearchTypeBox = searchTypeBox; @@ -1690,6 +1714,106 @@ XtVaSetValues(XtParent(window->findDlog), XmNtitle, "Find", NULL); } +/* +** search and highlight all matched strings in document if searchString is +** is not null. Else, clear the existing highlights. +*/ +void SearchAndHighlightDocument(WindowInfo *window, const char *searchString, + int searchType) +{ + char *hlColor = GetPrefSearchHiliteColor(); /* hilite color for matches */ + Rangeset *hiliteRange; + + if (!window->highlightSearchString && searchString == NULL) + return; + + XtFree(window->highlightSearchString); + window->highlightSearchString = NULL; + if (searchString) { + window->highlightSearchString = XtNewString(searchString); + window->highlightSearchType = searchType; + } + + if (searchString) { + /* search and highlight all match strings */ + int beginPos, wrap = False, found = False, foundStart, foundEnd; + char *string; + int label; + + if (window->buffer->rangesetTable == NULL) { + window->buffer->rangesetTable = RangesetTableAlloc(window->buffer); + } + + if ((label = RangesetCreate(window->buffer->rangesetTable)) == 0) { + fprintf(stderr,"nedit: unable to create rangeset for search highlighting\n"); + return; + } + + /* create rangeset for highlighting matching strings */ + hiliteRange = RangesetFetch(window->buffer->rangesetTable, label); + + /* assign rangeset name and color */ + RangesetAssignName(hiliteRange, (char*)searchHiliteRangesetName); + RangesetAssignColorName(hiliteRange, hlColor); + + /* refresh the ranges after we are done searching */ + RangesetSetRefresh(hiliteRange, False); + + /* put up the busy clock cursor, in case it take too long (?) */ + BeginWait(window->shell); + BusyWait(window->shell); + + /* search for matches and add to rangeset */ + string = BufGetAll(window->buffer); + beginPos = 0; + do { + found = SearchString(string, searchString, SEARCH_FORWARD, + searchType, wrap, beginPos, + &foundStart, &foundEnd, NULL, NULL, + GetWindowDelimiters(window)); + + if (found) { + /* add match pos to rangeset and continue searching */ + RangesetAddBetween(hiliteRange, foundStart, foundEnd); + beginPos = foundEnd; /* begin next search from here */ + } + } while (found); + + /* refresh the whole rangeset */ + RangesetSetRefresh(hiliteRange, True); + RangesetRefreshRange(hiliteRange, 0, window->buffer->length); + + EndWait(window->shell); + } + else { + /* remove highlight */ + hiliteRange = GetRangesetByName( + window->buffer->rangesetTable, searchHiliteRangesetName); + if (hiliteRange) { + int label; + RangesetGetInfo(hiliteRange, NULL, &label, NULL, + NULL, NULL, NULL); + /* refresh the ranges after we are done searching */ + RangesetSetRefresh(hiliteRange, False); + + /* remove the highlighted ranges */ + RangesetForget(window->buffer->rangesetTable, label); + + /* clear the highlight on display */ + RangesetSetRefresh(hiliteRange, True); + RangesetRefreshRange(hiliteRange, 0, window->buffer->length); + } + } +} + +static void fHighlightAllCB(Widget w, WindowInfo *window, caddr_t *callData) +{ + if (!XmToggleButtonGetState(w)) { + /* clear previous highlights */ + SearchAndHighlightDocument(WidgetToWindow(w), NULL, 0); + } +} + static void replaceCB(Widget w, WindowInfo *window, XmAnyCallbackStruct *callData) { @@ -2537,6 +2661,25 @@ /* Set the initial focus of the dialog back to the search string */ resetFindTabGroup(window); + /* highlight all matches */ + if (XmToggleButtonGetState(window->findHighlightAllBtn)) { + Rangeset *hiliteRange = GetRangesetByName( + window->buffer->rangesetTable, searchHiliteRangesetName); + int searchChanged = window->highlightSearchString && + (window->highlightSearchType != searchType || + strcmp(window->highlightSearchString, searchString)); + + /* do highlight if it wasn't done or, if search settings has changed + since last highlight. */ + if (!hiliteRange || searchChanged) { + /* clear previous hilite */ + SearchAndHighlightDocument(window, NULL, 0); + + /* search and hilite */ + SearchAndHighlightDocument(window, searchString, searchType); + } + } + /* find the text and mark it */ params[0] = searchString; params[1] = directionArg(direction); @@ -3099,6 +3242,9 @@ window = WidgetToWindow(w); iSearchTextSetString(w, window, NULL); + + /* clear previous highlights */ + SearchAndHighlightDocument(window, NULL, 0); } /* @@ -3112,6 +3258,7 @@ char *params[4]; char *searchString; int searchType, direction; + int doHilite; window = WidgetToWindow(w); @@ -3132,6 +3279,22 @@ direction = XmToggleButtonGetState(window->iSearchRevToggle) ? SEARCH_BACKWARD : SEARCH_FORWARD; + /* check to see if we need to highlight matched strings */ + if (GetPrefIncrSearchHilite()) { + Rangeset *hiliteRange = GetRangesetByName( + window->buffer->rangesetTable, searchHiliteRangesetName); + int searchChanged = window->highlightSearchString && + (window->highlightSearchType != searchType || + strcmp(window->highlightSearchString, searchString)); + + doHilite = !hiliteRange || searchChanged; + } + else { + /* clear previous highlights */ + SearchAndHighlightDocument(window, NULL, 0); + doHilite = False; + } + /* Reverse the search direction if the Ctrl or Shift key was pressed */ if (callData->event->xbutton.state & (ShiftMask | ControlMask)) direction = direction == SEARCH_FORWARD ? @@ -3143,6 +3306,18 @@ params[2] = searchTypeArg(searchType); params[3] = searchWrapArg(GetPrefSearchWraps()); XtCallActionProc(window->lastFocus, "find", callData->event, params, 4); + + + /* do highlight if it wasn't done or, if search settings has changed + since last highlight. */ + if (doHilite) { + /* clear previous hilite */ + SearchAndHighlightDocument(window, NULL, 0); + + /* search and hilite */ + SearchAndHighlightDocument(window, searchString, searchType); + } + XtFree(searchString); } @@ -3156,6 +3331,7 @@ char *params[5]; char *searchString; int searchType, direction, nParams; + int doHilite; window = WidgetToWindow(w); @@ -3192,6 +3368,22 @@ free((char *)compiledRE); } + /* check to see if we need to highlight matched strings */ + if (GetPrefIncrSearchHilite()) { + Rangeset *hiliteRange = GetRangesetByName( + window->buffer->rangesetTable, searchHiliteRangesetName); + int searchChanged = window->highlightSearchString && + (window->highlightSearchType != searchType || + strcmp(window->highlightSearchString, searchString)); + + doHilite = !hiliteRange || searchChanged; + } + else { + /* clear previous highlights */ + SearchAndHighlightDocument(window, NULL, 0); + doHilite = False; + } + /* Call the incremental search action proc to do the searching and selecting (this allows it to be recorded for learn/replay). If there's an incremental search already in progress, mark the operation @@ -3206,6 +3398,17 @@ params[nParams++] = "continued"; XtCallActionProc(window->lastFocus, "find_incremental", callData->event, params, nParams); + + /* do highlight if it wasn't done or, if search settings has changed + since last highlight. */ + if (doHilite) { + /* clear previous hilite */ + SearchAndHighlightDocument(window, NULL, 0); + + /* search and hilite */ + SearchAndHighlightDocument(window, searchString, searchType); + } + XtFree(searchString); } Index: source/search.h =================================================================== retrieving revision 1.25 diff -u -r1.25 search.h --- a/source/search.h 9 Nov 2004 21:58:44 -0000 1.25 +++ b/source/search.h 16 Dec 2004 23:14:47 -0000 @@ -44,6 +44,8 @@ void UpdateReplaceActionButtons(WindowInfo* window); void DoFindDlog(WindowInfo *window, int direction, int keepDialogs, int searchType, Time time); +void SearchAndHighlightDocument(WindowInfo *window, const char *searchString, + int searchType); int SearchAndSelect(WindowInfo *window, int direction, const char *searchString, int searchType, int searchWrap); int SearchAndSelectSame(WindowInfo *window, int direction, int searchWrap); @@ -122,5 +124,8 @@ ** History of search actions. */ extern int NHist; + +/* rangeset name for search highlighting */ +extern const char *searchHiliteRangesetName; #endif /* NEDIT_SEARCH_H_INCLUDED */ Index: source/window.c =================================================================== retrieving revision 1.180 diff -u -r1.180 window.c --- a/source/window.c 18 Oct 2004 19:27:25 -0000 1.180 +++ b/source/window.c 16 Dec 2004 23:14:47 -0000 @@ -304,6 +304,7 @@ window->macroCmdData = NULL; window->smartIndentData = NULL; window->languageMode = PLAIN_LANGUAGE_MODE; + window->highlightSearchString = NULL; window->iSearchHistIndex = 0; window->iSearchStartPos = -1; window->replaceLastRegexCase = TRUE; @@ -949,6 +950,9 @@ /* Destroy the file closed property for this file */ DeleteFileClosedProperty(window); + + /* release search highlighting rangeset and associated storage */ + SearchAndHighlightDocument(window, NULL, 0); /* if this is the last window, or must be kept alive temporarily because it's running the macro calling us, don't close it, make it Untitled */ @@ -3254,6 +3258,7 @@ window->languageMode = PLAIN_LANGUAGE_MODE; window->iSearchHistIndex = 0; window->iSearchStartPos = -1; + window->highlightSearchString = NULL; window->replaceLastRegexCase = TRUE; window->replaceLastLiteralCase = FALSE; window->iSearchLastRegexCase = TRUE; @@ -3853,7 +3858,8 @@ void RaiseDocument(WindowInfo *window) { WindowInfo *win, *lastwin; - + Rangeset *hiliteRange; + if (!window || !WindowList) return; @@ -3913,6 +3919,12 @@ RefreshWindowStates(window); RefreshTabState(window); + /* Set the state of the Find dialogs's Highlight All button */ + hiliteRange = GetRangesetByName(window->buffer->rangesetTable, + searchHiliteRangesetName); + XmToggleButtonSetState(window->findHighlightAllBtn, + hiliteRange != NULL, False); + /* put away the bg menu tearoffs of last active document */ hideTearOffs(win->bgMenuPane); @@ -4241,6 +4253,12 @@ memcpy(&window->markTable, &orgWin->markTable, sizeof(Bookmark)*window->nMarks); + /* clone search highlighting stuff */ + if (orgWin->highlightSearchString) { + window->highlightSearchString = XtNewString(orgWin->highlightSearchString); + window->highlightSearchType = orgWin->highlightSearchType; + } + /* clone rangeset info */ window->buffer->rangesetTable = RangesetTableClone(orgWin->buffer->rangesetTable, window->buffer);