Yet another attempted fix for 434383: menus showing up as blocks.
[nedit.git] / source / nedit.h
blob1e42e1f481dde04025c39e591341973f9c9243da
1 /* $Id: nedit.h,v 1.20 2002/01/08 14:33:11 amai 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};
56 enum showMatchingStyle {NO_FLASH, FLASH_DELIMIT, FLASH_RANGE};
58 #define NO_FLASH_STRING "off"
59 #define FLASH_DELIMIT_STRING "delimiter"
60 #define FLASH_RANGE_STRING "range"
62 #define CHARSET (XmStringCharSet)XmSTRING_DEFAULT_CHARSET
64 #define MKSTRING(string) \
65 XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET)
67 #define SET_ONE_RSRC(widget, name, newValue) \
68 { \
69 static Arg args[1] = {{name, (XtArgVal)0}}; \
70 args[0].value = (XtArgVal)newValue; \
71 XtSetValues(widget, args, 1); \
74 #define GET_ONE_RSRC(widget, name, valueAddr) \
75 { \
76 static Arg args[1] = {{name, (XtArgVal)0}}; \
77 args[0].value = (XtArgVal)valueAddr; \
78 XtGetValues(widget, args, 1); \
81 /* This handles all the different reasons files can be locked */
82 #define USER_LOCKED_BIT 0
83 #define PERM_LOCKED_BIT 1
84 #define TOO_MUCH_BINARY_DATA_LOCKED_BIT 2
86 #define LOCKED_BIT_TO_MASK(bitNum) (1 << (bitNum))
87 #define SET_LOCKED_BY_REASON(reasons, onOrOff, reasonBit) ((onOrOff) ? \
88 ((reasons) |= LOCKED_BIT_TO_MASK(reasonBit)) : \
89 ((reasons) &= ~LOCKED_BIT_TO_MASK(reasonBit)))
91 #define IS_USER_LOCKED(reasons) (((reasons) & LOCKED_BIT_TO_MASK(USER_LOCKED_BIT)) != 0)
92 #define SET_USER_LOCKED(reasons, onOrOff) SET_LOCKED_BY_REASON(reasons, onOrOff, USER_LOCKED_BIT)
93 #define IS_PERM_LOCKED(reasons) (((reasons) & LOCKED_BIT_TO_MASK(PERM_LOCKED_BIT)) != 0)
94 #define SET_PERM_LOCKED(reasons, onOrOff) SET_LOCKED_BY_REASON(reasons, onOrOff, PERM_LOCKED_BIT)
95 #define IS_TMBD_LOCKED(reasons) (((reasons) & LOCKED_BIT_TO_MASK(TOO_MUCH_BINARY_DATA_LOCKED_BIT)) != 0)
96 #define SET_TMBD_LOCKED(reasons, onOrOff) SET_LOCKED_BY_REASON(reasons, onOrOff, TOO_MUCH_BINARY_DATA_LOCKED_BIT)
98 #define IS_ANY_LOCKED_IGNORING_USER(reasons) (((reasons) & ~LOCKED_BIT_TO_MASK(USER_LOCKED_BIT)) != 0)
99 #define IS_ANY_LOCKED_IGNORING_PERM(reasons) (((reasons) & ~LOCKED_BIT_TO_MASK(PERM_LOCKED_BIT)) != 0)
100 #define IS_ANY_LOCKED(reasons) ((reasons) != 0)
101 #define CLEAR_ALL_LOCKS(reasons) ((reasons) = 0)
103 /* Record on undo list */
104 typedef struct _UndoInfo {
105 struct _UndoInfo *next; /* pointer to the next undo record */
106 int type;
107 int startPos;
108 int endPos;
109 int oldLen;
110 char *oldText;
111 char inUndo; /* flag to indicate undo command on
112 this record in progress. Redirects
113 SaveUndoInfo to save the next mod-
114 ifications on the redo list instead
115 of the undo list. */
116 char restoresToSaved; /* flag to indicate undoing this
117 operation will restore file to
118 last saved (unmodified) state */
119 } UndoInfo;
121 /* Element in bookmark table */
122 typedef struct {
123 char label;
124 int cursorPos;
125 selection sel;
126 } Bookmark;
128 typedef struct _WindowInfo {
129 struct _WindowInfo *next;
130 Widget shell; /* application shell of window */
131 Widget splitPane; /* paned win. for splitting text area */
132 Widget textArea; /* the first text editing area widget */
133 Widget textPanes[MAX_PANES]; /* additional ones created on demand */
134 Widget lastFocus; /* the last pane to have kbd. focus */
135 Widget statsLine; /* file stats information display */
136 Widget iSearchForm; /* incremental search line widgets */
137 Widget iSearchText;
138 Widget iSearchRegexToggle;
139 Widget iSearchCaseToggle;
140 Widget iSearchRevToggle;
141 Widget menuBar; /* the main menu bar */
142 Widget replaceDlog; /* replace dialog */
143 Widget replaceText; /* replace dialog settable widgets... */
144 Widget replaceWithText;
145 Widget replaceCaseToggle;
146 Widget replaceWordToggle;
147 Widget replaceRegexToggle;
148 Widget replaceRevToggle;
149 Widget replaceKeepBtn;
150 Widget replaceBtns;
151 Widget replaceBtn;
152 Widget replaceAllBtn;
153 #ifndef REPLACE_SCOPE
154 Widget replaceInWinBtn;
155 Widget replaceInSelBtn;
156 #endif
157 Widget replaceSearchTypeBox;
158 Widget replaceFindBtn;
159 Widget replaceAndFindBtn;
160 Widget findDlog; /* find dialog */
161 Widget findText; /* find dialog settable widgets... */
162 Widget findCaseToggle;
163 Widget findWordToggle;
164 Widget findRegexToggle;
165 Widget findRevToggle;
166 Widget findKeepBtn;
167 Widget findBtns;
168 Widget findBtn;
169 Widget findSearchTypeBox;
170 Widget replaceMultiFileDlog; /* Replace in multiple files */
171 Widget replaceMultiFileList;
172 Widget replaceMultiFilePathBtn;
173 Widget fontDialog; /* NULL, unless font dialog is up */
174 Widget readOnlyItem; /* menu bar settable widgets... */
175 Widget autoSaveItem;
176 Widget saveLastItem;
177 Widget openSelItem;
178 Widget closeItem;
179 Widget printSelItem;
180 Widget undoItem;
181 Widget redoItem;
182 Widget cutItem;
183 Widget delItem;
184 Widget copyItem;
185 Widget lowerItem;
186 Widget upperItem;
187 Widget findSelItem;
188 Widget findAgainItem;
189 Widget replaceFindAgainItem;
190 Widget replaceAgainItem;
191 Widget gotoSelItem;
192 Widget langModeCascade;
193 Widget findDefItem;
194 Widget autoIndentOffItem;
195 Widget autoIndentItem;
196 Widget smartIndentItem;
197 Widget noWrapItem;
198 Widget newlineWrapItem;
199 Widget continuousWrapItem;
200 Widget statsLineItem;
201 Widget iSearchLineItem;
202 Widget lineNumsItem;
203 Widget showMatchingOffItem;
204 Widget showMatchingDelimitItem;
205 Widget showMatchingRangeItem;
206 Widget overtypeModeItem;
207 Widget highlightItem;
208 Widget windowMenuPane;
209 Widget shellMenuPane;
210 Widget macroMenuPane;
211 Widget bgMenuPane;
212 Widget prevOpenMenuPane;
213 Widget prevOpenMenuItem;
214 Widget unloadTagsMenuPane;
215 Widget unloadTagsMenuItem;
216 Widget filterItem;
217 Widget autoIndentOffDefItem;
218 Widget autoIndentDefItem;
219 Widget smartIndentDefItem;
220 Widget autoSaveDefItem;
221 Widget saveLastDefItem;
222 Widget noWrapDefItem;
223 Widget newlineWrapDefItem;
224 Widget contWrapDefItem;
225 Widget showMatchingOffDefItem;
226 Widget showMatchingDelimitDefItem;
227 Widget showMatchingRangeDefItem;
228 Widget highlightOffDefItem;
229 Widget highlightDefItem;
230 Widget searchDlogsDefItem;
231 Widget beepOnSearchWrapDefItem;
232 Widget keepSearchDlogsDefItem;
233 Widget searchWrapsDefItem;
234 Widget sortOpenPrevDefItem;
235 Widget allTagsDefItem;
236 Widget smartTagsDefItem;
237 Widget reposDlogsDefItem;
238 Widget statsLineDefItem;
239 Widget iSearchLineDefItem;
240 Widget lineNumsDefItem;
241 Widget pathInWindowsMenuDefItem;
242 Widget modWarnDefItem;
243 Widget exitWarnDefItem;
244 Widget searchLiteralDefItem;
245 Widget searchCaseSenseDefItem;
246 Widget searchLiteralWordDefItem;
247 Widget searchCaseSenseWordDefItem;
248 Widget searchRegexNoCaseDefItem;
249 Widget searchRegexDefItem;
250 #ifdef REPLACE_SCOPE
251 Widget replScopeWinDefItem;
252 Widget replScopeSelDefItem;
253 Widget replScopeSmartDefItem;
254 #endif
255 Widget size24x80DefItem;
256 Widget size40x80DefItem;
257 Widget size60x80DefItem;
258 Widget size80x80DefItem;
259 Widget sizeCustomDefItem;
260 Widget cancelShellItem;
261 Widget learnItem;
262 Widget finishLearnItem;
263 Widget cancelMacroItem;
264 Widget replayItem;
265 Widget repeatItem;
266 Widget splitWindowItem;
267 Widget closePaneItem;
268 Widget bgMenuUndoItem;
269 Widget bgMenuRedoItem;
270 #ifdef SGI_CUSTOM
271 Widget shortMenusDefItem;
272 Widget toggleShortItems[MAX_SHORTENED_ITEMS]; /* Menu items to be
273 managed and unmanaged to toggle
274 short menus on and off */
275 int nToggleShortItems;
276 #endif
277 char filename[MAXPATHLEN]; /* name component of file being edited*/
278 char path[MAXPATHLEN]; /* path component of file being edited*/
279 int fileMode; /* permissions of file being edited */
280 int fileFormat; /* whether to save the file straight
281 (Unix format), or convert it to
282 MS DOS style with \r\n line breaks */
283 time_t lastModTime; /* time of last modification to file */
284 UndoInfo *undo; /* info for undoing last operation */
285 UndoInfo *redo; /* info for redoing last undone op */
286 textBuffer *buffer; /* holds the text being edited */
287 int nPanes; /* number of additional text editing
288 areas, created by splitWindow */
289 int autoSaveCharCount; /* count of single characters typed
290 since last backup file generated */
291 int autoSaveOpCount; /* count of editing operations "" */
292 int undoOpCount; /* count of stored undo operations */
293 int undoMemUsed; /* amount of memory (in bytes)
294 dedicated to the undo list */
295 char fontName[MAX_FONT_LEN]; /* names of the text fonts in use */
296 char italicFontName[MAX_FONT_LEN];
297 char boldFontName[MAX_FONT_LEN];
298 char boldItalicFontName[MAX_FONT_LEN];
299 XmFontList fontList; /* fontList for the primary font */
300 XFontStruct *italicFontStruct; /* fontStructs for highlighting fonts */
301 XFontStruct *boldFontStruct;
302 XFontStruct *boldItalicFontStruct;
303 XtIntervalId flashTimeoutID; /* timer procedure id for getting rid
304 of highlighted matching paren. Non-
305 zero val. means highlight is drawn */
306 int flashPos; /* position saved for erasing matching
307 paren highlight (if one is drawn) */
308 int wasSelected; /* last selection state (for dim/undim
309 of selection related menu items */
310 Boolean filenameSet; /* is the window still "Untitled"? */
311 Boolean fileChanged; /* has window been modified? */
312 int lockReasons; /* all ways a file can be locked */
313 Boolean autoSave; /* is autosave turned on? */
314 Boolean saveOldVersion; /* keep old version in filename.bck */
315 char indentStyle; /* whether/how to auto indent */
316 char wrapMode; /* line wrap style: NO_WRAP,
317 NEWLINE_WRAP or CONTINUOUS_WRAP */
318 Boolean overstrike; /* is overstrike mode turned on ? */
319 char showMatchingStyle; /* How to show matching parens:
320 NO_FLASH, FLASH_DELIMIT, or
321 FLASH_RANGE */
322 Boolean showStats; /* is stats line supposed to be shown */
323 Boolean showISearchLine; /* is incr. search line to be shown */
324 Boolean showLineNumbers; /* is the line number display shown */
325 Boolean showPathInWindowsMenu; /* is the path shown in windows menu */
326 Boolean highlightSyntax; /* is syntax highlighting turned on? */
327 Boolean modeMessageDisplayed; /* special stats line banner for learn
328 and shell command executing modes */
329 Boolean ignoreModify; /* ignore modifications to text area */
330 Boolean windowMenuValid; /* is window menu is up to date? */
331 Boolean prevOpenMenuValid; /* Prev. Opened Files menu up to date?*/
332 int rHistIndex, fHistIndex; /* history placeholders for */
333 int iSearchHistIndex; /* find and replace dialogs */
334 int iSearchStartPos; /* start pos. of current incr. search */
335 int iSearchLastBeginPos; /* beg. pos. last match of current i.s.*/
336 int nMarks; /* number of active bookmarks */
337 XtIntervalId markTimeoutID; /* backup timer for mark event handler*/
338 Bookmark markTable[MAX_MARKS]; /* marked locations in window */
339 void *highlightData; /* info for syntax highlighting */
340 void *shellCmdData; /* when a shell command is executing,
341 info. about it, otherwise, NULL */
342 void *macroCmdData; /* same for macro commands */
343 void *smartIndentData; /* compiled macros for smart indent */
344 int languageMode; /* identifies language mode currently
345 selected in the window */
346 Boolean multiFileReplSelected; /* selected during last multi-window
347 replacement operation (history) */
348 struct _WindowInfo** /* temporary list of writable windows */
349 writableWindows; /* used during multi-file replacements */
350 int nWritableWindows; /* number of elements in the list */
351 Bool multiFileBusy; /* suppresses multiple beeps/dialogs
352 during multi-file replacements */
353 Bool replaceFailed; /* flags replacements failures during
354 multi-file replacements */
355 Bool replaceLastRegexCase; /* last state of the case sense button
356 in regex mode for replace dialog */
357 Bool replaceLastLiteralCase; /* idem, for literal mode */
358 Bool iSearchLastRegexCase; /* idem, for regex mode in
359 incremental search bar */
360 Bool iSearchLastLiteralCase; /* idem, for literal mode */
361 Bool findLastRegexCase; /* idem, for regex mode in find dialog */
362 Bool findLastLiteralCase; /* idem, for literal mode */
364 #ifdef REPLACE_SCOPE
365 int replaceScope; /* Current scope for replace dialog */
366 Widget replaceScopeWinToggle; /* Scope for replace = window */
367 Widget replaceScopeSelToggle; /* Scope for replace = selection */
368 Widget replaceScopeMultiToggle;/* Scope for replace = multiple files */
369 #endif
370 } WindowInfo;
372 extern WindowInfo *WindowList;
373 extern Display *TheDisplay;
374 extern char *ArgV0;
375 extern Boolean IsServer;