Added "smart" replace scope behaviour to the replace dialog radio button
[nedit.git] / source / nedit.h
blobef0925b6262577f03fec44262824fa7ae659ecdb
1 /* $Id: nedit.h,v 1.10 2001/04/03 22:59:38 edg Exp $ */
2 /*******************************************************************************
3 * *
4 * nedit.h -- Nirvana Editor common include file *
5 * *
6 *******************************************************************************/
8 /* Tuning parameters */
9 #define SEARCHMAX 511 /* Maximum length of search/replace strings */
10 #define MAX_SEARCH_HISTORY 100 /* Maximum length of search string history */
11 #define MAX_PANES 6 /* Max # of ADDITIONAL text editing panes
12 that can be added to a window */
13 #ifndef VMS
14 #define AUTOSAVE_CHAR_LIMIT 30 /* number of characters user can type before
15 NEdit generates a new backup file */
16 #else
17 #define AUTOSAVE_CHAR_LIMIT 80 /* set higher on VMS becaus saving is slower */
18 #endif /*VMS*/
19 #define AUTOSAVE_OP_LIMIT 8 /* number of distinct editing operations user
20 can do before NEdit gens. new backup file */
21 #define MAX_FONT_LEN 100 /* maximum length for a font name */
22 #define MAX_MARKS 36 /* max. # of bookmarks (one per letter & #) */
23 #define MIN_LINE_NUM_COLS 4 /* Min. # of columns in line number display */
24 #define APP_NAME "nedit" /* application name for loading resources */
25 #define APP_CLASS "NEdit" /* application class for loading resources */
26 #ifdef SGI_CUSTOM
27 #define SGI_WINDOW_TITLE "nedit: " /* part of window title string for sgi */
28 #define SGI_WINDOW_TITLE_LEN 7 /* length of SGI_WINDOW_TITLE */
29 #endif
31 /* The accumulated list of undo operations can potentially consume huge
32 amounts of memory. These tuning parameters determine how much undo infor-
33 mation is retained. Normally, the list is kept between UNDO_OP_LIMIT and
34 UNDO_OP_TRIMTO in length (when the list reaches UNDO_OP_LIMIT, it is
35 trimmed to UNDO_OP_TRIMTO then allowed to grow back to UNDO_OP_LIMIT).
36 When there are very large amounts of saved text held in the list,
37 UNDO_WORRY_LIMIT and UNDO_PURGE_LIMIT take over and cause the list to
38 be trimmed back further to keep its size down. */
39 #define UNDO_PURGE_LIMIT 15000000 /* If undo list gets this large (in bytes),
40 trim it to length of UNDO_PURGE_TRIMTO */
41 #define UNDO_PURGE_TRIMTO 1 /* Amount to trim the undo list in a purge */
42 #define UNDO_WORRY_LIMIT 2000000 /* If undo list gets this large (in bytes),
43 trim it to length of UNDO_WORRY_TRIMTO */
44 #define UNDO_WORRY_TRIMTO 5 /* Amount to trim the undo list when memory
45 use begins to get serious */
46 #define UNDO_OP_LIMIT 400 /* normal limit for length of undo list */
47 #define UNDO_OP_TRIMTO 200 /* size undo list is normally trimmed to
48 when it exceeds UNDO_OP_TRIMTO in length */
49 #ifdef SGI_CUSTOM
50 #define MAX_SHORTENED_ITEMS 40 /* max. number of items excluded in short- */
51 #endif /* menus mode */
53 enum indentStyle {NO_AUTO_INDENT, AUTO_INDENT, SMART_INDENT};
54 enum wrapStyle {NO_WRAP, NEWLINE_WRAP, CONTINUOUS_WRAP};
55 enum fileFormats {UNIX_FILE_FORMAT, DOS_FILE_FORMAT, MAC_FILE_FORMAT};
57 #define CHARSET (XmStringCharSet)XmSTRING_DEFAULT_CHARSET
59 #define MKSTRING(string) \
60 XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET)
62 #define SET_ONE_RSRC(widget, name, newValue) \
63 { \
64 static Arg args[1] = {{name, (XtArgVal)0}}; \
65 args[0].value = (XtArgVal)newValue; \
66 XtSetValues(widget, args, 1); \
69 #define GET_ONE_RSRC(widget, name, valueAddr) \
70 { \
71 static Arg args[1] = {{name, (XtArgVal)0}}; \
72 args[0].value = (XtArgVal)valueAddr; \
73 XtGetValues(widget, args, 1); \
76 /* Record on undo list */
77 typedef struct _UndoInfo {
78 struct _UndoInfo *next; /* pointer to the next undo record */
79 int type;
80 int startPos;
81 int endPos;
82 int oldLen;
83 char *oldText;
84 char inUndo; /* flag to indicate undo command on
85 this record in progress. Redirects
86 SaveUndoInfo to save the next mod-
87 ifications on the redo list instead
88 of the undo list. */
89 char restoresToSaved; /* flag to indicate undoing this
90 operation will restore file to
91 last saved (unmodified) state */
92 } UndoInfo;
94 /* Element in bookmark table */
95 typedef struct {
96 char label;
97 int cursorPos;
98 selection sel;
99 } Bookmark;
101 typedef struct _WindowInfo {
102 struct _WindowInfo *next;
103 Widget shell; /* application shell of window */
104 Widget splitPane; /* paned win. for splitting text area */
105 Widget textArea; /* the first text editing area widget */
106 Widget textPanes[MAX_PANES]; /* additional ones created on demand */
107 Widget lastFocus; /* the last pane to have kbd. focus */
108 Widget statsLine; /* file stats information display */
109 Widget iSearchForm; /* incremental search line widgets */
110 Widget iSearchText;
111 Widget iSearchRegexToggle;
112 Widget iSearchCaseToggle;
113 Widget iSearchRevToggle;
114 Widget menuBar; /* the main menu bar */
115 Widget replaceDlog; /* replace dialog */
116 Widget replaceText; /* replace dialog settable widgets... */
117 Widget replaceWithText;
118 Widget replaceCaseToggle;
119 Widget replaceWordToggle;
120 Widget replaceRegexToggle;
121 Widget replaceRevToggle;
122 Widget replaceKeepBtn;
123 Widget replaceBtns;
124 Widget replaceBtn;
125 #ifdef REPLACE_SCOPE
126 Widget replaceAllBtn;
127 #else
128 Widget replaceInSelBtn;
129 #endif
130 Widget replaceSearchTypeBox;
131 Widget replaceFindBtn;
132 Widget replaceAndFindBtn;
133 Widget findDlog; /* find dialog */
134 Widget findText; /* find dialog settable widgets... */
135 Widget findCaseToggle;
136 Widget findWordToggle;
137 Widget findRegexToggle;
138 Widget findRevToggle;
139 Widget findKeepBtn;
140 Widget findBtns;
141 Widget findBtn;
142 Widget findSearchTypeBox;
143 Widget replaceMultiFileDlog; /* Replace in multiple files */
144 Widget replaceMultiFileList;
145 Widget replaceMultiFilePathBtn;
146 Widget fontDialog; /* NULL, unless font dialog is up */
147 Widget readOnlyItem; /* menu bar settable widgets... */
148 Widget autoSaveItem;
149 Widget saveLastItem;
150 Widget closeItem;
151 Widget printSelItem;
152 Widget undoItem;
153 Widget redoItem;
154 Widget cutItem;
155 Widget copyItem;
156 Widget langModeCascade;
157 Widget findDefItem;
158 Widget autoIndentOffItem;
159 Widget autoIndentItem;
160 Widget smartIndentItem;
161 Widget noWrapItem;
162 Widget newlineWrapItem;
163 Widget continuousWrapItem;
164 Widget statsLineItem;
165 Widget iSearchLineItem;
166 Widget lineNumsItem;
167 Widget showMatchingItem;
168 Widget overtypeModeItem;
169 Widget highlightItem;
170 Widget windowMenuPane;
171 Widget shellMenuPane;
172 Widget macroMenuPane;
173 Widget bgMenuPane;
174 Widget prevOpenMenuPane;
175 Widget prevOpenMenuItem;
176 Widget unloadTagsMenuPane;
177 Widget unloadTagsMenuItem;
178 Widget filterItem;
179 Widget autoIndentOffDefItem;
180 Widget autoIndentDefItem;
181 Widget smartIndentDefItem;
182 Widget autoSaveDefItem;
183 Widget saveLastDefItem;
184 Widget noWrapDefItem;
185 Widget newlineWrapDefItem;
186 Widget contWrapDefItem;
187 Widget showMatchingDefItem;
188 Widget highlightOffDefItem;
189 Widget highlightDefItem;
190 Widget searchDlogsDefItem;
191 Widget beepOnSearchWrapDefItem;
192 Widget keepSearchDlogsDefItem;
193 Widget searchWrapsDefItem;
194 Widget sortOpenPrevDefItem;
195 Widget allTagsDefItem;
196 Widget smartTagsDefItem;
197 Widget reposDlogsDefItem;
198 Widget statsLineDefItem;
199 Widget iSearchLineDefItem;
200 Widget lineNumsDefItem;
201 Widget modWarnDefItem;
202 Widget exitWarnDefItem;
203 Widget searchLiteralDefItem;
204 Widget searchCaseSenseDefItem;
205 Widget searchLiteralWordDefItem;
206 Widget searchCaseSenseWordDefItem;
207 Widget searchRegexNoCaseDefItem;
208 Widget searchRegexDefItem;
209 #ifdef REPLACE_SCOPE
210 Widget replScopeWinDefItem;
211 Widget replScopeSelDefItem;
212 Widget replScopeSmartDefItem;
213 #endif
214 Widget size24x80DefItem;
215 Widget size40x80DefItem;
216 Widget size60x80DefItem;
217 Widget size80x80DefItem;
218 Widget sizeCustomDefItem;
219 Widget cancelShellItem;
220 Widget learnItem;
221 Widget finishLearnItem;
222 Widget cancelMacroItem;
223 Widget replayItem;
224 Widget repeatItem;
225 Widget splitWindowItem;
226 Widget closePaneItem;
227 Widget bgMenuUndoItem;
228 Widget bgMenuRedoItem;
229 #ifdef SGI_CUSTOM
230 Widget shortMenusDefItem;
231 Widget toggleShortItems[MAX_SHORTENED_ITEMS]; /* Menu items to be
232 managed and unmanaged to toggle
233 short menus on and off */
234 int nToggleShortItems;
235 #endif
236 char filename[MAXPATHLEN]; /* name component of file being edited*/
237 char path[MAXPATHLEN]; /* path component of file being edited*/
238 int fileMode; /* permissions of file being edited */
239 int fileFormat; /* whether to save the file straight
240 (Unix format), or convert it to
241 MS DOS style with \r\n line breaks */
242 time_t lastModTime; /* time of last modification to file */
243 UndoInfo *undo; /* info for undoing last operation */
244 UndoInfo *redo; /* info for redoing last undone op */
245 textBuffer *buffer; /* holds the text being edited */
246 int nPanes; /* number of additional text editing
247 areas, created by splitWindow */
248 int autoSaveCharCount; /* count of single characters typed
249 since last backup file generated */
250 int autoSaveOpCount; /* count of editing operations "" */
251 int undoOpCount; /* count of stored undo operations */
252 int undoMemUsed; /* amount of memory (in bytes)
253 dedicated to the undo list */
254 char fontName[MAX_FONT_LEN]; /* names of the text fonts in use */
255 char italicFontName[MAX_FONT_LEN];
256 char boldFontName[MAX_FONT_LEN];
257 char boldItalicFontName[MAX_FONT_LEN];
258 XmFontList fontList; /* fontList for the primary font */
259 XFontStruct *italicFontStruct; /* fontStructs for highlighting fonts */
260 XFontStruct *boldFontStruct;
261 XFontStruct *boldItalicFontStruct;
262 XtIntervalId flashTimeoutID; /* timer procedure id for getting rid
263 of highlighted matching paren. Non-
264 zero val. means highlight is drawn */
265 int flashPos; /* position saved for erasing matching
266 paren highlight (if one is drawn) */
267 int wasSelected; /* last selection state (for dim/undim
268 of selection related menu items */
269 Boolean filenameSet; /* is the window still "Untitled"? */
270 Boolean fileChanged; /* has window been modified? */
271 Boolean readOnly; /* is current file read only? */
272 Boolean lockWrite; /* is Read Only selected in menu? */
273 Boolean autoSave; /* is autosave turned on? */
274 Boolean saveOldVersion; /* keep old version in filename.bck */
275 char indentStyle; /* whether/how to auto indent */
276 char wrapMode; /* line wrap style: NO_WRAP,
277 NEWLINE_WRAP or CONTINUOUS_WRAP */
278 Boolean overstrike; /* is overstrike mode turned on ? */
279 Boolean showMatching; /* is paren matching mode on? */
280 Boolean showStats; /* is stats line supposed to be shown */
281 Boolean showISearchLine; /* is incr. search line to be shown */
282 Boolean showLineNumbers; /* is the line number display shown */
283 Boolean highlightSyntax; /* is syntax highlighting turned on? */
284 Boolean modeMessageDisplayed; /* special stats line banner for learn
285 and shell command executing modes */
286 Boolean ignoreModify; /* ignore modifications to text area */
287 Boolean windowMenuValid; /* is window menu is up to date? */
288 Boolean prevOpenMenuValid; /* Prev. Opened Files menu up to date?*/
289 int rHistIndex, fHistIndex; /* history placeholders for */
290 int iSearchHistIndex; /* find and replace dialogs */
291 int iSearchStartPos; /* start pos. of current incr. search */
292 int nMarks; /* number of active bookmarks */
293 XtIntervalId markTimeoutID; /* backup timer for mark event handler*/
294 Bookmark markTable[MAX_MARKS]; /* marked locations in window */
295 void *highlightData; /* info for syntax highlighting */
296 void *shellCmdData; /* when a shell command is executing,
297 info. about it, otherwise, NULL */
298 void *macroCmdData; /* same for macro commands */
299 void *smartIndentData; /* compiled macros for smart indent */
300 int languageMode; /* identifies language mode currently
301 selected in the window */
302 Boolean multiFileReplSelected; /* selected during last multi-window
303 replacement operation (history) */
304 struct _WindowInfo** /* temporary list of writable windows */
305 writableWindows; /* used during multi-file replacements */
306 int nWritableWindows; /* number of elements in the list */
307 Bool multiFileBusy; /* suppresses multiple beeps/dialogs
308 during multi-file replacements */
309 Bool replaceFailed; /* flags replacements failures during
310 multi-file replacements */
311 Bool replaceLastRegexCase; /* last state of the case sense button
312 in regex mode for replace dialog */
313 Bool replaceLastLiteralCase; /* idem, for literal mode */
314 Bool iSearchLastRegexCase; /* idem, for regex mode in
315 incremental search bar */
316 Bool iSearchLastLiteralCase; /* idem, for literal mode */
317 Bool findLastRegexCase; /* idem, for regex mode in find dialog */
318 Bool findLastLiteralCase; /* idem, for literal mode */
320 #ifdef REPLACE_SCOPE
321 int replaceScope; /* Current scope for replace dialog */
322 Widget replaceScopeWinToggle; /* Scope for replace = window */
323 Widget replaceScopeSelToggle; /* Scope for replace = selection */
324 Widget replaceScopeMultiToggle;/* Scope for replace = multiple files */
325 #endif
326 } WindowInfo;
328 extern WindowInfo *WindowList;
329 extern Display *TheDisplay;
330 extern char *ArgV0;
331 Boolean IsServer;