- Change help version to 5.4DEV
[nedit.git] / source / nedit.h
blobdebf8aa6f6dd3b1ca35bb6023b2ce81e3e10c2bb
1 /* $Id: nedit.h,v 1.32 2002/11/08 20:22:45 edg Exp $ */
3 #ifndef NEDIT_NEDIT_H_INCLUDED
4 #define NEDIT_NEDIT_H_INCLUDED
6 /*******************************************************************************
7 * *
8 * nedit.h -- Nirvana Editor common include file *
9 * *
10 *******************************************************************************/
12 #include "textBuf.h"
14 #include <X11/Intrinsic.h>
15 #include <Xm/Xm.h>
16 #include <Xm/XmStrDefs.h>
17 #ifdef VMS
18 #include "../util/VMSparam.h"
19 #else
20 #ifndef __MVS__
21 #include <sys/param.h>
22 #endif
23 #endif /*VMS*/
25 /* Tuning parameters */
26 #define SEARCHMAX 511 /* Maximum length of search/replace strings */
27 #define MAX_SEARCH_HISTORY 100 /* Maximum length of search string history */
28 #define MAX_PANES 6 /* Max # of ADDITIONAL text editing panes
29 that can be added to a window */
30 #ifndef VMS
31 #define AUTOSAVE_CHAR_LIMIT 30 /* number of characters user can type before
32 NEdit generates a new backup file */
33 #else
34 #define AUTOSAVE_CHAR_LIMIT 80 /* set higher on VMS becaus saving is slower */
35 #endif /*VMS*/
36 #define AUTOSAVE_OP_LIMIT 8 /* number of distinct editing operations user
37 can do before NEdit gens. new backup file */
38 #define MAX_FONT_LEN 100 /* maximum length for a font name */
39 #define MAX_MARKS 36 /* max. # of bookmarks (one per letter & #) */
40 #define MIN_LINE_NUM_COLS 4 /* Min. # of columns in line number display */
41 #define APP_NAME "nedit" /* application name for loading resources */
42 #define APP_CLASS "NEdit" /* application class for loading resources */
43 #ifdef SGI_CUSTOM
44 #define SGI_WINDOW_TITLE "nedit: " /* part of window title string for sgi */
45 #define SGI_WINDOW_TITLE_LEN 7 /* length of SGI_WINDOW_TITLE */
46 #endif
48 /* The accumulated list of undo operations can potentially consume huge
49 amounts of memory. These tuning parameters determine how much undo infor-
50 mation is retained. Normally, the list is kept between UNDO_OP_LIMIT and
51 UNDO_OP_TRIMTO in length (when the list reaches UNDO_OP_LIMIT, it is
52 trimmed to UNDO_OP_TRIMTO then allowed to grow back to UNDO_OP_LIMIT).
53 When there are very large amounts of saved text held in the list,
54 UNDO_WORRY_LIMIT and UNDO_PURGE_LIMIT take over and cause the list to
55 be trimmed back further to keep its size down. */
56 #define UNDO_PURGE_LIMIT 15000000 /* If undo list gets this large (in bytes),
57 trim it to length of UNDO_PURGE_TRIMTO */
58 #define UNDO_PURGE_TRIMTO 1 /* Amount to trim the undo list in a purge */
59 #define UNDO_WORRY_LIMIT 2000000 /* If undo list gets this large (in bytes),
60 trim it to length of UNDO_WORRY_TRIMTO */
61 #define UNDO_WORRY_TRIMTO 5 /* Amount to trim the undo list when memory
62 use begins to get serious */
63 #define UNDO_OP_LIMIT 400 /* normal limit for length of undo list */
64 #define UNDO_OP_TRIMTO 200 /* size undo list is normally trimmed to
65 when it exceeds UNDO_OP_TRIMTO in length */
66 #ifdef SGI_CUSTOM
67 #define MAX_SHORTENED_ITEMS 40 /* max. number of items excluded in short- */
68 #endif /* menus mode */
70 enum indentStyle {NO_AUTO_INDENT, AUTO_INDENT, SMART_INDENT};
71 enum wrapStyle {NO_WRAP, NEWLINE_WRAP, CONTINUOUS_WRAP};
72 enum fileFormats {UNIX_FILE_FORMAT, DOS_FILE_FORMAT, MAC_FILE_FORMAT};
73 enum showMatchingStyle {NO_FLASH, FLASH_DELIMIT, FLASH_RANGE};
74 enum virtKeyOverride { VIRT_KEY_OVERRIDE_NEVER, VIRT_KEY_OVERRIDE_AUTO,
75 VIRT_KEY_OVERRIDE_ALWAYS };
77 #define NO_FLASH_STRING "off"
78 #define FLASH_DELIMIT_STRING "delimiter"
79 #define FLASH_RANGE_STRING "range"
81 #define CHARSET (XmStringCharSet)XmSTRING_DEFAULT_CHARSET
83 #define MKSTRING(string) \
84 XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET)
86 #define SET_ONE_RSRC(widget, name, newValue) \
87 { \
88 static Arg args[1] = {{name, (XtArgVal)0}}; \
89 args[0].value = (XtArgVal)newValue; \
90 XtSetValues(widget, args, 1); \
93 #define GET_ONE_RSRC(widget, name, valueAddr) \
94 { \
95 static Arg args[1] = {{name, (XtArgVal)0}}; \
96 args[0].value = (XtArgVal)valueAddr; \
97 XtGetValues(widget, args, 1); \
100 /* This handles all the different reasons files can be locked */
101 #define USER_LOCKED_BIT 0
102 #define PERM_LOCKED_BIT 1
103 #define TOO_MUCH_BINARY_DATA_LOCKED_BIT 2
105 #define LOCKED_BIT_TO_MASK(bitNum) (1 << (bitNum))
106 #define SET_LOCKED_BY_REASON(reasons, onOrOff, reasonBit) ((onOrOff) ? \
107 ((reasons) |= LOCKED_BIT_TO_MASK(reasonBit)) : \
108 ((reasons) &= ~LOCKED_BIT_TO_MASK(reasonBit)))
110 #define IS_USER_LOCKED(reasons) (((reasons) & LOCKED_BIT_TO_MASK(USER_LOCKED_BIT)) != 0)
111 #define SET_USER_LOCKED(reasons, onOrOff) SET_LOCKED_BY_REASON(reasons, onOrOff, USER_LOCKED_BIT)
112 #define IS_PERM_LOCKED(reasons) (((reasons) & LOCKED_BIT_TO_MASK(PERM_LOCKED_BIT)) != 0)
113 #define SET_PERM_LOCKED(reasons, onOrOff) SET_LOCKED_BY_REASON(reasons, onOrOff, PERM_LOCKED_BIT)
114 #define IS_TMBD_LOCKED(reasons) (((reasons) & LOCKED_BIT_TO_MASK(TOO_MUCH_BINARY_DATA_LOCKED_BIT)) != 0)
115 #define SET_TMBD_LOCKED(reasons, onOrOff) SET_LOCKED_BY_REASON(reasons, onOrOff, TOO_MUCH_BINARY_DATA_LOCKED_BIT)
117 #define IS_ANY_LOCKED_IGNORING_USER(reasons) (((reasons) & ~LOCKED_BIT_TO_MASK(USER_LOCKED_BIT)) != 0)
118 #define IS_ANY_LOCKED_IGNORING_PERM(reasons) (((reasons) & ~LOCKED_BIT_TO_MASK(PERM_LOCKED_BIT)) != 0)
119 #define IS_ANY_LOCKED(reasons) ((reasons) != 0)
120 #define CLEAR_ALL_LOCKS(reasons) ((reasons) = 0)
122 /* Record on undo list */
123 typedef struct _UndoInfo {
124 struct _UndoInfo *next; /* pointer to the next undo record */
125 int type;
126 int startPos;
127 int endPos;
128 int oldLen;
129 char *oldText;
130 char inUndo; /* flag to indicate undo command on
131 this record in progress. Redirects
132 SaveUndoInfo to save the next mod-
133 ifications on the redo list instead
134 of the undo list. */
135 char restoresToSaved; /* flag to indicate undoing this
136 operation will restore file to
137 last saved (unmodified) state */
138 } UndoInfo;
140 /* Element in bookmark table */
141 typedef struct {
142 char label;
143 int cursorPos;
144 selection sel;
145 } Bookmark;
147 typedef struct _WindowInfo {
148 struct _WindowInfo *next;
149 Widget shell; /* application shell of window */
150 Widget splitPane; /* paned win. for splitting text area */
151 Widget textArea; /* the first text editing area widget */
152 Widget textPanes[MAX_PANES]; /* additional ones created on demand */
153 Widget lastFocus; /* the last pane to have kbd. focus */
154 Widget statsLine; /* file stats information display */
155 Widget statsLineForm;
156 Widget statsLineColNo; /* Line/Column information display */
157 Widget iSearchForm; /* incremental search line widgets */
158 Widget iSearchText;
159 Widget iSearchRegexToggle;
160 Widget iSearchCaseToggle;
161 Widget iSearchRevToggle;
162 Widget menuBar; /* the main menu bar */
163 Widget replaceDlog; /* replace dialog */
164 Widget replaceText; /* replace dialog settable widgets... */
165 Widget replaceWithText;
166 Widget replaceCaseToggle;
167 Widget replaceWordToggle;
168 Widget replaceRegexToggle;
169 Widget replaceRevToggle;
170 Widget replaceKeepBtn;
171 Widget replaceBtns;
172 Widget replaceBtn;
173 Widget replaceAllBtn;
174 #ifndef REPLACE_SCOPE
175 Widget replaceInWinBtn;
176 Widget replaceInSelBtn;
177 #endif
178 Widget replaceSearchTypeBox;
179 Widget replaceFindBtn;
180 Widget replaceAndFindBtn;
181 Widget findDlog; /* find dialog */
182 Widget findText; /* find dialog settable widgets... */
183 Widget findCaseToggle;
184 Widget findWordToggle;
185 Widget findRegexToggle;
186 Widget findRevToggle;
187 Widget findKeepBtn;
188 Widget findBtns;
189 Widget findBtn;
190 Widget findSearchTypeBox;
191 Widget replaceMultiFileDlog; /* Replace in multiple files */
192 Widget replaceMultiFileList;
193 Widget replaceMultiFilePathBtn;
194 Widget fontDialog; /* NULL, unless font dialog is up */
195 Widget readOnlyItem; /* menu bar settable widgets... */
196 Widget autoSaveItem;
197 Widget saveLastItem;
198 Widget openSelItem;
199 Widget closeItem;
200 Widget printSelItem;
201 Widget undoItem;
202 Widget redoItem;
203 Widget cutItem;
204 Widget delItem;
205 Widget copyItem;
206 Widget lowerItem;
207 Widget upperItem;
208 Widget findSelItem;
209 Widget findAgainItem;
210 Widget replaceFindAgainItem;
211 Widget replaceAgainItem;
212 Widget gotoSelItem;
213 Widget langModeCascade;
214 Widget findDefItem;
215 Widget showTipItem;
216 Widget autoIndentOffItem;
217 Widget autoIndentItem;
218 Widget smartIndentItem;
219 Widget noWrapItem;
220 Widget newlineWrapItem;
221 Widget continuousWrapItem;
222 Widget statsLineItem;
223 Widget iSearchLineItem;
224 Widget lineNumsItem;
225 Widget showMatchingOffItem;
226 Widget showMatchingDelimitItem;
227 Widget showMatchingRangeItem;
228 Widget matchSyntaxBasedItem;
229 Widget overtypeModeItem;
230 Widget highlightItem;
231 Widget windowMenuPane;
232 Widget shellMenuPane;
233 Widget macroMenuPane;
234 Widget bgMenuPane;
235 Widget prevOpenMenuPane;
236 Widget prevOpenMenuItem;
237 Widget unloadTagsMenuPane;
238 Widget unloadTagsMenuItem;
239 Widget unloadTipsMenuPane;
240 Widget unloadTipsMenuItem;
241 Widget filterItem;
242 Widget autoIndentOffDefItem;
243 Widget autoIndentDefItem;
244 Widget smartIndentDefItem;
245 Widget autoSaveDefItem;
246 Widget saveLastDefItem;
247 Widget noWrapDefItem;
248 Widget newlineWrapDefItem;
249 Widget contWrapDefItem;
250 Widget showMatchingOffDefItem;
251 Widget showMatchingDelimitDefItem;
252 Widget showMatchingRangeDefItem;
253 Widget matchSyntaxBasedDefItem;
254 Widget highlightOffDefItem;
255 Widget highlightDefItem;
256 Widget backlightCharsItem;
257 Widget backlightCharsDefItem;
258 Widget searchDlogsDefItem;
259 Widget beepOnSearchWrapDefItem;
260 Widget keepSearchDlogsDefItem;
261 Widget searchWrapsDefItem;
262 Widget appendLFItem;
263 Widget sortOpenPrevDefItem;
264 Widget allTagsDefItem;
265 Widget smartTagsDefItem;
266 Widget reposDlogsDefItem;
267 Widget statsLineDefItem;
268 Widget iSearchLineDefItem;
269 Widget lineNumsDefItem;
270 Widget pathInWindowsMenuDefItem;
271 Widget modWarnDefItem;
272 Widget modWarnRealDefItem;
273 Widget exitWarnDefItem;
274 Widget searchLiteralDefItem;
275 Widget searchCaseSenseDefItem;
276 Widget searchLiteralWordDefItem;
277 Widget searchCaseSenseWordDefItem;
278 Widget searchRegexNoCaseDefItem;
279 Widget searchRegexDefItem;
280 #ifdef REPLACE_SCOPE
281 Widget replScopeWinDefItem;
282 Widget replScopeSelDefItem;
283 Widget replScopeSmartDefItem;
284 #endif
285 Widget size24x80DefItem;
286 Widget size40x80DefItem;
287 Widget size60x80DefItem;
288 Widget size80x80DefItem;
289 Widget sizeCustomDefItem;
290 Widget cancelShellItem;
291 Widget learnItem;
292 Widget finishLearnItem;
293 Widget cancelMacroItem;
294 Widget replayItem;
295 Widget repeatItem;
296 Widget splitWindowItem;
297 Widget closePaneItem;
298 Widget bgMenuUndoItem;
299 Widget bgMenuRedoItem;
300 #ifdef SGI_CUSTOM
301 Widget shortMenusDefItem;
302 Widget toggleShortItems[MAX_SHORTENED_ITEMS]; /* Menu items to be
303 managed and unmanaged to toggle
304 short menus on and off */
305 int nToggleShortItems;
306 #endif
307 char filename[MAXPATHLEN]; /* name component of file being edited*/
308 char path[MAXPATHLEN]; /* path component of file being edited*/
309 unsigned fileMode; /* permissions of file being edited */
310 int fileFormat; /* whether to save the file straight
311 (Unix format), or convert it to
312 MS DOS style with \r\n line breaks */
313 time_t lastModTime; /* time of last modification to file */
314 UndoInfo *undo; /* info for undoing last operation */
315 UndoInfo *redo; /* info for redoing last undone op */
316 textBuffer *buffer; /* holds the text being edited */
317 int nPanes; /* number of additional text editing
318 areas, created by splitWindow */
319 int autoSaveCharCount; /* count of single characters typed
320 since last backup file generated */
321 int autoSaveOpCount; /* count of editing operations "" */
322 int undoOpCount; /* count of stored undo operations */
323 int undoMemUsed; /* amount of memory (in bytes)
324 dedicated to the undo list */
325 char fontName[MAX_FONT_LEN]; /* names of the text fonts in use */
326 char italicFontName[MAX_FONT_LEN];
327 char boldFontName[MAX_FONT_LEN];
328 char boldItalicFontName[MAX_FONT_LEN];
329 XmFontList fontList; /* fontList for the primary font */
330 XFontStruct *italicFontStruct; /* fontStructs for highlighting fonts */
331 XFontStruct *boldFontStruct;
332 XFontStruct *boldItalicFontStruct;
333 XtIntervalId flashTimeoutID; /* timer procedure id for getting rid
334 of highlighted matching paren. Non-
335 zero val. means highlight is drawn */
336 int flashPos; /* position saved for erasing matching
337 paren highlight (if one is drawn) */
338 int wasSelected; /* last selection state (for dim/undim
339 of selection related menu items */
340 Boolean filenameSet; /* is the window still "Untitled"? */
341 Boolean fileChanged; /* has window been modified? */
342 Boolean fileMissing; /* is the window's file gone? */
343 int lockReasons; /* all ways a file can be locked */
344 Boolean autoSave; /* is autosave turned on? */
345 Boolean saveOldVersion; /* keep old version in filename.bck */
346 char indentStyle; /* whether/how to auto indent */
347 char wrapMode; /* line wrap style: NO_WRAP,
348 NEWLINE_WRAP or CONTINUOUS_WRAP */
349 Boolean overstrike; /* is overstrike mode turned on ? */
350 char showMatchingStyle; /* How to show matching parens:
351 NO_FLASH, FLASH_DELIMIT, or
352 FLASH_RANGE */
353 char matchSyntaxBased; /* Use syntax info to show matching */
354 Boolean showStats; /* is stats line supposed to be shown */
355 Boolean showISearchLine; /* is incr. search line to be shown */
356 Boolean showLineNumbers; /* is the line number display shown */
357 Boolean showPathInWindowsMenu; /* is the path shown in windows menu */
358 Boolean highlightSyntax; /* is syntax highlighting turned on? */
359 Boolean backlightChars; /* is char backlighting turned on? */
360 char *backlightCharTypes; /* what backlighting to use */
361 Boolean modeMessageDisplayed; /* special stats line banner for learn
362 and shell command executing modes */
363 Boolean ignoreModify; /* ignore modifications to text area */
364 Boolean windowMenuValid; /* is window menu is up to date? */
365 Boolean prevOpenMenuValid; /* Prev. Opened Files menu up to date?*/
366 int rHistIndex, fHistIndex; /* history placeholders for */
367 int iSearchHistIndex; /* find and replace dialogs */
368 int iSearchStartPos; /* start pos. of current incr. search */
369 int iSearchLastBeginPos; /* beg. pos. last match of current i.s.*/
370 int nMarks; /* number of active bookmarks */
371 XtIntervalId markTimeoutID; /* backup timer for mark event handler*/
372 Bookmark markTable[MAX_MARKS]; /* marked locations in window */
373 void *highlightData; /* info for syntax highlighting */
374 void *shellCmdData; /* when a shell command is executing,
375 info. about it, otherwise, NULL */
376 void *macroCmdData; /* same for macro commands */
377 void *smartIndentData; /* compiled macros for smart indent */
378 Atom fileClosedAtom; /* Atom used to tell nc that the file is closed */
379 int languageMode; /* identifies language mode currently
380 selected in the window */
381 Boolean multiFileReplSelected; /* selected during last multi-window
382 replacement operation (history) */
383 struct _WindowInfo** /* temporary list of writable windows */
384 writableWindows; /* used during multi-file replacements */
385 int nWritableWindows; /* number of elements in the list */
386 Bool multiFileBusy; /* suppresses multiple beeps/dialogs
387 during multi-file replacements */
388 Bool replaceFailed; /* flags replacements failures during
389 multi-file replacements */
390 Bool replaceLastRegexCase; /* last state of the case sense button
391 in regex mode for replace dialog */
392 Bool replaceLastLiteralCase; /* idem, for literal mode */
393 Bool iSearchLastRegexCase; /* idem, for regex mode in
394 incremental search bar */
395 Bool iSearchLastLiteralCase; /* idem, for literal mode */
396 Bool findLastRegexCase; /* idem, for regex mode in find dialog */
397 Bool findLastLiteralCase; /* idem, for literal mode */
399 #ifdef REPLACE_SCOPE
400 int replaceScope; /* Current scope for replace dialog */
401 Widget replaceScopeWinToggle; /* Scope for replace = window */
402 Widget replaceScopeSelToggle; /* Scope for replace = selection */
403 Widget replaceScopeMultiToggle;/* Scope for replace = multiple files */
404 #endif
405 } WindowInfo;
407 extern WindowInfo *WindowList;
408 extern Display *TheDisplay;
409 extern char *ArgV0;
410 extern Boolean IsServer;
412 #endif /* NEDIT_NEDIT_H_INCLUDED */