1 /* $Id: nedit.h,v 1.10 2001/04/03 22:59:38 edg Exp $ */
2 /*******************************************************************************
4 * nedit.h -- Nirvana Editor common include file *
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 */
14 #define AUTOSAVE_CHAR_LIMIT 30 /* number of characters user can type before
15 NEdit generates a new backup file */
17 #define AUTOSAVE_CHAR_LIMIT 80 /* set higher on VMS becaus saving is slower */
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 */
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 */
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 */
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) \
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) \
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 */
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
89 char restoresToSaved
; /* flag to indicate undoing this
90 operation will restore file to
91 last saved (unmodified) state */
94 /* Element in bookmark table */
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 */
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
;
126 Widget replaceAllBtn
;
128 Widget replaceInSelBtn
;
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
;
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... */
156 Widget langModeCascade
;
158 Widget autoIndentOffItem
;
159 Widget autoIndentItem
;
160 Widget smartIndentItem
;
162 Widget newlineWrapItem
;
163 Widget continuousWrapItem
;
164 Widget statsLineItem
;
165 Widget iSearchLineItem
;
167 Widget showMatchingItem
;
168 Widget overtypeModeItem
;
169 Widget highlightItem
;
170 Widget windowMenuPane
;
171 Widget shellMenuPane
;
172 Widget macroMenuPane
;
174 Widget prevOpenMenuPane
;
175 Widget prevOpenMenuItem
;
176 Widget unloadTagsMenuPane
;
177 Widget unloadTagsMenuItem
;
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
;
210 Widget replScopeWinDefItem
;
211 Widget replScopeSelDefItem
;
212 Widget replScopeSmartDefItem
;
214 Widget size24x80DefItem
;
215 Widget size40x80DefItem
;
216 Widget size60x80DefItem
;
217 Widget size80x80DefItem
;
218 Widget sizeCustomDefItem
;
219 Widget cancelShellItem
;
221 Widget finishLearnItem
;
222 Widget cancelMacroItem
;
225 Widget splitWindowItem
;
226 Widget closePaneItem
;
227 Widget bgMenuUndoItem
;
228 Widget bgMenuRedoItem
;
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
;
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 */
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 */
328 extern WindowInfo
*WindowList
;
329 extern Display
*TheDisplay
;