UNIXworkcode

1 /******************************************************************************* 2 * * 3 * search.h -- Nirvana Editor Search Header File * 4 * * 5 * Copyright 2003 The NEdit Developers * 6 * * 7 * This is free software; you can redistribute it and/or modify it under the * 8 * terms of the GNU General Public License as published by the Free Software * 9 * Foundation; either version 2 of the License, or (at your option) any later * 10 * version. In addition, you may distribute versions of this program linked to * 11 * Motif or Open Motif. See README for details. * 12 * * 13 * This software is distributed in the hope that it will be useful, but WITHOUT * 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * 16 * more details. * 17 * * 18 * You should have received a copy of the GNU General Public License along with * 19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple * 20 * Place, Suite 330, Boston, MA 02111-1307 USA * 21 * * 22 * Nirvana Text Editor * 23 * July 31, 2001 * 24 * * 25 *******************************************************************************/ 26 27 #ifndef NEDIT_SEARCH_H_INCLUDED 28 #define NEDIT_SEARCH_H_INCLUDED 29 30 #include "nedit.h" 31 32 #include <X11/Intrinsic.h> 33 #include <X11/X.h> 34 35 enum SearchDirection {SEARCH_FORWARD, SEARCH_BACKWARD}; 36 37 void CreateFindDlog(Widget parent, WindowInfo *window); 38 void CreateReplaceDlog(Widget parent, WindowInfo *window); 39 void CreateReplaceMultiFileDlog(WindowInfo *window); 40 void DoFindReplaceDlog(WindowInfo *window, int direction, int keepDialogs, 41 int searchType, Time time); 42 void DoReplaceMultiFileDlog(WindowInfo *window); 43 void UpdateReplaceActionButtons(WindowInfo* window); 44 void DoFindDlog(WindowInfo *window, int direction, int keepDialogs, 45 int searchType, Time time); 46 int SearchAndSelect(WindowInfo *window, int direction, const char *searchString, 47 int searchType, int searchWrap); 48 int SearchAndSelectSame(WindowInfo *window, int direction, int searchWrap); 49 int SearchAndSelectIncremental(WindowInfo *window, int direction, 50 const char *searchString, int searchType, int searchWrap, int continued); 51 void SearchForSelected(WindowInfo *window, int direction, int searchType, 52 int searchWrap, Time time); 53 int SearchAndReplace(WindowInfo *window, int direction, const char *searchString, 54 const char *replaceString, int searchType, int searchWrap); 55 int ReplaceAndSearch(WindowInfo *window, int direction, const char *searchString, 56 const char *replaceString, int searchType, int searchWrap); 57 int ReplaceFindSame(WindowInfo *window, int direction, int searchWrap); 58 int ReplaceSame(WindowInfo *window, int direction, int searchWrap); 59 int ReplaceAll(WindowInfo *window, const char *searchString, const char *replaceString, 60 int searchType); 61 void ReplaceInSelection(const WindowInfo* window, const char* searchString, 62 const char* replaceString, int searchType); 63 int SearchWindow(WindowInfo *window, int direction, const char *searchString, 64 int searchType, int searchWrap, int beginPos, int *startPos, int *endPos, 65 int *extentBW, int* extentFW); 66 int SearchString(const char *string, const char *searchString, int direction, 67 int searchType, int wrap, int beginPos, int *startPos, int *endPos, 68 int *searchExtentBW, int*searchExtentFW, const char *delimiters); 69 char *ReplaceAllInString(const char *inString, const char *searchString, 70 const char *replaceString, int searchType, int *copyStart, 71 int *copyEnd, int *replacementLength, const char *delimiters); 72 void BeginISearch(WindowInfo *window, int direction); 73 void EndISearch(WindowInfo *window); 74 void SetISearchTextCallbacks(WindowInfo *window); 75 void FlashMatching(WindowInfo *window, Widget textW); 76 void SelectToMatchingCharacter(WindowInfo *window); 77 void GotoMatchingCharacter(WindowInfo *window); 78 void RemoveFromMultiReplaceDialog(WindowInfo *window); 79 Boolean WindowCanBeClosed(WindowInfo *window); 80 void WriteSearchHistory(void); 81 void ReadSearchHistory(void); 82 83 void ChangeCase(const char *in, char *out, int makeUpper, int *in_len, int *out_len); 84 void UpCaseString(char *outString, const char *inString); 85 void DownCaseString(char *outString, const char *inString); 86 87 /* 88 ** Schwarzenberg: added SEARCH_LITERAL_WORD .. SEARCH_REGEX_NOCASE 89 ** 90 ** The order of the integers in this enumeration must be exactly 91 ** the same as the order of the coressponding strings of the 92 ** array SearchMethodStrings defined in preferences.c (!!) 93 ** 94 */ 95 enum SearchType { 96 SEARCH_LITERAL, SEARCH_CASE_SENSE, SEARCH_REGEX, 97 SEARCH_LITERAL_WORD, SEARCH_CASE_SENSE_WORD, SEARCH_REGEX_NOCASE, 98 N_SEARCH_TYPES /* must be last in enum SearchType */ }; 99 100 #ifdef REPLACE_SCOPE 101 /* Scope on which the replace operations apply */ 102 enum ReplaceScope { REPL_SCOPE_WIN, REPL_SCOPE_SEL, REPL_SCOPE_MULTI }; 103 104 /* Default scope if selection exists when replace dialog pops up. 105 "Smart" means "In Selection" if the selection spans more than 106 one line; "In Window" otherwise. */ 107 enum ReplaceAllDefaultScope { REPL_DEF_SCOPE_WINDOW, 108 REPL_DEF_SCOPE_SELECTION, 109 REPL_DEF_SCOPE_SMART }; 110 #endif 111 112 /* 113 ** Returns a pointer to the string describing the search type for search 114 ** action routine parameters (see menu.c for processing of action routines) 115 ** If searchType is invalid defaultRV is returned. 116 */ 117 const char *SearchTypeArg(int searchType, const char * defaultRV); 118 119 /* 120 ** Parses a search type description string. If the string contains a valid 121 ** search type description, returns TRUE and writes the corresponding 122 ** SearchType in searchType. Returns FALSE and leaves searchType untouched 123 ** otherwise. 124 */ 125 int StringToSearchType(const char * string, int *searchType); 126 127 /* 128 ** History of search actions. 129 */ 130 extern int NHist; 131 132 #endif /* NEDIT_SEARCH_H_INCLUDED */ 133