1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifdef HAVE_CONFIG_H
30 #include "../config.h"
31 #endif
32
33 #include "menu.h"
34 #include "textBuf.h"
35 #include "text.h"
36 #include "nedit.h"
37 #include "file.h"
38 #include "window.h"
39 #include "search.h"
40 #include "selection.h"
41 #include "undo.h"
42 #include "shift.h"
43 #include "help.h"
44 #include "preferences.h"
45 #include "tags.h"
46 #include "userCmds.h"
47 #include "shell.h"
48 #include "macro.h"
49 #include "filter.h"
50 #include "highlight.h"
51 #include "highlightData.h"
52 #include "interpret.h"
53 #include "smartIndent.h"
54 #include "windowTitle.h"
55 #include "../util/getfiles.h"
56 #include "../util/DialogF.h"
57 #include "../util/misc.h"
58 #include "../util/fileUtils.h"
59 #include "../util/utils.h"
60 #include "../Xlt/BubbleButton.h"
61 #include "../util/nedit_malloc.h"
62 #include "../util/pathutils.h"
63
64 #include <ctype.h>
65 #include <errno.h>
66 #include <stdio.h>
67 #include <stdlib.h>
68 #include <string.h>
69 #include <unistd.h>
70 #include <sys/stat.h>
71 #include <sys/types.h>
72
73 #ifndef __MVS__
74 #include <sys/param.h>
75 #endif
76
77 #include <X11/X.h>
78 #include <Xm/Xm.h>
79 #include <Xm/CascadeB.h>
80 #include <Xm/PushB.h>
81 #include <Xm/ToggleB.h>
82 #include <Xm/Separator.h>
83 #include <Xm/RowColumn.h>
84 #include <Xm/MenuShell.h>
85
86 #ifdef HAVE_DEBUG_H
87 #include "../debug.h"
88 #endif
89
90 #if XmVersion >=
1002
91 #define MENU_WIDGET(w) (XmGetPostedFromWidget(XtParent(w)))
92 #else
93 #define MENU_WIDGET(w) (w)
94 #endif
95
96
97 enum menuModes {
FULL,
SHORT};
98
99 typedef void (*menuCallbackProc)();
100
101 extern void _XmDismissTearOff(Widget, XtPointer, XtPointer);
102
103 static void doActionCB(Widget w, XtPointer clientData, XtPointer callData);
104 static void doTabActionCB(Widget w, XtPointer clientData, XtPointer callData);
105 static void pasteColCB(Widget w, XtPointer clientData, XtPointer callData);
106 static void shiftLeftCB(Widget w, XtPointer clientData, XtPointer callData);
107 static void shiftRightCB(Widget w, XtPointer clientData, XtPointer callData);
108 static void findCB(Widget w, XtPointer clientData, XtPointer callData);
109 static void findSameCB(Widget w, XtPointer clientData, XtPointer callData);
110 static void findSelCB(Widget w, XtPointer clientData, XtPointer callData);
111 static void findIncrCB(Widget w, XtPointer clientData, XtPointer callData);
112 static void replaceCB(Widget w, XtPointer clientData, XtPointer callData);
113 static void replaceSameCB(Widget w, XtPointer clientData, XtPointer callData);
114 static void replaceFindSameCB(Widget w, XtPointer clientData, XtPointer callData);
115 static void markCB(Widget w, XtPointer clientData, XtPointer callData);
116 static void gotoMarkCB(Widget w, XtPointer clientData, XtPointer callData);
117 static void gotoMatchingCB(Widget w, XtPointer clientData, XtPointer callData);
118 static void autoIndentOffCB(Widget w, WindowInfo *window,
caddr_t callData);
119 static void autoIndentCB(Widget w, WindowInfo *window,
caddr_t callData);
120 static void smartIndentCB(Widget w, WindowInfo *window,
caddr_t callData);
121 static void preserveCB(Widget w, WindowInfo *window,
caddr_t callData);
122 static void autoSaveCB(Widget w, WindowInfo *window,
caddr_t callData);
123 static void newlineWrapCB(Widget w, WindowInfo *window,
caddr_t callData);
124 static void noWrapCB(Widget w, WindowInfo *window,
caddr_t callData);
125 static void continuousWrapCB(Widget w, WindowInfo *window,
caddr_t callData);
126 static void wrapMarginCB(Widget w, WindowInfo *window,
caddr_t callData);
127 static void fontCB(Widget w, WindowInfo *window,
caddr_t callData);
128 static void resetZoomCB(Widget w, XtPointer clientData, XtPointer callData);
129 static void tabsCB(Widget w, WindowInfo *window,
caddr_t callData);
130 static void highlightCursorLineCB(Widget w, WindowInfo *window,
caddr_t callData);
131 static void indentRainbowCB(Widget w, WindowInfo *window,
caddr_t callData);
132 static void ansiColorsCB(Widget w, WindowInfo *window,
caddr_t callData);
133 static void backlightCharsCB(Widget w, WindowInfo *window,
caddr_t callData);
134 static void showMatchingOffCB(Widget w, WindowInfo *window,
caddr_t callData);
135 static void showMatchingDelimitCB(Widget w, WindowInfo *window,
caddr_t callData);
136 static void showMatchingRangeCB(Widget w, WindowInfo *window,
caddr_t callData);
137 static void matchSyntaxBasedCB(Widget w, WindowInfo *window,
caddr_t callData);
138 static void statsCB(Widget w, WindowInfo *window,
caddr_t callData);
139 static void autoIndentOffDefCB(Widget w, WindowInfo *window,
caddr_t callData);
140 static void autoIndentDefCB(Widget w, WindowInfo *window,
caddr_t callData);
141 static void smartIndentDefCB(Widget w, WindowInfo *window,
caddr_t callData);
142 static void autoSaveDefCB(Widget w, WindowInfo *window,
caddr_t callData);
143 static void preserveDefCB(Widget w, WindowInfo *window,
caddr_t callData);
144 static void noWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData);
145 static void newlineWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData);
146 static void contWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData);
147 static void wrapMarginDefCB(Widget w, WindowInfo *window,
caddr_t callData);
148 static void shellSelDefCB(Widget widget, WindowInfo* window,
caddr_t callData);
149 static void openInTabDefCB(Widget w, WindowInfo *window,
caddr_t callData);
150 static void tabBarDefCB(Widget w, WindowInfo *window,
caddr_t callData);
151 static void tabBarHideDefCB(Widget w, WindowInfo *window,
caddr_t callData);
152 static void tabSortDefCB(Widget w, WindowInfo *window,
caddr_t callData);
153 static void toolTipsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
154 static void tabNavigateDefCB(Widget w, WindowInfo *window,
caddr_t callData);
155 static void statsLineDefCB(Widget w, WindowInfo *window,
caddr_t callData);
156 static void iSearchLineDefCB(Widget w, WindowInfo *window,
caddr_t callData);
157 static void lineNumsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
158 static void pathInWindowsMenuDefCB(Widget w, WindowInfo *window,
caddr_t callData);
159 static void customizeTitleDefCB(Widget w, WindowInfo *window,
caddr_t callData);
160 static void tabsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
161 static void showMatchingOffDefCB(Widget w, WindowInfo *window,
caddr_t callData);
162 static void showMatchingDelimitDefCB(Widget w, WindowInfo *window,
caddr_t callData);
163 static void showMatchingRangeDefCB(Widget w, WindowInfo *window,
caddr_t callData);
164 static void matchSyntaxBasedDefCB(Widget w, WindowInfo *window,
caddr_t callData);
165 static void highlightOffDefCB(Widget w, WindowInfo *window,
caddr_t callData);
166 static void highlightDefCB(Widget w, WindowInfo *window,
caddr_t callData);
167 static void backlightCharsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
168 static void highlightCursorLineDefCB(Widget w, WindowInfo *window,
caddr_t callData);
169 static void indentRainbowDefCB(Widget w, WindowInfo *window,
caddr_t callData);
170 static void ansiColorsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
171 static void fontDefCB(Widget w, WindowInfo *window,
caddr_t callData);
172 static void colorDefCB(Widget w, WindowInfo *window,
caddr_t callData);
173 static void smartTagsDefCB(Widget parent, XtPointer client_data, XtPointer call_data);
174 static void showAllTagsDefCB(Widget parent, XtPointer client_data, XtPointer call_data);
175 static void languageDefCB(Widget w, WindowInfo *window,
caddr_t callData);
176 static void highlightingDefCB(Widget w, WindowInfo *window,
caddr_t callData);
177 static void smartMacrosDefCB(Widget w, WindowInfo *window,
caddr_t callData);
178 static void stylesDefCB(Widget w, WindowInfo *window,
caddr_t callData);
179 static void shellDefCB(Widget w, WindowInfo *window,
caddr_t callData);
180 static void macroDefCB(Widget w, WindowInfo *window,
caddr_t callData);
181 static void bgMenuDefCB(Widget w, WindowInfo *window,
caddr_t callData);
182 static void searchDlogsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
183 static void beepOnSearchWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData);
184 static void keepSearchDlogsDefCB(Widget w, WindowInfo *window,
185 caddr_t callData);
186 static void saveSearchHistoryDefCB(Widget w, WindowInfo *window,
caddr_t callData);
187 static void searchWrapsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
188 static void appendLFCB(Widget w, WindowInfo* window,
caddr_t callData);
189 static void sortOpenPrevDefCB(Widget w, WindowInfo *window,
caddr_t callData);
190 static void reposDlogsDefCB(Widget w, WindowInfo *window,
caddr_t callData);
191 static void autoScrollDefCB(Widget w, WindowInfo *window,
caddr_t callData);
192 static void editorConfigDefCB(Widget w, WindowInfo *window,
caddr_t callData);
193 static void lockEncodingErrorDefCB(Widget w, WindowInfo *window,
caddr_t callData);
194 static void filterDefCB(Widget w, WindowInfo *window,
caddr_t callData);
195 static void modWarnDefCB(Widget w, WindowInfo *window,
caddr_t callData);
196 static void modWarnRealDefCB(Widget w, WindowInfo *window,
caddr_t callData);
197 static void exitWarnDefCB(Widget w, WindowInfo *window,
caddr_t callData);
198 static void searchLiteralCB(Widget w, WindowInfo *window,
caddr_t callData);
199 static void searchCaseSenseCB(Widget w, WindowInfo *window,
caddr_t callData);
200 static void searchLiteralWordCB(Widget w, WindowInfo *window,
caddr_t callData);
201 static void searchCaseSenseWordCB(Widget w, WindowInfo *window,
caddr_t callData);
202 static void searchRegexNoCaseCB(Widget w, WindowInfo *window,
caddr_t callData);
203 static void searchRegexCB(Widget w, WindowInfo *window,
caddr_t callData);
204 #ifdef REPLACE_SCOPE
205 static void replaceScopeWindowCB(Widget w, WindowInfo *window,
caddr_t callData);
206 static void replaceScopeSelectionCB(Widget w, WindowInfo *window,
caddr_t callData);
207 static void replaceScopeSmartCB(Widget w, WindowInfo *window,
caddr_t callData);
208 #endif
209 static void size24x80CB(Widget w, WindowInfo *window,
caddr_t callData);
210 static void size40x80CB(Widget w, WindowInfo *window,
caddr_t callData);
211 static void size60x80CB(Widget w, WindowInfo *window,
caddr_t callData);
212 static void size80x80CB(Widget w, WindowInfo *window,
caddr_t callData);
213 static void sizeCustomCB(Widget w, WindowInfo *window,
caddr_t callData);
214 static void savePrefCB(Widget w, WindowInfo *window,
caddr_t callData);
215 static void formFeedCB(Widget w, XtPointer clientData, XtPointer callData);
216 static void cancelShellCB(Widget w, WindowInfo *window, XtPointer callData);
217 static void learnCB(Widget w, WindowInfo *window,
caddr_t callData);
218 static void finishLearnCB(Widget w, WindowInfo *window,
caddr_t callData);
219 static void cancelLearnCB(Widget w, WindowInfo *window,
caddr_t callData);
220 static void replayCB(Widget w, WindowInfo *window,
caddr_t callData);
221 static void windowMenuCB(Widget w, WindowInfo *window,
caddr_t callData);
222 static void prevOpenMenuCB(Widget w, WindowInfo *window,
caddr_t callData);
223 static void unloadTagsFileMenuCB(Widget w, WindowInfo *window,
224 caddr_t callData);
225 static void unloadTipsFileMenuCB(Widget w, WindowInfo *window,
226 caddr_t callData);
227 static void newAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
228 static void newOppositeAP(Widget w, XEvent *event, String *args,
229 Cardinal *nArgs);
230 static void newTabAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
231 static void openDialogAP(Widget w, XEvent *event, String *args,
232 Cardinal *nArgs);
233 static void openAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
234 static void openSelectedAP(Widget w, XEvent *event, String *args,
235 Cardinal *nArgs);
236 static void closeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
237 static void saveAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
238 static void saveAsDialogAP(Widget w, XEvent *event, String *args,
239 Cardinal *nArgs);
240 static void saveAsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
241 static void revertDialogAP(Widget w, XEvent *event, String *args,
242 Cardinal *nArgs);
243 static void revertAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
244 static void includeDialogAP(Widget w, XEvent *event, String *args,
245 Cardinal *nArgs);
246 static void includeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
247 static void loadMacroDialogAP(Widget w, XEvent *event, String *args,
248 Cardinal *nArgs) ;
249 static void loadMacroAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
250 static void loadTagsDialogAP(Widget w, XEvent *event, String *args,
251 Cardinal *nArgs);
252 static void loadTagsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
253 static void unloadTagsAP(Widget w, XEvent *event, String *args,
254 Cardinal *nArgs);
255 static void loadTipsDialogAP(Widget w, XEvent *event, String *args,
256 Cardinal *nArgs);
257 static void loadTipsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
258 static void unloadTipsAP(Widget w, XEvent *event, String *args,
259 Cardinal *nArgs);
260 static void printAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
261 static void printSelAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
262 static void exitAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
263 static void undoAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
264 static void redoAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
265 static void clearAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
266 static void selAllAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
267 static void shiftLeftAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
268 static void shiftLeftTabAP(Widget w, XEvent *event, String *args,
269 Cardinal *nArgs);
270 static void shiftRightAP(Widget w, XEvent *event, String *args,
271 Cardinal *nArgs);
272 static void shiftRightTabAP(Widget w, XEvent *event, String *args,
273 Cardinal *nArgs);
274 static void findDialogAP(Widget w, XEvent *event, String *args,
275 Cardinal *nArgs);
276 static void findAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
277 static void findSameAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
278 static void findSelAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
279 static void findIncrAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
280 static void startIncrFindAP(Widget w, XEvent *event, String *args,
281 Cardinal *nArgs);
282 static void replaceDialogAP(Widget w, XEvent *event, String *args,
283 Cardinal *nArgs);
284 static void replaceAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
285 static void replaceAllAP(Widget w, XEvent *event, String *args,
286 Cardinal *nArgs);
287 static void replaceInSelAP(Widget w, XEvent *event, String *args,
288 Cardinal *nArgs);
289 static void replaceSameAP(Widget w, XEvent *event, String *args,
290 Cardinal *nArgs);
291 static void replaceFindAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
292 static void replaceFindSameAP(Widget w, XEvent *event, String *args,
293 Cardinal *nArgs);
294 static void gotoAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
295 static void gotoDialogAP(Widget w, XEvent *event, String *args,
296 Cardinal *nArgs);
297 static void gotoSelectedAP(Widget w, XEvent *event, String *args,
298 Cardinal *nArgs);
299 static void repeatDialogAP(Widget w, XEvent *event, String *args,
300 Cardinal *nArgs);
301 static void repeatMacroAP(Widget w, XEvent *event, String *args,
302 Cardinal *nArgs);
303 static void markAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
304 static void markDialogAP(Widget w, XEvent *event, String *args,
305 Cardinal *nArgs);
306 static void gotoMarkAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
307 static void gotoMarkDialogAP(Widget w, XEvent *event, String *args,
308 Cardinal *nArgs);
309 static void selectToMatchingAP(Widget w, XEvent *event, String *args,
310 Cardinal *nArgs);
311 static void gotoMatchingAP(Widget w, XEvent *event, String *args,
312 Cardinal *nArgs);
313 static void findDefAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
314 static void showTipAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
315 static void splitPaneAP(Widget w, XEvent *event, String *args,
316 Cardinal *nArgs);
317 static void detachDocumentDialogAP(Widget w, XEvent *event, String *args,
318 Cardinal *nArgs);
319 static void detachDocumentAP(Widget w, XEvent *event, String *args,
320 Cardinal *nArgs);
321 static void moveDocumentDialogAP(Widget w, XEvent *event, String *args,
322 Cardinal *nArgs);
323 static void nextDocumentAP(Widget w, XEvent *event, String *args,
324 Cardinal *nArgs);
325 static void prevDocumentAP(Widget w, XEvent *event, String *args,
326 Cardinal *nArgs);
327 static void lastDocumentAP(Widget w, XEvent *event, String *args,
328 Cardinal *nArgs);
329 static void closePaneAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
330 static void capitalizeAP(Widget w, XEvent *event, String *args,
331 Cardinal *nArgs);
332 static void lowercaseAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
333 static void fillAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
334 static void unicodeDialogAP(Widget w, XEvent *event, String *args,
335 Cardinal *nArgs);
336
337 static void filterDialogAP(Widget w, XEvent *event, String *args,
338 Cardinal *nArgs);
339 static void shellFilterAP(Widget w, XEvent *event, String *args,
340 Cardinal *nArgs);
341 static void execDialogAP(Widget w, XEvent *event, String *args,
342 Cardinal *nArgs);
343 static void execAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
344 static void execLineAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
345 static void shellMenuAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
346
347 static void macroMenuAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
348 static void bgMenuAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
349 static void beginningOfSelectionAP(Widget w, XEvent *event, String *args,
350 Cardinal *nArgs);
351 static void endOfSelectionAP(Widget w, XEvent *event, String *args,
352 Cardinal *nArgs);
353 static Widget createMenu(Widget parent,
char *name,
char *label,
354 char mnemonic, Widget *cascadeBtn,
int mode);
355 static Widget createMenuItem(Widget parent,
char *name,
char *label,
356 char mnemonic, menuCallbackProc callback,
void *cbArg,
int mode);
357 static Widget createFakeMenuItem(Widget parent,
char *name,
358 menuCallbackProc callback,
void *cbArg);
359 static Widget createMenuToggle(Widget parent,
char *name,
char *label,
360 char mnemonic, menuCallbackProc callback,
void *cbArg,
int set,
361 int mode);
362 static Widget createMenuRadioToggle(Widget parent,
char *name,
char *label,
363 char mnemonic, menuCallbackProc callback,
void *cbArg,
int set,
364 int mode);
365 static Widget createMenuSeparator(Widget parent,
char *name,
int mode);
366 static void invalidatePrevOpenMenus(
void);
367 static void updateWindowMenu(
const WindowInfo *window);
368 static void updatePrevOpenMenu(WindowInfo *window);
369 static void updateTagsFileMenu(WindowInfo *window);
370 static void updateTipsFileMenu(WindowInfo *window);
371 static int searchDirection(
int ignoreArgs, String *args, Cardinal *nArgs);
372 static int searchWrap(
int ignoreArgs, String *args, Cardinal *nArgs);
373 static int searchKeepDialogs(
int ignoreArgs, String *args, Cardinal *nArgs);
374 static int searchType(
int ignoreArgs, String *args, Cardinal *nArgs);
375 static char **shiftKeyToDir(XtPointer callData);
376 static void raiseCB(Widget w, WindowInfo *window,
caddr_t callData);
377 static void openPrevCB(Widget w,
char *name,
caddr_t callData);
378 static void unloadTagsFileCB(Widget w,
char *name,
caddr_t callData);
379 static void unloadTipsFileCB(Widget w,
char *name,
caddr_t callData);
380 static int cmpStrPtr(
const void *strA,
const void *strB);
381 static void setWindowSizeDefault(
int rows,
int cols);
382 static void updateWindowSizeMenus(
void);
383 static void updateWindowSizeMenu(WindowInfo *win);
384 static int compareWindowNames(
const void *windowA,
const void *windowB);
385 static void bgMenuPostAP(Widget w, XEvent *event, String *args,
386 Cardinal *nArgs);
387 static void tabMenuPostAP(Widget w, XEvent *event, String *args,
388 Cardinal *nArgs);
389 static void raiseWindowAP(Widget w, XEvent *event, String *args,
390 Cardinal *nArgs);
391 static void focusPaneAP(Widget w, XEvent *event, String *args,
392 Cardinal *nArgs);
393 static void setStatisticsLineAP(Widget w, XEvent *event, String *args,
394 Cardinal *nArgs);
395 static void setIncrementalSearchLineAP(Widget w, XEvent *event, String *args,
396 Cardinal *nArgs);
397 static void setShowLineNumbersAP(Widget w, XEvent *event, String *args,
398 Cardinal *nArgs);
399 static void setAutoIndentAP(Widget w, XEvent *event, String *args,
400 Cardinal *nArgs);
401 static void setWrapTextAP(Widget w, XEvent *event, String *args,
402 Cardinal *nArgs);
403 static void setWrapMarginAP(Widget w, XEvent *event, String *args,
404 Cardinal *nArgs);
405 static void setHighlightSyntaxAP(Widget w, XEvent *event, String *args,
406 Cardinal *nArgs);
407 static void setMakeBackupCopyAP(Widget w, XEvent *event, String *args,
408 Cardinal *nArgs);
409 static void setIncrementalBackupAP(Widget w, XEvent *event, String *args,
410 Cardinal *nArgs);
411 static void setShowMatchingAP(Widget w, XEvent *event, String *args,
412 Cardinal *nArgs);
413 static void setMatchSyntaxBasedAP(Widget w, XEvent *event, String *args,
414 Cardinal *nArgs);
415 static void setOvertypeModeAP(Widget w, XEvent *event, String *args,
416 Cardinal *nArgs);
417 static void setLockedAP(Widget w, XEvent *event, String *args,
418 Cardinal *nArgs);
419 static void setUseTabsAP(Widget w, XEvent *event, String *args,
420 Cardinal *nArgs);
421 static void setEmTabDistAP(Widget w, XEvent *event, String *args,
422 Cardinal *nArgs);
423 static void setTabDistAP(Widget w, XEvent *event, String *args,
424 Cardinal *nArgs);
425 static void setFontsAP(Widget w, XEvent *event, String *args,
426 Cardinal *nArgs);
427 static void setLanguageModeAP(Widget w, XEvent *event, String *args,
428 Cardinal *nArgs);
429 #ifdef SGI_CUSTOM
430 static void shortMenusCB(Widget w, WindowInfo *window,
caddr_t callData);
431 static void addToToggleShortList(Widget w);
432 static int shortPrefAskDefault(Widget parent, Widget w,
const char *settingName);
433 #endif
434
435 static HelpMenu * buildHelpMenu( Widget pane, HelpMenu * menu,
436 WindowInfo * window);
437
438
439 static XtActionsRec Actions[] = {
440 {
"new", newAP},
441 {
"new_opposite", newOppositeAP},
442 {
"new_tab", newTabAP},
443 {
"open", openAP},
444 {
"open-dialog", openDialogAP},
445 {
"open_dialog", openDialogAP},
446 {
"open-selected", openSelectedAP},
447 {
"open_selected", openSelectedAP},
448 {
"close", closeAP},
449 {
"save", saveAP},
450 {
"save-as", saveAsAP},
451 {
"save_as", saveAsAP},
452 {
"save-as-dialog", saveAsDialogAP},
453 {
"save_as_dialog", saveAsDialogAP},
454 {
"revert-to-saved", revertAP},
455 {
"revert_to_saved", revertAP},
456 {
"revert_to_saved_dialog", revertDialogAP},
457 {
"include-file", includeAP},
458 {
"include_file", includeAP},
459 {
"include-file-dialog", includeDialogAP},
460 {
"include_file_dialog", includeDialogAP},
461 {
"load-macro-file", loadMacroAP},
462 {
"load_macro_file", loadMacroAP},
463 {
"load-macro-file-dialog", loadMacroDialogAP},
464 {
"load_macro_file_dialog", loadMacroDialogAP},
465 {
"load-tags-file", loadTagsAP},
466 {
"load_tags_file", loadTagsAP},
467 {
"load-tags-file-dialog", loadTagsDialogAP},
468 {
"load_tags_file_dialog", loadTagsDialogAP},
469 {
"unload_tags_file", unloadTagsAP},
470 {
"load_tips_file", loadTipsAP},
471 {
"load_tips_file_dialog", loadTipsDialogAP},
472 {
"unload_tips_file", unloadTipsAP},
473 {
"print", printAP},
474 {
"print-selection", printSelAP},
475 {
"print_selection", printSelAP},
476 {
"exit", exitAP},
477 {
"undo", undoAP},
478 {
"redo", redoAP},
479 {
"delete", clearAP},
480 {
"select-all", selAllAP},
481 {
"select_all", selAllAP},
482 {
"shift-left", shiftLeftAP},
483 {
"shift_left", shiftLeftAP},
484 {
"shift-left-by-tab", shiftLeftTabAP},
485 {
"shift_left_by_tab", shiftLeftTabAP},
486 {
"shift-right", shiftRightAP},
487 {
"shift_right", shiftRightAP},
488 {
"shift-right-by-tab", shiftRightTabAP},
489 {
"shift_right_by_tab", shiftRightTabAP},
490 {
"find", findAP},
491 {
"find-dialog", findDialogAP},
492 {
"find_dialog", findDialogAP},
493 {
"find-again", findSameAP},
494 {
"find_again", findSameAP},
495 {
"find-selection", findSelAP},
496 {
"find_selection", findSelAP},
497 {
"find_incremental", findIncrAP},
498 {
"start_incremental_find", startIncrFindAP},
499 {
"replace", replaceAP},
500 {
"replace-dialog", replaceDialogAP},
501 {
"replace_dialog", replaceDialogAP},
502 {
"replace-all", replaceAllAP},
503 {
"replace_all", replaceAllAP},
504 {
"replace-in-selection", replaceInSelAP},
505 {
"replace_in_selection", replaceInSelAP},
506 {
"replace-again", replaceSameAP},
507 {
"replace_again", replaceSameAP},
508 {
"replace_find", replaceFindAP},
509 {
"replace_find_same", replaceFindSameAP},
510 {
"replace_find_again", replaceFindSameAP},
511 {
"goto-line-number", gotoAP},
512 {
"goto_line_number", gotoAP},
513 {
"goto-line-number-dialog", gotoDialogAP},
514 {
"goto_line_number_dialog", gotoDialogAP},
515 {
"goto-selected", gotoSelectedAP},
516 {
"goto_selected", gotoSelectedAP},
517 {
"mark", markAP},
518 {
"mark-dialog", markDialogAP},
519 {
"mark_dialog", markDialogAP},
520 {
"goto-mark", gotoMarkAP},
521 {
"goto_mark", gotoMarkAP},
522 {
"goto-mark-dialog", gotoMarkDialogAP},
523 {
"goto_mark_dialog", gotoMarkDialogAP},
524 {
"match", selectToMatchingAP},
525 {
"select_to_matching", selectToMatchingAP},
526 {
"goto_matching", gotoMatchingAP},
527 {
"find-definition", findDefAP},
528 {
"find_definition", findDefAP},
529 {
"show_tip", showTipAP},
530 {
"split-pane", splitPaneAP},
531 {
"split_pane", splitPaneAP},
532 {
"close-pane", closePaneAP},
533 {
"close_pane", closePaneAP},
534 {
"detach_document", detachDocumentAP},
535 {
"detach_document_dialog", detachDocumentDialogAP},
536 {
"move_document_dialog", moveDocumentDialogAP},
537 {
"next_document", nextDocumentAP},
538 {
"previous_document", prevDocumentAP},
539 {
"last_document", lastDocumentAP},
540 {
"uppercase", capitalizeAP},
541 {
"lowercase", lowercaseAP},
542 {
"fill-paragraph", fillAP},
543 {
"fill_paragraph", fillAP},
544 {
"control-code-dialog", unicodeDialogAP},
545 {
"control_code_dialog", unicodeDialogAP},
546 {
"unicode_dialog", unicodeDialogAP},
547 {
"filter-selection-dialog", filterDialogAP},
548 {
"filter_selection_dialog", filterDialogAP},
549 {
"filter-selection", shellFilterAP},
550 {
"filter_selection", shellFilterAP},
551 {
"execute-command", execAP},
552 {
"execute_command", execAP},
553 {
"execute-command-dialog", execDialogAP},
554 {
"execute_command_dialog", execDialogAP},
555 {
"execute-command-line", execLineAP},
556 {
"execute_command_line", execLineAP},
557 {
"shell-menu-command", shellMenuAP},
558 {
"shell_menu_command", shellMenuAP},
559 {
"macro-menu-command", macroMenuAP},
560 {
"macro_menu_command", macroMenuAP},
561 {
"bg_menu_command", bgMenuAP},
562 {
"post_window_bg_menu", bgMenuPostAP},
563 {
"post_tab_context_menu", tabMenuPostAP},
564 {
"beginning-of-selection", beginningOfSelectionAP},
565 {
"beginning_of_selection", beginningOfSelectionAP},
566 {
"end-of-selection", endOfSelectionAP},
567 {
"end_of_selection", endOfSelectionAP},
568 {
"repeat_macro", repeatMacroAP},
569 {
"repeat_dialog", repeatDialogAP},
570 {
"raise_window", raiseWindowAP},
571 {
"focus_pane", focusPaneAP},
572 {
"set_statistics_line", setStatisticsLineAP},
573 {
"set_incremental_search_line", setIncrementalSearchLineAP},
574 {
"set_show_line_numbers", setShowLineNumbersAP},
575 {
"set_auto_indent", setAutoIndentAP},
576 {
"set_wrap_text", setWrapTextAP},
577 {
"set_wrap_margin", setWrapMarginAP},
578 {
"set_highlight_syntax", setHighlightSyntaxAP},
579 {
"set_make_backup_copy", setMakeBackupCopyAP},
580 {
"set_incremental_backup", setIncrementalBackupAP},
581 {
"set_show_matching", setShowMatchingAP},
582 {
"set_match_syntax_based", setMatchSyntaxBasedAP},
583 {
"set_overtype_mode", setOvertypeModeAP},
584 {
"set_locked", setLockedAP},
585 {
"set_tab_dist", setTabDistAP},
586 {
"set_em_tab_dist", setEmTabDistAP},
587 {
"set_use_tabs", setUseTabsAP},
588 {
"set_fonts", setFontsAP},
589 {
"set_language_mode", setLanguageModeAP}
590 };
591
592
593 static int NPrevOpen =
0;
594 static char** PrevOpen =
NULL;
595
596 #ifdef SGI_CUSTOM
597
598 static WindowInfo *ShortMenuWindow;
599 #endif
600
601 void HidePointerOnKeyedEvent(Widget w, XEvent *event)
602 {
603 if (event && (event->type == KeyPress || event->type == KeyRelease)) {
604 ShowHidePointer((TextWidget)w, True);
605 }
606 }
607
608
609
610
611
612 void InstallMenuActions(XtAppContext context)
613 {
614 XtAppAddActions(context, Actions, XtNumber(Actions));
615 }
616
617
618
619
620 XtActionsRec *GetMenuActions(
int *nActions)
621 {
622 *nActions = XtNumber(Actions);
623 return Actions;
624 }
625 Widget CreateMenuBar(Widget parent, WindowInfo *window)
626 {
627
628
629
630 Widget menuBar = XmCreateMenuBar(parent,
"menuBar",
NULL,
0);
631 return RecreateMenuBar(parent, menuBar, window, False);
632 }
633
634
635
636
637 Widget RecreateMenuBar(Widget parent, Widget menuBar, WindowInfo *window, Boolean clear)
638 {
639 Widget menuPane, btn, subPane, subSubPane, subSubSubPane, cascade;
640
641 if(clear) {
642 WidgetList children;
643 Cardinal numChildren;
644 XtVaGetValues(menuBar, XmNchildren, &children, XmNnumChildren, &numChildren,
NULL);
645 for(
int i=
0;i<numChildren;i++) {
646 XtUnmanageChild(children[i]);
647
648 }
649 }
650
651
652
653
654
655 window->userMenuCache = CreateUserMenuCache();
656
657 #ifdef SGI_CUSTOM
658
659
660
661
662
663
664
665
666
667
668
669 ShortMenuWindow = window;
670 window->nToggleShortItems =
0;
671 #endif
672
673
674
675
676 menuPane = createMenu(menuBar,
"fileMenu",
"File",
0,
NULL,
SHORT);
677 createMenuItem(menuPane,
"new",
"New",
'N', doActionCB,
"new",
SHORT);
678 if ( GetPrefOpenInTab() )
679 window->newOppositeItem = createMenuItem(menuPane,
"newOpposite",
680 "New Window",
'W', doActionCB,
"new_opposite",
SHORT);
681 else
682 window->newOppositeItem = createMenuItem(menuPane,
"newOpposite",
683 "New Tab",
'T', doActionCB,
"new_opposite",
SHORT);
684 createMenuItem(menuPane,
"open",
"Open...",
'O', doActionCB,
"open_dialog",
685 SHORT);
686 window->openSelItem=createMenuItem(menuPane,
"openSelected",
"Open Selected",
'd',
687 doActionCB,
"open_selected",
FULL);
688 if (GetPrefMaxPrevOpenFiles() >
0) {
689 window->prevOpenMenuPane = createMenu(menuPane,
"openPrevious",
690 "Open Previous",
'v', &window->prevOpenMenuItem,
SHORT);
691 XtSetSensitive(window->prevOpenMenuItem, NPrevOpen !=
0);
692 XtAddCallback(window->prevOpenMenuItem, XmNcascadingCallback,
693 (XtCallbackProc)prevOpenMenuCB, window);
694 }
695 createMenuSeparator(menuPane,
"sep1",
SHORT);
696 window->closeItem = createMenuItem(menuPane,
"close",
"Close",
'C',
697 doActionCB,
"close",
SHORT);
698 createMenuItem(menuPane,
"save",
"Save",
'S', doActionCB,
"save",
SHORT);
699 createMenuItem(menuPane,
"saveAs",
"Save As...",
'A', doActionCB,
700 "save_as_dialog",
SHORT);
701 createMenuItem(menuPane,
"revertToSaved",
"Revert to Saved",
'R',
702 doActionCB,
"revert_to_saved_dialog",
SHORT);
703 createMenuSeparator(menuPane,
"sep2",
SHORT);
704 createMenuItem(menuPane,
"includeFile",
"Include File...",
'I',
705 doActionCB,
"include_file_dialog",
SHORT);
706 createMenuItem(menuPane,
"loadMacroFile",
"Load Macro File...",
'M',
707 doActionCB,
"load_macro_file_dialog",
FULL);
708 createMenuItem(menuPane,
"loadTagsFile",
"Load Tags File...",
'g',
709 doActionCB,
"load_tags_file_dialog",
FULL);
710 window->unloadTagsMenuPane = createMenu(menuPane,
"unloadTagsFiles",
711 "Unload Tags File",
'U', &window->unloadTagsMenuItem,
FULL);
712 XtSetSensitive(window->unloadTagsMenuItem, TagsFileList !=
NULL);
713 XtAddCallback(window->unloadTagsMenuItem, XmNcascadingCallback,
714 (XtCallbackProc)unloadTagsFileMenuCB, window);
715 createMenuItem(menuPane,
"loadTipsFile",
"Load Calltips File...",
'F',
716 doActionCB,
"load_tips_file_dialog",
FULL);
717 window->unloadTipsMenuPane = createMenu(menuPane,
"unloadTipsFiles",
718 "Unload Calltips File",
'e', &window->unloadTipsMenuItem,
FULL);
719 XtSetSensitive(window->unloadTipsMenuItem, TipsFileList !=
NULL);
720 XtAddCallback(window->unloadTipsMenuItem, XmNcascadingCallback,
721 (XtCallbackProc)unloadTipsFileMenuCB, window);
722 createMenuSeparator(menuPane,
"sep3",
SHORT);
723 createMenuItem(menuPane,
"print",
"Print...",
'P', doActionCB,
"print",
724 SHORT);
725 window->printSelItem = createMenuItem(menuPane,
"printSelection",
726 "Print Selection...",
'l', doActionCB,
"print_selection",
727 SHORT);
728 XtSetSensitive(window->printSelItem, window->wasSelected);
729 createMenuSeparator(menuPane,
"sep4",
SHORT);
730 createMenuItem(menuPane,
"exit",
"Exit",
'x', doActionCB,
"exit",
SHORT);
731 CheckCloseDim();
732
733
734
735
736 menuPane = createMenu(menuBar,
"editMenu",
"Edit",
0,
NULL,
SHORT);
737 window->undoItem = createMenuItem(menuPane,
"undo",
"Undo",
'U',
738 doActionCB,
"undo",
SHORT);
739 XtSetSensitive(window->undoItem, False);
740 window->redoItem = createMenuItem(menuPane,
"redo",
"Redo",
'R',
741 doActionCB,
"redo",
SHORT);
742 XtSetSensitive(window->redoItem, False);
743 createMenuSeparator(menuPane,
"sep1",
SHORT);
744 window->cutItem = createMenuItem(menuPane,
"cut",
"Cut",
't', doActionCB,
745 "cut_clipboard",
SHORT);
746 XtSetSensitive(window->cutItem, window->wasSelected);
747 window->copyItem = createMenuItem(menuPane,
"copy",
"Copy",
'C', doActionCB,
748 "copy_clipboard",
SHORT);
749 XtSetSensitive(window->copyItem, window->wasSelected);
750 createMenuItem(menuPane,
"paste",
"Paste",
'P', doActionCB,
751 "paste_clipboard",
SHORT);
752 createMenuItem(menuPane,
"pasteColumn",
"Paste Column",
's', pasteColCB,
753 window,
SHORT);
754 window->delItem=createMenuItem(menuPane,
"delete",
"Delete",
'D', doActionCB,
"delete_selection",
755 SHORT);
756 XtSetSensitive(window->delItem, window->wasSelected);
757 createMenuItem(menuPane,
"selectAll",
"Select All",
'A', doActionCB,
758 "select_all",
SHORT);
759 createMenuSeparator(menuPane,
"sep2",
SHORT);
760 createMenuItem(menuPane,
"shiftLeft",
"Shift Left",
'L',
761 shiftLeftCB, window,
SHORT);
762 createFakeMenuItem(menuPane,
"shiftLeftShift", shiftLeftCB, window);
763 createMenuItem(menuPane,
"shiftRight",
"Shift Right",
'g',
764 shiftRightCB, window,
SHORT);
765 createFakeMenuItem(menuPane,
"shiftRightShift", shiftRightCB, window);
766 window->lowerItem=createMenuItem(menuPane,
"lowerCase",
"Lower-case",
'w',
767 doActionCB,
"lowercase",
SHORT);
768 window->upperItem=createMenuItem(menuPane,
"upperCase",
"Upper-case",
'e',
769 doActionCB,
"uppercase",
SHORT);
770 createMenuItem(menuPane,
"fillParagraph",
"Fill Paragraph",
'F',
771 doActionCB,
"fill_paragraph",
SHORT);
772 createMenuSeparator(menuPane,
"sep3",
FULL);
773 createMenuItem(menuPane,
"insertFormFeed",
"Insert Form Feed",
'I',
774 formFeedCB, window,
FULL);
775 createMenuItem(menuPane,
"insertUnicode",
"Insert Unicode...",
'U',
776 doActionCB,
"unicode_dialog",
FULL);
777 #ifdef SGI_CUSTOM
778 createMenuSeparator(menuPane,
"sep4",
SHORT);
779 window->overtypeModeItem = createMenuToggle(menuPane,
"overtype",
"Overtype",
'O',
780 doActionCB,
"set_overtype_mode", False,
SHORT);
781 window->readOnlyItem = createMenuToggle(menuPane,
"readOnly",
"Read Only",
782 'y', doActionCB,
"set_locked",
IS_USER_LOCKED(window->lockReasons),
FULL);
783 #endif
784
785
786
787
788 menuPane = createMenu(menuBar,
"searchMenu",
"Search",
0,
NULL,
SHORT);
789 createMenuItem(menuPane,
"find",
"Find...",
'F', findCB, window,
SHORT);
790 createFakeMenuItem(menuPane,
"findShift", findCB, window);
791 window->findAgainItem=createMenuItem(menuPane,
"findAgain",
"Find Again",
'i', findSameCB, window,
792 SHORT);
793 XtSetSensitive(window->findAgainItem, NHist);
794 createFakeMenuItem(menuPane,
"findAgainShift", findSameCB, window);
795 window->findSelItem=createMenuItem(menuPane,
"findSelection",
"Find Selection",
'S',
796 findSelCB, window,
SHORT);
797 createFakeMenuItem(menuPane,
"findSelectionShift", findSelCB, window);
798 createMenuItem(menuPane,
"findIncremental",
"Find Incremental",
'n',
799 findIncrCB, window,
SHORT);
800 createFakeMenuItem(menuPane,
"findIncrementalShift", findIncrCB, window);
801 createMenuItem(menuPane,
"replace",
"Replace...",
'R', replaceCB, window,
802 SHORT);
803 createFakeMenuItem(menuPane,
"replaceShift", replaceCB, window);
804 window->replaceFindAgainItem=createMenuItem(menuPane,
"replaceFindAgain",
"Replace Find Again",
'A',
805 replaceFindSameCB, window,
SHORT);
806 XtSetSensitive(window->replaceFindAgainItem, NHist);
807 createFakeMenuItem(menuPane,
"replaceFindAgainShift", replaceFindSameCB, window);
808 window->replaceAgainItem=createMenuItem(menuPane,
"replaceAgain",
"Replace Again",
'p',
809 replaceSameCB, window,
SHORT);
810 XtSetSensitive(window->replaceAgainItem, NHist);
811 createFakeMenuItem(menuPane,
"replaceAgainShift", replaceSameCB, window);
812 createMenuSeparator(menuPane,
"sep1",
FULL);
813 createMenuItem(menuPane,
"gotoLineNumber",
"Goto Line Number...",
'L',
814 doActionCB,
"goto_line_number_dialog",
FULL);
815 window->gotoSelItem=createMenuItem(menuPane,
"gotoSelected",
"Goto Selected",
'G',
816 doActionCB,
"goto_selected",
FULL);
817 createMenuSeparator(menuPane,
"sep2",
FULL);
818 createMenuItem(menuPane,
"mark",
"Mark",
'k', markCB, window,
FULL);
819 createMenuItem(menuPane,
"gotoMark",
"Goto Mark",
'o', gotoMarkCB, window,
820 FULL);
821 createFakeMenuItem(menuPane,
"gotoMarkShift", gotoMarkCB, window);
822 createMenuSeparator(menuPane,
"sep3",
FULL);
823 createMenuItem(menuPane,
"gotoMatching",
"Goto Matching (..)",
'M',
824 gotoMatchingCB, window,
FULL);
825 createFakeMenuItem(menuPane,
"gotoMatchingShift", gotoMatchingCB, window);
826 window->findDefItem = createMenuItem(menuPane,
"findDefinition",
827 "Find Definition",
'D', doActionCB,
"find_definition",
FULL);
828 XtSetSensitive(window->findDefItem, TagsFileList !=
NULL);
829 window->showTipItem = createMenuItem(menuPane,
"showCalltip",
830 "Show Calltip",
'C', doActionCB,
"show_tip",
FULL);
831 XtSetSensitive(window->showTipItem, (TagsFileList !=
NULL ||
832 TipsFileList !=
NULL) );
833
834
835
836
837 menuPane = createMenu(menuBar,
"preferencesMenu",
"Preferences",
0,
NULL,
838 SHORT);
839 subPane = createMenu(menuPane,
"defaultSettings",
"Default Settings",
'D',
840 NULL,
FULL);
841 createMenuItem(subPane,
"languageModes",
"Language Modes...",
'L',
842 languageDefCB, window,
FULL);
843
844
845 subSubPane = createMenu(subPane,
"autoIndent",
"Auto Indent",
'A',
846 NULL,
FULL);
847 window->autoIndentOffDefItem = createMenuRadioToggle(subSubPane,
"off",
848 "Off",
'O', autoIndentOffDefCB, window,
849 GetPrefAutoIndent(
PLAIN_LANGUAGE_MODE) ==
NO_AUTO_INDENT,
SHORT);
850 window->autoIndentDefItem = createMenuRadioToggle(subSubPane,
"on",
851 "On",
'n', autoIndentDefCB, window,
852 GetPrefAutoIndent(
PLAIN_LANGUAGE_MODE) ==
AUTO_INDENT,
SHORT);
853 window->smartIndentDefItem = createMenuRadioToggle(subSubPane,
"smart",
854 "Smart",
'S', smartIndentDefCB, window,
855 GetPrefAutoIndent(
PLAIN_LANGUAGE_MODE) ==
SMART_INDENT,
SHORT);
856 createMenuSeparator(subSubPane,
"sep1",
SHORT);
857 createMenuItem(subSubPane,
"ProgramSmartIndent",
"Program Smart Indent...",
858 'P', smartMacrosDefCB, window,
FULL);
859
860
861 subSubPane = createMenu(subPane,
"wrap",
"Wrap",
'W',
NULL,
FULL);
862 window->noWrapDefItem = createMenuRadioToggle(subSubPane,
863 "none",
"None",
'N', noWrapDefCB,
864 window, GetPrefWrap(
PLAIN_LANGUAGE_MODE) ==
NO_WRAP,
SHORT);
865 window->newlineWrapDefItem = createMenuRadioToggle(subSubPane,
866 "autoNewline",
"Auto Newline",
'A', newlineWrapDefCB,
867 window, GetPrefWrap(
PLAIN_LANGUAGE_MODE) ==
NEWLINE_WRAP,
SHORT);
868 window->contWrapDefItem = createMenuRadioToggle(subSubPane,
"continuous",
869 "Continuous",
'C', contWrapDefCB, window,
870 GetPrefWrap(
PLAIN_LANGUAGE_MODE) ==
CONTINUOUS_WRAP,
SHORT);
871 createMenuSeparator(subSubPane,
"sep1",
SHORT);
872 createMenuItem(subSubPane,
"wrapMargin",
"Wrap Margin...",
'W',
873 wrapMarginDefCB, window,
SHORT);
874
875
876 subSubPane = createMenu(subPane,
"smartTags",
"Tag Collisions",
'l',
877 NULL,
FULL);
878 window->allTagsDefItem = createMenuRadioToggle(subSubPane,
"showall",
879 "Show All",
'A', showAllTagsDefCB, window, !GetPrefSmartTags(),
880 FULL);
881 window->smartTagsDefItem = createMenuRadioToggle(subSubPane,
"smart",
882 "Smart",
'S', smartTagsDefCB, window, GetPrefSmartTags(),
FULL);
883
884 createMenuItem(subPane,
"shellSel",
"Command Shell...",
's', shellSelDefCB,
885 window,
SHORT);
886 createMenuItem(subPane,
"tabDistance",
"Tab Stops...",
'T', tabsDefCB, window,
887 SHORT);
888 createMenuItem(subPane,
"textFont",
"Text Fonts...",
'F', fontDefCB, window,
889 FULL);
890 createMenuItem(subPane,
"colors",
"Colors...",
'C', colorDefCB, window,
891 FULL);
892
893
894 subSubPane = createMenu(subPane,
"customizeMenus",
"Customize Menus",
895 'u',
NULL,
FULL);
896 createMenuItem(subSubPane,
"shellMenu",
"Shell Menu...",
'S',
897 shellDefCB, window,
FULL);
898 createMenuItem(subSubPane,
"macroMenu",
"Macro Menu...",
'M',
899 macroDefCB, window,
FULL);
900 createMenuItem(subSubPane,
"windowBackgroundMenu",
901 "Window Background Menu...",
'W', bgMenuDefCB, window,
FULL);
902 createMenuSeparator(subSubPane,
"sep1",
SHORT);
903 window->sortOpenPrevDefItem = createMenuToggle(subSubPane,
"sortOpenPrevMenu",
904 "Sort Open Prev. Menu",
'o', sortOpenPrevDefCB, window,
905 GetPrefSortOpenPrevMenu(),
FULL);
906 window->pathInWindowsMenuDefItem = createMenuToggle(subSubPane,
"pathInWindowsMenu",
907 "Show Path In Windows Menu",
'P', pathInWindowsMenuDefCB, window, GetPrefShowPathInWindowsMenu(),
908 SHORT);
909
910 createMenuItem(subPane,
"custimizeTitle",
"Customize Window Title...",
'd',
911 customizeTitleDefCB, window,
FULL);
912
913
914 subSubPane = createMenu(subPane,
"searching",
"Searching",
915 'g',
NULL,
FULL);
916 window->searchDlogsDefItem = createMenuToggle(subSubPane,
"verbose",
917 "Verbose",
'V', searchDlogsDefCB, window,
918 GetPrefSearchDlogs(),
SHORT);
919 window->searchWrapsDefItem = createMenuToggle(subSubPane,
"wrapAround",
920 "Wrap Around",
'W', searchWrapsDefCB, window,
921 GetPrefSearchWraps(),
SHORT);
922 window->beepOnSearchWrapDefItem = createMenuToggle(subSubPane,
923 "beepOnSearchWrap",
"Beep On Search Wrap",
'B',
924 beepOnSearchWrapDefCB, window, GetPrefBeepOnSearchWrap(),
SHORT);
925 window->keepSearchDlogsDefItem = createMenuToggle(subSubPane,
926 "keepDialogsUp",
"Keep Dialogs Up",
'K',
927 keepSearchDlogsDefCB, window, GetPrefKeepSearchDlogs(),
SHORT);
928 window->saveSearchHistoryDefItem = createMenuToggle(subSubPane,
929 "saveSearchHistory",
"Save History",
'S',
930 saveSearchHistoryDefCB, window, GetPrefSaveSearchHistory(),
SHORT);
931 subSubSubPane = createMenu(subSubPane,
"defaultSearchStyle",
932 "Default Search Style",
'D',
NULL,
FULL);
933 XtVaSetValues(subSubSubPane, XmNradioBehavior, True,
NULL);
934 window->searchLiteralDefItem = createMenuToggle(subSubSubPane,
"literal",
935 "Literal",
'L', searchLiteralCB, window,
936 GetPrefSearch() ==
SEARCH_LITERAL,
FULL);
937 window->searchCaseSenseDefItem = createMenuToggle(subSubSubPane,
938 "caseSensitive",
"Literal, Case Sensitive",
'C', searchCaseSenseCB, window,
939 GetPrefSearch() ==
SEARCH_CASE_SENSE,
FULL);
940 window->searchLiteralWordDefItem = createMenuToggle(subSubSubPane,
"literalWord",
941 "Literal, Whole Word",
'W', searchLiteralWordCB, window,
942 GetPrefSearch() ==
SEARCH_LITERAL_WORD,
FULL);
943 window->searchCaseSenseWordDefItem = createMenuToggle(subSubSubPane,
944 "caseSensitiveWord",
"Literal, Case Sensitive, Whole Word",
't', searchCaseSenseWordCB, window,
945 GetPrefSearch() ==
SEARCH_CASE_SENSE_WORD,
FULL);
946 window->searchRegexDefItem = createMenuToggle(subSubSubPane,
947 "regularExpression",
"Regular Expression",
'R', searchRegexCB,
948 window, GetPrefSearch() ==
SEARCH_REGEX,
FULL);
949 window->searchRegexNoCaseDefItem = createMenuToggle(subSubSubPane,
950 "regularExpressionNoCase",
"Regular Expression, Case Insensitive",
'I', searchRegexNoCaseCB, window,
951 GetPrefSearch() ==
SEARCH_REGEX_NOCASE,
FULL);
952 #ifdef REPLACE_SCOPE
953 subSubSubPane = createMenu(subSubPane,
"defaultReplaceScope",
954 "Default Replace Scope",
'R',
NULL,
FULL);
955 XtVaSetValues(subSubSubPane, XmNradioBehavior, True,
NULL);
956 window->replScopeWinDefItem = createMenuToggle(subSubSubPane,
"window",
957 "In Window",
'W', replaceScopeWindowCB, window,
958 GetPrefReplaceDefScope() ==
REPL_DEF_SCOPE_WINDOW,
FULL);
959 window->replScopeSelDefItem = createMenuToggle(subSubSubPane,
"selection",
960 "In Selection",
'S', replaceScopeSelectionCB, window,
961 GetPrefReplaceDefScope() ==
REPL_DEF_SCOPE_SELECTION,
FULL);
962 window->replScopeSmartDefItem = createMenuToggle(subSubSubPane,
"window",
963 "Smart",
'm', replaceScopeSmartCB, window,
964 GetPrefReplaceDefScope() ==
REPL_DEF_SCOPE_SMART,
FULL);
965 #endif
966
967
968 subSubPane = createMenu(subPane,
"syntaxHighlighting",
"Syntax Highlighting",
969 'H',
NULL,
FULL);
970 window->highlightOffDefItem = createMenuRadioToggle(subSubPane,
"off",
"Off",
971 'O', highlightOffDefCB, window, !GetPrefHighlightSyntax(),
FULL);
972 window->highlightDefItem = createMenuRadioToggle(subSubPane,
"on",
973 "On",
'n', highlightDefCB, window, GetPrefHighlightSyntax(),
FULL);
974 createMenuSeparator(subSubPane,
"sep1",
SHORT);
975 createMenuItem(subSubPane,
"recognitionPatterns",
"Recognition Patterns...",
976 'R', highlightingDefCB, window,
FULL);
977 createMenuItem(subSubPane,
"textDrawingStyles",
"Text Drawing Styles...",
'T',
978 stylesDefCB, window,
FULL);
979 window->backlightCharsDefItem = createMenuToggle(subPane,
980 "backlightChars",
"Apply Backlighting",
'g', backlightCharsDefCB,
981 window, GetPrefBacklightChars(),
FULL);
982
983
984 window->highlightCursorLineDefItem = createMenuToggle(subPane,
985 "highlightCursorLine",
"Highlight Cursor Line",
'e', highlightCursorLineDefCB,
986 window, GetPrefHighlightCursorLine(),
FULL);
987 window->indentRainbowDefItem = createMenuToggle(subPane,
988 "indentRainbow",
"Indent Rainbow",
'R', indentRainbowDefCB,
989 window, GetPrefIndentRainbow(),
FULL);
990 window->ansiColorsDefItem = createMenuToggle(subPane,
991 "ansiColors",
"ANSI Colors",
'I', ansiColorsDefCB,
992 window, GetPrefAnsiColors(),
FULL);
993
994
995 subSubPane = createMenu(subPane,
"tabbedEditMenu",
"Tabbed Editing",
0,
996 &cascade,
SHORT);
997 window->openInTabDefItem = createMenuToggle(subSubPane,
"openAsTab",
998 "Open File In New Tab",
'T', openInTabDefCB, window,
999 GetPrefOpenInTab(),
FULL);
1000 window->tabBarDefItem = createMenuToggle(subSubPane,
"showTabBar",
1001 "Show Tab Bar",
'B', tabBarDefCB, window,
1002 GetPrefTabBar(),
FULL);
1003 window->tabBarHideDefItem = createMenuToggle(subSubPane,
1004 "hideTabBar",
"Hide Tab Bar When Only One Document is Open",
'H',
1005 tabBarHideDefCB, window, GetPrefTabBarHideOne(),
FULL);
1006 window->tabNavigateDefItem = createMenuToggle(subSubPane,
"tabNavigateDef",
1007 "Next/Prev Tabs Across Windows",
'W', tabNavigateDefCB, window,
1008 GetPrefGlobalTabNavigate(),
FULL);
1009 window->tabSortDefItem = createMenuToggle(subSubPane,
"tabSortDef",
1010 "Sort Tabs Alphabetically",
'S', tabSortDefCB, window,
1011 GetPrefSortTabs(),
FULL);
1012
1013 window->toolTipsDefItem = createMenuToggle(subPane,
"showTooltips",
1014 "Show Tooltips",
0, toolTipsDefCB, window, GetPrefToolTips(),
1015 FULL);
1016 window->statsLineDefItem = createMenuToggle(subPane,
"statisticsLine",
1017 "Statistics Line",
'S', statsLineDefCB, window, GetPrefStatsLine(),
1018 SHORT);
1019 window->iSearchLineDefItem = createMenuToggle(subPane,
1020 "incrementalSearchLine",
"Incremental Search Line",
'i',
1021 iSearchLineDefCB, window, GetPrefISearchLine(),
FULL);
1022 window->lineNumsDefItem = createMenuToggle(subPane,
"showLineNumbers",
1023 "Show Line Numbers",
'N', lineNumsDefCB, window, GetPrefLineNums(),
1024 SHORT);
1025 window->saveLastDefItem = createMenuToggle(subPane,
"preserveLastVersion",
1026 "Make Backup Copy (*.bck)",
'e', preserveDefCB, window,
1027 GetPrefSaveOldVersion(),
SHORT);
1028 window->autoSaveDefItem = createMenuToggle(subPane,
"incrementalBackup",
1029 "Incremental Backup",
'B', autoSaveDefCB, window, GetPrefAutoSave(),
1030 SHORT);
1031
1032
1033
1034 subSubPane = createMenu(subPane,
"showMatching",
"Show Matching (..)",
'M',
1035 NULL,
FULL);
1036 window->showMatchingOffDefItem = createMenuRadioToggle(subSubPane,
"off",
1037 "Off",
'O', showMatchingOffDefCB, window,
1038 GetPrefShowMatching() ==
NO_FLASH,
SHORT);
1039 window->showMatchingDelimitDefItem = createMenuRadioToggle(subSubPane,
1040 "delimiter",
"Delimiter",
'D', showMatchingDelimitDefCB, window,
1041 GetPrefShowMatching() ==
FLASH_DELIMIT,
SHORT);
1042 window->showMatchingRangeDefItem = createMenuRadioToggle(subSubPane,
1043 "range",
"Range",
'R', showMatchingRangeDefCB, window,
1044 GetPrefShowMatching() ==
FLASH_RANGE,
SHORT);
1045 createMenuSeparator(subSubPane,
"sep",
SHORT);
1046 window->matchSyntaxBasedDefItem = createMenuToggle(subSubPane,
1047 "matchSyntax",
"Syntax Based",
'S', matchSyntaxBasedDefCB, window,
1048 GetPrefMatchSyntaxBased(),
SHORT);
1049
1050
1051 window->appendLFItem = createMenuToggle(subPane,
"appendLFItem",
1052 "Terminate with Line Break on Save",
'v', appendLFCB,
NULL,
1053 GetPrefAppendLF(),
FULL);
1054
1055 window->reposDlogsDefItem = createMenuToggle(subPane,
"popupsUnderPointer",
1056 "Popups Under Pointer",
'P', reposDlogsDefCB, window,
1057 GetPrefRepositionDialogs(),
FULL);
1058 window->autoScrollDefItem = createMenuToggle(subPane,
"autoScroll",
1059 "Auto Scroll Near Window Top/Bottom",
0, autoScrollDefCB, window,
1060 GetPrefAutoScroll(),
FULL);
1061 window->editorConfigDefItem = createMenuToggle(subPane,
"editorConfig",
1062 "Load Settings from .editorconfig",
0, editorConfigDefCB, window,
1063 GetPrefEditorConfig(),
FULL);
1064 window->lockEncodingErrorDefItem = createMenuToggle(subPane,
"lockEncodingError",
1065 "Lock File On Encoding Error",
0, lockEncodingErrorDefCB, window,
1066 GetPrefLockEncodingError(),
FULL);
1067 createMenuItem(subPane,
"filters",
"Filters...",
'F', filterDefCB, window,
1068 FULL);
1069 subSubPane = createMenu(subPane,
"warnings",
"Warnings",
'r',
NULL,
FULL);
1070 window->modWarnDefItem = createMenuToggle(subSubPane,
1071 "filesModifiedExternally",
"Files Modified Externally",
'F',
1072 modWarnDefCB, window, GetPrefWarnFileMods(),
FULL);
1073 window->modWarnRealDefItem = createMenuToggle(subSubPane,
1074 "checkModifiedFileContents",
"Check Modified File Contents",
'C',
1075 modWarnRealDefCB, window, GetPrefWarnRealFileMods(),
FULL);
1076 XtSetSensitive(window->modWarnRealDefItem, GetPrefWarnFileMods());
1077 window->exitWarnDefItem = createMenuToggle(subSubPane,
"onExit",
"On Exit",
'O',
1078 exitWarnDefCB, window, GetPrefWarnExit(),
FULL);
1079
1080 subSubPane = createMenu(subPane,
"initialwindowSize",
1081 "Initial Window Size",
'z',
NULL,
FULL);
1082
1083 window->size24x80DefItem = btn = createMenuToggle(subSubPane,
"24X80",
1084 "24 x 80",
'2', size24x80CB, window, False,
SHORT);
1085 XtVaSetValues(btn, XmNindicatorType, XmONE_OF_MANY,
NULL);
1086 window->size40x80DefItem = btn = createMenuToggle(subSubPane,
"40X80",
1087 "40 x 80",
'4', size40x80CB, window, False,
SHORT);
1088 XtVaSetValues(btn, XmNindicatorType, XmONE_OF_MANY,
NULL);
1089 window->size60x80DefItem = btn = createMenuToggle(subSubPane,
"60X80",
1090 "60 x 80",
'6', size60x80CB, window, False,
SHORT);
1091 XtVaSetValues(btn, XmNindicatorType, XmONE_OF_MANY,
NULL);
1092 window->size80x80DefItem = btn = createMenuToggle(subSubPane,
"80X80",
1093 "80 x 80",
'8', size80x80CB, window, False,
SHORT);
1094 XtVaSetValues(btn, XmNindicatorType, XmONE_OF_MANY,
NULL);
1095 window->sizeCustomDefItem = btn = createMenuToggle(subSubPane,
"custom",
1096 "Custom...",
'C', sizeCustomCB, window, False,
SHORT);
1097 XtVaSetValues(btn, XmNindicatorType, XmONE_OF_MANY,
NULL);
1098 updateWindowSizeMenu(window);
1099
1100
1101
1102
1103 createMenuItem(menuPane,
"saveDefaults",
"Save Defaults...",
'v',
1104 savePrefCB, window,
FULL);
1105 #ifdef SGI_CUSTOM
1106 window->shortMenusDefItem = createMenuToggle(menuPane,
1107 "shortMenus",
"Short Menus",
'h', shortMenusCB, window,
1108 GetPrefShortMenus(),
SHORT);
1109 #endif
1110 createMenuSeparator(menuPane,
"sep1",
SHORT);
1111 window->statsLineItem = createMenuToggle(menuPane,
"statisticsLine",
"Statistics Line",
'S',
1112 statsCB, window, GetPrefStatsLine(),
SHORT);
1113 window->iSearchLineItem = createMenuToggle(menuPane,
"incrementalSearchLine",
"Incremental Search Line",
1114 'I', doActionCB,
"set_incremental_search_line", GetPrefISearchLine(),
FULL);
1115 window->lineNumsItem = createMenuToggle(menuPane,
"lineNumbers",
"Show Line Numbers",
'N',
1116 doActionCB,
"set_show_line_numbers", GetPrefLineNums(),
SHORT);
1117 #ifndef DISABLE_COLORPROFILES
1118 CreateColorProfilesSubMenu(window, menuPane,
"colorProfile",
"Color Profile",
'C');
1119 #endif
1120 CreateLanguageModeSubMenu(window, menuPane,
"languageMode",
1121 "Language Mode",
'L');
1122 subPane = createMenu(menuPane,
"autoIndent",
"Auto Indent",
1123 'A',
NULL,
FULL);
1124 window->autoIndentOffItem = createMenuRadioToggle(subPane,
"off",
"Off",
1125 'O', autoIndentOffCB, window, window->indentStyle ==
NO_AUTO_INDENT,
1126 SHORT);
1127 window->autoIndentItem = createMenuRadioToggle(subPane,
"on",
"On",
'n',
1128 autoIndentCB, window, window->indentStyle ==
AUTO_INDENT,
SHORT);
1129 window->smartIndentItem = createMenuRadioToggle(subPane,
"smart",
"Smart",
1130 'S', smartIndentCB, window, window->indentStyle ==
SMART_INDENT,
1131 SHORT);
1132 subPane = createMenu(menuPane,
"wrap",
"Wrap",
1133 'W',
NULL,
FULL);
1134 window->noWrapItem = createMenuRadioToggle(subPane,
"none",
1135 "None",
'N', noWrapCB, window,
1136 window->wrapMode==
NO_WRAP,
SHORT);
1137 window->newlineWrapItem = createMenuRadioToggle(subPane,
"autoNewlineWrap",
1138 "Auto Newline",
'A', newlineWrapCB, window,
1139 window->wrapMode==
NEWLINE_WRAP,
SHORT);
1140 window->continuousWrapItem = createMenuRadioToggle(subPane,
1141 "continuousWrap",
"Continuous",
'C', continuousWrapCB, window,
1142 window->wrapMode==
CONTINUOUS_WRAP,
SHORT);
1143 createMenuSeparator(subPane,
"sep1",
SHORT);
1144 createMenuItem(subPane,
"wrapMargin",
"Wrap Margin...",
'W',
1145 wrapMarginCB, window,
SHORT);
1146 createMenuItem(menuPane,
"tabs",
"Tab Stops...",
'T', tabsCB, window,
SHORT);
1147 createMenuItem(menuPane,
"textFont",
"Text Fonts...",
'F', fontCB, window,
1148 FULL);
1149
1150 window->resetZoomItem = createMenuItem(menuPane,
"resetZoom",
"Reset Zoom",
'Z', resetZoomCB,
NULL,
1151 SHORT);
1152 XtSetSensitive(window->resetZoomItem, window->zoom ==
0 ? False : True);
1153
1154 window->highlightItem = createMenuToggle(menuPane,
"highlightSyntax",
1155 "Highlight Syntax",
'H', doActionCB,
"set_highlight_syntax",
1156 GetPrefHighlightSyntax(),
SHORT);
1157 window->backlightCharsItem = createMenuToggle(menuPane,
"backlightChars",
1158 "Apply Backlighting",
'g', backlightCharsCB, window,
1159 window->backlightChars,
FULL);
1160 window->highlightCursorLineItem = createMenuToggle(menuPane,
"highlightCursorLine",
1161 "Highlight Cursor Line",
'C', highlightCursorLineCB, window,
1162 window->highlightCursorLine,
FULL);
1163 window->indentRainbowItem = createMenuToggle(menuPane,
"indentRainbow",
1164 "Indent Rainbow",
'R', indentRainbowCB, window,
1165 window->indentRainbow,
FULL);
1166 window->ansiColorsItem = createMenuToggle(menuPane,
"ansiColors",
1167 "ANSI Colors",
'S', ansiColorsCB, window,
1168 window->ansiColors,
FULL);
1169
1170 window->saveLastItem = createMenuToggle(menuPane,
"makeBackupCopy",
1171 "Make Backup Copy (*.bck)",
'e', preserveCB, window,
1172 window->saveOldVersion,
SHORT);
1173
1174 window->autoSaveItem = createMenuToggle(menuPane,
"incrementalBackup",
1175 "Incremental Backup",
'B', autoSaveCB, window, window->autoSave,
1176 SHORT);
1177
1178 subPane = createMenu(menuPane,
"showMatching",
"Show Matching (..)",
1179 'M',
NULL,
FULL);
1180 window->showMatchingOffItem = createMenuRadioToggle(subPane,
"off",
"Off",
1181 'O', showMatchingOffCB, window, window->showMatchingStyle ==
NO_FLASH,
1182 SHORT);
1183 window->showMatchingDelimitItem = createMenuRadioToggle(subPane,
1184 "delimiter",
"Delimiter",
'D', showMatchingDelimitCB, window,
1185 window->showMatchingStyle ==
FLASH_DELIMIT,
SHORT);
1186 window->showMatchingRangeItem = createMenuRadioToggle(subPane,
"range",
1187 "Range",
'R', showMatchingRangeCB, window,
1188 window->showMatchingStyle ==
FLASH_RANGE,
SHORT);
1189 createMenuSeparator(subPane,
"sep",
SHORT);
1190 window->matchSyntaxBasedItem = createMenuToggle(subPane,
"matchSyntax",
1191 "Syntax Based",
'S', matchSyntaxBasedCB, window,
1192 window->matchSyntaxBased,
SHORT);
1193
1194 #ifndef SGI_CUSTOM
1195 createMenuSeparator(menuPane,
"sep2",
SHORT);
1196 window->overtypeModeItem = createMenuToggle(menuPane,
"overtype",
"Overtype",
'O',
1197 doActionCB,
"set_overtype_mode", False,
SHORT);
1198 window->readOnlyItem = createMenuToggle(menuPane,
"readOnly",
"Read Only",
1199 'y', doActionCB,
"set_locked",
IS_USER_LOCKED(window->lockReasons),
FULL);
1200 #endif
1201
1202
1203
1204
1205 menuPane = window->shellMenuPane =
1206 createMenu(menuBar,
"shellMenu",
"Shell",
0, &cascade,
FULL);
1207 btn = createMenuItem(menuPane,
"executeCommand",
"Execute Command...",
1208 'E', doActionCB,
"execute_command_dialog",
SHORT);
1209 XtVaSetValues(btn, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1210 btn = createMenuItem(menuPane,
"executeCommandLine",
"Execute Command Line",
1211 'x', doActionCB,
"execute_command_line",
SHORT);
1212 XtVaSetValues(btn, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1213 window->filterItem = createMenuItem(menuPane,
"filterSelection",
1214 "Filter Selection...",
'F', doActionCB,
"filter_selection_dialog",
1215 SHORT);
1216 XtVaSetValues(window->filterItem, XmNuserData,
PERMANENT_MENU_ITEM,
1217 XmNsensitive, window->wasSelected,
NULL);
1218 window->cancelShellItem = createMenuItem(menuPane,
"cancelShellCommand",
1219 "Cancel Shell Command",
'C', cancelShellCB, window,
SHORT);
1220 XtVaSetValues(window->cancelShellItem, XmNuserData,
PERMANENT_MENU_ITEM,
1221 XmNsensitive, False,
NULL);
1222 btn = createMenuSeparator(menuPane,
"sep1",
SHORT);
1223 XtVaSetValues(btn, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1224
1225
1226
1227
1228 menuPane = window->macroMenuPane =
1229 createMenu(menuBar,
"macroMenu",
"Macro",
0, &cascade,
FULL);
1230 window->learnItem = createMenuItem(menuPane,
"learnKeystrokes",
1231 "Learn Keystrokes",
'L', learnCB, window,
SHORT);
1232 XtVaSetValues(window->learnItem , XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1233 window->finishLearnItem = createMenuItem(menuPane,
"finishLearn",
1234 "Finish Learn",
'F', finishLearnCB, window,
SHORT);
1235 XtVaSetValues(window->finishLearnItem , XmNuserData,
PERMANENT_MENU_ITEM,
1236 XmNsensitive, False,
NULL);
1237 window->cancelMacroItem = createMenuItem(menuPane,
"cancelLearn",
1238 "Cancel Learn",
'C', cancelLearnCB, window,
SHORT);
1239 XtVaSetValues(window->cancelMacroItem, XmNuserData,
PERMANENT_MENU_ITEM,
1240 XmNsensitive, False,
NULL);
1241 window->replayItem = createMenuItem(menuPane,
"replayKeystrokes",
1242 "Replay Keystrokes",
'K', replayCB, window,
SHORT);
1243 XtVaSetValues(window->replayItem, XmNuserData,
PERMANENT_MENU_ITEM,
1244 XmNsensitive, GetReplayMacro() !=
NULL,
NULL);
1245 window->repeatItem = createMenuItem(menuPane,
"repeat",
1246 "Repeat...",
'R', doActionCB,
"repeat_dialog",
SHORT);
1247 XtVaSetValues(window->repeatItem, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1248 btn = createMenuSeparator(menuPane,
"sep1",
SHORT);
1249 XtVaSetValues(btn, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1250
1251
1252
1253
1254 menuPane = window->windowMenuPane = createMenu(menuBar,
"windowsMenu",
1255 "Windows",
0, &cascade,
FULL);
1256 XtAddCallback(cascade, XmNcascadingCallback, (XtCallbackProc)windowMenuCB,
1257 window);
1258 window->splitPaneItem = createMenuItem(menuPane,
"splitPane",
1259 "Split Pane",
'S', doActionCB,
"split_pane",
SHORT);
1260 XtVaSetValues(window->splitPaneItem, XmNuserData,
PERMANENT_MENU_ITEM,
1261 NULL);
1262 window->closePaneItem = createMenuItem(menuPane,
"closePane",
1263 "Close Pane",
'C', doActionCB,
"close_pane",
SHORT);
1264 XtVaSetValues(window->closePaneItem, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1265 XtSetSensitive(window->closePaneItem, False);
1266
1267 btn = createMenuSeparator(menuPane,
"sep01",
SHORT);
1268 XtVaSetValues(btn, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1269 window->detachDocumentItem = createMenuItem(menuPane,
"detachBuffer",
1270 "Detach Tab",
'D', doActionCB,
"detach_document",
SHORT);
1271 XtSetSensitive(window->detachDocumentItem, False);
1272
1273 window->moveDocumentItem = createMenuItem(menuPane,
"moveDocument",
1274 "Move Tab To...",
'M', doActionCB,
"move_document_dialog",
SHORT);
1275 XtSetSensitive(window->moveDocumentItem, False);
1276 btn = createMenuSeparator(menuPane,
"sep1",
SHORT);
1277 XtVaSetValues(btn, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
1278
1279
1280
1281
1282 menuPane = createMenu(menuBar,
"helpMenu",
"Help",
0, &cascade,
SHORT);
1283 XtVaSetValues(menuBar, XmNmenuHelpWidget, cascade,
NULL);
1284 buildHelpMenu( menuPane, &
H_M[
0], window );
1285
1286 return menuBar;
1287 }
1288
1289
1290
1291 static Widget makeHelpMenuItem(
1292
1293 Widget parent,
1294 char *name,
1295 char *label,
1296 char mnemonic,
1297 menuCallbackProc callback,
1298 void *cbArg,
1299 int mode,
1300 enum HelpTopic topic
1301 )
1302 {
1303 Widget menuItem =
1304 createMenuItem( parent, name, label, mnemonic, callback, cbArg, mode );
1305
1306 XtVaSetValues( menuItem, XmNuserData, (XtPointer)topic,
NULL );
1307 return menuItem;
1308 }
1309
1310
1311
1312 static void helpCB( Widget menuItem, XtPointer clientData, XtPointer callData )
1313 {
1314 enum HelpTopic topic;
1315 XtPointer userData;
1316
1317 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(menuItem))->lastFocus,
1318 ((XmAnyCallbackStruct *)callData)->event);
1319 XtVaGetValues( menuItem, XmNuserData, &userData,
NULL );
1320 topic = (
enum HelpTopic)(
long long)userData;
1321
1322 Help(topic);
1323 }
1324
1325
1326
1327 #define NON_MENU_HELP 9
1328
1329 static HelpMenu * buildHelpMenu(
1330
1331 Widget pane,
1332 HelpMenu * menu,
1333 WindowInfo * window
1334 )
1335 {
1336 int hideIt = -
1;
1337
1338 if( menu !=
NULL )
1339 {
1340 int crntLevel = menu->level;
1341
1342
1343
1344
1345 while( menu !=
NULL && menu->level == crntLevel )
1346 {
1347
1348
1349
1350 if( menu->topic == HELP_none )
1351 {
1352 if( menu->mnemonic ==
'-' )
1353 {
1354 createMenuSeparator(pane, menu->wgtName,
SHORT);
1355 menu = menu->next;
1356 }
1357 else
1358 {
1359
1360
1361
1362 if( menu->hideIt == hideIt || menu->hideIt ==
NON_MENU_HELP )
1363 {
1364 do { menu = menu->next;
1365 }
while( menu !=
NULL && menu->level > crntLevel );
1366
1367 }
1368 else
1369 {
1370 Widget subPane =
1371 createMenu( pane, menu->wgtName, menu->subTitle,
1372 menu->mnemonic,
NULL,
FULL);
1373
1374 menu = buildHelpMenu( subPane, menu->next, window );
1375 }
1376 }
1377 }
1378
1379 else
1380 {
1381
1382
1383
1384
1385
1386
1387
1388
1389 if( menu->hideIt != hideIt && menu->hideIt !=
NON_MENU_HELP )
1390 makeHelpMenuItem(
1391 pane, menu->wgtName, HelpTitles[menu->topic],
1392 menu->mnemonic, helpCB, window,
SHORT, menu->topic );
1393
1394 menu = menu->next;
1395 }
1396 }
1397 }
1398
1399 return menu;
1400 }
1401
1402
1403
1404
1405
1406
1407 static void doTabActionCB(Widget w, XtPointer clientData, XtPointer callData)
1408 {
1409 Widget menu =
MENU_WIDGET(w);
1410 WindowInfo *win, *window = WidgetToWindow(menu);
1411
1412
1413
1414 XtVaGetValues(window->tabMenuPane, XmNuserData, &win,
NULL);
1415
1416 HidePointerOnKeyedEvent(win->lastFocus,
1417 ((XmAnyCallbackStruct *)callData)->event);
1418 XtCallActionProc(win->lastFocus, (
char *)clientData,
1419 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1420 }
1421
1422 static void doActionCB(Widget w, XtPointer clientData, XtPointer callData)
1423 {
1424 Widget menu =
MENU_WIDGET(w);
1425 Widget widget = WidgetToWindow(menu)->lastFocus;
1426 String action = (String) clientData;
1427 XEvent* event = ((XmAnyCallbackStruct*) callData)->event;
1428
1429 HidePointerOnKeyedEvent(widget, event);
1430
1431 XtCallActionProc(widget, action, event,
NULL,
0);
1432 }
1433
1434 static void pasteColCB(Widget w, XtPointer clientData, XtPointer callData)
1435 {
1436 static char *params[
1] = {
"rect"};
1437
1438 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1439 ((XmAnyCallbackStruct *)callData)->event);
1440 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"paste_clipboard",
1441 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1442 }
1443
1444 static void shiftLeftCB(Widget w, XtPointer clientData, XtPointer callData)
1445 {
1446 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1447 ((XmAnyCallbackStruct *)callData)->event);
1448 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1449 (((XmAnyCallbackStruct *)callData)->event->xbutton.state & ShiftMask)
1450 ?
"shift_left_by_tab" :
"shift_left",
1451 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1452 }
1453
1454 static void shiftRightCB(Widget w, XtPointer clientData, XtPointer callData)
1455 {
1456 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1457 ((XmAnyCallbackStruct *)callData)->event);
1458 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1459 (((XmAnyCallbackStruct *)callData)->event->xbutton.state & ShiftMask)
1460 ?
"shift_right_by_tab" :
"shift_right",
1461 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1462 }
1463
1464 static void findCB(Widget w, XtPointer clientData, XtPointer callData)
1465 {
1466 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1467 ((XmAnyCallbackStruct *)callData)->event);
1468 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"find_dialog",
1469 ((XmAnyCallbackStruct *)callData)->event,
1470 shiftKeyToDir(callData),
1);
1471 }
1472
1473 static void findSameCB(Widget w, XtPointer clientData, XtPointer callData)
1474 {
1475 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1476 ((XmAnyCallbackStruct *)callData)->event);
1477 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"find_again",
1478 ((XmAnyCallbackStruct *)callData)->event,
1479 shiftKeyToDir(callData),
1);
1480 }
1481
1482 static void findSelCB(Widget w, XtPointer clientData, XtPointer callData)
1483 {
1484 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1485 ((XmAnyCallbackStruct *)callData)->event);
1486 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"find_selection",
1487 ((XmAnyCallbackStruct *)callData)->event,
1488 shiftKeyToDir(callData),
1);
1489 }
1490
1491 static void findIncrCB(Widget w, XtPointer clientData, XtPointer callData)
1492 {
1493 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1494 ((XmAnyCallbackStruct *)callData)->event);
1495 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1496 "start_incremental_find", ((XmAnyCallbackStruct *)callData)->event,
1497 shiftKeyToDir(callData),
1);
1498 }
1499
1500 static void replaceCB(Widget w, XtPointer clientData, XtPointer callData)
1501 {
1502 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1503 ((XmAnyCallbackStruct *)callData)->event);
1504 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"replace_dialog",
1505 ((XmAnyCallbackStruct *)callData)->event,
1506 shiftKeyToDir(callData),
1);
1507 }
1508
1509 static void replaceSameCB(Widget w, XtPointer clientData, XtPointer callData)
1510 {
1511 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1512 ((XmAnyCallbackStruct *)callData)->event);
1513 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"replace_again",
1514 ((XmAnyCallbackStruct *)callData)->event,
1515 shiftKeyToDir(callData),
1);
1516 }
1517
1518 static void replaceFindSameCB(Widget w, XtPointer clientData, XtPointer callData)
1519 {
1520 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1521 ((XmAnyCallbackStruct *)callData)->event);
1522 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"replace_find_same",
1523 ((XmAnyCallbackStruct *)callData)->event,
1524 shiftKeyToDir(callData),
1);
1525 }
1526
1527 static void markCB(Widget w, XtPointer clientData, XtPointer callData)
1528 {
1529 XEvent *event = ((XmAnyCallbackStruct *)callData)->event;
1530 WindowInfo *window = WidgetToWindow(
MENU_WIDGET(w));
1531
1532 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1533 ((XmAnyCallbackStruct *)callData)->event);
1534 if (event->type == KeyPress || event->type == KeyRelease)
1535 BeginMarkCommand(window);
1536 else
1537 XtCallActionProc(window->lastFocus,
"mark_dialog", event,
NULL,
0);
1538 }
1539
1540 static void gotoMarkCB(Widget w, XtPointer clientData, XtPointer callData)
1541 {
1542 XEvent *event = ((XmAnyCallbackStruct *)callData)->event;
1543 WindowInfo *window = WidgetToWindow(
MENU_WIDGET(w));
1544 int extend = event->xbutton.state & ShiftMask;
1545 static char *params[
1] = {
"extend"};
1546
1547 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1548 ((XmAnyCallbackStruct *)callData)->event);
1549 if (event->type == KeyPress || event->type == KeyRelease)
1550 BeginGotoMarkCommand(window, extend);
1551 else
1552 XtCallActionProc(window->lastFocus,
"goto_mark_dialog", event, params,
1553 extend ?
1 :
0);
1554 }
1555
1556 static void gotoMatchingCB(Widget w, XtPointer clientData, XtPointer callData)
1557 {
1558 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1559 ((XmAnyCallbackStruct *)callData)->event);
1560 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1561 (((XmAnyCallbackStruct *)callData)->event->xbutton.state & ShiftMask)
1562 ?
"select_to_matching" :
"goto_matching",
1563 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1564 }
1565
1566 static void autoIndentOffCB(Widget w, WindowInfo *window,
caddr_t callData)
1567 {
1568 static char *params[
1] = {
"off"};
1569 Widget menu =
MENU_WIDGET(w);
1570
1571 window = WidgetToWindow(menu);
1572
1573 #ifdef SGI_CUSTOM
1574 if (shortPrefAskDefault(window->shell, w,
"Auto Indent Off")) {
1575 autoIndentOffDefCB(w, window, callData);
1576 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1577 }
1578 #endif
1579 HidePointerOnKeyedEvent(WidgetToWindow(menu)->lastFocus,
1580 ((XmAnyCallbackStruct *)callData)->event);
1581 XtCallActionProc(WidgetToWindow(menu)->lastFocus,
"set_auto_indent",
1582 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1583 }
1584
1585 static void autoIndentCB(Widget w, WindowInfo *window,
caddr_t callData)
1586 {
1587 static char *params[
1] = {
"on"};
1588 Widget menu =
MENU_WIDGET(w);
1589
1590 window = WidgetToWindow(menu);
1591
1592 #ifdef SGI_CUSTOM
1593 if (shortPrefAskDefault(window->shell, w,
"Auto Indent")) {
1594 autoIndentDefCB(w, window, callData);
1595 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1596 }
1597 #endif
1598 HidePointerOnKeyedEvent(WidgetToWindow(menu)->lastFocus,
1599 ((XmAnyCallbackStruct *)callData)->event);
1600 XtCallActionProc(WidgetToWindow(menu)->lastFocus,
"set_auto_indent",
1601 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1602 }
1603
1604 static void smartIndentCB(Widget w, WindowInfo *window,
caddr_t callData)
1605 {
1606 static char *params[
1] = {
"smart"};
1607 Widget menu =
MENU_WIDGET(w);
1608
1609 window = WidgetToWindow(menu);
1610
1611 #ifdef SGI_CUSTOM
1612 if (shortPrefAskDefault(window->shell, w,
"Smart Indent")) {
1613 smartIndentDefCB(w, window, callData);
1614 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1615 }
1616 #endif
1617 HidePointerOnKeyedEvent(WidgetToWindow(menu)->lastFocus,
1618 ((XmAnyCallbackStruct *)callData)->event);
1619 XtCallActionProc(WidgetToWindow(menu)->lastFocus,
"set_auto_indent",
1620 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1621 }
1622
1623 static void autoSaveCB(Widget w, WindowInfo *window,
caddr_t callData)
1624 {
1625 Widget menu =
MENU_WIDGET(w);
1626
1627 window = WidgetToWindow(menu);
1628
1629 #ifdef SGI_CUSTOM
1630 if (shortPrefAskDefault(window->shell, w,
"Incremental Backup")) {
1631 autoSaveDefCB(w, window, callData);
1632 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1633 }
1634 #endif
1635 HidePointerOnKeyedEvent(window->lastFocus,
1636 ((XmAnyCallbackStruct *)callData)->event);
1637 XtCallActionProc(window->lastFocus,
"set_incremental_backup",
1638 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1639 }
1640
1641 static void preserveCB(Widget w, WindowInfo *window,
caddr_t callData)
1642 {
1643 Widget menu =
MENU_WIDGET(w);
1644
1645 window = WidgetToWindow(menu);
1646
1647 #ifdef SGI_CUSTOM
1648 if (shortPrefAskDefault(window->shell, w,
"Make Backup Copy")) {
1649 preserveDefCB(w, window, callData);
1650 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1651 }
1652 #endif
1653 HidePointerOnKeyedEvent(window->lastFocus,
1654 ((XmAnyCallbackStruct *)callData)->event);
1655 XtCallActionProc(window->lastFocus,
"set_make_backup_copy",
1656 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1657 }
1658
1659 static void showMatchingOffCB(Widget w, WindowInfo *window,
caddr_t callData)
1660 {
1661 static char *params[
1] = {
NO_FLASH_STRING};
1662 Widget menu =
MENU_WIDGET(w);
1663
1664 window = WidgetToWindow(menu);
1665
1666 #ifdef SGI_CUSTOM
1667 if (shortPrefAskDefault(window->shell, w,
"Show Matching Off")) {
1668 showMatchingOffDefCB(w, window, callData);
1669 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1670 }
1671 #endif
1672 HidePointerOnKeyedEvent(window->lastFocus,
1673 ((XmAnyCallbackStruct *)callData)->event);
1674 XtCallActionProc(window->lastFocus,
"set_show_matching",
1675 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1676 }
1677
1678 static void showMatchingDelimitCB(Widget w, WindowInfo *window,
caddr_t callData)
1679 {
1680 static char *params[
1] = {
FLASH_DELIMIT_STRING};
1681 Widget menu =
MENU_WIDGET(w);
1682
1683 window = WidgetToWindow(menu);
1684
1685 #ifdef SGI_CUSTOM
1686 if (shortPrefAskDefault(window->shell, w,
"Show Matching Delimiter")) {
1687 showMatchingDelimitDefCB(w, window, callData);
1688 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1689 }
1690 #endif
1691 HidePointerOnKeyedEvent(window->lastFocus,
1692 ((XmAnyCallbackStruct *)callData)->event);
1693 XtCallActionProc(window->lastFocus,
"set_show_matching",
1694 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1695 }
1696
1697 static void showMatchingRangeCB(Widget w, WindowInfo *window,
caddr_t callData)
1698 {
1699 static char *params[
1] = {
FLASH_RANGE_STRING};
1700 Widget menu =
MENU_WIDGET(w);
1701
1702 window = WidgetToWindow(menu);
1703
1704 #ifdef SGI_CUSTOM
1705 if (shortPrefAskDefault(window->shell, w,
"Show Matching Range")) {
1706 showMatchingRangeDefCB(w, window, callData);
1707 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1708 }
1709 #endif
1710 HidePointerOnKeyedEvent(window->lastFocus,
1711 ((XmAnyCallbackStruct *)callData)->event);
1712 XtCallActionProc(window->lastFocus,
"set_show_matching",
1713 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1714 }
1715
1716 static void matchSyntaxBasedCB(Widget w, WindowInfo *window,
caddr_t callData)
1717 {
1718 Widget menu =
MENU_WIDGET(w);
1719
1720 window = WidgetToWindow(menu);
1721
1722 #ifdef SGI_CUSTOM
1723 if (shortPrefAskDefault(window->shell, w,
"Match Syntax Based")) {
1724 matchSyntaxBasedDefCB(w, window, callData);
1725 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1726 }
1727 #endif
1728 HidePointerOnKeyedEvent(window->lastFocus,
1729 ((XmAnyCallbackStruct *)callData)->event);
1730 XtCallActionProc(window->lastFocus,
"set_match_syntax_based",
1731 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1732 }
1733
1734 static void fontCB(Widget w, WindowInfo *window,
caddr_t callData)
1735 {
1736 ChooseFonts(WidgetToWindow(
MENU_WIDGET(w)), True);
1737 }
1738
1739 static void resetZoomCB(Widget w, XtPointer clientData, XtPointer callData)
1740 {
1741 WindowInfo *window = WidgetToWindow(
MENU_WIDGET(w));
1742 if(window->zoom !=
0) {
1743 SetZoom(window, -window->zoom);
1744 }
1745 }
1746
1747 static void noWrapCB(Widget w, WindowInfo *window,
caddr_t callData)
1748 {
1749 static char *params[
1] = {
"none"};
1750 Widget menu =
MENU_WIDGET(w);
1751
1752 window = WidgetToWindow(menu);
1753
1754 #ifdef SGI_CUSTOM
1755 if (shortPrefAskDefault(window->shell, w,
"No Wrap")) {
1756 noWrapDefCB(w, window, callData);
1757 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1758 }
1759 #endif
1760 HidePointerOnKeyedEvent(window->lastFocus,
1761 ((XmAnyCallbackStruct *)callData)->event);
1762 XtCallActionProc(window->lastFocus,
"set_wrap_text",
1763 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1764 }
1765
1766 static void newlineWrapCB(Widget w, WindowInfo *window,
caddr_t callData)
1767 {
1768 static char *params[
1] = {
"auto"};
1769 Widget menu =
MENU_WIDGET(w);
1770
1771 window = WidgetToWindow(menu);
1772
1773 #ifdef SGI_CUSTOM
1774 if (shortPrefAskDefault(window->shell, w,
"Auto Newline Wrap")) {
1775 newlineWrapDefCB(w, window, callData);
1776 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1777 }
1778 #endif
1779 HidePointerOnKeyedEvent(window->lastFocus,
1780 ((XmAnyCallbackStruct *)callData)->event);
1781 XtCallActionProc(window->lastFocus,
"set_wrap_text",
1782 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1783 }
1784
1785 static void continuousWrapCB(Widget w, WindowInfo *window,
caddr_t callData)
1786 {
1787 static char *params[
1] = {
"continuous"};
1788 Widget menu =
MENU_WIDGET(w);
1789
1790 window = WidgetToWindow(menu);
1791
1792 #ifdef SGI_CUSTOM
1793 if (shortPrefAskDefault(window->shell, w,
"Continuous Wrap")) {
1794 contWrapDefCB(w, window, callData);
1795 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1796 }
1797 #endif
1798 HidePointerOnKeyedEvent(window->lastFocus,
1799 ((XmAnyCallbackStruct *)callData)->event);
1800 XtCallActionProc(window->lastFocus,
"set_wrap_text",
1801 ((XmAnyCallbackStruct *)callData)->event, params,
1);
1802 }
1803
1804 static void wrapMarginCB(Widget w, WindowInfo *window,
caddr_t callData)
1805 {
1806 window = WidgetToWindow(
MENU_WIDGET(w));
1807
1808 HidePointerOnKeyedEvent(window->lastFocus,
1809 ((XmAnyCallbackStruct *)callData)->event);
1810 WrapMarginDialog(window->shell, window);
1811 }
1812
1813 static void highlightCursorLineCB(Widget w, WindowInfo *window,
caddr_t callData)
1814 {
1815 int highlightCursorLine = XmToggleButtonGetState(w);
1816 window = WidgetToWindow(
MENU_WIDGET(w));
1817 SetHighlightCursorLine(window, highlightCursorLine);
1818 }
1819
1820 static void indentRainbowCB(Widget w, WindowInfo *window,
caddr_t callData)
1821 {
1822 int indentRainbow = XmToggleButtonGetState(w);
1823 window = WidgetToWindow(
MENU_WIDGET(w));
1824 SetIndentRainbow(window, indentRainbow);
1825 }
1826
1827 static void ansiColorsCB(Widget w, WindowInfo *window,
caddr_t callData)
1828 {
1829 int state = XmToggleButtonGetState(w);
1830 window = WidgetToWindow(
MENU_WIDGET(w));
1831 SetAnsiColors(window, state);
1832 }
1833
1834 static void backlightCharsCB(Widget w, WindowInfo *window,
caddr_t callData)
1835 {
1836 int applyBacklight = XmToggleButtonGetState(w);
1837 window = WidgetToWindow(
MENU_WIDGET(w));
1838 SetBacklightChars(window, applyBacklight?GetPrefBacklightCharTypes():
NULL);
1839 }
1840
1841 static void tabsCB(Widget w, WindowInfo *window,
caddr_t callData)
1842 {
1843 window = WidgetToWindow(
MENU_WIDGET(w));
1844
1845 HidePointerOnKeyedEvent(window->lastFocus,
1846 ((XmAnyCallbackStruct *)callData)->event);
1847 TabsPrefDialog(window->shell, window);
1848 }
1849
1850 static void statsCB(Widget w, WindowInfo *window,
caddr_t callData)
1851 {
1852 Widget menu =
MENU_WIDGET(w);
1853
1854 window = WidgetToWindow(menu);
1855
1856 #ifdef SGI_CUSTOM
1857 if (shortPrefAskDefault(window->shell, w,
"Statistics Line")) {
1858 statsLineDefCB(w, window, callData);
1859 SaveNEditPrefs(window->shell, GetPrefShortMenus());
1860 }
1861 #endif
1862 HidePointerOnKeyedEvent(window->lastFocus,
1863 ((XmAnyCallbackStruct *)callData)->event);
1864 XtCallActionProc(window->lastFocus,
"set_statistics_line",
1865 ((XmAnyCallbackStruct *)callData)->event,
NULL,
0);
1866 }
1867
1868 static void autoIndentOffDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1869 {
1870 WindowInfo *win;
1871
1872
1873 SetPrefAutoIndent(
NO_AUTO_INDENT);
1874 for (win=WindowList; win!=
NULL; win=win->next) {
1875 if (!IsTopDocument(win))
1876 continue;
1877 XmToggleButtonSetState(win->autoIndentOffDefItem, True, False);
1878 XmToggleButtonSetState(win->autoIndentDefItem, False, False);
1879 XmToggleButtonSetState(win->smartIndentDefItem, False, False);
1880 }
1881 }
1882
1883 static void autoIndentDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1884 {
1885 WindowInfo *win;
1886
1887
1888 SetPrefAutoIndent(
AUTO_INDENT);
1889 for (win=WindowList; win!=
NULL; win=win->next) {
1890 if (!IsTopDocument(win))
1891 continue;
1892 XmToggleButtonSetState(win->autoIndentDefItem, True, False);
1893 XmToggleButtonSetState(win->autoIndentOffDefItem, False, False);
1894 XmToggleButtonSetState(win->smartIndentDefItem, False, False);
1895 }
1896 }
1897
1898 static void smartIndentDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1899 {
1900 WindowInfo *win;
1901
1902
1903 SetPrefAutoIndent(
SMART_INDENT);
1904 for (win=WindowList; win!=
NULL; win=win->next) {
1905 if (!IsTopDocument(win))
1906 continue;
1907 XmToggleButtonSetState(win->smartIndentDefItem, True, False);
1908 XmToggleButtonSetState(win->autoIndentOffDefItem, False, False);
1909 XmToggleButtonSetState(win->autoIndentDefItem, False, False);
1910 }
1911 }
1912
1913 static void autoSaveDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1914 {
1915 WindowInfo *win;
1916 int state = XmToggleButtonGetState(w);
1917
1918
1919 SetPrefAutoSave(state);
1920 for (win=WindowList; win!=
NULL; win=win->next) {
1921 if (IsTopDocument(win))
1922 XmToggleButtonSetState(win->autoSaveDefItem, state, False);
1923 }
1924 }
1925
1926 static void preserveDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1927 {
1928 WindowInfo *win;
1929 int state = XmToggleButtonGetState(w);
1930
1931
1932 SetPrefSaveOldVersion(state);
1933 for (win=WindowList; win!=
NULL; win=win->next) {
1934 if (IsTopDocument(win))
1935 XmToggleButtonSetState(win->saveLastDefItem, state, False);
1936 }
1937 }
1938
1939 static void fontDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1940 {
1941 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1942 ((XmAnyCallbackStruct *)callData)->event);
1943 ChooseFonts(WidgetToWindow(
MENU_WIDGET(w)), False);
1944 }
1945
1946 static void colorDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1947 {
1948 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
1949 ((XmAnyCallbackStruct *)callData)->event);
1950 ChooseColors(WidgetToWindow(
MENU_WIDGET(w)));
1951 }
1952
1953 static void noWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1954 {
1955 WindowInfo *win;
1956
1957
1958 SetPrefWrap(
NO_WRAP);
1959 for (win=WindowList; win!=
NULL; win=win->next) {
1960 if (!IsTopDocument(win))
1961 continue;
1962 XmToggleButtonSetState(win->noWrapDefItem, True, False);
1963 XmToggleButtonSetState(win->newlineWrapDefItem, False, False);
1964 XmToggleButtonSetState(win->contWrapDefItem, False, False);
1965 }
1966 }
1967
1968 static void newlineWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1969 {
1970 WindowInfo *win;
1971
1972
1973 SetPrefWrap(
NEWLINE_WRAP);
1974 for (win=WindowList; win!=
NULL; win=win->next) {
1975 if (!IsTopDocument(win))
1976 continue;
1977 XmToggleButtonSetState(win->newlineWrapDefItem, True, False);
1978 XmToggleButtonSetState(win->contWrapDefItem, False, False);
1979 XmToggleButtonSetState(win->noWrapDefItem, False, False);
1980 }
1981 }
1982
1983 static void contWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1984 {
1985 WindowInfo *win;
1986
1987
1988 SetPrefWrap(
CONTINUOUS_WRAP);
1989 for (win=WindowList; win!=
NULL; win=win->next) {
1990 if (!IsTopDocument(win))
1991 continue;
1992 XmToggleButtonSetState(win->contWrapDefItem, True, False);
1993 XmToggleButtonSetState(win->newlineWrapDefItem, False, False);
1994 XmToggleButtonSetState(win->noWrapDefItem, False, False);
1995 }
1996 }
1997
1998 static void wrapMarginDefCB(Widget w, WindowInfo *window,
caddr_t callData)
1999 {
2000 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2001 ((XmAnyCallbackStruct *)callData)->event);
2002 WrapMarginDialog(WidgetToWindow(
MENU_WIDGET(w))->shell,
NULL);
2003 }
2004
2005 static void smartTagsDefCB(Widget w, XtPointer client_data, XtPointer callData)
2006 {
2007 WindowInfo *win;
2008
2009 SetPrefSmartTags(True);
2010 for (win=WindowList; win!=
NULL; win=win->next) {
2011 if (!IsTopDocument(win))
2012 continue;
2013 XmToggleButtonSetState(win->smartTagsDefItem, True, False);
2014 XmToggleButtonSetState(win->allTagsDefItem, False, False);
2015 }
2016 }
2017
2018 static void showAllTagsDefCB(Widget w, XtPointer client_data, XtPointer callData)
2019 {
2020 WindowInfo *win;
2021
2022 SetPrefSmartTags(False);
2023 for (win=WindowList; win!=
NULL; win=win->next) {
2024 if (!IsTopDocument(win))
2025 continue;
2026 XmToggleButtonSetState(win->smartTagsDefItem, False, False);
2027 XmToggleButtonSetState(win->allTagsDefItem, True, False);
2028 }
2029 }
2030
2031 static void shellSelDefCB(Widget widget, WindowInfo* window,
caddr_t callData)
2032 {
2033 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(widget))->lastFocus,
2034 ((XmAnyCallbackStruct*) callData)->event);
2035 SelectShellDialog(WidgetToWindow(
MENU_WIDGET(widget))->shell,
NULL);
2036 }
2037
2038 static void tabsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2039 {
2040 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2041 ((XmAnyCallbackStruct *)callData)->event);
2042 TabsPrefDialog(WidgetToWindow(
MENU_WIDGET(w))->shell,
NULL);
2043 }
2044
2045 static void showMatchingOffDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2046 {
2047 WindowInfo *win;
2048
2049
2050 SetPrefShowMatching(
NO_FLASH);
2051 for (win=WindowList; win!=
NULL; win=win->next) {
2052 if (!IsTopDocument(win))
2053 continue;
2054 XmToggleButtonSetState(win->showMatchingOffDefItem, True, False);
2055 XmToggleButtonSetState(win->showMatchingDelimitDefItem, False, False);
2056 XmToggleButtonSetState(win->showMatchingRangeDefItem, False, False);
2057 }
2058 }
2059
2060 static void showMatchingDelimitDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2061 {
2062 WindowInfo *win;
2063
2064
2065 SetPrefShowMatching(
FLASH_DELIMIT);
2066 for (win=WindowList; win!=
NULL; win=win->next) {
2067 if (!IsTopDocument(win))
2068 continue;
2069 XmToggleButtonSetState(win->showMatchingOffDefItem, False, False);
2070 XmToggleButtonSetState(win->showMatchingDelimitDefItem, True, False);
2071 XmToggleButtonSetState(win->showMatchingRangeDefItem, False, False);
2072 }
2073 }
2074
2075 static void showMatchingRangeDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2076 {
2077 WindowInfo *win;
2078
2079
2080 SetPrefShowMatching(
FLASH_RANGE);
2081 for (win=WindowList; win!=
NULL; win=win->next) {
2082 if (!IsTopDocument(win))
2083 continue;
2084 XmToggleButtonSetState(win->showMatchingOffDefItem, False, False);
2085 XmToggleButtonSetState(win->showMatchingDelimitDefItem, False, False);
2086 XmToggleButtonSetState(win->showMatchingRangeDefItem, True, False);
2087 }
2088 }
2089
2090 static void matchSyntaxBasedDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2091 {
2092 WindowInfo *win;
2093
2094 int state = XmToggleButtonGetState(w);
2095
2096
2097 SetPrefMatchSyntaxBased(state);
2098 for (win=WindowList; win!=
NULL; win=win->next) {
2099 if (IsTopDocument(win))
2100 XmToggleButtonSetState(win->matchSyntaxBasedDefItem, state, False);
2101 }
2102 }
2103
2104 static void backlightCharsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2105 {
2106 WindowInfo *win;
2107 int state = XmToggleButtonGetState(w);
2108
2109
2110 SetPrefBacklightChars(state);
2111 for (win=WindowList; win!=
NULL; win=win->next) {
2112 if (IsTopDocument(win))
2113 XmToggleButtonSetState(win->backlightCharsDefItem, state, False);
2114 }
2115 }
2116
2117 static void highlightCursorLineDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2118 {
2119 WindowInfo *win;
2120 int state = XmToggleButtonGetState(w);
2121
2122
2123 SetPrefHighlightCursorLine(state);
2124 for (win=WindowList; win!=
NULL; win=win->next) {
2125 if (IsTopDocument(win))
2126 XmToggleButtonSetState(win->highlightCursorLineDefItem, state, False);
2127 }
2128 }
2129
2130 static void indentRainbowDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2131 {
2132 WindowInfo *win;
2133 int state = XmToggleButtonGetState(w);
2134
2135
2136 SetPrefIndentRainbow(state);
2137 for (win=WindowList; win!=
NULL; win=win->next) {
2138 if (IsTopDocument(win))
2139 XmToggleButtonSetState(win->indentRainbowDefItem, state, False);
2140 }
2141 }
2142
2143 static void ansiColorsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2144 {
2145 WindowInfo *win;
2146 int state = XmToggleButtonGetState(w);
2147
2148
2149 SetPrefAnsiColors(state);
2150 for (win=WindowList; win!=
NULL; win=win->next) {
2151 if (IsTopDocument(win))
2152 XmToggleButtonSetState(win->ansiColorsDefItem, state, False);
2153 }
2154 }
2155
2156 static void highlightOffDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2157 {
2158 WindowInfo *win;
2159
2160
2161 SetPrefHighlightSyntax(False);
2162 for (win=WindowList; win!=
NULL; win=win->next) {
2163 if (!IsTopDocument(win))
2164 continue;
2165 XmToggleButtonSetState(win->highlightOffDefItem, True, False);
2166 XmToggleButtonSetState(win->highlightDefItem, False, False);
2167 }
2168 }
2169
2170 static void highlightDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2171 {
2172 WindowInfo *win;
2173
2174
2175 SetPrefHighlightSyntax(True);
2176 for (win=WindowList; win!=
NULL; win=win->next) {
2177 if (!IsTopDocument(win))
2178 continue;
2179 XmToggleButtonSetState(win->highlightOffDefItem, False, False);
2180 XmToggleButtonSetState(win->highlightDefItem, True, False);
2181 }
2182 }
2183
2184 static void highlightingDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2185 {
2186 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2187 ((XmAnyCallbackStruct *)callData)->event);
2188 EditHighlightPatterns(WidgetToWindow(
MENU_WIDGET(w)));
2189 }
2190
2191 static void smartMacrosDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2192 {
2193 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2194 ((XmAnyCallbackStruct *)callData)->event);
2195 EditSmartIndentMacros(WidgetToWindow(
MENU_WIDGET(w)));
2196 }
2197
2198 static void stylesDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2199 {
2200 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2201 ((XmAnyCallbackStruct *)callData)->event);
2202 EditHighlightStyles(
NULL);
2203 }
2204
2205 static void languageDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2206 {
2207 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2208 ((XmAnyCallbackStruct *)callData)->event);
2209 EditLanguageModes();
2210 }
2211
2212 static void shellDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2213 {
2214 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2215 ((XmAnyCallbackStruct *)callData)->event);
2216 EditShellMenu(WidgetToWindow(
MENU_WIDGET(w)));
2217 }
2218
2219 static void macroDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2220 {
2221 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2222 ((XmAnyCallbackStruct *)callData)->event);
2223 EditMacroMenu(WidgetToWindow(
MENU_WIDGET(w)));
2224 }
2225
2226 static void bgMenuDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2227 {
2228 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2229 ((XmAnyCallbackStruct *)callData)->event);
2230 EditBGMenu(WidgetToWindow(
MENU_WIDGET(w)));
2231 }
2232
2233 static void customizeTitleDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2234 {
2235 window = WidgetToWindow(
MENU_WIDGET(w));
2236
2237 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2238 ((XmAnyCallbackStruct *)callData)->event);
2239 EditCustomTitleFormat(window);
2240 }
2241
2242 static void searchDlogsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2243 {
2244 WindowInfo *win;
2245 int state = XmToggleButtonGetState(w);
2246
2247
2248 SetPrefSearchDlogs(state);
2249 for (win=WindowList; win!=
NULL; win=win->next) {
2250 if (IsTopDocument(win))
2251 XmToggleButtonSetState(win->searchDlogsDefItem, state, False);
2252 }
2253 }
2254
2255 static void beepOnSearchWrapDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2256 {
2257 WindowInfo *win;
2258 int state = XmToggleButtonGetState(w);
2259
2260
2261 SetPrefBeepOnSearchWrap(state);
2262 for (win=WindowList; win!=
NULL; win=win->next) {
2263 if (IsTopDocument(win))
2264 XmToggleButtonSetState(win->beepOnSearchWrapDefItem, state, False);
2265 }
2266 }
2267
2268 static void keepSearchDlogsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2269 {
2270 WindowInfo *win;
2271 int state = XmToggleButtonGetState(w);
2272
2273
2274 SetPrefKeepSearchDlogs(state);
2275 for (win=WindowList; win!=
NULL; win=win->next) {
2276 if (IsTopDocument(win))
2277 XmToggleButtonSetState(win->keepSearchDlogsDefItem, state, False);
2278 }
2279 }
2280
2281 static void saveSearchHistoryDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2282 {
2283 WindowInfo *win;
2284 int state = XmToggleButtonGetState(w);
2285
2286
2287 SetPrefSaveSearchHistory(state);
2288 for (win=WindowList; win!=
NULL; win=win->next) {
2289 if (IsTopDocument(win))
2290 XmToggleButtonSetState(win->saveSearchHistoryDefItem, state, False);
2291 }
2292 }
2293
2294 static void searchWrapsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2295 {
2296 WindowInfo *win;
2297 int state = XmToggleButtonGetState(w);
2298
2299
2300 SetPrefSearchWraps(state);
2301 for (win=WindowList; win!=
NULL; win=win->next) {
2302 if (IsTopDocument(win))
2303 XmToggleButtonSetState(win->searchWrapsDefItem, state, False);
2304 }
2305 }
2306
2307 static void appendLFCB(Widget w, WindowInfo* window,
caddr_t callData)
2308 {
2309 WindowInfo *win;
2310 int state = XmToggleButtonGetState(w);
2311
2312 SetPrefAppendLF(state);
2313 for (win = WindowList; win !=
NULL; win = win->next) {
2314 if (IsTopDocument(win))
2315 XmToggleButtonSetState(win->appendLFItem, state, False);
2316 }
2317 }
2318
2319 static void sortOpenPrevDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2320 {
2321 WindowInfo *win;
2322 int state = XmToggleButtonGetState(w);
2323
2324
2325
2326 SetPrefSortOpenPrevMenu(state);
2327 for (win=WindowList; win!=
NULL; win=win->next) {
2328 if (IsTopDocument(win))
2329 XmToggleButtonSetState(win->sortOpenPrevDefItem, state, False);
2330 }
2331 }
2332
2333 static void reposDlogsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2334 {
2335 WindowInfo *win;
2336 int state = XmToggleButtonGetState(w);
2337
2338
2339 SetPrefRepositionDialogs(state);
2340 SetPointerCenteredDialogs(state);
2341 for (win=WindowList; win!=
NULL; win=win->next) {
2342 if (IsTopDocument(win))
2343 XmToggleButtonSetState(win->reposDlogsDefItem, state, False);
2344 }
2345 }
2346
2347 static void autoScrollDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2348 {
2349 WindowInfo *win;
2350 int state = XmToggleButtonGetState(w);
2351
2352
2353 SetPrefAutoScroll(state);
2354
2355 for (win=WindowList; win!=
NULL; win=win->next) {
2356 if (IsTopDocument(win))
2357 XmToggleButtonSetState(win->autoScrollDefItem, state, False);
2358 }
2359 }
2360
2361 static void editorConfigDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2362 {
2363 WindowInfo *win;
2364 int state = XmToggleButtonGetState(w);
2365
2366
2367 SetPrefEditorConfig(state);
2368 for (win=WindowList; win!=
NULL; win=win->next) {
2369 if (IsTopDocument(win))
2370 XmToggleButtonSetState(win->editorConfigDefItem, state, False);
2371 }
2372 }
2373
2374 static void lockEncodingErrorDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2375 {
2376 WindowInfo *win;
2377 int state = XmToggleButtonGetState(w);
2378
2379
2380 SetPrefLockEncodingError(state);
2381 for (win=WindowList; win!=
NULL; win=win->next) {
2382 if (IsTopDocument(win))
2383 XmToggleButtonSetState(win->lockEncodingErrorDefItem, state, False);
2384 }
2385 }
2386
2387 static void filterDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2388 {
2389 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2390 ((XmAnyCallbackStruct *)callData)->event);
2391 FilterSettings(WidgetToWindow(
MENU_WIDGET(w)));
2392 }
2393
2394 static void modWarnDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2395 {
2396 WindowInfo *win;
2397 int state = XmToggleButtonGetState(w);
2398
2399
2400 SetPrefWarnFileMods(state);
2401 for (win=WindowList; win!=
NULL; win=win->next) {
2402 if (!IsTopDocument(win))
2403 continue;
2404 XmToggleButtonSetState(win->modWarnDefItem, state, False);
2405 XtSetSensitive(win->modWarnRealDefItem, state);
2406 }
2407 }
2408
2409 static void modWarnRealDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2410 {
2411 WindowInfo *win;
2412 int state = XmToggleButtonGetState(w);
2413
2414
2415 SetPrefWarnRealFileMods(state);
2416 for (win=WindowList; win!=
NULL; win=win->next) {
2417 if (IsTopDocument(win))
2418 XmToggleButtonSetState(win->modWarnRealDefItem, state, False);
2419 }
2420 }
2421
2422 static void exitWarnDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2423 {
2424 WindowInfo *win;
2425 int state = XmToggleButtonGetState(w);
2426
2427
2428 SetPrefWarnExit(state);
2429 for (win=WindowList; win!=
NULL; win=win->next) {
2430 if (IsTopDocument(win))
2431 XmToggleButtonSetState(win->exitWarnDefItem, state, False);
2432 }
2433 }
2434
2435 static void openInTabDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2436 {
2437 WindowInfo *win;
2438 int state = XmToggleButtonGetState(w);
2439
2440
2441 SetPrefOpenInTab(state);
2442 for (win=WindowList; win!=
NULL; win=win->next)
2443 XmToggleButtonSetState(win->openInTabDefItem, state, False);
2444 }
2445
2446 static void tabBarDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2447 {
2448 WindowInfo *win;
2449 int state = XmToggleButtonGetState(w);
2450
2451
2452 SetPrefTabBar(state);
2453 for (win=WindowList; win!=
NULL; win=win->next) {
2454 if (!IsTopDocument(win))
2455 continue;
2456 XmToggleButtonSetState(win->tabBarDefItem, state, False);
2457 ShowWindowTabBar(win);
2458 }
2459 }
2460
2461 static void tabBarHideDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2462 {
2463 WindowInfo *win;
2464 int state = XmToggleButtonGetState(w);
2465
2466
2467 SetPrefTabBarHideOne(state);
2468 for (win=WindowList; win!=
NULL; win=win->next) {
2469 if (!IsTopDocument(win))
2470 continue;
2471 XmToggleButtonSetState(win->tabBarHideDefItem, state, False);
2472 ShowWindowTabBar(win);
2473 }
2474 }
2475
2476 static void toolTipsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2477 {
2478 WindowInfo *win;
2479 int state = XmToggleButtonGetState(w);
2480
2481
2482 SetPrefToolTips(state);
2483 for (win=WindowList; win!=
NULL; win=win->next) {
2484 XtVaSetValues(win->tab, XltNshowBubble, GetPrefToolTips(),
NULL);
2485 if (IsTopDocument(win))
2486 XmToggleButtonSetState(win->toolTipsDefItem, state, False);
2487 }
2488 }
2489
2490 static void tabNavigateDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2491 {
2492 WindowInfo *win;
2493 int state = XmToggleButtonGetState(w);
2494
2495
2496 SetPrefGlobalTabNavigate(state);
2497 for (win=WindowList; win!=
NULL; win=win->next) {
2498 if (IsTopDocument(win))
2499 XmToggleButtonSetState(win->tabNavigateDefItem, state, False);
2500 }
2501 }
2502
2503 static void tabSortDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2504 {
2505 WindowInfo *win;
2506 int state = XmToggleButtonGetState(w);
2507
2508
2509 SetPrefSortTabs(state);
2510 for (win=WindowList; win!=
NULL; win=win->next) {
2511 if (IsTopDocument(win))
2512 XmToggleButtonSetState(win->tabSortDefItem, state, False);
2513 }
2514
2515
2516
2517
2518 if (state) {
2519 Widget shell=(Widget)
0;
2520 for (win=WindowList; win!=
NULL; win=win->next) {
2521 if ( win->shell != shell ) {
2522 SortTabBar(win);
2523 shell = win->shell;
2524 }
2525 }
2526 }
2527 }
2528
2529 static void statsLineDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2530 {
2531 WindowInfo *win;
2532 int state = XmToggleButtonGetState(w);
2533
2534
2535 SetPrefStatsLine(state);
2536 for (win=WindowList; win!=
NULL; win=win->next) {
2537 if (IsTopDocument(win))
2538 XmToggleButtonSetState(win->statsLineDefItem, state, False);
2539 }
2540 }
2541
2542 static void iSearchLineDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2543 {
2544 WindowInfo *win;
2545 int state = XmToggleButtonGetState(w);
2546
2547
2548 SetPrefISearchLine(state);
2549 for (win=WindowList; win!=
NULL; win=win->next) {
2550 if (IsTopDocument(win))
2551 XmToggleButtonSetState(win->iSearchLineDefItem, state, False);
2552 }
2553 }
2554
2555 static void lineNumsDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2556 {
2557 WindowInfo *win;
2558 int state = XmToggleButtonGetState(w);
2559
2560
2561 SetPrefLineNums(state);
2562 for (win=WindowList; win!=
NULL; win=win->next) {
2563 if (IsTopDocument(win))
2564 XmToggleButtonSetState(win->lineNumsDefItem, state, False);
2565 }
2566 }
2567
2568 static void pathInWindowsMenuDefCB(Widget w, WindowInfo *window,
caddr_t callData)
2569 {
2570 WindowInfo *win;
2571 int state = XmToggleButtonGetState(w);
2572
2573
2574 SetPrefShowPathInWindowsMenu(state);
2575 for (win=WindowList; win!=
NULL; win=win->next) {
2576 if (IsTopDocument(win))
2577 XmToggleButtonSetState(win->pathInWindowsMenuDefItem, state, False);
2578 }
2579 InvalidateWindowMenus();
2580 }
2581
2582 static void searchLiteralCB(Widget w, WindowInfo *window,
caddr_t callData)
2583 {
2584 WindowInfo *win;
2585
2586
2587 if (XmToggleButtonGetState(w)) {
2588 SetPrefSearch(
SEARCH_LITERAL);
2589 for (win=WindowList; win!=
NULL; win=win->next){
2590 if (!IsTopDocument(win))
2591 continue;
2592 XmToggleButtonSetState(win->searchLiteralDefItem, True, False);
2593 XmToggleButtonSetState(win->searchCaseSenseDefItem, False, False);
2594 XmToggleButtonSetState(win->searchLiteralWordDefItem, False, False);
2595 XmToggleButtonSetState(win->searchCaseSenseWordDefItem, False, False);
2596 XmToggleButtonSetState(win->searchRegexDefItem, False, False);
2597 XmToggleButtonSetState(win->searchRegexNoCaseDefItem, False, False);
2598 }
2599 }
2600 }
2601
2602 static void searchCaseSenseCB(Widget w, WindowInfo *window,
caddr_t callData)
2603 {
2604 WindowInfo *win;
2605
2606
2607 if (XmToggleButtonGetState(w)) {
2608 SetPrefSearch(
SEARCH_CASE_SENSE);
2609 for (win=WindowList; win!=
NULL; win=win->next) {
2610 if (!IsTopDocument(win))
2611 continue;
2612 XmToggleButtonSetState(win->searchLiteralDefItem, False, False);
2613 XmToggleButtonSetState(win->searchCaseSenseDefItem, True, False);
2614 XmToggleButtonSetState(win->searchLiteralWordDefItem, False, False);
2615 XmToggleButtonSetState(win->searchCaseSenseWordDefItem, False, False);
2616 XmToggleButtonSetState(win->searchRegexDefItem, False, False);
2617 XmToggleButtonSetState(win->searchRegexNoCaseDefItem, False, False);
2618 }
2619 }
2620 }
2621
2622 static void searchLiteralWordCB(Widget w, WindowInfo *window,
caddr_t callData)
2623 {
2624 WindowInfo *win;
2625
2626
2627 if (XmToggleButtonGetState(w)) {
2628 SetPrefSearch(
SEARCH_LITERAL_WORD);
2629 for (win=WindowList; win!=
NULL; win=win->next){
2630 if (!IsTopDocument(win))
2631 continue;
2632 XmToggleButtonSetState(win->searchLiteralDefItem, False, False);
2633 XmToggleButtonSetState(win->searchCaseSenseDefItem, False, False);
2634 XmToggleButtonSetState(win->searchLiteralWordDefItem, True, False);
2635 XmToggleButtonSetState(win->searchCaseSenseWordDefItem, False, False);
2636 XmToggleButtonSetState(win->searchRegexDefItem, False, False);
2637 XmToggleButtonSetState(win->searchRegexNoCaseDefItem, False, False);
2638 }
2639 }
2640 }
2641
2642 static void searchCaseSenseWordCB(Widget w, WindowInfo *window,
caddr_t callData)
2643 {
2644 WindowInfo *win;
2645
2646
2647 if (XmToggleButtonGetState(w)) {
2648 SetPrefSearch(
SEARCH_CASE_SENSE_WORD);
2649 for (win=WindowList; win!=
NULL; win=win->next) {
2650 if (!IsTopDocument(win))
2651 continue;
2652 XmToggleButtonSetState(win->searchLiteralDefItem, False, False);
2653 XmToggleButtonSetState(win->searchCaseSenseDefItem, False, False);
2654 XmToggleButtonSetState(win->searchLiteralWordDefItem, False, False);
2655 XmToggleButtonSetState(win->searchCaseSenseWordDefItem, True, False);
2656 XmToggleButtonSetState(win->searchRegexDefItem, False, False);
2657 XmToggleButtonSetState(win->searchRegexNoCaseDefItem, False, False);
2658 }
2659 }
2660 }
2661
2662 static void searchRegexCB(Widget w, WindowInfo *window,
caddr_t callData)
2663 {
2664 WindowInfo *win;
2665
2666
2667 if (XmToggleButtonGetState(w)) {
2668 SetPrefSearch(
SEARCH_REGEX);
2669 for (win=WindowList; win!=
NULL; win=win->next){
2670 if (!IsTopDocument(win))
2671 continue;
2672 XmToggleButtonSetState(win->searchLiteralDefItem, False, False);
2673 XmToggleButtonSetState(win->searchCaseSenseDefItem, False, False);
2674 XmToggleButtonSetState(win->searchLiteralWordDefItem, False, False);
2675 XmToggleButtonSetState(win->searchCaseSenseWordDefItem, False, False);
2676 XmToggleButtonSetState(win->searchRegexDefItem, True, False);
2677 XmToggleButtonSetState(win->searchRegexNoCaseDefItem, False, False);
2678 }
2679 }
2680 }
2681
2682 static void searchRegexNoCaseCB(Widget w, WindowInfo *window,
caddr_t callData)
2683 {
2684 WindowInfo *win;
2685
2686
2687 if (XmToggleButtonGetState(w)) {
2688 SetPrefSearch(
SEARCH_REGEX_NOCASE);
2689 for (win=WindowList; win!=
NULL; win=win->next){
2690 if (!IsTopDocument(win))
2691 continue;
2692 XmToggleButtonSetState(win->searchLiteralDefItem, False, False);
2693 XmToggleButtonSetState(win->searchCaseSenseDefItem, False, False);
2694 XmToggleButtonSetState(win->searchLiteralWordDefItem, False, False);
2695 XmToggleButtonSetState(win->searchCaseSenseWordDefItem, False, False);
2696 XmToggleButtonSetState(win->searchRegexDefItem, False, False);
2697 XmToggleButtonSetState(win->searchRegexNoCaseDefItem, True, False);
2698 }
2699 }
2700 }
2701
2702 #ifdef REPLACE_SCOPE
2703 static void replaceScopeWindowCB(Widget w, WindowInfo *window,
caddr_t callData)
2704 {
2705 WindowInfo *win;
2706
2707
2708 if (XmToggleButtonGetState(w)) {
2709 SetPrefReplaceDefScope(
REPL_DEF_SCOPE_WINDOW);
2710 for (win=WindowList; win!=
NULL; win=win->next){
2711 if (!IsTopDocument(win))
2712 continue;
2713 XmToggleButtonSetState(win->replScopeWinDefItem, True, False);
2714 XmToggleButtonSetState(win->replScopeSelDefItem, False, False);
2715 XmToggleButtonSetState(win->replScopeSmartDefItem, False, False);
2716 }
2717 }
2718 }
2719
2720 static void replaceScopeSelectionCB(Widget w, WindowInfo *window,
caddr_t callData)
2721 {
2722 WindowInfo *win;
2723
2724
2725 if (XmToggleButtonGetState(w)) {
2726 SetPrefReplaceDefScope(
REPL_DEF_SCOPE_SELECTION);
2727 for (win=WindowList; win!=
NULL; win=win->next){
2728 if (!IsTopDocument(win))
2729 continue;
2730 XmToggleButtonSetState(win->replScopeWinDefItem, False, False);
2731 XmToggleButtonSetState(win->replScopeSelDefItem, True, False);
2732 XmToggleButtonSetState(win->replScopeSmartDefItem, False, False);
2733 }
2734 }
2735 }
2736
2737 static void replaceScopeSmartCB(Widget w, WindowInfo *window,
caddr_t callData)
2738 {
2739 WindowInfo *win;
2740
2741
2742 if (XmToggleButtonGetState(w)) {
2743 SetPrefReplaceDefScope(
REPL_DEF_SCOPE_SMART);
2744 for (win=WindowList; win!=
NULL; win=win->next){
2745 if (!IsTopDocument(win))
2746 continue;
2747 XmToggleButtonSetState(win->replScopeWinDefItem, False, False);
2748 XmToggleButtonSetState(win->replScopeSelDefItem, False, False);
2749 XmToggleButtonSetState(win->replScopeSmartDefItem, True, False);
2750 }
2751 }
2752 }
2753 #endif
2754
2755 static void size24x80CB(Widget w, WindowInfo *window,
caddr_t callData)
2756 {
2757 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2758 ((XmAnyCallbackStruct *)callData)->event);
2759 setWindowSizeDefault(
24,
80);
2760 }
2761
2762 static void size40x80CB(Widget w, WindowInfo *window,
caddr_t callData)
2763 {
2764 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2765 ((XmAnyCallbackStruct *)callData)->event);
2766 setWindowSizeDefault(
40,
80);
2767 }
2768
2769 static void size60x80CB(Widget w, WindowInfo *window,
caddr_t callData)
2770 {
2771 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2772 ((XmAnyCallbackStruct *)callData)->event);
2773 setWindowSizeDefault(
60,
80);
2774 }
2775
2776 static void size80x80CB(Widget w, WindowInfo *window,
caddr_t callData)
2777 {
2778 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2779 ((XmAnyCallbackStruct *)callData)->event);
2780 setWindowSizeDefault(
80,
80);
2781 }
2782
2783 static void sizeCustomCB(Widget w, WindowInfo *window,
caddr_t callData)
2784 {
2785 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2786 ((XmAnyCallbackStruct *)callData)->event);
2787 RowColumnPrefDialog(WidgetToWindow(
MENU_WIDGET(w))->shell);
2788 updateWindowSizeMenus();
2789 }
2790
2791 static void savePrefCB(Widget w, WindowInfo *window,
caddr_t callData)
2792 {
2793 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2794 ((XmAnyCallbackStruct *)callData)->event);
2795 SaveNEditPrefs(WidgetToWindow(
MENU_WIDGET(w))->shell, False);
2796 }
2797
2798 static void formFeedCB(Widget w, XtPointer clientData, XtPointer callData)
2799 {
2800 static char *params[
1] = {
"\f"};
2801
2802 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2803 ((XmAnyCallbackStruct *)callData)->event);
2804 XtCallActionProc(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
"insert_string",
2805 ((XmAnyCallbackStruct *)callData)->event, params,
1);
2806 }
2807
2808 static void cancelShellCB(Widget w, WindowInfo *window, XtPointer callData)
2809 {
2810 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2811 ((XmAnyCallbackStruct *)callData)->event);
2812 AbortShellCommand(WidgetToWindow(
MENU_WIDGET(w)));
2813 }
2814
2815 static void learnCB(Widget w, WindowInfo *window,
caddr_t callData)
2816 {
2817 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2818 ((XmAnyCallbackStruct *)callData)->event);
2819 BeginLearn(WidgetToWindow(
MENU_WIDGET(w)));
2820 }
2821
2822 static void finishLearnCB(Widget w, WindowInfo *window,
caddr_t callData)
2823 {
2824 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2825 ((XmAnyCallbackStruct *)callData)->event);
2826 FinishLearn();
2827 }
2828
2829 static void cancelLearnCB(Widget w, WindowInfo *window,
caddr_t callData)
2830 {
2831 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2832 ((XmAnyCallbackStruct *)callData)->event);
2833 CancelMacroOrLearn(WidgetToWindow(
MENU_WIDGET(w)));
2834 }
2835
2836 static void replayCB(Widget w, WindowInfo *window,
caddr_t callData)
2837 {
2838 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
2839 ((XmAnyCallbackStruct *)callData)->event);
2840 Replay(WidgetToWindow(
MENU_WIDGET(w)));
2841 }
2842
2843 static void windowMenuCB(Widget w, WindowInfo *window,
caddr_t callData)
2844 {
2845 window = WidgetToWindow(
MENU_WIDGET(w));
2846
2847 if (!window->windowMenuValid) {
2848 updateWindowMenu(window);
2849 window->windowMenuValid = True;
2850 }
2851 }
2852
2853 static void prevOpenMenuCB(Widget w, WindowInfo *window,
caddr_t callData)
2854 {
2855 window = WidgetToWindow(
MENU_WIDGET(w));
2856
2857 updatePrevOpenMenu(window);
2858 }
2859
2860 static void unloadTagsFileMenuCB(Widget w, WindowInfo *window,
caddr_t callData)
2861 {
2862 updateTagsFileMenu(WidgetToWindow(
MENU_WIDGET(w)));
2863 }
2864
2865 static void unloadTipsFileMenuCB(Widget w, WindowInfo *window,
caddr_t callData)
2866 {
2867 updateTipsFileMenu(WidgetToWindow(
MENU_WIDGET(w)));
2868 }
2869
2870
2871
2872
2873 static void newAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
2874 {
2875 WindowInfo *window = WidgetToWindow(w);
2876 int openInTab = GetPrefOpenInTab();
2877
2878 if (*nArgs >
0) {
2879 if (strcmp(args[
0],
"prefs") ==
0) {
2880 ;
2881 }
2882 else if (strcmp(args[
0],
"tab") ==
0) {
2883 openInTab =
1;
2884 }
2885 else if (strcmp(args[
0],
"window") ==
0) {
2886 openInTab =
0;
2887 }
2888 else if (strcmp(args[
0],
"opposite") ==
0) {
2889 openInTab = !openInTab;
2890 }
2891 else {
2892 fprintf(stderr,
"xnedit: Unknown argument to action procedure \"new\": %s\n", args[
0]);
2893 }
2894 }
2895
2896 EditNewFile(openInTab? window :
NULL,
NULL, False,
NULL, window->path);
2897 CheckCloseDim();
2898 }
2899
2900
2901
2902
2903
2904
2905 static void newOppositeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
2906 {
2907 WindowInfo *window = WidgetToWindow(w);
2908
2909 EditNewFile(GetPrefOpenInTab()?
NULL : window,
NULL, False,
NULL,
2910 window->path);
2911 CheckCloseDim();
2912 }
2913 static void newTabAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
2914 {
2915 WindowInfo *window = WidgetToWindow(w);
2916
2917 EditNewFile(window,
NULL, False,
NULL, window->path);
2918 CheckCloseDim();
2919 }
2920
2921 static void openDialogAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
2922 {
2923 WindowInfo *window = WidgetToWindow(w);
2924 FileSelection file = {
NULL,
NULL,
NULL, True };
2925 char *params[
4];
2926 int response;
2927
2928 response = PromptForExistingFile(window,
"Open File", &file);
2929 if (response !=
GFN_OK)
2930 return;
2931 params[
0] = file.path;
2932
2933
2934
2935
2936 params[
1] = file.encoding;
2937 params[
2] = file.filter;
2938
2939 XtCallActionProc(window->lastFocus,
"open", event, params,
3);
2940 NEditFree(file.path);
2941 NEditFree(file.filter);
2942 CheckCloseDim();
2943 }
2944
2945 static void openAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
2946 {
2947 WindowInfo *window = WidgetToWindow(w);
2948 char *enc =
NULL;
2949 char *filter =
NULL;
2950
2951 if (*nArgs ==
0) {
2952 fprintf(stderr,
"xnedit: open action requires file argument\n");
2953 return;
2954 }
2955 if(*nArgs >
1) {
2956 enc = args[
1];
2957 }
2958 if(*nArgs >
2) {
2959 filter = args[
2];
2960 }
2961
2962
2963
2964 char *name = FileName(args[
0]);
2965 char *dirpath = ParentPath(args[
0]);
2966
2967 EditExistingFile(window, name, dirpath, enc, filter,
0,
NULL, False,
2968 NULL, GetPrefOpenInTab(), False);
2969 CheckCloseDim();
2970
2971 NEditFree(dirpath);
2972 }
2973
2974 static void openSelectedAP(Widget w, XEvent *event, String *args,
2975 Cardinal *nArgs)
2976 {
2977 OpenSelectedFile(WidgetToWindow(w), event->xbutton.time);
2978 CheckCloseDim();
2979 }
2980
2981 static void closeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
2982 {
2983 int preResponse =
PROMPT_SBC_DIALOG_RESPONSE;
2984
2985 if (*nArgs >
0) {
2986 if (strcmp(args[
0],
"prompt") ==
0) {
2987 preResponse =
PROMPT_SBC_DIALOG_RESPONSE;
2988 }
2989 else if (strcmp(args[
0],
"save") ==
0) {
2990 preResponse =
YES_SBC_DIALOG_RESPONSE;
2991 }
2992 else if (strcmp(args[
0],
"nosave") ==
0) {
2993 preResponse =
NO_SBC_DIALOG_RESPONSE;
2994 }
2995 }
2996 CloseFileAndWindow(WidgetToWindow(w), preResponse);
2997 CheckCloseDim();
2998 }
2999
3000 static void saveAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3001 {
3002 WindowInfo *window = WidgetToWindow(w);
3003
3004 if (CheckReadOnly(window))
3005 return;
3006 SaveWindow(window);
3007 }
3008
3009 static void saveAsDialogAP(Widget w, XEvent *event, String *args,
3010 Cardinal *nArgs)
3011 {
3012 WindowInfo *window = WidgetToWindow(w);
3013 int response, fileFormat;
3014 char *params[
8];
3015
3016 FileSelection file;
3017 memset(&file,
0,
sizeof(FileSelection));
3018 file.extraoptions = True;
3019 file.writebom = window->bom;
3020 file.format = window->fileFormat;
3021 if(strlen(window->encoding) >
0) {
3022 file.encoding = window->encoding;
3023 }
3024 file.filter = window->filter;
3025 response = PromptForNewFile(window,
"Save File As", &file,
3026 &fileFormat);
3027 if (response !=
GFN_OK)
3028 return;
3029 window->fileFormat = fileFormat;
3030
3031 char *formatStr;
3032 switch(file.format) {
3033 default:
3034 case UNIX_FILE_FORMAT: formatStr =
"0";
break;
3035 case DOS_FILE_FORMAT: formatStr =
"1";
break;
3036 case MAC_FILE_FORMAT: formatStr =
"2";
break;
3037 }
3038
3039 params[
0] = file.path;
3040 params[
1] = file.writebom ?
"writebom" :
"";
3041 params[
2] = file.setxattr ?
"setxattr" :
"";
3042 params[
3] = file.addwrap ?
"wrapped" :
"";
3043 params[
4] = formatStr;
3044 params[
5] = file.encoding;
3045 params[
6] = file.filter;
3046 XtCallActionProc(window->lastFocus,
"save_as", event, params,
7);
3047 NEditFree(file.path);
3048 NEditFree(file.filter);
3049 }
3050
3051 static void saveAsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3052 {
3053 if (*nArgs ==
0) {
3054 fprintf(stderr,
"xnedit: save_as action requires file argument\n");
3055 return;
3056 }
3057 FileSelection file;
3058 memset(&file,
0,
sizeof(FileSelection));
3059 file.path = args[
0];
3060 file.writebom = *nArgs >
1 && !strcasecmp(args[
1],
"writebom") ?
1 :
0;
3061 file.setxattr = *nArgs >
2 && !strcasecmp(args[
2],
"setxattr") ?
1 :
0;
3062 file.addwrap = *nArgs >
3 && !strcasecmp(args[
3],
"wrapped") ?
1 :
0;
3063 file.format = *nArgs >
4 ? atoi(args[
4]) :
UNIX_FILE_FORMAT;
3064 file.encoding = *nArgs >
5 ? args[
5] :
NULL;
3065 file.filter = *nArgs >
6 ? args[
6] :
NULL;
3066 SaveWindowAs(WidgetToWindow(w), &file);
3067 }
3068
3069 static void revertDialogAP(Widget w, XEvent *event, String *args,
3070 Cardinal *nArgs)
3071 {
3072 WindowInfo *window = WidgetToWindow(w);
3073 int b;
3074
3075
3076 if (window->fileChanged)
3077 {
3078 b = DialogF(
DF_QUES, window->shell,
3,
"Reload File",
3079 "Re-load file and discard changes to\n%s%s?",
"Re-read",
"Change encoding",
"Cancel", window->path,
3080 window->filename);
3081 }
else
3082 {
3083 b = DialogF(
DF_QUES, window->shell,
3,
"Reload File",
3084 "Re-load file\n%s%s?",
"Re-read",
"Change encoding",
"Cancel", window->path,
3085 window->filename);
3086 }
3087
3088 if(b ==
1) {
3089
3090 XtCallActionProc(window->lastFocus,
"revert_to_saved", event,
NULL,
0);
3091 }
else if(b ==
2) {
3092
3093 ShowEncodingInfoBar(window,
TRUE);
3094 }
3095 }
3096
3097
3098 static void revertAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3099 {
3100 RevertToSaved(WidgetToWindow(w),
NULL);
3101 }
3102
3103 static void includeDialogAP(Widget w, XEvent *event, String *args,
3104 Cardinal *nArgs)
3105 {
3106 WindowInfo *window = WidgetToWindow(w);
3107 FileSelection file = {
NULL,
NULL,
NULL, True };
3108 char *params[
4];
3109 int response;
3110 int n =
3;
3111
3112 if (CheckReadOnly(window))
3113 return;
3114 response = PromptForExistingFile(window,
"Include File", &file);
3115 if (response !=
GFN_OK)
3116 return;
3117 params[
0] = file.path;
3118 params[
1] = file.encoding;
3119 params[
2] = file.filter;
3120 XtCallActionProc(window->lastFocus,
"include_file", event, params, n);
3121 NEditFree(file.path);
3122 NEditFree(file.filter);
3123 }
3124
3125 static void includeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3126 {
3127 WindowInfo *window = WidgetToWindow(w);
3128
3129 if (CheckReadOnly(window))
3130 return;
3131 if (*nArgs ==
0) {
3132 fprintf(stderr,
"xnedit: include action requires file argument\n");
3133 return;
3134 }
3135 char *encoding = *nArgs >
1 ? args[
1] :
NULL;
3136 char *filter = *nArgs >
2 ? args[
2] :
NULL;
3137 IncludeFile(WidgetToWindow(w), args[
0], encoding, filter);
3138 }
3139
3140 static void loadMacroDialogAP(Widget w, XEvent *event, String *args,
3141 Cardinal *nArgs)
3142 {
3143 WindowInfo *window = WidgetToWindow(w);
3144 FileSelection file = {
NULL,
NULL,
NULL, False };
3145 char *params[
1];
3146 int response;
3147
3148 response = PromptForExistingFile(window,
"Load Macro File", &file);
3149 if (response !=
GFN_OK)
3150 return;
3151 params[
0] = file.path;
3152 XtCallActionProc(window->lastFocus,
"load_macro_file", event, params,
1);
3153 NEditFree(file.path);
3154 NEditFree(file.filter);
3155 }
3156
3157 static void loadMacroAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3158 {
3159 if (*nArgs ==
0) {
3160 fprintf(stderr,
"xnedit: load_macro_file action requires file argument\n");
3161 return;
3162 }
3163 ReadMacroFile(WidgetToWindow(w), args[
0], True);
3164 }
3165
3166 static void loadTagsDialogAP(Widget w, XEvent *event, String *args,
3167 Cardinal *nArgs)
3168 {
3169 WindowInfo *window = WidgetToWindow(w);
3170 FileSelection file = {
NULL,
NULL,
NULL, False };
3171 char *params[
1];
3172 int response;
3173
3174 response = PromptForExistingFile(window,
"Load Tags File", &file);
3175 if (response !=
GFN_OK)
3176 return;
3177 params[
0] = file.path;
3178 XtCallActionProc(window->lastFocus,
"load_tags_file", event, params,
1);
3179 NEditFree(file.path);
3180 NEditFree(file.filter);
3181 }
3182
3183 static void loadTagsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3184 {
3185 if (*nArgs ==
0) {
3186 fprintf(stderr,
"xnedit: load_tags_file action requires file argument\n");
3187 return;
3188 }
3189
3190 if (!AddTagsFile(args[
0],
TAG))
3191 {
3192 DialogF(
DF_WARN, WidgetToWindow(w)->shell,
1,
"Error Reading File",
3193 "Error reading ctags file:\n''%s''\ntags not loaded",
"OK",
3194 args[
0]);
3195 }
3196 }
3197
3198 static void unloadTagsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3199 {
3200 if (*nArgs ==
0) {
3201 fprintf(stderr,
3202 "xnedit: unload_tags_file action requires file argument\n");
3203 return;
3204 }
3205
3206 if (DeleteTagsFile(args[
0],
TAG, True)) {
3207 WindowInfo *win;
3208
3209
3210
3211 for (win=WindowList; win!=
NULL; win=win->next) {
3212 if (IsTopDocument(win) &&
3213 !XmIsMenuShell(XtParent(win->unloadTagsMenuPane))) {
3214 if (XtIsSensitive(win->unloadTagsMenuItem))
3215 updateTagsFileMenu(win);
3216 else
3217 _XmDismissTearOff(XtParent(win->unloadTagsMenuPane),
3218 NULL,
NULL);
3219 }
3220 }
3221 }
3222 }
3223
3224 static void loadTipsDialogAP(Widget w, XEvent *event, String *args,
3225 Cardinal *nArgs)
3226 {
3227 WindowInfo *window = WidgetToWindow(w);
3228 FileSelection file = {
NULL,
NULL,
NULL, False };
3229 char *params[
1];
3230 int response;
3231
3232 response = PromptForExistingFile(window,
"Load Calltips File", &file);
3233 if (response !=
GFN_OK)
3234 return;
3235 params[
0] = file.path;
3236 XtCallActionProc(window->lastFocus,
"load_tips_file", event, params,
1);
3237 NEditFree(file.path);
3238 NEditFree(file.filter);
3239 }
3240
3241 static void loadTipsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3242 {
3243 if (*nArgs ==
0) {
3244 fprintf(stderr,
"xnedit: load_tips_file action requires file argument\n");
3245 return;
3246 }
3247
3248 if (!AddTagsFile(args[
0],
TIP))
3249 {
3250 DialogF(
DF_WARN, WidgetToWindow(w)->shell,
1,
"Error Reading File",
3251 "Error reading tips file:\n''%s''\ntips not loaded",
"OK",
3252 args[
0]);
3253 }
3254 }
3255
3256 static void unloadTipsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3257 {
3258 if (*nArgs ==
0) {
3259 fprintf(stderr,
3260 "xnedit: unload_tips_file action requires file argument\n");
3261 return;
3262 }
3263
3264
3265 if (DeleteTagsFile(args[
0],
TIP, True)) {
3266 WindowInfo *win;
3267
3268 for (win=WindowList; win!=
NULL; win=win->next) {
3269 if (IsTopDocument(win) &&
3270 !XmIsMenuShell(XtParent(win->unloadTipsMenuPane))) {
3271 if (XtIsSensitive(win->unloadTipsMenuItem))
3272 updateTipsFileMenu(win);
3273 else
3274 _XmDismissTearOff(XtParent(win->unloadTipsMenuPane),
3275 NULL,
NULL);
3276 }
3277 }
3278 }
3279 }
3280
3281 static void printAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3282 {
3283 PrintWindow(WidgetToWindow(w), False);
3284 }
3285
3286 static void printSelAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3287 {
3288 PrintWindow(WidgetToWindow(w), True);
3289 }
3290
3291 static void exitAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3292 {
3293 WindowInfo *window = WidgetToWindow(w);
3294
3295 if (!CheckPrefsChangesSaved(window->shell))
3296 return;
3297
3298
3299
3300 if (GetPrefWarnExit() && !(window == WindowList && window->next ==
NULL)) {
3301 int resp, titleLen, lineLen;
3302 char exitMsg[
DF_MAX_MSG_LENGTH], *ptr, *title;
3303 char filename[
MAXPATHLEN +
1];
3304 WindowInfo *win;
3305
3306
3307
3308 ptr = exitMsg;
3309 lineLen =
0;
3310 strcpy(ptr,
"Editing: "); ptr +=
9; lineLen +=
9;
3311 for (win=WindowList; win!=
NULL; win=win->next) {
3312 snprintf(filename,
sizeof(filename),
3313 "%s%s", win->filename, win->fileChanged?
"*":
"");
3314 title = filename;
3315 titleLen = strlen(title);
3316 if (ptr - exitMsg + titleLen +
30 >=
DF_MAX_MSG_LENGTH) {
3317 strcpy(ptr,
"..."); ptr +=
3;
3318 break;
3319 }
3320 if (lineLen + titleLen + (win->next==
NULL?
5:
2) >
50) {
3321 *ptr++ =
'\n';
3322 lineLen =
0;
3323 }
3324 if (win->next ==
NULL) {
3325 sprintf(ptr,
"and %s.", title);
3326 ptr +=
5 + titleLen;
3327 lineLen +=
5 + titleLen;
3328 }
else {
3329 sprintf(ptr,
"%s, ", title);
3330 ptr +=
2 + titleLen;
3331 lineLen +=
2 + titleLen;
3332 }
3333 }
3334 sprintf(ptr,
"\n\nExit NEdit?");
3335 resp = DialogF(
DF_QUES, window->shell,
2,
"Exit",
"%s",
"Exit",
3336 "Cancel", exitMsg);
3337 if (resp ==
2)
3338 return;
3339 }
3340
3341
3342 if (CloseAllFilesAndWindows()) {
3343 exit(
EXIT_SUCCESS);
3344 }
3345 }
3346
3347 static void undoAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3348 {
3349 WindowInfo *window = WidgetToWindow(w);
3350
3351 if (CheckReadOnly(window))
3352 return;
3353 Undo(window);
3354 }
3355
3356 static void redoAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3357 {
3358 WindowInfo *window = WidgetToWindow(w);
3359
3360 if (CheckReadOnly(window))
3361 return;
3362 Redo(window);
3363 }
3364
3365 static void clearAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3366 {
3367 WindowInfo *window = WidgetToWindow(w);
3368
3369 if (CheckReadOnly(window))
3370 return;
3371 BufRemoveSelected(window->buffer);
3372 }
3373
3374 static void selAllAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3375 {
3376 WindowInfo *window = WidgetToWindow(w);
3377
3378 BufSelect(window->buffer,
0, window->buffer->length);
3379 }
3380
3381 static void shiftLeftAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3382 {
3383 WindowInfo *window = WidgetToWindow(w);
3384
3385 if (CheckReadOnly(window))
3386 return;
3387 ShiftSelection(window,
SHIFT_LEFT, False);
3388 }
3389
3390 static void shiftLeftTabAP(Widget w, XEvent *event, String *args,
3391 Cardinal *nArgs)
3392 {
3393 WindowInfo *window = WidgetToWindow(w);
3394
3395 if (CheckReadOnly(window))
3396 return;
3397 ShiftSelection(window,
SHIFT_LEFT, True);
3398 }
3399
3400 static void shiftRightAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3401 {
3402 WindowInfo *window = WidgetToWindow(w);
3403
3404 if (CheckReadOnly(window))
3405 return;
3406 ShiftSelection(window,
SHIFT_RIGHT, False);
3407 }
3408
3409 static void shiftRightTabAP(Widget w, XEvent *event, String *args,
3410 Cardinal *nArgs)
3411 {
3412 WindowInfo *window = WidgetToWindow(w);
3413
3414 if (CheckReadOnly(window))
3415 return;
3416 ShiftSelection(window,
SHIFT_RIGHT, True);
3417 }
3418
3419 static void findDialogAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3420 {
3421 DoFindDlog(WidgetToWindow(w), searchDirection(
0, args, nArgs),
3422 searchKeepDialogs(
0, args, nArgs), searchType(
0, args, nArgs),
3423 event->xbutton.time);
3424 }
3425
3426 static void findAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3427 {
3428 if (*nArgs ==
0) {
3429 fprintf(stderr,
"xnedit: find action requires search string argument\n");
3430 return;
3431 }
3432 SearchAndSelect(WidgetToWindow(w), searchDirection(
1, args, nArgs), args[
0],
3433 searchType(
1, args, nArgs), searchWrap(
1, args, nArgs));
3434 }
3435
3436 static void findSameAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3437 {
3438 SearchAndSelectSame(WidgetToWindow(w), searchDirection(
0, args, nArgs),
3439 searchWrap(
0, args, nArgs));
3440 }
3441
3442 static void findSelAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3443 {
3444 SearchForSelected(WidgetToWindow(w), searchDirection(
0, args, nArgs),
3445 searchType(
0, args, nArgs), searchWrap(
0, args, nArgs),
3446 event->xbutton.time);
3447 }
3448
3449 static void startIncrFindAP(Widget w, XEvent *event, String *args,
3450 Cardinal *nArgs)
3451 {
3452 BeginISearch(WidgetToWindow(w), searchDirection(
0, args, nArgs));
3453 }
3454
3455 static void findIncrAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3456 {
3457 int i, continued =
FALSE;
3458 if (*nArgs ==
0) {
3459 fprintf(stderr,
"xnedit: find action requires search string argument\n");
3460 return;
3461 }
3462 for (i=
1; i<(
int)*nArgs; i++)
3463 if (!strcasecmp(args[i],
"continued"))
3464 continued =
TRUE;
3465 SearchAndSelectIncremental(WidgetToWindow(w),
3466 searchDirection(
1, args, nArgs), args[
0],
3467 searchType(
1, args, nArgs), searchWrap(
1, args, nArgs), continued);
3468 }
3469
3470 static void replaceDialogAP(Widget w, XEvent *event, String *args,
3471 Cardinal *nArgs)
3472 {
3473 WindowInfo *window = WidgetToWindow(w);
3474
3475 if (CheckReadOnly(window))
3476 return;
3477 DoFindReplaceDlog(window, searchDirection(
0, args, nArgs),
3478 searchKeepDialogs(
0, args, nArgs), searchType(
0, args, nArgs),
3479 event->xbutton.time);
3480 }
3481
3482 static void replaceAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3483 {
3484 WindowInfo *window = WidgetToWindow(w);
3485
3486 if (CheckReadOnly(window))
3487 return;
3488 if (*nArgs <
2) {
3489 fprintf(stderr,
3490 "xnedit: replace action requires search and replace string arguments\n");
3491 return;
3492 }
3493 SearchAndReplace(window, searchDirection(
2, args, nArgs),
3494 args[
0], args[
1], searchType(
2, args, nArgs), searchWrap(
2, args, nArgs));
3495 }
3496
3497 static void replaceAllAP(Widget w, XEvent *event, String *args,
3498 Cardinal *nArgs)
3499 {
3500 WindowInfo *window = WidgetToWindow(w);
3501
3502 if (CheckReadOnly(window))
3503 return;
3504 if (*nArgs <
2) {
3505 fprintf(stderr,
3506 "xnedit: replace_all action requires search and replace string arguments\n");
3507 return;
3508 }
3509 ReplaceAll(window, args[
0], args[
1], searchType(
2, args, nArgs));
3510 }
3511
3512 static void replaceInSelAP(Widget w, XEvent *event, String *args,
3513 Cardinal *nArgs)
3514 {
3515 WindowInfo *window = WidgetToWindow(w);
3516
3517 if (CheckReadOnly(window))
3518 return;
3519 if (*nArgs <
2) {
3520 fprintf(stderr,
3521 "xnedit: replace_in_selection requires search and replace string arguments\n");
3522 return;
3523 }
3524 ReplaceInSelection(window, args[
0], args[
1],
3525 searchType(
2, args, nArgs));
3526 }
3527
3528 static void replaceSameAP(Widget w, XEvent *event, String *args,
3529 Cardinal *nArgs)
3530 {
3531 WindowInfo *window = WidgetToWindow(w);
3532
3533 if (CheckReadOnly(window))
3534 return;
3535 ReplaceSame(window, searchDirection(
0, args, nArgs), searchWrap(
0, args, nArgs));
3536 }
3537
3538 static void replaceFindAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3539 {
3540 WindowInfo *window = WidgetToWindow(w);
3541
3542 if (CheckReadOnly(window))
3543 {
3544 return;
3545 }
3546
3547 if (*nArgs <
2)
3548 {
3549 DialogF(
DF_WARN, window->shell,
1,
"Error in replace_find",
3550 "replace_find action requires search and replace string arguments",
3551 "OK");
3552 return;
3553 }
3554
3555 ReplaceAndSearch(window, searchDirection(
2, args, nArgs), args[
0], args[
1],
3556 searchType(
2, args, nArgs), searchWrap(
0, args, nArgs));
3557 }
3558
3559 static void replaceFindSameAP(Widget w, XEvent *event, String *args,
3560 Cardinal *nArgs)
3561 {
3562 WindowInfo *window = WidgetToWindow(w);
3563
3564 if (CheckReadOnly(window))
3565 return;
3566 ReplaceFindSame(window, searchDirection(
0, args, nArgs), searchWrap(
0, args, nArgs));
3567 }
3568
3569 static void gotoAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3570 {
3571 int lineNum, column, position, curCol;
3572
3573
3574
3575
3576
3577 if (*nArgs ==
0 || *nArgs >
2
3578 || (*nArgs ==
1
3579 && StringToLineAndCol(args[
0], &lineNum, &column ) == -
1)
3580 || (*nArgs ==
2
3581 && (!StringToNum(args[
0], &lineNum)
3582 || !StringToNum(args[
1], &column)))) {
3583 fprintf(stderr,
"xnedit: goto_line_number action requires line and/or column number\n");
3584 return;
3585 }
3586
3587
3588 if (lineNum == -
1) {
3589 position = TextGetCursorPos(w);
3590 if (TextPosToLineAndCol(w, position, &lineNum, &curCol) == False) {
3591 return;
3592 }
3593 }
else if ( column == -
1 ) {
3594
3595 SelectNumberedLine(WidgetToWindow(w), lineNum);
3596 return;
3597 }
3598
3599 position = TextLineAndColToPos(w, lineNum, column );
3600 if ( position == -
1 ) {
3601 return;
3602 }
3603
3604 TextSetCursorPos(w, position);
3605 return;
3606 }
3607
3608 static void gotoDialogAP(Widget w, XEvent *event, String *args,
3609 Cardinal *nArgs)
3610 {
3611 GotoLineNumber(WidgetToWindow(w));
3612 }
3613
3614 static void gotoSelectedAP(Widget w, XEvent *event, String *args,
3615 Cardinal *nArgs)
3616 {
3617 GotoSelectedLineNumber(WidgetToWindow(w), event->xbutton.time);
3618 }
3619
3620 static void repeatDialogAP(Widget w, XEvent *event, String *args,
3621 Cardinal *nArgs)
3622 {
3623 RepeatDialog(WidgetToWindow(w));
3624 }
3625
3626 static void repeatMacroAP(Widget w, XEvent *event, String *args,
3627 Cardinal *nArgs)
3628 {
3629 int how;
3630
3631 if (*nArgs !=
2) {
3632 fprintf(stderr,
"xnedit: repeat_macro requires two arguments\n");
3633 return;
3634 }
3635 if (!strcmp(args[
0],
"in_selection"))
3636 how =
REPEAT_IN_SEL;
3637 else if (!strcmp(args[
0],
"to_end"))
3638 how =
REPEAT_TO_END;
3639 else if (sscanf(args[
0],
"%d", &how) !=
1) {
3640 fprintf(stderr,
"xnedit: repeat_macro requires method/count\n");
3641 return;
3642 }
3643 RepeatMacro(WidgetToWindow(w), args[
1], how);
3644 }
3645
3646 static void markAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3647 {
3648 if (*nArgs ==
0 || strlen(args[
0]) !=
1 ||
3649 !isalnum((
unsigned char)args[
0][
0])) {
3650 fprintf(stderr,
"xnedit: mark action requires a single-letter label\n");
3651 return;
3652 }
3653 AddMark(WidgetToWindow(w), w, args[
0][
0]);
3654 }
3655
3656 static void markDialogAP(Widget w, XEvent *event, String *args,
3657 Cardinal *nArgs)
3658 {
3659 MarkDialog(WidgetToWindow(w));
3660 }
3661
3662 static void gotoMarkAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3663 {
3664 if (*nArgs ==
0 || strlen(args[
0]) !=
1 ||
3665 !isalnum((
unsigned char)args[
0][
0])) {
3666 fprintf(stderr,
3667 "xnedit: goto_mark action requires a single-letter label\n");
3668 return;
3669 }
3670 GotoMark(WidgetToWindow(w), w, args[
0][
0], *nArgs >
1 &&
3671 !strcmp(args[
1],
"extend"));
3672 }
3673
3674 static void gotoMarkDialogAP(Widget w, XEvent *event, String *args,
3675 Cardinal *nArgs)
3676 {
3677 GotoMarkDialog(WidgetToWindow(w), *nArgs!=
0 && !strcmp(args[
0],
"extend"));
3678 }
3679
3680 static void selectToMatchingAP(Widget w, XEvent *event, String *args,
3681 Cardinal *nArgs)
3682 {
3683 SelectToMatchingCharacter(WidgetToWindow(w));
3684 }
3685
3686 static void gotoMatchingAP(Widget w, XEvent *event, String *args,
3687 Cardinal *nArgs)
3688 {
3689 GotoMatchingCharacter(WidgetToWindow(w));
3690 }
3691
3692 static void findDefAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3693 {
3694 FindDefinition(WidgetToWindow(w), event->xbutton.time,
3695 *nArgs ==
0 ?
NULL : args[
0]);
3696 }
3697
3698 static void showTipAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3699 {
3700 FindDefCalltip(WidgetToWindow(w), event->xbutton.time,
3701 *nArgs ==
0 ?
NULL : args[
0]);
3702 }
3703
3704 static void splitPaneAP(Widget w, XEvent *event, String *args,
3705 Cardinal *nArgs)
3706 {
3707 WindowInfo *window = WidgetToWindow(w);
3708
3709 SplitPane(window);
3710 if (IsTopDocument(window)) {
3711 XtSetSensitive(window->splitPaneItem, window->nPanes <
MAX_PANES);
3712 XtSetSensitive(window->closePaneItem, window->nPanes >
0);
3713 }
3714 }
3715
3716 static void closePaneAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3717 {
3718 WindowInfo *window = WidgetToWindow(w);
3719
3720 ClosePane(window);
3721 if (IsTopDocument(window)) {
3722 XtSetSensitive(window->splitPaneItem, window->nPanes <
MAX_PANES);
3723 XtSetSensitive(window->closePaneItem, window->nPanes >
0);
3724 }
3725 }
3726
3727 static void detachDocumentDialogAP(Widget w, XEvent *event, String *args,
3728 Cardinal *nArgs)
3729 {
3730 WindowInfo *window = WidgetToWindow(w);
3731 int resp;
3732
3733 if (NDocuments(window) <
2)
3734 return;
3735
3736 resp = DialogF(
DF_QUES, window->shell,
2,
"Detach %s?",
3737 "Detach",
"Cancel", window->filename);
3738
3739 if (resp ==
1)
3740 DetachDocument(window);
3741 }
3742
3743 static void detachDocumentAP(Widget w, XEvent *event, String *args,
3744 Cardinal *nArgs)
3745 {
3746 WindowInfo *window = WidgetToWindow(w);
3747
3748 if (NDocuments(window) <
2)
3749 return;
3750
3751 DetachDocument(window);
3752 }
3753
3754 static void moveDocumentDialogAP(Widget w, XEvent *event, String *args,
3755 Cardinal *nArgs)
3756 {
3757 MoveDocumentDialog(WidgetToWindow(w));
3758 }
3759
3760 static void nextDocumentAP(Widget w, XEvent *event, String *args,
3761 Cardinal *nArgs)
3762 {
3763 NextDocument(WidgetToWindow(w));
3764 }
3765
3766 static void prevDocumentAP(Widget w, XEvent *event, String *args,
3767 Cardinal *nArgs)
3768 {
3769 PreviousDocument(WidgetToWindow(w));
3770 }
3771
3772 static void lastDocumentAP(Widget w, XEvent *event, String *args,
3773 Cardinal *nArgs)
3774 {
3775 LastDocument(WidgetToWindow(w));
3776 }
3777
3778 static void capitalizeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3779 {
3780 WindowInfo *window = WidgetToWindow(w);
3781
3782 if (CheckReadOnly(window))
3783 return;
3784 UpcaseSelection(window);
3785 }
3786
3787 static void lowercaseAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3788 {
3789 WindowInfo *window = WidgetToWindow(w);
3790
3791 if (CheckReadOnly(window))
3792 return;
3793 DowncaseSelection(window);
3794 }
3795
3796 static void fillAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3797 {
3798 WindowInfo *window = WidgetToWindow(w);
3799
3800 if (CheckReadOnly(window))
3801 return;
3802 FillSelection(window);
3803 }
3804
3805 static void unicodeDialogAP(Widget w, XEvent *event, String *args,
3806 Cardinal *nArgs)
3807 {
3808 WindowInfo *window = WidgetToWindow(w);
3809 char codePointText[
DF_MAX_PROMPT_LENGTH], str[
8];
3810 char *params[
1];
3811 int response;
3812 size_t inputLen =
0;
3813
3814 if (CheckReadOnly(window))
3815 return;
3816
3817 response = DialogF(
DF_PROMPT, window->shell,
2,
"Insert Unicode Codepoint",
3818 "Unicode Codepoint:", codePointText,
"OK",
"Cancel");
3819
3820 if (response ==
2)
3821 return;
3822
3823 inputLen = strlen(codePointText);
3824 int base =
10;
3825 int offset =
0;
3826 if(inputLen >
2 && (
3827 !memcmp(codePointText,
"0x",
2) ||
3828 !memcmp(codePointText,
"\\u",
2) ||
3829 !memcmp(codePointText,
"\\U",
2) ||
3830 !memcmp(codePointText,
"U+",
2) ||
3831 !memcmp(codePointText,
"u+",
2)))
3832 {
3833 base =
16;
3834 offset =
2;
3835 }
else if(inputLen >
1 && (codePointText[
0] ==
'u' || codePointText[
0] ==
'U')) {
3836 base =
16;
3837 offset =
1;
3838 }
3839
3840 char *endPtr =
NULL;
3841 errno =
0;
3842 unsigned long value = strtoul(codePointText + offset, &endPtr, base);
3843 if(errno !=
0) {
3844 XBell(TheDisplay,
0);
3845 return;
3846 }
3847
3848
3849 memset(str,
'\0',
8);
3850 Ucs4ToUtf8((FcChar32)value, str);
3851
3852 params[
0] = (
char *)str;
3853 XtCallActionProc(w,
"insert_string", event, params,
1);
3854 }
3855
3856 static void filterDialogAP(Widget w, XEvent *event, String *args,
3857 Cardinal *nArgs)
3858 {
3859 WindowInfo *window = WidgetToWindow(w);
3860 char *params[
1], cmdText[
DF_MAX_PROMPT_LENGTH];
3861 int resp;
3862 static char **cmdHistory =
NULL;
3863 static int nHistoryCmds =
0;
3864
3865 if (CheckReadOnly(window))
3866 return;
3867 if (!window->buffer->primary.selected) {
3868 XBell(TheDisplay,
0);
3869 return;
3870 }
3871
3872 SetDialogFPromptHistory(cmdHistory, nHistoryCmds);
3873
3874 resp = DialogF(
DF_PROMPT, window->shell,
2,
"Filter Selection",
3875 "Shell command: (use up arrow key to recall previous)",
3876 cmdText,
"OK",
"Cancel");
3877
3878 if (resp ==
2)
3879 return;
3880 AddToHistoryList(cmdText, &cmdHistory, &nHistoryCmds);
3881 params[
0] = cmdText;
3882 XtCallActionProc(w,
"filter_selection", event, params,
1);
3883 }
3884
3885 static void shellFilterAP(Widget w, XEvent *event, String *args,
3886 Cardinal *nArgs)
3887 {
3888 WindowInfo *window = WidgetToWindow(w);
3889
3890 if (CheckReadOnly(window))
3891 return;
3892 if (*nArgs ==
0) {
3893 fprintf(stderr,
3894 "xnedit: filter_selection requires shell command argument\n");
3895 return;
3896 }
3897 FilterSelection(window, args[
0],
3898 event->xany.send_event ==
MACRO_EVENT_MARKER);
3899 }
3900
3901 static void execDialogAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3902 {
3903 WindowInfo *window = WidgetToWindow(w);
3904 char *params[
1], cmdText[
DF_MAX_PROMPT_LENGTH];
3905 int resp;
3906 static char **cmdHistory =
NULL;
3907 static int nHistoryCmds =
0;
3908
3909 if (CheckReadOnly(window))
3910 return;
3911 SetDialogFPromptHistory(cmdHistory, nHistoryCmds);
3912
3913 resp = DialogF(
DF_PROMPT, window->shell,
2,
"Execute Command",
3914 "Shell command: (use up arrow key to recall previous;\n"
3915 "%% expands to current filename, # to line number)", cmdText,
"OK",
3916 "Cancel");
3917
3918 if (resp ==
2)
3919 return;
3920 AddToHistoryList(cmdText, &cmdHistory, &nHistoryCmds);
3921 params[
0] = cmdText;
3922 XtCallActionProc(w,
"execute_command", event, params,
1);;
3923 }
3924
3925 static void execAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3926 {
3927 WindowInfo *window = WidgetToWindow(w);
3928
3929 if (CheckReadOnly(window))
3930 return;
3931 if (*nArgs ==
0) {
3932 fprintf(stderr,
3933 "xnedit: execute_command requires shell command argument\n");
3934 return;
3935 }
3936 ExecShellCommand(window, args[
0],
3937 event->xany.send_event ==
MACRO_EVENT_MARKER);
3938 }
3939
3940 static void execLineAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3941 {
3942 WindowInfo *window = WidgetToWindow(w);
3943
3944 if (CheckReadOnly(window))
3945 return;
3946 ExecCursorLine(window, event->xany.send_event ==
MACRO_EVENT_MARKER);
3947 }
3948
3949 static void shellMenuAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3950 {
3951 if (*nArgs ==
0) {
3952 fprintf(stderr,
3953 "xnedit: shell_menu_command requires item-name argument\n");
3954 return;
3955 }
3956 HidePointerOnKeyedEvent(w, event);
3957 DoNamedShellMenuCmd(WidgetToWindow(w), args[
0],
3958 event->xany.send_event ==
MACRO_EVENT_MARKER);
3959 }
3960
3961 static void macroMenuAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3962 {
3963 if (*nArgs ==
0) {
3964 fprintf(stderr,
3965 "xnedit: macro_menu_command requires item-name argument\n");
3966 return;
3967 }
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978 if (event->xany.send_event !=
MACRO_EVENT_MARKER) {
3979 if (WidgetToWindow(w)->macroCmdData !=
NULL) {
3980 XBell(TheDisplay,
0);
3981 return;
3982 }
3983 }
3984 HidePointerOnKeyedEvent(w, event);
3985 DoNamedMacroMenuCmd(WidgetToWindow(w), args[
0]);
3986 }
3987
3988 static void bgMenuAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
3989 {
3990 if (*nArgs ==
0) {
3991 fprintf(stderr,
3992 "xnedit: bg_menu_command requires item-name argument\n");
3993 return;
3994 }
3995
3996 if (event->xany.send_event !=
MACRO_EVENT_MARKER) {
3997 if (WidgetToWindow(w)->macroCmdData !=
NULL) {
3998 XBell(TheDisplay,
0);
3999 return;
4000 }
4001 }
4002 HidePointerOnKeyedEvent(w, event);
4003 DoNamedBGMenuCmd(WidgetToWindow(w), args[
0]);
4004 }
4005
4006 static void beginningOfSelectionAP(Widget w, XEvent *event, String *args,
4007 Cardinal *nArgs)
4008 {
4009 textBuffer *buf = TextGetBuffer(w);
4010 int start, end, isRect, rectStart, rectEnd;
4011
4012 if (!BufGetSelectionPos(buf, &start, &end, &isRect, &rectStart, &rectEnd))
4013 return;
4014 if (!isRect)
4015 TextSetCursorPos(w, start);
4016 else
4017 TextSetCursorPos(w, BufCountForwardDispChars(buf,
4018 BufStartOfLine(buf, start), rectStart));
4019 }
4020
4021 static void endOfSelectionAP(Widget w, XEvent *event, String *args,
4022 Cardinal *nArgs)
4023 {
4024 textBuffer *buf = TextGetBuffer(w);
4025 int start, end, isRect, rectStart, rectEnd;
4026
4027 if (!BufGetSelectionPos(buf, &start, &end, &isRect, &rectStart, &rectEnd))
4028 return;
4029 if (!isRect)
4030 TextSetCursorPos(w, end);
4031 else
4032 TextSetCursorPos(w, BufCountForwardDispChars(buf,
4033 BufStartOfLine(buf, end), rectEnd));
4034 }
4035
4036 static void raiseWindowAP(Widget w, XEvent *event, String *args,
4037 Cardinal *nArgs)
4038 {
4039 WindowInfo *window = WidgetToWindow(w);
4040 WindowInfo *nextWindow;
4041 WindowInfo *tmpWindow;
4042 int windowIndex;
4043 Boolean focus = GetPrefFocusOnRaise();
4044
4045 if (*nArgs >
0) {
4046 if (strcmp(args[
0],
"last") ==
0) {
4047 window = WindowList;
4048 }
4049 else if (strcmp(args[
0],
"first") ==
0) {
4050 window = WindowList;
4051 if (window !=
NULL) {
4052 nextWindow = window->next;
4053 while (nextWindow !=
NULL) {
4054 window = nextWindow;
4055 nextWindow = nextWindow->next;
4056 }
4057 }
4058 }
4059 else if (strcmp(args[
0],
"previous") ==
0) {
4060 tmpWindow = window;
4061 window = WindowList;
4062 if (window !=
NULL) {
4063 nextWindow = window->next;
4064 while (nextWindow !=
NULL && nextWindow != tmpWindow) {
4065 window = nextWindow;
4066 nextWindow = nextWindow->next;
4067 }
4068 if (nextWindow ==
NULL && tmpWindow != WindowList) {
4069 window =
NULL;
4070 }
4071 }
4072 }
4073 else if (strcmp(args[
0],
"next") ==
0) {
4074 if (window !=
NULL) {
4075 window = window->next;
4076 if (window ==
NULL) {
4077 window = WindowList;
4078 }
4079 }
4080 }
4081 else {
4082 if (sscanf(args[
0],
"%d", &windowIndex) ==
1) {
4083 if (windowIndex >
0) {
4084 for (window = WindowList; window !=
NULL && windowIndex >
1;
4085 --windowIndex) {
4086 window = window->next;
4087 }
4088 }
4089 else if (windowIndex <
0) {
4090 for (window = WindowList; window !=
NULL;
4091 window = window->next) {
4092 ++windowIndex;
4093 }
4094 if (windowIndex >=
0) {
4095 for (window = WindowList; window !=
NULL &&
4096 windowIndex >
0; window = window->next) {
4097 --windowIndex;
4098 }
4099 }
4100 else {
4101 window =
NULL;
4102 }
4103 }
4104 else {
4105 window =
NULL;
4106 }
4107 }
4108 else {
4109 window =
NULL;
4110 }
4111 }
4112
4113 if (*nArgs >
1) {
4114 if (strcmp(args[
1],
"focus") ==
0) {
4115 focus = True;
4116 }
4117 else if (strcmp(args[
1],
"nofocus") ==
0) {
4118 focus = False;
4119 }
4120 }
4121 }
4122 if (window !=
NULL) {
4123 RaiseFocusDocumentWindow(window, focus);
4124 }
4125 else {
4126 XBell(TheDisplay,
0);
4127 }
4128 }
4129
4130 static void focusPaneAP(Widget w, XEvent *event, String *args,
4131 Cardinal *nArgs)
4132 {
4133 WindowInfo *window = WidgetToWindow(w);
4134 Widget newFocusPane =
NULL;
4135 int paneIndex;
4136
4137 if (*nArgs >
0) {
4138 if (strcmp(args[
0],
"first") ==
0) {
4139 paneIndex =
0;
4140 }
4141 else if (strcmp(args[
0],
"last") ==
0) {
4142 paneIndex = window->nPanes;
4143 }
4144 else if (strcmp(args[
0],
"next") ==
0) {
4145 paneIndex = WidgetToPaneIndex(window, window->lastFocus) +
1;
4146 if (paneIndex > window->nPanes) {
4147 paneIndex =
0;
4148 }
4149 }
4150 else if (strcmp(args[
0],
"previous") ==
0) {
4151 paneIndex = WidgetToPaneIndex(window, window->lastFocus) -
1;
4152 if (paneIndex <
0) {
4153 paneIndex = window->nPanes;
4154 }
4155 }
4156 else {
4157 if (sscanf(args[
0],
"%d", &paneIndex) ==
1) {
4158 if (paneIndex >
0) {
4159 paneIndex = paneIndex -
1;
4160 }
4161 else if (paneIndex <
0) {
4162 paneIndex = window->nPanes + (paneIndex +
1);
4163 }
4164 else {
4165 paneIndex = -
1;
4166 }
4167 }
4168 }
4169 if (paneIndex >=
0 && paneIndex <= window->nPanes) {
4170 newFocusPane = GetPaneByIndex(window, paneIndex);
4171 }
4172 if (newFocusPane !=
NULL) {
4173 window->lastFocus = newFocusPane;
4174 XmProcessTraversal(window->lastFocus, XmTRAVERSE_CURRENT);
4175 }
4176 else {
4177 XBell(TheDisplay,
0);
4178 }
4179 }
4180 else {
4181 fprintf(stderr,
"xnedit: focus_pane requires argument\n");
4182 }
4183 }
4184
4185 #define ACTION_BOOL_PARAM_OR_TOGGLE(newState, numArgs, argvVal, oValue, actionName) \
4186 if ((numArgs) >
0) { \
4187 int intState; \
4188 \
4189 if (sscanf(argvVal[
0],
"%d", &intState) ==
1) { \
4190 (newState) = (intState !=
0); \
4191 } \
4192 else { \
4193 fprintf(stderr,
"xnedit: %s requires 0 or 1 argument\n", actionName); \
4194 return; \
4195 } \
4196 } \
4197 else { \
4198 (newState) = !(oValue); \
4199 }
4200
4201 static void setStatisticsLineAP(Widget w, XEvent *event, String *args,
4202 Cardinal *nArgs)
4203 {
4204 WindowInfo *window = WidgetToWindow(w);
4205 Boolean newState;
4206
4207
4208
4209 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args, window->showStats,
4210 "set_statistics_line");
4211 XmToggleButtonSetState(window->statsLineItem, newState, False);
4212 ShowStatsLine(window, newState);
4213 }
4214
4215 static void setIncrementalSearchLineAP(Widget w, XEvent *event, String *args,
4216 Cardinal *nArgs)
4217 {
4218 WindowInfo *window = WidgetToWindow(w);
4219 Boolean newState;
4220
4221
4222
4223 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args,
4224 window->showISearchLine,
"set_incremental_search_line");
4225 XmToggleButtonSetState(window->iSearchLineItem, newState, False);
4226 ShowISearchLine(window, newState);
4227 }
4228
4229 static void setShowLineNumbersAP(Widget w, XEvent *event, String *args,
4230 Cardinal *nArgs)
4231 {
4232 WindowInfo *window = WidgetToWindow(w);
4233 Boolean newState;
4234
4235
4236
4237 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args,
4238 window->showLineNumbers,
"set_show_line_numbers");
4239 XmToggleButtonSetState(window->lineNumsItem, newState, False);
4240 ShowLineNumbers(window, newState);
4241 }
4242
4243 static void setAutoIndentAP(Widget w, XEvent *event, String *args,
4244 Cardinal *nArgs)
4245 {
4246 WindowInfo *window = WidgetToWindow(w);
4247 if (*nArgs >
0) {
4248 if (strcmp(args[
0],
"off") ==
0) {
4249 SetAutoIndent(window,
NO_AUTO_INDENT);
4250 }
4251 else if (strcmp(args[
0],
"on") ==
0) {
4252 SetAutoIndent(window,
AUTO_INDENT);
4253 }
4254 else if (strcmp(args[
0],
"smart") ==
0) {
4255 SetAutoIndent(window,
SMART_INDENT);
4256 }
4257 else {
4258 fprintf(stderr,
"xnedit: set_auto_indent invalid argument\n");
4259 }
4260 }
4261 else {
4262 fprintf(stderr,
"xnedit: set_auto_indent requires argument\n");
4263 }
4264 }
4265
4266 static void setWrapTextAP(Widget w, XEvent *event, String *args,
4267 Cardinal *nArgs)
4268 {
4269 WindowInfo *window = WidgetToWindow(w);
4270 if (*nArgs >
0) {
4271 if (strcmp(args[
0],
"none") ==
0) {
4272 SetAutoWrap(window,
NO_WRAP);
4273 }
4274 else if (strcmp(args[
0],
"auto") ==
0) {
4275 SetAutoWrap(window,
NEWLINE_WRAP);
4276 }
4277 else if (strcmp(args[
0],
"continuous") ==
0) {
4278 SetAutoWrap(window,
CONTINUOUS_WRAP);
4279 }
4280 else {
4281 fprintf(stderr,
"xnedit: set_wrap_text invalid argument\n");
4282 }
4283 }
4284 else {
4285 fprintf(stderr,
"xnedit: set_wrap_text requires argument\n");
4286 }
4287 }
4288
4289 static void setWrapMarginAP(Widget w, XEvent *event, String *args,
4290 Cardinal *nArgs)
4291 {
4292 WindowInfo *window = WidgetToWindow(w);
4293
4294 if (*nArgs >
0) {
4295 int newMargin =
0;
4296 if (sscanf(args[
0],
"%d", &newMargin) ==
1 &&
4297 newMargin >=
0 &&
4298 newMargin <
1000) {
4299 int i;
4300
4301 XtVaSetValues(window->textArea, textNwrapMargin, newMargin,
NULL);
4302 for (i =
0; i < window->nPanes; ++i) {
4303 XtVaSetValues(window->textPanes[i], textNwrapMargin, newMargin,
NULL);
4304 }
4305 }
4306 else {
4307 fprintf(stderr,
4308 "xnedit: set_wrap_margin requires integer argument >= 0 and < 1000\n");
4309 }
4310 }
4311 else {
4312 fprintf(stderr,
"xnedit: set_wrap_margin requires argument\n");
4313 }
4314 }
4315
4316 static void setHighlightSyntaxAP(Widget w, XEvent *event, String *args,
4317 Cardinal *nArgs)
4318 {
4319 WindowInfo *window = WidgetToWindow(w);
4320 Boolean newState;
4321
4322 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args, window->highlightSyntax,
"set_highlight_syntax");
4323
4324 if (IsTopDocument(window))
4325 XmToggleButtonSetState(window->highlightItem, newState, False);
4326 window->highlightSyntax = newState;
4327 if (window->highlightSyntax) {
4328 StartHighlighting(window, True);
4329 }
else {
4330 StopHighlighting(window);
4331 }
4332 }
4333
4334 static void setMakeBackupCopyAP(Widget w, XEvent *event, String *args,
4335 Cardinal *nArgs)
4336 {
4337 WindowInfo *window = WidgetToWindow(w);
4338 Boolean newState;
4339
4340 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args, window->saveOldVersion,
"set_make_backup_copy");
4341
4342 if (IsTopDocument(window))
4343 XmToggleButtonSetState(window->saveLastItem, newState, False);
4344 window->saveOldVersion = newState;
4345 }
4346
4347 static void setIncrementalBackupAP(Widget w, XEvent *event, String *args,
4348 Cardinal *nArgs)
4349 {
4350 WindowInfo *window = WidgetToWindow(w);
4351 Boolean newState;
4352
4353 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args, window->autoSave,
"set_incremental_backup");
4354
4355 if (IsTopDocument(window))
4356 XmToggleButtonSetState(window->autoSaveItem, newState, False);
4357 window->autoSave = newState;
4358 }
4359
4360 static void setShowMatchingAP(Widget w, XEvent *event, String *args,
4361 Cardinal *nArgs)
4362 {
4363 WindowInfo *window = WidgetToWindow(w);
4364 if (*nArgs >
0) {
4365 if (strcmp(args[
0],
NO_FLASH_STRING) ==
0) {
4366 SetShowMatching(window,
NO_FLASH);
4367 }
4368 else if (strcmp(args[
0],
FLASH_DELIMIT_STRING) ==
0) {
4369 SetShowMatching(window,
FLASH_DELIMIT);
4370 }
4371 else if (strcmp(args[
0],
FLASH_RANGE_STRING) ==
0) {
4372 SetShowMatching(window,
FLASH_RANGE);
4373 }
4374
4375
4376
4377
4378
4379 else if (strcmp(args[
0],
"0") ==
0) {
4380 SetShowMatching(window,
NO_FLASH);
4381 }
4382 else if (strcmp(args[
0],
"1") ==
0) {
4383 SetShowMatching(window,
FLASH_DELIMIT);
4384 }
4385 else {
4386 fprintf(stderr,
"xnedit: Invalid argument for set_show_matching\n");
4387 }
4388 }
4389 else {
4390 fprintf(stderr,
"xnedit: set_show_matching requires argument\n");
4391 }
4392 }
4393
4394 static void setMatchSyntaxBasedAP(Widget w, XEvent *event, String *args,
4395 Cardinal *nArgs)
4396 {
4397 WindowInfo *window = WidgetToWindow(w);
4398 Boolean newState;
4399
4400 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args, window->matchSyntaxBased,
"set_match_syntax_based");
4401
4402 if (IsTopDocument(window))
4403 XmToggleButtonSetState(window->matchSyntaxBasedItem, newState, False);
4404 window->matchSyntaxBased = newState;
4405 }
4406
4407 static void setOvertypeModeAP(Widget w, XEvent *event, String *args,
4408 Cardinal *nArgs)
4409 {
4410 WindowInfo *window = WidgetToWindow(w);
4411 Boolean newState;
4412
4413 if (window ==
NULL)
4414 return;
4415
4416 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args, window->overstrike,
"set_overtype_mode");
4417
4418 if (IsTopDocument(window))
4419 XmToggleButtonSetState(window->overtypeModeItem, newState, False);
4420 SetOverstrike(window, newState);
4421 }
4422
4423 static void setLockedAP(Widget w, XEvent *event, String *args,
4424 Cardinal *nArgs)
4425 {
4426 WindowInfo *window = WidgetToWindow(w);
4427 Boolean newState;
4428
4429 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args,
IS_USER_LOCKED(window->lockReasons),
"set_locked");
4430
4431 SET_USER_LOCKED(window->lockReasons, newState);
4432 if(!newState) {
4433 SET_ENCODING_LOCKED(window->lockReasons,
0);
4434 }
4435
4436 if (IsTopDocument(window))
4437 XmToggleButtonSetState(window->readOnlyItem,
IS_ANY_LOCKED(window->lockReasons), False);
4438 UpdateWindowTitle(window);
4439 UpdateWindowReadOnly(window);
4440 }
4441
4442 static void setTabDistAP(Widget w, XEvent *event, String *args,
4443 Cardinal *nArgs)
4444 {
4445 WindowInfo *window = WidgetToWindow(w);
4446
4447 if (*nArgs >
0) {
4448 int newTabDist =
0;
4449 if (sscanf(args[
0],
"%d", &newTabDist) ==
1 &&
4450 newTabDist >
0 &&
4451 newTabDist <=
MAX_EXP_CHAR_LEN) {
4452 SetTabDist(window, newTabDist);
4453 }
4454 else {
4455 fprintf(stderr,
4456 "xnedit: set_tab_dist requires integer argument > 0 and <= %d\n",
4457 MAX_EXP_CHAR_LEN);
4458 }
4459 }
4460 else {
4461 fprintf(stderr,
"xnedit: set_tab_dist requires argument\n");
4462 }
4463 }
4464
4465 static void setEmTabDistAP(Widget w, XEvent *event, String *args,
4466 Cardinal *nArgs)
4467 {
4468 WindowInfo *window = WidgetToWindow(w);
4469
4470 if (*nArgs >
0) {
4471 int newEmTabDist =
0;
4472 if (sscanf(args[
0],
"%d", &newEmTabDist) ==
1 &&
4473 newEmTabDist <
1000) {
4474 if (newEmTabDist <
0) {
4475 newEmTabDist =
0;
4476 }
4477 SetEmTabDist(window, newEmTabDist);
4478 }
4479 else {
4480 fprintf(stderr,
4481 "xnedit: set_em_tab_dist requires integer argument >= -1 and < 1000\n");
4482 }
4483 }
4484 else {
4485 fprintf(stderr,
"xnedit: set_em_tab_dist requires integer argument\n");
4486 }
4487 }
4488
4489 static void setUseTabsAP(Widget w, XEvent *event, String *args,
4490 Cardinal *nArgs)
4491 {
4492 WindowInfo *window = WidgetToWindow(w);
4493 Boolean newState;
4494
4495 ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args, window->buffer->useTabs,
"set_use_tabs");
4496
4497 window->buffer->useTabs = newState;
4498 }
4499
4500 static void setFontsAP(Widget w, XEvent *event, String *args,
4501 Cardinal *nArgs)
4502 {
4503 WindowInfo *window = WidgetToWindow(w);
4504 if (*nArgs >=
4) {
4505 SetFonts(window, args[
0], args[
1], args[
2], args[
3]);
4506 window->zoom =
0;
4507 XtSetSensitive(window->resetZoomItem, False);
4508 }
4509 else {
4510 fprintf(stderr,
"xnedit: set_fonts requires 4 arguments\n");
4511 }
4512 }
4513
4514 static void setLanguageModeAP(Widget w, XEvent *event, String *args,
4515 Cardinal *nArgs)
4516 {
4517 WindowInfo *window = WidgetToWindow(w);
4518
4519 if (*nArgs >
0) {
4520 SetLanguageMode(window, FindLanguageMode(args[
0]),
FALSE);
4521 }
4522 else {
4523 fprintf(stderr,
"xnedit: set_language_mode requires argument\n");
4524 }
4525 }
4526
4527
4528
4529
4530
4531
4532
4533
4534 static Widget createMenu(Widget parent,
char *name,
char *label,
4535 char mnemonic, Widget *cascadeBtn,
int mode)
4536 {
4537 Widget menu, cascade;
4538 XmString st1;
4539
4540 menu = CreatePulldownMenu(parent, name,
NULL,
0);
4541 cascade = XtVaCreateWidget(name, xmCascadeButtonWidgetClass, parent,
4542 XmNlabelString, st1=XmStringCreateSimple(label),
4543 XmNsubMenuId, menu,
NULL);
4544 XmStringFree(st1);
4545 if (mnemonic !=
0)
4546 XtVaSetValues(cascade, XmNmnemonic, mnemonic,
NULL);
4547 #ifdef SGI_CUSTOM
4548 if (mode ==
SHORT || !GetPrefShortMenus())
4549 XtManageChild(cascade);
4550 if (mode ==
FULL)
4551 addToToggleShortList(cascade);
4552 #else
4553 XtManageChild(cascade);
4554 #endif
4555 if (cascadeBtn !=
NULL)
4556 *cascadeBtn = cascade;
4557 return menu;
4558 }
4559
4560
4561
4562
4563
4564
4565 static Widget createMenuItem(Widget parent,
char *name,
char *label,
4566 char mnemonic, menuCallbackProc callback,
void *cbArg,
int mode)
4567 {
4568 Widget button;
4569 XmString st1;
4570
4571
4572 button = XtVaCreateWidget(name, xmPushButtonWidgetClass, parent,
4573 XmNlabelString, st1=XmStringCreateSimple(label),
4574 XmNmnemonic, mnemonic,
NULL);
4575 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)callback, cbArg);
4576 XmStringFree(st1);
4577 #ifdef SGI_CUSTOM
4578 if (mode ==
SHORT || !GetPrefShortMenus())
4579 XtManageChild(button);
4580 if (mode ==
FULL)
4581 addToToggleShortList(button);
4582 XtVaSetValues(button, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
4583 #else
4584 XtManageChild(button);
4585 #endif
4586 return button;
4587 }
4588
4589
4590
4591
4592
4593
4594
4595 static Widget createFakeMenuItem(Widget parent,
char *name,
4596 menuCallbackProc callback,
void *cbArg)
4597 {
4598 Widget button;
4599 XmString st1;
4600
4601 button = XtVaCreateManagedWidget(name, xmPushButtonWidgetClass, parent,
4602 XmNlabelString, st1=XmStringCreateSimple(
""),
4603 XmNshadowThickness,
0,
4604 XmNmarginHeight,
0,
4605 XmNheight,
0,
NULL);
4606 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)callback, cbArg);
4607 XmStringFree(st1);
4608 XtVaSetValues(button, XmNtraversalOn, False,
NULL);
4609
4610 return button;
4611 }
4612
4613
4614
4615
4616
4617 static Widget createMenuToggle(Widget parent,
char *name,
char *label,
4618 char mnemonic, menuCallbackProc callback,
void *cbArg,
int set,
4619 int mode)
4620 {
4621 Widget button;
4622 XmString st1;
4623
4624 button = XtVaCreateWidget(name, xmToggleButtonWidgetClass, parent,
4625 XmNlabelString, st1=XmStringCreateSimple(label),
4626 XmNmnemonic, mnemonic,
4627 XmNset, set,
NULL);
4628 XtAddCallback(button, XmNvalueChangedCallback, (XtCallbackProc)callback,
4629 cbArg);
4630 XmStringFree(st1);
4631 #ifdef SGI_CUSTOM
4632 if (mode ==
SHORT || !GetPrefShortMenus())
4633 XtManageChild(button);
4634 if (mode ==
FULL)
4635 addToToggleShortList(button);
4636 XtVaSetValues(button, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
4637 #else
4638 XtManageChild(button);
4639 #endif
4640 return button;
4641 }
4642
4643
4644
4645
4646 static Widget createMenuRadioToggle(Widget parent,
char *name,
char *label,
4647 char mnemonic, menuCallbackProc callback,
void *cbArg,
int set,
4648 int mode)
4649 {
4650 Widget button;
4651 button = createMenuToggle(parent, name, label, mnemonic, callback, cbArg,
4652 set, mode);
4653 XtVaSetValues(button, XmNindicatorType, XmONE_OF_MANY,
NULL);
4654 return button;
4655 }
4656
4657 static Widget createMenuSeparator(Widget parent,
char *name,
int mode)
4658 {
4659 Widget button;
4660
4661 button = XmCreateSeparator(parent, name,
NULL,
0);
4662 #ifdef SGI_CUSTOM
4663 if (mode ==
SHORT || !GetPrefShortMenus())
4664 XtManageChild(button);
4665 if (mode ==
FULL)
4666 addToToggleShortList(button);
4667 XtVaSetValues(button, XmNuserData,
PERMANENT_MENU_ITEM,
NULL);
4668 #else
4669 XtManageChild(button);
4670 #endif
4671 return button;
4672 }
4673
4674
4675
4676
4677
4678
4679 void CheckCloseDim(
void)
4680 {
4681 WindowInfo *window;
4682
4683 if (WindowList ==
NULL)
4684 return;
4685 if (WindowList->next==
NULL &&
4686 !WindowList->filenameSet && !WindowList->fileChanged) {
4687 XtSetSensitive(WindowList->closeItem,
FALSE);
4688 return;
4689 }
4690
4691 for (window=WindowList; window!=
NULL; window=window->next) {
4692 if (!IsTopDocument(window))
4693 continue;
4694 XtSetSensitive(window->closeItem, True);
4695 }
4696 }
4697
4698
4699
4700
4701
4702
4703
4704
4705 void InvalidateWindowMenus(
void)
4706 {
4707 WindowInfo *w;
4708
4709
4710
4711
4712 for (w=WindowList; w!=
NULL; w=w->next) {
4713 if (!XmIsMenuShell(XtParent(w->windowMenuPane)))
4714 updateWindowMenu(w);
4715 else
4716 w->windowMenuValid = False;
4717 }
4718 }
4719
4720
4721
4722
4723
4724
4725 static void invalidatePrevOpenMenus(
void)
4726 {
4727 WindowInfo *w;
4728
4729
4730
4731
4732 for (w=WindowList; w!=
NULL; w=w->next) {
4733 if (!XmIsMenuShell(XtParent(w->prevOpenMenuPane)))
4734 updatePrevOpenMenu(w);
4735 }
4736 }
4737
4738
4739
4740
4741
4742 void AddToPrevOpenMenu(
const char *filename)
4743 {
4744 int i;
4745 char *nameCopy;
4746 WindowInfo *w;
4747
4748
4749 if (GetPrefMaxPrevOpenFiles() <
1) {
4750 return;
4751 }
4752
4753
4754
4755
4756
4757
4758
4759 ReadNEditDB();
4760
4761
4762 for (i=
0; i<NPrevOpen; i++) {
4763 if (!strcmp(filename, PrevOpen[i])) {
4764 nameCopy = PrevOpen[i];
4765 memmove(&PrevOpen[
1], &PrevOpen[
0],
sizeof(
char *) * i);
4766 PrevOpen[
0] = nameCopy;
4767 invalidatePrevOpenMenus();
4768 WriteNEditDB();
4769 return;
4770 }
4771 }
4772
4773
4774 if (NPrevOpen >= GetPrefMaxPrevOpenFiles()) {
4775
4776 NEditFree(PrevOpen[--NPrevOpen]);
4777 }
4778
4779
4780 nameCopy = NEditStrdup(filename);
4781 memmove(&PrevOpen[
1], &PrevOpen[
0],
sizeof(
char *) * NPrevOpen);
4782 PrevOpen[
0] = nameCopy;
4783 NPrevOpen++;
4784
4785
4786 invalidatePrevOpenMenus();
4787
4788
4789 if (NPrevOpen >
0) {
4790 for (w=WindowList; w!=
NULL; w=w->next) {
4791 if (!IsTopDocument(w))
4792 continue;
4793 XtSetSensitive(w->prevOpenMenuItem, True);
4794 }
4795 }
4796
4797
4798 WriteNEditDB();
4799 }
4800
4801 #define MAX_WINDOW_TITLE_LEN MAXPATHLEN *
2 +
3 +
2 +
1
4802 static char* getWindowsMenuEntry(
const WindowInfo* window)
4803 {
4804 static char fullTitle[
MAX_WINDOW_TITLE_LEN];
4805
4806 char *parenthese_open =
"";
4807 char *parenthese_close =
"";
4808 if(!window->mapped) {
4809 parenthese_open =
"(";
4810 parenthese_close =
")";
4811 }
4812 if (GetPrefShowPathInWindowsMenu() && window->filenameSet) {
4813 snprintf(
4814 fullTitle,
4815 MAX_WINDOW_TITLE_LEN,
4816 "%s%s%s - %s%s",
4817 parenthese_open,
4818 window->filename, window->fileChanged?
"*" :
"", window->path,
4819 parenthese_close);
4820 }
else {
4821 snprintf(
4822 fullTitle,
4823 MAX_WINDOW_TITLE_LEN,
4824 "%s%s%s%s",
4825 parenthese_open,
4826 window->filename, window->fileChanged?
"*" :
"",
4827 parenthese_close);
4828 }
4829
4830 return(fullTitle);
4831 }
4832
4833
4834
4835
4836
4837 static void updateWindowMenu(
const WindowInfo *window)
4838 {
4839 WindowInfo *w;
4840 WidgetList items;
4841 Cardinal nItems;
4842 int i, n, nWindows, windowIndex;
4843 WindowInfo **windows;
4844
4845 if (!IsTopDocument(window))
4846 return;
4847
4848 EnableWindowResourceDB(window);
4849
4850
4851 for (w=WindowList, nWindows=
0; w!=
NULL; w=w->next, nWindows++);
4852 windows = (WindowInfo **)NEditMalloc(
sizeof(WindowInfo *) * nWindows);
4853 for (w=WindowList, i=
0; w!=
NULL; w=w->next, i++)
4854 windows[i] = w;
4855 qsort(windows, nWindows,
sizeof(WindowInfo *), compareWindowNames);
4856
4857
4858
4859
4860
4861 if (!XmIsMenuShell(XtParent(window->windowMenuPane)))
4862 XtUnmanageChild(window->windowMenuPane);
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873 XtVaGetValues(window->windowMenuPane, XmNchildren, &items,
4874 XmNnumChildren, &nItems,
NULL);
4875 windowIndex =
0;
4876 nWindows = NWindows();
4877 for (n=
0; n<(
int)nItems; n++) {
4878 XtPointer userData;
4879 XtVaGetValues(items[n], XmNuserData, &userData,
NULL);
4880 if (userData ==
TEMPORARY_MENU_ITEM) {
4881 if (windowIndex >= nWindows) {
4882
4883 XtUnmanageChild(items[n]);
4884 XtDestroyWidget(items[n]);
4885 }
else {
4886 XmString st1;
4887 char* title = getWindowsMenuEntry(windows[windowIndex]);
4888 XtVaSetValues(items[n], XmNlabelString,
4889 st1=XmStringCreateSimple(title),
NULL);
4890 XtRemoveAllCallbacks(items[n], XmNactivateCallback);
4891 XtAddCallback(items[n], XmNactivateCallback,
4892 (XtCallbackProc)raiseCB, windows[windowIndex]);
4893 XmStringFree(st1);
4894 windowIndex++;
4895 }
4896 }
4897 }
4898
4899
4900 for (; windowIndex<nWindows; windowIndex++) {
4901 XmString st1;
4902 char* title = getWindowsMenuEntry(windows[windowIndex]);
4903 Widget btn = XtVaCreateManagedWidget(
"win", xmPushButtonWidgetClass,
4904 window->windowMenuPane,
4905 XmNlabelString, st1=XmStringCreateSimple(title),
4906 XmNmarginHeight,
0,
4907 XmNuserData,
TEMPORARY_MENU_ITEM,
NULL);
4908 XtAddCallback(btn, XmNactivateCallback, (XtCallbackProc)raiseCB,
4909 windows[windowIndex]);
4910 XmStringFree(st1);
4911 }
4912 NEditFree(windows);
4913
4914
4915
4916
4917
4918 if (!XmIsMenuShell(XtParent(window->windowMenuPane))) {
4919 Dimension width, height;
4920
4921 XtVaGetValues(window->windowMenuPane, XmNwidth, &width,
4922 XmNheight, &height,
NULL);
4923 XtVaSetValues(XtParent(window->windowMenuPane), XmNwidth, width,
4924 XmNheight, height,
NULL);
4925 XtManageChild(window->windowMenuPane);
4926 }
4927
4928 EnableDefaultColorProfileResourceDB(XtDisplay(window->mainWin));
4929 }
4930
4931
4932
4933
4934
4935
4936 static void updatePrevOpenMenu(WindowInfo *window)
4937 {
4938 Widget btn;
4939 WidgetList items;
4940 Cardinal nItems;
4941 int n, index;
4942 XmString st1;
4943 char **prevOpenSorted;
4944
4945 EnableWindowResourceDB(window);
4946
4947
4948 ReadNEditDB();
4949
4950
4951 prevOpenSorted = (
char **)NEditMalloc(NPrevOpen *
sizeof(
char*));
4952 memcpy(prevOpenSorted, PrevOpen, NPrevOpen *
sizeof(
char*));
4953 if (GetPrefSortOpenPrevMenu())
4954 qsort(prevOpenSorted, NPrevOpen,
sizeof(
char*), cmpStrPtr);
4955
4956
4957
4958
4959
4960
4961 XtVaGetValues(window->prevOpenMenuPane, XmNchildren, &items,
4962 XmNnumChildren, &nItems,
NULL);
4963 index =
0;
4964 for (n=
0; n<(
int)nItems; n++) {
4965 if (index >= NPrevOpen) {
4966
4967 XtUnmanageChild(items[n]);
4968 XtDestroyWidget(items[n]);
4969 }
else {
4970 XtVaSetValues(items[n], XmNlabelString,
4971 st1=XmStringCreateSimple(prevOpenSorted[index]),
NULL);
4972 XtRemoveAllCallbacks(items[n], XmNactivateCallback);
4973 XtAddCallback(items[n], XmNactivateCallback,
4974 (XtCallbackProc)openPrevCB, prevOpenSorted[index]);
4975 XmStringFree(st1);
4976 index++;
4977 }
4978 }
4979
4980
4981 for (; index<NPrevOpen; index++) {
4982 btn = XtVaCreateManagedWidget(
"win", xmPushButtonWidgetClass,
4983 window->prevOpenMenuPane,
4984 XmNlabelString, st1=XmStringCreateSimple(prevOpenSorted[index]),
4985 XmNmarginHeight,
0,
4986 XmNuserData,
TEMPORARY_MENU_ITEM,
NULL);
4987 XtAddCallback(btn, XmNactivateCallback, (XtCallbackProc)openPrevCB,
4988 prevOpenSorted[index]);
4989 XmStringFree(st1);
4990 }
4991
4992 NEditFree(prevOpenSorted);
4993
4994 EnableDefaultColorProfileResourceDB(XtDisplay(window->mainWin));
4995 }
4996
4997
4998
4999
5000
5001 static void updateTagsFileMenu(WindowInfo *window)
5002 {
5003 tagFile *tf;
5004 Widget btn;
5005 WidgetList items;
5006 Cardinal nItems;
5007 int n;
5008 XmString st1;
5009
5010 EnableWindowResourceDB(window);
5011
5012
5013
5014
5015
5016
5017 XtVaGetValues(window->unloadTagsMenuPane, XmNchildren, &items,
5018 XmNnumChildren, &nItems,
NULL);
5019 tf = TagsFileList;
5020 for (n=
0; n<(
int)nItems; n++) {
5021 if (!tf) {
5022
5023 XtUnmanageChild(items[n]);
5024 XtDestroyWidget(items[n]);
5025 }
else {
5026 XtVaSetValues(items[n], XmNlabelString,
5027 st1=XmStringCreateSimple(tf->filename),
NULL);
5028 XtRemoveAllCallbacks(items[n], XmNactivateCallback);
5029 XtAddCallback(items[n], XmNactivateCallback,
5030 (XtCallbackProc)unloadTagsFileCB, tf->filename);
5031 XmStringFree(st1);
5032 tf = tf->next;
5033 }
5034 }
5035
5036
5037 while (tf) {
5038 btn = XtVaCreateManagedWidget(
"win", xmPushButtonWidgetClass,
5039 window->unloadTagsMenuPane, XmNlabelString,
5040 st1=XmStringCreateSimple(tf->filename),XmNmarginHeight,
0,
5041 XmNuserData,
TEMPORARY_MENU_ITEM,
NULL);
5042 XtAddCallback(btn, XmNactivateCallback,
5043 (XtCallbackProc)unloadTagsFileCB, tf->filename);
5044 XmStringFree(st1);
5045 tf = tf->next;
5046 }
5047
5048 EnableDefaultColorProfileResourceDB(XtDisplay(window->mainWin));
5049 }
5050
5051
5052
5053
5054
5055 static void updateTipsFileMenu(WindowInfo *window)
5056 {
5057 tagFile *tf;
5058 Widget btn;
5059 WidgetList items;
5060 Cardinal nItems;
5061 int n;
5062 XmString st1;
5063
5064 EnableWindowResourceDB(window);
5065
5066
5067
5068
5069
5070
5071 XtVaGetValues(window->unloadTipsMenuPane, XmNchildren, &items,
5072 XmNnumChildren, &nItems,
NULL);
5073 tf = TipsFileList;
5074 for (n=
0; n<(
int)nItems; n++) {
5075 if (!tf) {
5076
5077 XtUnmanageChild(items[n]);
5078 XtDestroyWidget(items[n]);
5079 }
else {
5080 XtVaSetValues(items[n], XmNlabelString,
5081 st1=XmStringCreateSimple(tf->filename),
NULL);
5082 XtRemoveAllCallbacks(items[n], XmNactivateCallback);
5083 XtAddCallback(items[n], XmNactivateCallback,
5084 (XtCallbackProc)unloadTipsFileCB, tf->filename);
5085 XmStringFree(st1);
5086 tf = tf->next;
5087 }
5088 }
5089
5090
5091 while (tf) {
5092 btn = XtVaCreateManagedWidget(
"win", xmPushButtonWidgetClass,
5093 window->unloadTipsMenuPane, XmNlabelString,
5094 st1=XmStringCreateSimple(tf->filename),XmNmarginHeight,
0,
5095 XmNuserData,
TEMPORARY_MENU_ITEM,
NULL);
5096 XtAddCallback(btn, XmNactivateCallback,
5097 (XtCallbackProc)unloadTipsFileCB, tf->filename);
5098 XmStringFree(st1);
5099 tf = tf->next;
5100 }
5101
5102 EnableDefaultColorProfileResourceDB(XtDisplay(window->mainWin));
5103 }
5104
5105
5106
5107
5108 static int cmpStrPtr(
const void *strA,
const void *strB)
5109 {
5110 return strcmp(*((
char**)strA), *((
char**)strB));
5111 }
5112
5113 static char neditDBBadFilenameChars[] =
"\n";
5114
5115
5116
5117
5118
5119
5120
5121 void WriteNEditDB(
void)
5122 {
5123 const char* fullName = GetRCFileName(
NEDIT_HISTORY);
5124 FILE *fp;
5125 int i;
5126 static char fileHeader[] =
5127 "# File name database for XNEdit Open Previous command\n";
5128
5129 if (fullName ==
NULL) {
5130
5131
5132 return;
5133 }
5134
5135
5136 if (GetPrefMaxPrevOpenFiles() <
1) {
5137 return;
5138 }
5139
5140
5141 if ((fp = fopen(fullName,
"w")) ==
NULL) {
5142 return;
5143 }
5144
5145
5146 fprintf(fp,
"%s", fileHeader);
5147
5148
5149 for (i =
0; i < NPrevOpen; ++i) {
5150 size_t lineLen = strlen(PrevOpen[i]);
5151
5152 if (lineLen >
0 && PrevOpen[i][
0] !=
'#' &&
5153 strcspn(PrevOpen[i], neditDBBadFilenameChars) == lineLen) {
5154 fprintf(fp,
"%s\n", PrevOpen[i]);
5155 }
5156 }
5157
5158 fclose(fp);
5159 }
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173 void ReadNEditDB(
void)
5174 {
5175 const char *fullName = GetRCFileName(
NEDIT_HISTORY);
5176 char line[
MAXPATHLEN +
2];
5177 char *nameCopy;
5178 struct stat attribute;
5179 FILE *fp;
5180 size_t lineLen;
5181 static time_t lastNeditdbModTime =
0;
5182
5183
5184
5185 if (GetPrefMaxPrevOpenFiles() <
1) {
5186 return;
5187 }
5188
5189
5190
5191 if (!PrevOpen) {
5192 PrevOpen = (
char**) NEditMalloc(
sizeof(
char*) * GetPrefMaxPrevOpenFiles());
5193 NPrevOpen =
0;
5194 }
5195
5196
5197
5198 if (fullName ==
NULL)
5199 {
5200
5201
5202 return;
5203 }
5204
5205
5206
5207 if (
0 == stat(fullName, &attribute)) {
5208 if (lastNeditdbModTime >= attribute.st_mtime) {
5209
5210 return;
5211 }
else {
5212
5213 lastNeditdbModTime = attribute.st_mtime;
5214 }
5215 }
else {
5216
5217 if (
ENOENT != errno)
5218 {
5219 perror(
"xnedit: Error reading history database");
5220 }
5221 return;
5222 }
5223
5224
5225 if ((fp = fopen(fullName,
"r")) ==
NULL) {
5226 return;
5227 }
5228
5229
5230 while (
0 != NPrevOpen) {
5231 NEditFree(PrevOpen[--NPrevOpen]);
5232 }
5233
5234
5235
5236
5237 while (True) {
5238 if (fgets(line,
sizeof(line), fp) ==
NULL) {
5239
5240 fclose(fp);
5241 return;
5242 }
5243 if (line[
0] ==
'#') {
5244
5245 continue;
5246 }
5247 lineLen = strlen(line);
5248 if (lineLen ==
0) {
5249
5250 continue;
5251 }
5252 if (line[lineLen -
1] !=
'\n') {
5253
5254 fprintf(stderr,
"xnedit: Line too long in history file\n");
5255 while (fgets(line,
sizeof(line), fp) !=
NULL) {
5256 lineLen = strlen(line);
5257 if (lineLen >
0 && line[lineLen -
1] ==
'\n') {
5258 break;
5259 }
5260 }
5261 continue;
5262 }
5263 line[--lineLen] =
'\0';
5264 if (strcspn(line, neditDBBadFilenameChars) != lineLen) {
5265
5266 fprintf(stderr,
"xnedit: History file may be corrupted\n");
5267 continue;
5268 }
5269 nameCopy = NEditStrdup(line);
5270 PrevOpen[NPrevOpen++] = nameCopy;
5271 if (NPrevOpen >= GetPrefMaxPrevOpenFiles()) {
5272
5273 fclose(fp);
5274 return;
5275 }
5276 }
5277 }
5278
5279 static void setWindowSizeDefault(
int rows,
int cols)
5280 {
5281 SetPrefRows(rows);
5282 SetPrefCols(cols);
5283 updateWindowSizeMenus();
5284 }
5285
5286 static void updateWindowSizeMenus(
void)
5287 {
5288 WindowInfo *win;
5289
5290 for (win=WindowList; win!=
NULL; win=win->next)
5291 updateWindowSizeMenu(win);
5292 }
5293
5294 static void updateWindowSizeMenu(WindowInfo *win)
5295 {
5296 int rows = GetPrefRows(), cols = GetPrefCols();
5297 char title[
50];
5298 XmString st1;
5299
5300 if (!IsTopDocument(win))
5301 return;
5302
5303 XmToggleButtonSetState(win->size24x80DefItem, rows==
24&&cols==
80,False);
5304 XmToggleButtonSetState(win->size40x80DefItem, rows==
40&&cols==
80,False);
5305 XmToggleButtonSetState(win->size60x80DefItem, rows==
60&&cols==
80,False);
5306 XmToggleButtonSetState(win->size80x80DefItem, rows==
80&&cols==
80,False);
5307 if ((rows!=
24 && rows!=
40 && rows!=
60 && rows!=
80) || cols!=
80) {
5308 XmToggleButtonSetState(win->sizeCustomDefItem, True, False);
5309 sprintf(title,
"Custom... (%d x %d)", rows, cols);
5310 XtVaSetValues(win->sizeCustomDefItem,
5311 XmNlabelString, st1=XmStringCreateSimple(title),
NULL);
5312 XmStringFree(st1);
5313 }
else {
5314 XmToggleButtonSetState(win->sizeCustomDefItem, False, False);
5315 XtVaSetValues(win->sizeCustomDefItem,
5316 XmNlabelString, st1=XmStringCreateSimple(
"Custom..."),
NULL);
5317 XmStringFree(st1);
5318 }
5319 }
5320
5321
5322
5323
5324
5325
5326
5327 static int searchDirection(
int ignoreArgs, String *args, Cardinal *nArgs)
5328 {
5329 int i;
5330
5331 for (i=ignoreArgs; i<(
int)*nArgs; i++) {
5332 if (!strcasecmp(args[i],
"forward"))
5333 return SEARCH_FORWARD;
5334 if (!strcasecmp(args[i],
"backward"))
5335 return SEARCH_BACKWARD;
5336 }
5337 return SEARCH_FORWARD;
5338 }
5339
5340
5341
5342
5343
5344
5345
5346 static int searchKeepDialogs(
int ignoreArgs, String *args, Cardinal *nArgs)
5347 {
5348 int i;
5349
5350 for (i=ignoreArgs; i<(
int)*nArgs; i++) {
5351 if (!strcasecmp(args[i],
"keep"))
5352 return TRUE;
5353 if (!strcasecmp(args[i],
"nokeep"))
5354 return FALSE;
5355 }
5356 return GetPrefKeepSearchDlogs();
5357 }
5358
5359
5360
5361
5362
5363
5364
5365 static int searchWrap(
int ignoreArgs, String *args, Cardinal *nArgs)
5366 {
5367 int i;
5368
5369 for (i=ignoreArgs; i<(
int)*nArgs; i++) {
5370 if (!strcasecmp(args[i],
"wrap"))
5371 return(
TRUE);
5372 if (!strcasecmp(args[i],
"nowrap"))
5373 return(
FALSE);
5374 }
5375 return GetPrefSearchWraps();
5376 }
5377
5378
5379
5380
5381
5382
5383
5384 static int searchType(
int ignoreArgs, String *args, Cardinal *nArgs)
5385 {
5386 int i, tmpSearchType;
5387
5388 for (i=ignoreArgs; i<(
int)*nArgs; i++) {
5389 if (StringToSearchType(args[i], &tmpSearchType))
5390 return tmpSearchType;
5391 }
5392 return GetPrefSearch();
5393 }
5394
5395
5396
5397
5398
5399
5400 static char **shiftKeyToDir(XtPointer callData)
5401 {
5402 static char *backwardParam[
1] = {
"backward"};
5403 static char *forwardParam[
1] = {
"forward"};
5404 if (((XmAnyCallbackStruct *)callData)->event->xbutton.state & ShiftMask)
5405 return backwardParam;
5406 return forwardParam;
5407 }
5408
5409 static void raiseCB(Widget w, WindowInfo *window,
caddr_t callData)
5410 {
5411 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
5412 ((XmAnyCallbackStruct *)callData)->event);
5413 RaiseFocusDocumentWindow(window, True );
5414 }
5415
5416 static void openPrevCB(Widget w,
char *name,
caddr_t callData)
5417 {
5418 char *params[
1];
5419 Widget menu =
MENU_WIDGET(w);
5420
5421 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
5422 ((XmAnyCallbackStruct *)callData)->event);
5423 params[
0] = name;
5424 XtCallActionProc(WidgetToWindow(menu)->lastFocus,
"open",
5425 ((XmAnyCallbackStruct *)callData)->event, params,
1);
5426 CheckCloseDim();
5427 }
5428
5429 static void unloadTagsFileCB(Widget w,
char *name,
caddr_t callData)
5430 {
5431 char *params[
1];
5432 Widget menu =
MENU_WIDGET(w);
5433
5434 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
5435 ((XmAnyCallbackStruct *)callData)->event);
5436 params[
0] = name;
5437 XtCallActionProc(WidgetToWindow(menu)->lastFocus,
"unload_tags_file",
5438 ((XmAnyCallbackStruct *)callData)->event, params,
1);
5439 }
5440
5441 static void unloadTipsFileCB(Widget w,
char *name,
caddr_t callData)
5442 {
5443 char *params[
1];
5444 #if XmVersion >=
1002
5445 Widget menu = XmGetPostedFromWidget(XtParent(w));
5446 #else
5447 Widget menu = w;
5448 #endif
5449
5450 params[
0] = name;
5451 XtCallActionProc(WidgetToWindow(menu)->lastFocus,
"unload_tips_file",
5452 ((XmAnyCallbackStruct *)callData)->event, params,
1);
5453 }
5454
5455
5456
5457
5458
5459
5460 static int compareWindowNames(
const void *windowA,
const void *windowB)
5461 {
5462 int rc;
5463 const WindowInfo *a = *((WindowInfo**)windowA);
5464 const WindowInfo *b = *((WindowInfo**)windowB);
5465
5466 rc = a->filenameSet == b->filenameSet ?
0 :
5467 a->filenameSet && !b->filenameSet ?
1 : -
1;
5468 if (rc !=
0)
5469 return rc;
5470 rc = strcmp(a->filename, b->filename);
5471 if (rc !=
0)
5472 return rc;
5473 rc = strcmp(a->path, b->path);
5474 return rc;
5475 }
5476
5477
5478
5479
5480 Widget CreateBGMenu(WindowInfo *window)
5481 {
5482 Arg args[
1];
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496 return CreatePopupMenu(window->textArea,
"bgMenu", args,
0);
5497 }
5498
5499
5500
5501
5502 Widget CreateTabContextMenu(Widget parent, WindowInfo *window)
5503 {
5504 Widget menu;
5505 Arg args[
8];
5506 int n;
5507
5508 n =
0;
5509 XtSetArg(args[n], XmNtearOffModel, XmTEAR_OFF_DISABLED); n++;
5510 menu = CreatePopupMenu(parent,
"tabContext", args, n);
5511
5512 createMenuItem(menu,
"new",
"New Tab",
0, doTabActionCB,
"new_tab",
SHORT);
5513 createMenuItem(menu,
"close",
"Close Tab",
0, doTabActionCB,
"close",
SHORT);
5514 createMenuSeparator(menu,
"sep1",
SHORT);
5515 window->contextDetachDocumentItem = createMenuItem(menu,
"detach",
5516 "Detach Tab",
0, doTabActionCB,
"detach_document",
SHORT);
5517 XtSetSensitive(window->contextDetachDocumentItem, False);
5518 window->contextMoveDocumentItem = createMenuItem(menu,
"attach",
5519 "Move Tab To...",
0, doTabActionCB,
"move_document_dialog",
SHORT);
5520
5521 return menu;
5522 }
5523
5524
5525
5526
5527
5528
5529 void AddBGMenuAction(Widget widget)
5530 {
5531 static XtTranslations table =
NULL;
5532
5533 if (table ==
NULL) {
5534 char translations[
MAX_ACCEL_LEN +
25];
5535 snprintf(translations,
MAX_ACCEL_LEN +
25,
"%s: post_window_bg_menu()\n",GetPrefBGMenuBtn());
5536 table = XtParseTranslationTable(translations);
5537 }
5538 XtOverrideTranslations(widget, table);
5539 }
5540
5541 static void bgMenuPostAP(Widget w, XEvent *event, String *args,
5542 Cardinal *nArgs)
5543 {
5544 WindowInfo *window = WidgetToWindow(w);
5545
5546
5547
5548
5549 XtCallActionProc(window->lastFocus,
"process_cancel", event,
NULL,
0);
5550
5551
5552 XmMenuPosition(window->bgMenuPane, (XButtonPressedEvent *)event);
5553 XtManageChild(window->bgMenuPane);
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567 }
5568
5569 void AddTabContextMenuAction(Widget widget)
5570 {
5571 static XtTranslations table =
NULL;
5572
5573 if (table ==
NULL) {
5574 char *translations =
"<Btn3Down>: post_tab_context_menu()\n";
5575 table = XtParseTranslationTable(translations);
5576 }
5577 XtOverrideTranslations(widget, table);
5578 }
5579
5580
5581
5582
5583 static void tabMenuPostAP(Widget w, XEvent *event, String *args,
5584 Cardinal *nArgs)
5585 {
5586 WindowInfo *window;
5587 XButtonPressedEvent *xbutton = (XButtonPressedEvent *)event;
5588 Widget wgt;
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601 if (XtClass(w) == xrwsBubbleButtonWidgetClass)
5602 window = TabToWindow(w);
5603 else if (xbutton->subwindow) {
5604 wgt = XtWindowToWidget(XtDisplay(w), xbutton->subwindow);
5605 window = TabToWindow(wgt);
5606 }
5607 else {
5608 window = WidgetToWindow(w);
5609 }
5610 XtVaSetValues(window->tabMenuPane, XmNuserData, (XtPointer)window,
NULL);
5611
5612
5613
5614
5615 XtCallActionProc(window->lastFocus,
"process_cancel", event,
NULL,
0);
5616
5617
5618 XmMenuPosition(window->tabMenuPane, (XButtonPressedEvent *)event);
5619 XtManageChild(window->tabMenuPane);
5620 }
5621
5622
5623
5624
5625
5626 static void tearoffMappedCB(Widget w, XtPointer clientData, XUnmapEvent *event)
5627 {
5628 Widget shell = (Widget)clientData;
5629 XWMHints *wmHints;
5630
5631 if (event->type != MapNotify)
5632 return;
5633
5634
5635 wmHints = XGetWMHints(TheDisplay, XtWindow(shell));
5636 wmHints->input = True;
5637 wmHints->flags |= InputHint;
5638 XSetWMHints(TheDisplay, XtWindow(shell), wmHints);
5639 XFree(wmHints);
5640
5641
5642 XtRemoveEventHandler(shell, StructureNotifyMask, False,
5643 (XtEventHandler)tearoffMappedCB, shell);
5644 }
5645
5646
5647
5648
5649 void ShowHiddenTearOff(Widget menuPane)
5650 {
5651 Widget shell;
5652
5653 if (!menuPane)
5654 return;
5655
5656 shell = XtParent(menuPane);
5657 if (!XmIsMenuShell(shell)) {
5658 XWindowAttributes winAttr;
5659
5660 XGetWindowAttributes(XtDisplay(shell), XtWindow(shell), &winAttr);
5661 if (winAttr.map_state == IsUnmapped) {
5662 XWMHints *wmHints;
5663
5664
5665
5666
5667
5668 wmHints = XGetWMHints(XtDisplay(shell), XtWindow(shell));
5669 wmHints->input = False;
5670 wmHints->flags |= InputHint;
5671 XSetWMHints(XtDisplay(shell), XtWindow(shell), wmHints);
5672 XFree(wmHints);
5673
5674
5675 XtMapWidget(shell);
5676
5677
5678
5679 XtAddEventHandler(shell, StructureNotifyMask, False,
5680 (XtEventHandler)tearoffMappedCB, shell);
5681 }
5682 }
5683 }
5684
5685 #ifdef SGI_CUSTOM
5686 static void shortMenusCB(Widget w, WindowInfo *window,
caddr_t callData)
5687 {
5688 WindowInfo *win;
5689 int i, state = XmToggleButtonGetState(w);
5690 Widget parent;
5691
5692 window = WidgetToWindow(w);
5693
5694 HidePointerOnKeyedEvent(WidgetToWindow(
MENU_WIDGET(w))->lastFocus,
5695 ((XmAnyCallbackStruct *)callData)->event);
5696
5697 SetPrefShortMenus(state);
5698
5699
5700 for (win=WindowList; win!=
NULL; win=win->next) {
5701 for (i=
0; i<win->nToggleShortItems; i++) {
5702 if (state)
5703 XtUnmanageChild(win->toggleShortItems[i]);
5704 else
5705 XtManageChild(win->toggleShortItems[i]);
5706 }
5707 }
5708 if (GetPrefShortMenus())
5709 SaveNEditPrefs(window->shell, True);
5710 }
5711
5712 static void addToToggleShortList(Widget w)
5713 {
5714 if (ShortMenuWindow->nToggleShortItems >=
MAX_SHORTENED_ITEMS) {
5715 fprintf(stderr,
"xnedit, internal error: increase MAX_SHORTENED_ITEMS\n");
5716 return;
5717 }
5718 ShortMenuWindow->toggleShortItems[ShortMenuWindow->nToggleShortItems++] = w;
5719 }
5720
5721
5722
5723
5724
5725
5726
5727
5728 static int shortPrefAskDefault(Widget parent, Widget w,
const char *settingName)
5729 {
5730 char msg[
100] =
"";
5731
5732 if (!GetPrefShortMenus()) {
5733 return False;
5734 }
5735
5736 sprintf(msg,
"%s: %s\nSave as default for future windows as well?",
5737 settingName, XmToggleButtonGetState(w) ?
"On" :
"Off");
5738 switch (DialogF (
DF_QUES, parent,
3,
"Save Default", msg,
"Yes",
"No",
5739 "Cancel"))
5740 {
5741 case 1:
5742 return True;
5743 case 2:
5744 return False;
5745 case 3:
5746 XmToggleButtonSetState(w, !XmToggleButtonGetState(w), False);
5747 return False;
5748 }
5749 return False;
5750 }
5751 #endif
5752