1 static const char CVSID
[] = "$Id: menu.c,v 1.66 2002/11/08 20:22:45 edg Exp $";
2 /*******************************************************************************
4 * menu.c -- Nirvana Editor menus *
6 * Copyright (C) 1999 Mark Edel *
8 * This is free software; you can redistribute it and/or modify it under the *
9 * terms of the GNU General Public License as published by the Free Software *
10 * Foundation; either version 2 of the License, or (at your option) any later *
13 * This software is distributed in the hope that it will be useful, but WITHOUT *
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
18 * You should have received a copy of the GNU General Public License along with *
19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
20 * Place, Suite 330, Boston, MA 02111-1307 USA *
22 * Nirvana Text Editor *
25 * Written by Mark Edel *
27 *******************************************************************************/
30 #include "../config.h"
40 #include "selection.h"
44 #include "preferences.h"
49 #include "highlight.h"
50 #include "highlightData.h"
51 #include "interpret.h"
52 #include "smartIndent.h"
53 #include "windowTitle.h"
54 #include "../util/getfiles.h"
55 #include "../util/DialogF.h"
56 #include "../util/misc.h"
57 #include "../util/fileUtils.h"
58 #include "../util/utils.h"
65 #include "../util/VMSparam.h"
68 #include <sys/param.h>
73 #include <Xm/CascadeB.h>
75 #include <Xm/ToggleB.h>
76 #include <Xm/RowColumn.h>
77 #include <Xm/Separator.h>
78 #include <Xm/MenuShell.h>
85 #define MENU_WIDGET(w) (XmGetPostedFromWidget(XtParent(w)))
87 #define MENU_WIDGET(w) (w)
90 /* Menu modes for SGI_CUSTOM short-menus feature */
91 enum menuModes
{FULL
, SHORT
};
93 typedef void (*menuCallbackProc
)();
95 static void doActionCB(Widget w
, XtPointer clientData
, XtPointer callData
);
96 static void pasteColCB(Widget w
, XtPointer clientData
, XtPointer callData
);
97 static void shiftLeftCB(Widget w
, XtPointer clientData
, XtPointer callData
);
98 static void shiftRightCB(Widget w
, XtPointer clientData
, XtPointer callData
);
99 static void findCB(Widget w
, XtPointer clientData
, XtPointer callData
);
100 static void findSameCB(Widget w
, XtPointer clientData
, XtPointer callData
);
101 static void findSelCB(Widget w
, XtPointer clientData
, XtPointer callData
);
102 static void findIncrCB(Widget w
, XtPointer clientData
, XtPointer callData
);
103 static void replaceCB(Widget w
, XtPointer clientData
, XtPointer callData
);
104 static void replaceSameCB(Widget w
, XtPointer clientData
, XtPointer callData
);
105 static void replaceFindSameCB(Widget w
, XtPointer clientData
, XtPointer callData
);
106 static void markCB(Widget w
, XtPointer clientData
, XtPointer callData
);
107 static void gotoMarkCB(Widget w
, XtPointer clientData
, XtPointer callData
);
108 static void gotoMatchingCB(Widget w
, XtPointer clientData
, XtPointer callData
);
109 static void autoIndentOffCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
110 static void autoIndentCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
111 static void smartIndentCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
112 static void preserveCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
113 static void autoSaveCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
114 static void newlineWrapCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
115 static void noWrapCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
116 static void continuousWrapCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
117 static void wrapMarginCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
118 static void fontCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
119 static void tabsCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
120 static void backlightCharsCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
121 static void showMatchingOffCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
122 static void showMatchingDelimitCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
123 static void showMatchingRangeCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
124 static void matchSyntaxBasedCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
125 static void statsCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
126 static void autoIndentOffDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
127 static void autoIndentDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
128 static void smartIndentDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
129 static void autoSaveDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
130 static void preserveDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
131 static void noWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
132 static void newlineWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
133 static void contWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
134 static void wrapMarginDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
135 static void statsLineDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
136 static void iSearchLineDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
137 static void lineNumsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
138 static void pathInWindowsMenuDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
139 static void customizeTitleDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
140 static void tabsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
141 static void showMatchingOffDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
142 static void showMatchingDelimitDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
143 static void showMatchingRangeDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
144 static void matchSyntaxBasedDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
145 static void highlightOffDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
146 static void highlightDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
147 static void backlightCharsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
148 static void backlightCharTypesDefCB(Widget w
, WindowInfo
*window
,
150 static void fontDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
151 static void smartTagsDefCB(Widget parent
, XtPointer client_data
, XtPointer call_data
);
152 static void showAllTagsDefCB(Widget parent
, XtPointer client_data
, XtPointer call_data
);
153 static void languageDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
154 static void highlightingDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
155 static void smartMacrosDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
156 static void stylesDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
157 static void shellDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
158 static void macroDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
159 static void bgMenuDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
160 static void searchDlogsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
161 static void beepOnSearchWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
162 static void keepSearchDlogsDefCB(Widget w
, WindowInfo
*window
,
164 static void searchWrapsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
165 static void appendLFCB(Widget w
, WindowInfo
* window
, caddr_t callData
);
166 static void sortOpenPrevDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
167 static void reposDlogsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
168 static void modWarnDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
169 static void modWarnRealDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
170 static void exitWarnDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
171 static void searchLiteralCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
172 static void searchCaseSenseCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
173 static void searchLiteralWordCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
174 static void searchCaseSenseWordCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
175 static void searchRegexNoCaseCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
176 static void searchRegexCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
178 static void replaceScopeWindowCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
179 static void replaceScopeSelectionCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
180 static void replaceScopeSmartCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
182 static void size24x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
);
183 static void size40x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
);
184 static void size60x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
);
185 static void size80x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
);
186 static void sizeCustomCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
187 static void savePrefCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
188 static void formFeedCB(Widget w
, XtPointer clientData
, XtPointer callData
);
189 static void cancelShellCB(Widget w
, WindowInfo
*window
, XtPointer callData
);
190 static void learnCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
191 static void finishLearnCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
192 static void cancelLearnCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
193 static void replayCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
194 static void windowMenuCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
195 static void prevOpenMenuCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
196 static void unloadTagsFileMenuCB(Widget w
, WindowInfo
*window
,
198 static void unloadTipsFileMenuCB(Widget w
, WindowInfo
*window
,
200 static void newAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
201 static void openDialogAP(Widget w
, XEvent
*event
, String
*args
,
203 static void openAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
204 static void openSelectedAP(Widget w
, XEvent
*event
, String
*args
,
206 static void closeAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
207 static void saveAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
208 static void saveAsDialogAP(Widget w
, XEvent
*event
, String
*args
,
210 static void saveAsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
211 static void revertDialogAP(Widget w
, XEvent
*event
, String
*args
,
213 static void revertAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
214 static void includeDialogAP(Widget w
, XEvent
*event
, String
*args
,
216 static void includeAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
217 static void loadMacroDialogAP(Widget w
, XEvent
*event
, String
*args
,
219 static void loadMacroAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
220 static void loadTagsDialogAP(Widget w
, XEvent
*event
, String
*args
,
222 static void loadTagsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
223 static void unloadTagsAP(Widget w
, XEvent
*event
, String
*args
,
225 static void loadTipsDialogAP(Widget w
, XEvent
*event
, String
*args
,
227 static void loadTipsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
228 static void unloadTipsAP(Widget w
, XEvent
*event
, String
*args
,
230 static void printAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
231 static void printSelAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
232 static void exitAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
233 static void undoAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
234 static void redoAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
235 static void clearAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
236 static void selAllAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
237 static void shiftLeftAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
238 static void shiftLeftTabAP(Widget w
, XEvent
*event
, String
*args
,
240 static void shiftRightAP(Widget w
, XEvent
*event
, String
*args
,
242 static void shiftRightTabAP(Widget w
, XEvent
*event
, String
*args
,
244 static void findDialogAP(Widget w
, XEvent
*event
, String
*args
,
246 static void findAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
247 static void findSameAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
248 static void findSelAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
249 static void findIncrAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
250 static void startIncrFindAP(Widget w
, XEvent
*event
, String
*args
,
252 static void replaceDialogAP(Widget w
, XEvent
*event
, String
*args
,
254 static void replaceAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
255 static void replaceAllAP(Widget w
, XEvent
*event
, String
*args
,
257 static void replaceInSelAP(Widget w
, XEvent
*event
, String
*args
,
259 static void replaceSameAP(Widget w
, XEvent
*event
, String
*args
,
261 static void replaceFindAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
262 static void replaceFindSameAP(Widget w
, XEvent
*event
, String
*args
,
264 static void gotoAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
265 static void gotoDialogAP(Widget w
, XEvent
*event
, String
*args
,
267 static void gotoSelectedAP(Widget w
, XEvent
*event
, String
*args
,
269 static void repeatDialogAP(Widget w
, XEvent
*event
, String
*args
,
271 static void repeatMacroAP(Widget w
, XEvent
*event
, String
*args
,
273 static void markAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
274 static void markDialogAP(Widget w
, XEvent
*event
, String
*args
,
276 static void gotoMarkAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
277 static void gotoMarkDialogAP(Widget w
, XEvent
*event
, String
*args
,
279 static void selectToMatchingAP(Widget w
, XEvent
*event
, String
*args
,
281 static void gotoMatchingAP(Widget w
, XEvent
*event
, String
*args
,
283 static void findDefAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
284 static void showTipAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
285 static void splitWindowAP(Widget w
, XEvent
*event
, String
*args
,
287 static void closePaneAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
288 static void capitalizeAP(Widget w
, XEvent
*event
, String
*args
,
290 static void lowercaseAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
291 static void fillAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
292 static void controlDialogAP(Widget w
, XEvent
*event
, String
*args
,
295 static void filterDialogAP(Widget w
, XEvent
*event
, String
*args
,
297 static void shellFilterAP(Widget w
, XEvent
*event
, String
*args
,
299 static void execDialogAP(Widget w
, XEvent
*event
, String
*args
,
301 static void execAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
302 static void execLineAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
303 static void shellMenuAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
305 static void macroMenuAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
306 static void bgMenuAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
);
307 static void beginningOfSelectionAP(Widget w
, XEvent
*event
, String
*args
,
309 static void endOfSelectionAP(Widget w
, XEvent
*event
, String
*args
,
311 static Widget
createMenu(Widget parent
, char *name
, char *label
,
312 char mnemonic
, Widget
*cascadeBtn
, int mode
);
313 static Widget
createMenuItem(Widget parent
, char *name
, char *label
,
314 char mnemonic
, menuCallbackProc callback
, void *cbArg
, int mode
);
315 static Widget
createFakeMenuItem(Widget parent
, char *name
,
316 menuCallbackProc callback
, void *cbArg
);
317 static Widget
createMenuToggle(Widget parent
, char *name
, char *label
,
318 char mnemonic
, menuCallbackProc callback
, void *cbArg
, int set
,
320 static Widget
createMenuRadioToggle(Widget parent
, char *name
, char *label
,
321 char mnemonic
, menuCallbackProc callback
, void *cbArg
, int set
,
323 static Widget
createMenuSeparator(Widget parent
, char *name
, int mode
);
324 static void invalidatePrevOpenMenus(void);
325 static void updateWindowMenu(const WindowInfo
*window
);
326 static void updatePrevOpenMenu(WindowInfo
*window
);
327 static void updateTagsFileMenu(WindowInfo
*window
);
328 static void updateTipsFileMenu(WindowInfo
*window
);
329 static int searchDirection(int ignoreArgs
, String
*args
, Cardinal
*nArgs
);
330 static int searchWrap(int ignoreArgs
, String
*args
, Cardinal
*nArgs
);
331 static int searchKeepDialogs(int ignoreArgs
, String
*args
, Cardinal
*nArgs
);
332 static int searchType(int ignoreArgs
, String
*args
, Cardinal
*nArgs
);
333 static char **shiftKeyToDir(XtPointer callData
);
334 static void raiseCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
335 static void openPrevCB(Widget w
, char *name
, caddr_t callData
);
336 static void unloadTagsFileCB(Widget w
, char *name
, caddr_t callData
);
337 static void unloadTipsFileCB(Widget w
, char *name
, caddr_t callData
);
338 static int cmpStrPtr(const void *strA
, const void *strB
);
339 static void setWindowSizeDefault(int rows
, int cols
);
340 static void updateWindowSizeMenus(void);
341 static void updateWindowSizeMenu(WindowInfo
*win
);
342 static int strCaseCmp(const char *str1
, const char *str2
);
343 static int compareWindowNames(const void *windowA
, const void *windowB
);
344 static void bgMenuPostAP(Widget w
, XEvent
*event
, String
*args
,
346 static void raiseWindowAP(Widget w
, XEvent
*event
, String
*args
,
348 static void focusPaneAP(Widget w
, XEvent
*event
, String
*args
,
350 static void setStatisticsLineAP(Widget w
, XEvent
*event
, String
*args
,
352 static void setIncrementalSearchLineAP(Widget w
, XEvent
*event
, String
*args
,
354 static void setShowLineNumbersAP(Widget w
, XEvent
*event
, String
*args
,
356 static void setAutoIndentAP(Widget w
, XEvent
*event
, String
*args
,
358 static void setWrapTextAP(Widget w
, XEvent
*event
, String
*args
,
360 static void setWrapMarginAP(Widget w
, XEvent
*event
, String
*args
,
362 static void setHighlightSyntaxAP(Widget w
, XEvent
*event
, String
*args
,
364 static void setMakeBackupCopyAP(Widget w
, XEvent
*event
, String
*args
,
366 static void setIncrementalBackupAP(Widget w
, XEvent
*event
, String
*args
,
368 static void setShowMatchingAP(Widget w
, XEvent
*event
, String
*args
,
370 static void setMatchSyntaxBasedAP(Widget w
, XEvent
*event
, String
*args
,
372 static void setOvertypeModeAP(Widget w
, XEvent
*event
, String
*args
,
374 static void setLockedAP(Widget w
, XEvent
*event
, String
*args
,
376 static void setUseTabsAP(Widget w
, XEvent
*event
, String
*args
,
378 static void setEmTabDistAP(Widget w
, XEvent
*event
, String
*args
,
380 static void setTabDistAP(Widget w
, XEvent
*event
, String
*args
,
382 static void setFontsAP(Widget w
, XEvent
*event
, String
*args
,
384 static void setLanguageModeAP(Widget w
, XEvent
*event
, String
*args
,
387 static void shortMenusCB(Widget w
, WindowInfo
*window
, caddr_t callData
);
388 static void addToToggleShortList(Widget w
);
389 static int shortPrefAskDefault(Widget parent
, Widget w
, const char *settingName
);
392 static HelpMenu
* buildHelpMenu( Widget pane
, HelpMenu
* menu
,
393 WindowInfo
* window
);
395 /* Application action table */
396 static XtActionsRec Actions
[] = {
399 {"open-dialog", openDialogAP
},
400 {"open_dialog", openDialogAP
},
401 {"open-selected", openSelectedAP
},
402 {"open_selected", openSelectedAP
},
405 {"save-as", saveAsAP
},
406 {"save_as", saveAsAP
},
407 {"save-as-dialog", saveAsDialogAP
},
408 {"save_as_dialog", saveAsDialogAP
},
409 {"revert-to-saved", revertAP
},
410 {"revert_to_saved", revertAP
},
411 {"revert_to_saved_dialog", revertDialogAP
},
412 {"include-file", includeAP
},
413 {"include_file", includeAP
},
414 {"include-file-dialog", includeDialogAP
},
415 {"include_file_dialog", includeDialogAP
},
416 {"load-macro-file", loadMacroAP
},
417 {"load_macro_file", loadMacroAP
},
418 {"load-macro-file-dialog", loadMacroDialogAP
},
419 {"load_macro_file_dialog", loadMacroDialogAP
},
420 {"load-tags-file", loadTagsAP
},
421 {"load_tags_file", loadTagsAP
},
422 {"load-tags-file-dialog", loadTagsDialogAP
},
423 {"load_tags_file_dialog", loadTagsDialogAP
},
424 {"unload_tags_file", unloadTagsAP
},
425 {"load_tips_file", loadTipsAP
},
426 {"load_tips_file_dialog", loadTipsDialogAP
},
427 {"unload_tips_file", unloadTipsAP
},
429 {"print-selection", printSelAP
},
430 {"print_selection", printSelAP
},
435 {"select-all", selAllAP
},
436 {"select_all", selAllAP
},
437 {"shift-left", shiftLeftAP
},
438 {"shift_left", shiftLeftAP
},
439 {"shift-left-by-tab", shiftLeftTabAP
},
440 {"shift_left_by_tab", shiftLeftTabAP
},
441 {"shift-right", shiftRightAP
},
442 {"shift_right", shiftRightAP
},
443 {"shift-right-by-tab", shiftRightTabAP
},
444 {"shift_right_by_tab", shiftRightTabAP
},
446 {"find-dialog", findDialogAP
},
447 {"find_dialog", findDialogAP
},
448 {"find-again", findSameAP
},
449 {"find_again", findSameAP
},
450 {"find-selection", findSelAP
},
451 {"find_selection", findSelAP
},
452 {"find_incremental", findIncrAP
},
453 {"start_incremental_find", startIncrFindAP
},
454 {"replace", replaceAP
},
455 {"replace-dialog", replaceDialogAP
},
456 {"replace_dialog", replaceDialogAP
},
457 {"replace-all", replaceAllAP
},
458 {"replace_all", replaceAllAP
},
459 {"replace-in-selection", replaceInSelAP
},
460 {"replace_in_selection", replaceInSelAP
},
461 {"replace-again", replaceSameAP
},
462 {"replace_again", replaceSameAP
},
463 {"replace_find", replaceFindAP
},
464 {"replace_find_same", replaceFindSameAP
},
465 {"replace_find_again", replaceFindSameAP
},
466 {"goto-line-number", gotoAP
},
467 {"goto_line_number", gotoAP
},
468 {"goto-line-number-dialog", gotoDialogAP
},
469 {"goto_line_number_dialog", gotoDialogAP
},
470 {"goto-selected", gotoSelectedAP
},
471 {"goto_selected", gotoSelectedAP
},
473 {"mark-dialog", markDialogAP
},
474 {"mark_dialog", markDialogAP
},
475 {"goto-mark", gotoMarkAP
},
476 {"goto_mark", gotoMarkAP
},
477 {"goto-mark-dialog", gotoMarkDialogAP
},
478 {"goto_mark_dialog", gotoMarkDialogAP
},
479 {"match", selectToMatchingAP
},
480 {"select_to_matching", selectToMatchingAP
},
481 {"goto_matching", gotoMatchingAP
},
482 {"find-definition", findDefAP
},
483 {"find_definition", findDefAP
},
484 {"show_tip", showTipAP
},
485 {"split-window", splitWindowAP
},
486 {"split_window", splitWindowAP
},
487 {"close-pane", closePaneAP
},
488 {"close_pane", closePaneAP
},
489 {"uppercase", capitalizeAP
},
490 {"lowercase", lowercaseAP
},
491 {"fill-paragraph", fillAP
},
492 {"fill_paragraph", fillAP
},
493 {"control-code-dialog", controlDialogAP
},
494 {"control_code_dialog", controlDialogAP
},
496 {"filter-selection-dialog", filterDialogAP
},
497 {"filter_selection_dialog", filterDialogAP
},
498 {"filter-selection", shellFilterAP
},
499 {"filter_selection", shellFilterAP
},
500 {"execute-command", execAP
},
501 {"execute_command", execAP
},
502 {"execute-command-dialog", execDialogAP
},
503 {"execute_command_dialog", execDialogAP
},
504 {"execute-command-line", execLineAP
},
505 {"execute_command_line", execLineAP
},
506 {"shell-menu-command", shellMenuAP
},
507 {"shell_menu_command", shellMenuAP
},
509 {"macro-menu-command", macroMenuAP
},
510 {"macro_menu_command", macroMenuAP
},
511 {"bg_menu_command", bgMenuAP
},
512 {"post_window_bg_menu", bgMenuPostAP
},
513 {"beginning-of-selection", beginningOfSelectionAP
},
514 {"beginning_of_selection", beginningOfSelectionAP
},
515 {"end-of-selection", endOfSelectionAP
},
516 {"end_of_selection", endOfSelectionAP
},
517 {"repeat_macro", repeatMacroAP
},
518 {"repeat_dialog", repeatDialogAP
},
519 {"raise_window", raiseWindowAP
},
520 {"focus_pane", focusPaneAP
},
521 {"set_statistics_line", setStatisticsLineAP
},
522 {"set_incremental_search_line", setIncrementalSearchLineAP
},
523 {"set_show_line_numbers", setShowLineNumbersAP
},
524 {"set_auto_indent", setAutoIndentAP
},
525 {"set_wrap_text", setWrapTextAP
},
526 {"set_wrap_margin", setWrapMarginAP
},
527 {"set_highlight_syntax", setHighlightSyntaxAP
},
529 {"set_make_backup_copy", setMakeBackupCopyAP
},
531 {"set_incremental_backup", setIncrementalBackupAP
},
532 {"set_show_matching", setShowMatchingAP
},
533 {"set_match_syntax_based", setMatchSyntaxBasedAP
},
534 {"set_overtype_mode", setOvertypeModeAP
},
535 {"set_locked", setLockedAP
},
536 {"set_tab_dist", setTabDistAP
},
537 {"set_em_tab_dist", setEmTabDistAP
},
538 {"set_use_tabs", setUseTabsAP
},
539 {"set_fonts", setFontsAP
},
540 {"set_language_mode", setLanguageModeAP
}
543 /* List of previously opened files for File menu */
544 static int NPrevOpen
= 0;
545 static char **PrevOpen
;
548 /* Window to receive items to be toggled on and off in short menus mode */
549 static WindowInfo
*ShortMenuWindow
;
552 void HidePointerOnKeyedEvent(Widget w
, XEvent
*event
)
554 if (event
&& (event
->type
== KeyPress
|| event
->type
== KeyRelease
)) {
555 ShowHidePointer((TextWidget
)w
, True
);
560 ** Install actions for use in translation tables and macro recording, relating
561 ** to menu item commands
563 void InstallMenuActions(XtAppContext context
)
565 XtAppAddActions(context
, Actions
, XtNumber(Actions
));
569 ** Return the (statically allocated) action table for menu item actions.
571 XtActionsRec
*GetMenuActions(int *nActions
)
573 *nActions
= XtNumber(Actions
);
578 ** Create the menu bar
580 Widget
CreateMenuBar(Widget parent
, WindowInfo
*window
)
582 Widget menuBar
, menuPane
, btn
, subPane
, subSubPane
, subSubSubPane
, cascade
;
585 ** Create the menu bar (row column) widget
587 menuBar
= XmCreateMenuBar(parent
, "menuBar", NULL
, 0);
591 ** Short menu mode is a special feature for the SGI system distribution
594 ** To make toggling short-menus mode faster (re-creating the menus was
595 ** too slow), a list is kept in the window data structure of items to
596 ** be turned on and off. Initialize that list and give the menu creation
597 ** routines a pointer to the window on which this list is kept. This is
598 ** (unfortunately) a global variable to keep the interface simple for
599 ** the mainstream case.
601 ShortMenuWindow
= window
;
602 window
->nToggleShortItems
= 0;
606 ** "File" pull down menu.
608 menuPane
= createMenu(menuBar
, "fileMenu", "File", 0, NULL
, SHORT
);
609 createMenuItem(menuPane
, "new", "New", 'N', doActionCB
, "new", SHORT
);
610 createMenuItem(menuPane
, "open", "Open...", 'O', doActionCB
, "open_dialog",
612 window
->openSelItem
=createMenuItem(menuPane
, "openSelected", "Open Selected", 'd',
613 doActionCB
, "open_selected", FULL
);
614 if (GetPrefMaxPrevOpenFiles() != 0) {
615 window
->prevOpenMenuPane
= createMenu(menuPane
, "openPrevious",
616 "Open Previous", 'v', &window
->prevOpenMenuItem
, SHORT
);
617 XtSetSensitive(window
->prevOpenMenuItem
, NPrevOpen
!= 0);
618 XtAddCallback(window
->prevOpenMenuItem
, XmNcascadingCallback
,
619 (XtCallbackProc
)prevOpenMenuCB
, window
);
621 createMenuSeparator(menuPane
, "sep1", SHORT
);
622 window
->closeItem
= createMenuItem(menuPane
, "close", "Close", 'C',
623 doActionCB
, "close", SHORT
);
624 createMenuItem(menuPane
, "save", "Save", 'S', doActionCB
, "save", SHORT
);
625 createMenuItem(menuPane
, "saveAs", "Save As...", 'A', doActionCB
,
626 "save_as_dialog", SHORT
);
627 createMenuItem(menuPane
, "revertToSaved", "Revert to Saved", 'R',
628 doActionCB
, "revert_to_saved_dialog", SHORT
);
629 createMenuSeparator(menuPane
, "sep2", SHORT
);
630 createMenuItem(menuPane
, "includeFile", "Include File...", 'I',
631 doActionCB
, "include_file_dialog", SHORT
);
632 createMenuItem(menuPane
, "loadMacroFile", "Load Macro File...", 'M',
633 doActionCB
, "load_macro_file_dialog", FULL
);
634 createMenuItem(menuPane
, "loadTagsFile", "Load Tags File...", 'T',
635 doActionCB
, "load_tags_file_dialog", FULL
);
636 window
->unloadTagsMenuPane
= createMenu(menuPane
, "unloadTagsFiles",
637 "Unload Tags File", 'U', &window
->unloadTagsMenuItem
, FULL
);
638 XtSetSensitive(window
->unloadTagsMenuItem
, TagsFileList
!= NULL
);
639 XtAddCallback(window
->unloadTagsMenuItem
, XmNcascadingCallback
,
640 (XtCallbackProc
)unloadTagsFileMenuCB
, window
);
641 createMenuItem(menuPane
, "loadTipsFile", "Load Calltips File...", 'F',
642 doActionCB
, "load_tips_file_dialog", FULL
);
643 window
->unloadTipsMenuPane
= createMenu(menuPane
, "unloadTipsFiles",
644 "Unload Calltips File", 'e', &window
->unloadTipsMenuItem
, FULL
);
645 XtSetSensitive(window
->unloadTipsMenuItem
, TipsFileList
!= NULL
);
646 XtAddCallback(window
->unloadTipsMenuItem
, XmNcascadingCallback
,
647 (XtCallbackProc
)unloadTipsFileMenuCB
, window
);
648 createMenuSeparator(menuPane
, "sep3", SHORT
);
649 createMenuItem(menuPane
, "print", "Print...", 'P', doActionCB
, "print",
651 window
->printSelItem
= createMenuItem(menuPane
, "printSelection",
652 "Print Selection...", 'l', doActionCB
, "print_selection",
654 XtSetSensitive(window
->printSelItem
, window
->wasSelected
);
655 createMenuSeparator(menuPane
, "sep4", SHORT
);
656 createMenuItem(menuPane
, "exit", "Exit", 'x', doActionCB
, "exit", SHORT
);
660 ** "Edit" pull down menu.
662 menuPane
= createMenu(menuBar
, "editMenu", "Edit", 0, NULL
, SHORT
);
663 window
->undoItem
= createMenuItem(menuPane
, "undo", "Undo", 'U',
664 doActionCB
, "undo", SHORT
);
665 XtSetSensitive(window
->undoItem
, False
);
666 window
->redoItem
= createMenuItem(menuPane
, "redo", "Redo", 'R',
667 doActionCB
, "redo", SHORT
);
668 XtSetSensitive(window
->redoItem
, False
);
669 createMenuSeparator(menuPane
, "sep1", SHORT
);
670 window
->cutItem
= createMenuItem(menuPane
, "cut", "Cut", 't', doActionCB
,
671 "cut_clipboard", SHORT
);
672 XtSetSensitive(window
->cutItem
, window
->wasSelected
);
673 window
->copyItem
= createMenuItem(menuPane
, "copy", "Copy", 'C', doActionCB
,
674 "copy_clipboard", SHORT
);
675 XtSetSensitive(window
->copyItem
, window
->wasSelected
);
676 createMenuItem(menuPane
, "paste", "Paste", 'P', doActionCB
,
677 "paste_clipboard", SHORT
);
678 createMenuItem(menuPane
, "pasteColumn", "Paste Column", 's', pasteColCB
,
680 window
->delItem
=createMenuItem(menuPane
, "delete", "Delete", 'D', doActionCB
, "delete_selection",
682 XtSetSensitive(window
->delItem
, window
->wasSelected
);
683 createMenuItem(menuPane
, "selectAll", "Select All", 'A', doActionCB
,
684 "select_all", SHORT
);
685 createMenuSeparator(menuPane
, "sep2", SHORT
);
686 createMenuItem(menuPane
, "shiftLeft", "Shift Left", 'L',
687 shiftLeftCB
, window
, SHORT
);
688 createFakeMenuItem(menuPane
, "shiftLeftShift", shiftLeftCB
, window
);
689 createMenuItem(menuPane
, "shiftRight", "Shift Right", 'g',
690 shiftRightCB
, window
, SHORT
);
691 createFakeMenuItem(menuPane
, "shiftRightShift", shiftRightCB
, window
);
692 window
->lowerItem
=createMenuItem(menuPane
, "lowerCase", "Lower-case", 'w',
693 doActionCB
, "lowercase", SHORT
);
694 window
->upperItem
=createMenuItem(menuPane
, "upperCase", "Upper-case", 'e',
695 doActionCB
, "uppercase", SHORT
);
696 createMenuItem(menuPane
, "fillParagraph", "Fill Paragraph", 'F',
697 doActionCB
, "fill_paragraph", SHORT
);
698 createMenuSeparator(menuPane
, "sep3", FULL
);
699 createMenuItem(menuPane
, "insertFormFeed", "Insert Form Feed", 'I',
700 formFeedCB
, window
, FULL
);
701 createMenuItem(menuPane
, "insertCtrlCode", "Insert Ctrl Code...", 'n',
702 doActionCB
, "control_code_dialog", FULL
);
704 createMenuSeparator(menuPane
, "sep4", SHORT
);
705 createMenuToggle(menuPane
, "overtype", "Overtype", 'O',
706 doActionCB
, "set_overtype_mode", False
, SHORT
);
707 window
->readOnlyItem
= createMenuToggle(menuPane
, "readOnly", "Read Only",
708 'y', doActionCB
, "set_locked", IS_USER_LOCKED(window
->lockReasons
), FULL
);
712 ** "Search" pull down menu.
714 menuPane
= createMenu(menuBar
, "searchMenu", "Search", 0, NULL
, SHORT
);
715 createMenuItem(menuPane
, "find", "Find...", 'F', findCB
, window
, SHORT
);
716 createFakeMenuItem(menuPane
, "findShift", findCB
, window
);
717 window
->findAgainItem
=createMenuItem(menuPane
, "findAgain", "Find Again", 'i', findSameCB
, window
,
719 XtSetSensitive(window
->findAgainItem
, NHist
);
720 createFakeMenuItem(menuPane
, "findAgainShift", findSameCB
, window
);
721 window
->findSelItem
=createMenuItem(menuPane
, "findSelection", "Find Selection", 'S',
722 findSelCB
, window
, SHORT
);
723 createFakeMenuItem(menuPane
, "findSelectionShift", findSelCB
, window
);
724 createMenuItem(menuPane
, "findIncremental", "Find Incremental", 'n',
725 findIncrCB
, window
, SHORT
);
726 createFakeMenuItem(menuPane
, "findIncrementalShift", findIncrCB
, window
);
727 createMenuItem(menuPane
, "replace", "Replace...", 'R', replaceCB
, window
,
729 createFakeMenuItem(menuPane
, "replaceShift", replaceCB
, window
);
730 window
->replaceFindAgainItem
=createMenuItem(menuPane
, "replaceFindAgain", "Replace Find Again", 'A',
731 replaceFindSameCB
, window
, SHORT
);
732 XtSetSensitive(window
->replaceFindAgainItem
, NHist
);
733 createFakeMenuItem(menuPane
, "replaceFindAgainShift", replaceFindSameCB
, window
);
734 window
->replaceAgainItem
=createMenuItem(menuPane
, "replaceAgain", "Replace Again", 'p',
735 replaceSameCB
, window
, SHORT
);
736 XtSetSensitive(window
->replaceAgainItem
, NHist
);
737 createFakeMenuItem(menuPane
, "replaceAgainShift", replaceSameCB
, window
);
738 createMenuSeparator(menuPane
, "sep1", FULL
);
739 createMenuItem(menuPane
, "gotoLineNumber", "Goto Line Number...", 'L',
740 doActionCB
, "goto_line_number_dialog", FULL
);
741 window
->gotoSelItem
=createMenuItem(menuPane
, "gotoSelected", "Goto Selected", 'G',
742 doActionCB
, "goto_selected", FULL
);
743 createMenuSeparator(menuPane
, "sep2", FULL
);
744 createMenuItem(menuPane
, "mark", "Mark", 'k', markCB
, window
, FULL
);
745 createMenuItem(menuPane
, "gotoMark", "Goto Mark", 'o', gotoMarkCB
, window
,
747 createFakeMenuItem(menuPane
, "gotoMarkShift", gotoMarkCB
, window
);
748 createMenuSeparator(menuPane
, "sep3", FULL
);
749 createMenuItem(menuPane
, "gotoMatching", "Goto Matching (..)", 'M',
750 gotoMatchingCB
, window
, FULL
);
751 createFakeMenuItem(menuPane
, "gotoMatchingShift", gotoMatchingCB
, window
);
752 window
->findDefItem
= createMenuItem(menuPane
, "findDefinition",
753 "Find Definition", 'D', doActionCB
, "find_definition", FULL
);
754 XtSetSensitive(window
->findDefItem
, TagsFileList
!= NULL
);
755 window
->showTipItem
= createMenuItem(menuPane
, "showCalltip",
756 "Show Calltip", 'C', doActionCB
, "show_tip", FULL
);
757 XtSetSensitive(window
->showTipItem
, (TagsFileList
!= NULL
||
758 TipsFileList
!= NULL
) );
761 ** Preferences menu, Default Settings sub menu
763 menuPane
= createMenu(menuBar
, "preferencesMenu", "Preferences", 0, NULL
,
765 subPane
= createMenu(menuPane
, "defaultSettings", "Default Settings", 'D',
767 createMenuItem(subPane
, "languageModes", "Language Modes...", 'L',
768 languageDefCB
, window
, FULL
);
770 /* Auto Indent sub menu */
771 subSubPane
= createMenu(subPane
, "autoIndent", "Auto Indent", 'A',
773 window
->autoIndentOffDefItem
= createMenuRadioToggle(subSubPane
, "off",
774 "Off", 'O', autoIndentOffDefCB
, window
,
775 GetPrefAutoIndent(PLAIN_LANGUAGE_MODE
) == NO_AUTO_INDENT
, SHORT
);
776 window
->autoIndentDefItem
= createMenuRadioToggle(subSubPane
, "on",
777 "On", 'n', autoIndentDefCB
, window
,
778 GetPrefAutoIndent(PLAIN_LANGUAGE_MODE
) == AUTO_INDENT
, SHORT
);
779 window
->smartIndentDefItem
= createMenuRadioToggle(subSubPane
, "smart",
780 "Smart", 'S', smartIndentDefCB
, window
,
781 GetPrefAutoIndent(PLAIN_LANGUAGE_MODE
) == SMART_INDENT
, SHORT
);
782 createMenuSeparator(subSubPane
, "sep1", SHORT
);
783 createMenuItem(subSubPane
, "ProgramSmartIndent", "Program Smart Indent...",
784 'P', smartMacrosDefCB
, window
, FULL
);
787 subSubPane
= createMenu(subPane
, "wrap", "Wrap", 'W', NULL
, FULL
);
788 window
->noWrapDefItem
= createMenuRadioToggle(subSubPane
,
789 "none", "None", 'N', noWrapDefCB
,
790 window
, GetPrefWrap(PLAIN_LANGUAGE_MODE
) == NO_WRAP
, SHORT
);
791 window
->newlineWrapDefItem
= createMenuRadioToggle(subSubPane
,
792 "autoNewline", "Auto Newline", 'A', newlineWrapDefCB
,
793 window
, GetPrefWrap(PLAIN_LANGUAGE_MODE
) == NEWLINE_WRAP
, SHORT
);
794 window
->contWrapDefItem
= createMenuRadioToggle(subSubPane
, "continuous",
795 "Continuous", 'C', contWrapDefCB
, window
,
796 GetPrefWrap(PLAIN_LANGUAGE_MODE
) == CONTINUOUS_WRAP
, SHORT
);
797 createMenuSeparator(subSubPane
, "sep1", SHORT
);
798 createMenuItem(subSubPane
, "wrapMargin", "Wrap Margin...", 'W',
799 wrapMarginDefCB
, window
, SHORT
);
801 /* Smart Tags sub menu */
802 subSubPane
= createMenu(subPane
, "smartTags", "Tag Collisions", 'C',
804 window
->allTagsDefItem
= createMenuRadioToggle(subSubPane
, "showall",
805 "Show All", 'A', showAllTagsDefCB
, window
, !GetPrefSmartTags(),
807 window
->smartTagsDefItem
= createMenuRadioToggle(subSubPane
, "smart",
808 "Smart", 'S', smartTagsDefCB
, window
, GetPrefSmartTags(), FULL
);
810 createMenuItem(subPane
, "tabDistance", "Tabs...", 'T', tabsDefCB
, window
,
812 createMenuItem(subPane
, "textFont", "Text Font...", 'F', fontDefCB
, window
,
815 /* Customize Menus sub menu */
816 subSubPane
= createMenu(subPane
, "customizeMenus", "Customize Menus",
819 createMenuItem(subSubPane
, "shellMenu", "Shell Menu...", 'S',
820 shellDefCB
, window
, FULL
);
822 createMenuItem(subSubPane
, "macroMenu", "Macro Menu...", 'M',
823 macroDefCB
, window
, FULL
);
824 createMenuItem(subSubPane
, "windowBackgroundMenu",
825 "Window Background Menu...", 'W', bgMenuDefCB
, window
, FULL
);
826 createMenuSeparator(subSubPane
, "sep1", SHORT
);
827 window
->pathInWindowsMenuDefItem
= createMenuToggle(subSubPane
, "pathInWindowsMenu",
828 "Show Path In Windows Menu", 'P', pathInWindowsMenuDefCB
, window
, GetPrefShowPathInWindowsMenu(),
830 createMenuItem(subPane
, "custimizeTitle", "Customize Window Title...", 'd',
831 customizeTitleDefCB
, window
, FULL
);
833 /* Search sub menu */
834 subSubPane
= createMenu(subPane
, "searching", "Searching",
836 window
->searchDlogsDefItem
= createMenuToggle(subSubPane
, "verbose",
837 "Verbose", 'V', searchDlogsDefCB
, window
,
838 GetPrefSearchDlogs(), SHORT
);
839 window
->searchWrapsDefItem
= createMenuToggle(subSubPane
, "wrapAround",
840 "Wrap Around", 'W', searchWrapsDefCB
, window
,
841 GetPrefSearchWraps(), SHORT
);
842 window
->beepOnSearchWrapDefItem
= createMenuToggle(subSubPane
,
843 "beepOnSearchWrap", "Beep On Search Wrap", 'B',
844 beepOnSearchWrapDefCB
, window
, GetPrefBeepOnSearchWrap(), SHORT
);
845 window
->keepSearchDlogsDefItem
= createMenuToggle(subSubPane
,
846 "keepDialogsUp", "Keep Dialogs Up", 'K',
847 keepSearchDlogsDefCB
, window
, GetPrefKeepSearchDlogs(), SHORT
);
848 subSubSubPane
= createMenu(subSubPane
, "defaultSearchStyle",
849 "Default Search Style", 'D', NULL
, FULL
);
850 XtVaSetValues(subSubSubPane
, XmNradioBehavior
, True
, NULL
);
851 window
->searchLiteralDefItem
= createMenuToggle(subSubSubPane
, "literal",
852 "Literal", 'L', searchLiteralCB
, window
,
853 GetPrefSearch() == SEARCH_LITERAL
, FULL
);
854 window
->searchCaseSenseDefItem
= createMenuToggle(subSubSubPane
,
855 "caseSensitive", "Literal, Case Sensitive", 'C', searchCaseSenseCB
, window
,
856 GetPrefSearch() == SEARCH_CASE_SENSE
, FULL
);
857 window
->searchLiteralWordDefItem
= createMenuToggle(subSubSubPane
, "literalWord",
858 "Literal, Whole Word", 'W', searchLiteralWordCB
, window
,
859 GetPrefSearch() == SEARCH_LITERAL_WORD
, FULL
);
860 window
->searchCaseSenseWordDefItem
= createMenuToggle(subSubSubPane
,
861 "caseSensitiveWord", "Literal, Case Sensitive, Whole Word", 't', searchCaseSenseWordCB
, window
,
862 GetPrefSearch() == SEARCH_CASE_SENSE_WORD
, FULL
);
863 window
->searchRegexDefItem
= createMenuToggle(subSubSubPane
,
864 "regularExpression", "Regular Expression", 'R', searchRegexCB
,
865 window
, GetPrefSearch() == SEARCH_REGEX
, FULL
);
866 window
->searchRegexNoCaseDefItem
= createMenuToggle(subSubSubPane
,
867 "regularExpressionNoCase", "Regular Expression, Case Insensitive", 'I', searchRegexNoCaseCB
, window
,
868 GetPrefSearch() == SEARCH_REGEX_NOCASE
, FULL
);
870 subSubSubPane
= createMenu(subSubPane
, "defaultReplaceScope",
871 "Default Replace Scope", 'R', NULL
, FULL
);
872 XtVaSetValues(subSubSubPane
, XmNradioBehavior
, True
, NULL
);
873 window
->replScopeWinDefItem
= createMenuToggle(subSubSubPane
, "window",
874 "In Window", 'W', replaceScopeWindowCB
, window
,
875 GetPrefReplaceDefScope() == REPL_DEF_SCOPE_WINDOW
, FULL
);
876 window
->replScopeSelDefItem
= createMenuToggle(subSubSubPane
, "selection",
877 "In Selection", 'S', replaceScopeSelectionCB
, window
,
878 GetPrefReplaceDefScope() == REPL_DEF_SCOPE_SELECTION
, FULL
);
879 window
->replScopeSmartDefItem
= createMenuToggle(subSubSubPane
, "window",
880 "Smart", 'm', replaceScopeSmartCB
, window
,
881 GetPrefReplaceDefScope() == REPL_DEF_SCOPE_SMART
, FULL
);
884 /* Syntax Highlighting sub menu */
885 subSubPane
= createMenu(subPane
, "syntaxHighlighting","Syntax Highlighting",
887 window
->highlightOffDefItem
= createMenuRadioToggle(subSubPane
, "off","Off",
888 'O', highlightOffDefCB
, window
, !GetPrefHighlightSyntax(), FULL
);
889 window
->highlightDefItem
= createMenuRadioToggle(subSubPane
, "on",
890 "On", 'n', highlightDefCB
, window
, GetPrefHighlightSyntax(), FULL
);
891 createMenuSeparator(subSubPane
, "sep1", SHORT
);
892 createMenuItem(subSubPane
, "recognitionPatterns", "Recognition Patterns...",
893 'R', highlightingDefCB
, window
, FULL
);
894 createMenuItem(subSubPane
, "textDrawingStyles", "Text Drawing Styles...", 'T',
895 stylesDefCB
, window
, FULL
);
896 subSubPane
= createMenu(subPane
, "backlighting", "Backlighting",
898 window
->backlightCharsDefItem
= createMenuToggle(subSubPane
,
899 "backlightChars", "Apply Backlighting", 'g', backlightCharsDefCB
,
900 window
, GetPrefBacklightChars(), FULL
);
901 createMenuItem(subSubPane
, "backlightCharTypes", "Use Current",
902 'U', backlightCharTypesDefCB
, window
, FULL
);
904 window
->statsLineDefItem
= createMenuToggle(subPane
, "statisticsLine",
905 "Statistics Line", 'S', statsLineDefCB
, window
, GetPrefStatsLine(),
907 window
->iSearchLineDefItem
= createMenuToggle(subPane
,
908 "incrementalSearchLine", "Incremental Search Line", 'i',
909 iSearchLineDefCB
, window
, GetPrefISearchLine(), FULL
);
910 window
->lineNumsDefItem
= createMenuToggle(subPane
, "showLineNumbers",
911 "Show Line Numbers", 'N', lineNumsDefCB
, window
, GetPrefLineNums(),
913 window
->saveLastDefItem
= createMenuToggle(subPane
, "preserveLastVersion",
914 "Make Backup Copy (*.bck)", 'e', preserveDefCB
, window
,
915 GetPrefSaveOldVersion(), SHORT
);
916 window
->autoSaveDefItem
= createMenuToggle(subPane
, "incrementalBackup",
917 "Incremental Backup", 'B', autoSaveDefCB
, window
, GetPrefAutoSave(),
920 /* Show Matching sub menu */
921 subSubPane
= createMenu(subPane
, "showMatching", "Show Matching (..)", 'M',
923 window
->showMatchingOffDefItem
= createMenuRadioToggle(subSubPane
, "off",
924 "Off", 'O', showMatchingOffDefCB
, window
,
925 GetPrefShowMatching() == NO_FLASH
, SHORT
);
926 window
->showMatchingDelimitDefItem
= createMenuRadioToggle(subSubPane
,
927 "delimiter", "Delimiter", 'D', showMatchingDelimitDefCB
, window
,
928 GetPrefShowMatching() == FLASH_DELIMIT
, SHORT
);
929 window
->showMatchingRangeDefItem
= createMenuRadioToggle(subSubPane
,
930 "range", "Range", 'R', showMatchingRangeDefCB
, window
,
931 GetPrefShowMatching() == FLASH_RANGE
, SHORT
);
932 createMenuSeparator(subSubPane
, "sep", SHORT
);
933 window
->matchSyntaxBasedDefItem
= createMenuToggle(subSubPane
,
934 "matchSyntax", "Syntax Based", 'S', matchSyntaxBasedDefCB
, window
,
935 GetPrefMatchSyntaxBased(), SHORT
);
937 /* Append LF at end of files on save */
938 window
->appendLFItem
= createMenuToggle(subPane
, "appendLFItem",
939 "Append Line Feed on Save", 'v', appendLFCB
, NULL
,
940 GetPrefAppendLF(), FULL
);
942 window
->sortOpenPrevDefItem
= createMenuToggle(subPane
, "sortOpenPrevMenu",
943 "Sort Open Prev. Menu", 'o', sortOpenPrevDefCB
, window
,
944 GetPrefSortOpenPrevMenu(), FULL
);
945 window
->reposDlogsDefItem
= createMenuToggle(subPane
, "popupsUnderPointer",
946 "Popups Under Pointer", 'P', reposDlogsDefCB
, window
,
947 GetPrefRepositionDialogs(), FULL
);
948 subSubPane
= createMenu(subPane
, "warnings", "Warnings", 'r', NULL
, FULL
);
949 window
->modWarnDefItem
= createMenuToggle(subSubPane
,
950 "filesModifiedExternally", "Files Modified Externally", 'F',
951 modWarnDefCB
, window
, GetPrefWarnFileMods(), FULL
);
952 window
->modWarnRealDefItem
= createMenuToggle(subSubPane
,
953 "checkModifiedFileContents", "Check Modified File Contents", 'C',
954 modWarnRealDefCB
, window
, GetPrefWarnRealFileMods(), FULL
);
955 XtSetSensitive(window
->modWarnRealDefItem
, GetPrefWarnFileMods());
956 window
->exitWarnDefItem
= createMenuToggle(subSubPane
, "onExit", "On Exit", 'O',
957 exitWarnDefCB
, window
, GetPrefWarnExit(), FULL
);
959 /* Initial Window Size sub menu (simulates radioBehavior) */
960 subSubPane
= createMenu(subPane
, "initialwindowSize",
961 "Initial Window Size", 'z', NULL
, FULL
);
962 /* XtVaSetValues(subSubPane, XmNradioBehavior, True, NULL); */
963 window
->size24x80DefItem
= btn
= createMenuToggle(subSubPane
, "24X80",
964 "24 x 80", '2', size24x80CB
, window
, False
, SHORT
);
965 XtVaSetValues(btn
, XmNindicatorType
, XmONE_OF_MANY
, NULL
);
966 window
->size40x80DefItem
= btn
= createMenuToggle(subSubPane
, "40X80",
967 "40 x 80", '4', size40x80CB
, window
, False
, SHORT
);
968 XtVaSetValues(btn
, XmNindicatorType
, XmONE_OF_MANY
, NULL
);
969 window
->size60x80DefItem
= btn
= createMenuToggle(subSubPane
, "60X80",
970 "60 x 80", '6', size60x80CB
, window
, False
, SHORT
);
971 XtVaSetValues(btn
, XmNindicatorType
, XmONE_OF_MANY
, NULL
);
972 window
->size80x80DefItem
= btn
= createMenuToggle(subSubPane
, "80X80",
973 "80 x 80", '8', size80x80CB
, window
, False
, SHORT
);
974 XtVaSetValues(btn
, XmNindicatorType
, XmONE_OF_MANY
, NULL
);
975 window
->sizeCustomDefItem
= btn
= createMenuToggle(subSubPane
, "custom",
976 "Custom...", 'C', sizeCustomCB
, window
, False
, SHORT
);
977 XtVaSetValues(btn
, XmNindicatorType
, XmONE_OF_MANY
, NULL
);
978 updateWindowSizeMenu(window
);
981 ** Remainder of Preferences menu
983 createMenuItem(menuPane
, "saveDefaults", "Save Defaults...", 'v',
984 savePrefCB
, window
, FULL
);
986 window
->shortMenusDefItem
= createMenuToggle(menuPane
,
987 "shortMenus", "Short Menus", 'h', shortMenusCB
, window
,
988 GetPrefShortMenus(), SHORT
);
990 createMenuSeparator(menuPane
, "sep1", SHORT
);
991 window
->statsLineItem
= createMenuToggle(menuPane
, "statisticsLine", "Statistics Line", 'S',
992 statsCB
, window
, GetPrefStatsLine(), SHORT
);
993 window
->iSearchLineItem
= createMenuToggle(menuPane
, "incremntalSearchLine","Incremental Search Line",
994 'I', doActionCB
, "set_incremental_search_line", GetPrefISearchLine(), FULL
);
995 window
->lineNumsItem
= createMenuToggle(menuPane
, "lineNumbers", "Show Line Numbers", 'N',
996 doActionCB
, "set_show_line_numbers", GetPrefLineNums(), SHORT
);
997 CreateLanguageModeSubMenu(window
, menuPane
, "languageMode",
998 "Language Mode", 'L');
999 subPane
= createMenu(menuPane
, "autoIndent", "Auto Indent",
1001 window
->autoIndentOffItem
= createMenuRadioToggle(subPane
, "off", "Off",
1002 'O', autoIndentOffCB
, window
, window
->indentStyle
== NO_AUTO_INDENT
,
1004 window
->autoIndentItem
= createMenuRadioToggle(subPane
, "on", "On", 'n',
1005 autoIndentCB
, window
, window
->indentStyle
== AUTO_INDENT
, SHORT
);
1006 window
->smartIndentItem
= createMenuRadioToggle(subPane
, "smart", "Smart",
1007 'S', smartIndentCB
, window
, window
->indentStyle
== SMART_INDENT
,
1009 subPane
= createMenu(menuPane
, "wrap", "Wrap",
1011 window
->noWrapItem
= createMenuRadioToggle(subPane
, "none",
1012 "None", 'N', noWrapCB
, window
,
1013 window
->wrapMode
==NO_WRAP
, SHORT
);
1014 window
->newlineWrapItem
= createMenuRadioToggle(subPane
, "autoNewlineWrap",
1015 "Auto Newline", 'A', newlineWrapCB
, window
,
1016 window
->wrapMode
==NEWLINE_WRAP
, SHORT
);
1017 window
->continuousWrapItem
= createMenuRadioToggle(subPane
,
1018 "continuousWrap", "Continuous", 'C', continuousWrapCB
, window
,
1019 window
->wrapMode
==CONTINUOUS_WRAP
, SHORT
);
1020 createMenuSeparator(subPane
, "sep1", SHORT
);
1021 createMenuItem(subPane
, "wrapMargin", "Wrap Margin...", 'W',
1022 wrapMarginCB
, window
, SHORT
);
1023 createMenuItem(menuPane
, "tabs", "Tabs...", 'T', tabsCB
, window
, SHORT
);
1024 createMenuItem(menuPane
, "textFont", "Text Font...", 'F', fontCB
, window
,
1026 window
->highlightItem
= createMenuToggle(menuPane
, "highlightSyntax",
1027 "Highlight Syntax", 'H', doActionCB
, "set_highlight_syntax",
1028 GetPrefHighlightSyntax(), SHORT
);
1029 window
->backlightCharsItem
= createMenuToggle(menuPane
, "backlightChars",
1030 "Apply Backlighting", 'g', backlightCharsCB
, window
,
1031 window
->backlightChars
, FULL
);
1033 window
->saveLastItem
= createMenuToggle(menuPane
, "makeBackupCopy",
1034 "Make Backup Copy (*.bck)", 'e', preserveCB
, window
,
1035 window
->saveOldVersion
, SHORT
);
1037 window
->autoSaveItem
= createMenuToggle(menuPane
, "incrementalBackup",
1038 "Incremental Backup", 'B', autoSaveCB
, window
, window
->autoSave
,
1041 subPane
= createMenu(menuPane
, "showMatching", "Show Matching (..)",
1043 window
->showMatchingOffItem
= createMenuRadioToggle(subPane
, "off", "Off",
1044 'O', showMatchingOffCB
, window
, window
->showMatchingStyle
== NO_FLASH
,
1046 window
->showMatchingDelimitItem
= createMenuRadioToggle(subPane
,
1047 "delimiter", "Delimiter", 'D', showMatchingDelimitCB
, window
,
1048 window
->showMatchingStyle
== FLASH_DELIMIT
, SHORT
);
1049 window
->showMatchingRangeItem
= createMenuRadioToggle(subPane
, "range",
1050 "Range", 'R', showMatchingRangeCB
, window
,
1051 window
->showMatchingStyle
== FLASH_RANGE
, SHORT
);
1052 createMenuSeparator(subPane
, "sep", SHORT
);
1053 window
->matchSyntaxBasedItem
= createMenuToggle(subPane
, "matchSyntax",
1054 "Syntax Based", 'S', matchSyntaxBasedCB
, window
,
1055 window
->matchSyntaxBased
, SHORT
);
1058 createMenuSeparator(menuPane
, "sep2", SHORT
);
1059 window
->overtypeModeItem
= createMenuToggle(menuPane
, "overtype", "Overtype", 'O',
1060 doActionCB
, "set_overtype_mode", False
, SHORT
);
1061 window
->readOnlyItem
= createMenuToggle(menuPane
, "readOnly", "Read Only",
1062 'y', doActionCB
, "set_locked", IS_USER_LOCKED(window
->lockReasons
), FULL
);
1067 ** Create the Shell menu
1069 menuPane
= window
->shellMenuPane
=
1070 createMenu(menuBar
, "shellMenu", "Shell", 0, NULL
, FULL
);
1071 btn
= createMenuItem(menuPane
, "executeCommand", "Execute Command...",
1072 'E', doActionCB
, "execute_command_dialog", SHORT
);
1073 XtVaSetValues(btn
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1074 btn
= createMenuItem(menuPane
, "executeCommandLine", "Execute Command Line",
1075 'x', doActionCB
, "execute_command_line", SHORT
);
1076 XtVaSetValues(btn
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1077 window
->filterItem
= createMenuItem(menuPane
, "filterSelection",
1078 "Filter Selection...", 'F', doActionCB
, "filter_selection_dialog",
1080 XtVaSetValues(window
->filterItem
, XmNuserData
, PERMANENT_MENU_ITEM
,
1081 XmNsensitive
, window
->wasSelected
, NULL
);
1082 window
->cancelShellItem
= createMenuItem(menuPane
, "cancelShellCommand",
1083 "Cancel Shell Command", 'C', cancelShellCB
, window
, SHORT
);
1084 XtVaSetValues(window
->cancelShellItem
, XmNuserData
, PERMANENT_MENU_ITEM
,
1085 XmNsensitive
, False
, NULL
);
1086 btn
= createMenuSeparator(menuPane
, "sep1", SHORT
);
1087 XtVaSetValues(btn
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1088 /* UpdateShellMenu(window) now done in DetermineLanguageMode */
1092 ** Create the Macro menu
1094 menuPane
= window
->macroMenuPane
=
1095 createMenu(menuBar
, "macroMenu", "Macro", 0, NULL
, FULL
);
1096 window
->learnItem
= createMenuItem(menuPane
, "learnKeystrokes",
1097 "Learn Keystrokes", 'L', learnCB
, window
, SHORT
);
1098 XtVaSetValues(window
->learnItem
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1099 window
->finishLearnItem
= createMenuItem(menuPane
, "finishLearn",
1100 "Finish Learn", 'F', finishLearnCB
, window
, SHORT
);
1101 XtVaSetValues(window
->finishLearnItem
, XmNuserData
, PERMANENT_MENU_ITEM
,
1102 XmNsensitive
, False
, NULL
);
1103 window
->cancelMacroItem
= createMenuItem(menuPane
, "cancelLearn",
1104 "Cancel Learn", 'C', cancelLearnCB
, window
, SHORT
);
1105 XtVaSetValues(window
->cancelMacroItem
, XmNuserData
, PERMANENT_MENU_ITEM
,
1106 XmNsensitive
, False
, NULL
);
1107 window
->replayItem
= createMenuItem(menuPane
, "replayKeystrokes",
1108 "Replay Keystrokes", 'K', replayCB
, window
, SHORT
);
1109 XtVaSetValues(window
->replayItem
, XmNuserData
, PERMANENT_MENU_ITEM
,
1110 XmNsensitive
, GetReplayMacro() != NULL
, NULL
);
1111 window
->repeatItem
= createMenuItem(menuPane
, "repeat",
1112 "Repeat...", 'R', doActionCB
, "repeat_dialog", SHORT
);
1113 XtVaSetValues(window
->repeatItem
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1114 XtVaSetValues(btn
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1115 btn
= createMenuSeparator(menuPane
, "sep1", SHORT
);
1116 XtVaSetValues(btn
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1117 /* UpdateMacroMenu(window) now done in DetermineLanguageMode */
1120 ** Create the Windows menu
1122 menuPane
= window
->windowMenuPane
= createMenu(menuBar
, "windowsMenu",
1123 "Windows", 0, &cascade
, FULL
);
1124 XtAddCallback(cascade
, XmNcascadingCallback
, (XtCallbackProc
)windowMenuCB
,
1126 window
->splitWindowItem
= createMenuItem(menuPane
, "splitWindow",
1127 "Split Window", 'S', doActionCB
, "split_window", SHORT
);
1128 XtVaSetValues(window
->splitWindowItem
, XmNuserData
, PERMANENT_MENU_ITEM
,
1130 window
->closePaneItem
= createMenuItem(menuPane
, "closePane",
1131 "Close Pane", 'C', doActionCB
, "close_pane", SHORT
);
1132 XtVaSetValues(window
->closePaneItem
, XmNuserData
, PERMANENT_MENU_ITEM
,NULL
);
1133 XtSetSensitive(window
->closePaneItem
, False
);
1134 btn
= createMenuSeparator(menuPane
, "sep1", SHORT
);
1135 XtVaSetValues(btn
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
1138 ** Create "Help" pull down menu.
1140 menuPane
= createMenu(menuBar
, "helpMenu", "Help", 0, &cascade
, SHORT
);
1141 XtVaSetValues(menuBar
, XmNmenuHelpWidget
, cascade
, NULL
);
1142 buildHelpMenu( menuPane
, &H_M
[0], window
);
1147 /*----------------------------------------------------------------------------*/
1149 static Widget
makeHelpMenuItem(
1152 char *name
, /* to be assigned to the child widget */
1153 char *label
, /* text to be displayed in menu */
1154 char mnemonic
, /* letter in label to be underlined */
1155 menuCallbackProc callback
, /* activated when menu item selected */
1156 void *cbArg
, /* passed to activated call back */
1157 int mode
, /* SGI_CUSTOM menu option */
1158 enum HelpTopic topic
/* associated with this menu item */
1162 createMenuItem( parent
, name
, label
, mnemonic
, callback
, cbArg
, mode
);
1164 XtVaSetValues( menuItem
, XmNuserData
, topic
, 0 );
1168 /*----------------------------------------------------------------------------*/
1170 static void helpCB( Widget menuItem
, XtPointer clientData
, XtPointer callData
)
1172 WindowInfo
*window
= (WindowInfo
*) clientData
;
1173 enum HelpTopic topic
;
1175 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(menuItem
))->lastFocus
,
1176 ((XmAnyCallbackStruct
*)callData
)->event
);
1177 XtVaGetValues( menuItem
, XmNuserData
, &topic
, 0 );
1179 Help( window
->shell
, topic
);
1182 /*----------------------------------------------------------------------------*/
1184 #define NON_MENU_HELP 9
1186 static HelpMenu
* buildHelpMenu(
1188 Widget pane
, /* Menu pane on which to place new menu items */
1189 HelpMenu
* menu
, /* Data to drive building the help menu */
1190 WindowInfo
* window
/* Main NEdit window information */
1194 int hideIt
= 1; /* All menu items matching this will be inaccessible */
1196 int hideIt
= -1; /* This value should make all menu items accessible */
1201 int crntLevel
= menu
->level
;
1203 /*-------------------------
1204 * For each menu element ...
1205 *-------------------------*/
1206 while( menu
!= NULL
&& menu
->level
== crntLevel
)
1208 /*----------------------------------------------
1209 * ... see if dealing with a separator or submenu
1210 *----------------------------------------------*/
1211 if( menu
->topic
== HELP_none
)
1213 if( menu
->mnemonic
== '-' )
1215 createMenuSeparator(pane
, menu
->wgtName
, SHORT
);
1220 /*-------------------------------------------------------
1221 * Do not show any of the submenu when it is to be hidden.
1222 *-------------------------------------------------------*/
1223 if( menu
->hideIt
== hideIt
|| menu
->hideIt
== NON_MENU_HELP
)
1225 do { menu
= menu
->next
;
1226 } while( menu
!= NULL
&& menu
->level
> crntLevel
);
1232 createMenu( pane
, menu
->wgtName
, menu
->subTitle
,
1233 menu
->mnemonic
, NULL
, FULL
);
1235 menu
= buildHelpMenu( subPane
, menu
->next
, window
);
1242 /*---------------------------------------
1243 * Show menu item if not going to hide it.
1244 * This is the easy way out of hiding
1245 * menu items. When entire submenus want
1246 * to be hidden, either the entire branch
1247 * will have to be marked, or this algorithm
1248 * will have to become a lot smarter.
1249 *---------------------------------------*/
1250 if( menu
->hideIt
!= hideIt
&& menu
->hideIt
!= NON_MENU_HELP
)
1252 pane
, menu
->wgtName
, HelpTitles
[menu
->topic
],
1253 menu
->mnemonic
, helpCB
, window
, SHORT
, menu
->topic
);
1263 /*----------------------------------------------------------------------------*/
1265 static void doActionCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1267 Widget menu
= MENU_WIDGET(w
);
1269 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1270 ((XmAnyCallbackStruct
*)callData
)->event
);
1271 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, (char *)clientData
,
1272 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1275 static void pasteColCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1277 static char *params
[1] = {"rect"};
1279 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1280 ((XmAnyCallbackStruct
*)callData
)->event
);
1281 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "paste_clipboard",
1282 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1285 static void shiftLeftCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1287 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1288 ((XmAnyCallbackStruct
*)callData
)->event
);
1289 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
,
1290 ((XmAnyCallbackStruct
*)callData
)->event
->xbutton
.state
& ShiftMask
1291 ? "shift_left_by_tab" : "shift_left",
1292 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1295 static void shiftRightCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1297 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1298 ((XmAnyCallbackStruct
*)callData
)->event
);
1299 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
,
1300 ((XmAnyCallbackStruct
*)callData
)->event
->xbutton
.state
& ShiftMask
1301 ? "shift_right_by_tab" : "shift_right",
1302 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1305 static void findCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1307 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1308 ((XmAnyCallbackStruct
*)callData
)->event
);
1309 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "find_dialog",
1310 ((XmAnyCallbackStruct
*)callData
)->event
,
1311 shiftKeyToDir(callData
), 1);
1314 static void findSameCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1316 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1317 ((XmAnyCallbackStruct
*)callData
)->event
);
1318 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "find_again",
1319 ((XmAnyCallbackStruct
*)callData
)->event
,
1320 shiftKeyToDir(callData
), 1);
1323 static void findSelCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1325 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1326 ((XmAnyCallbackStruct
*)callData
)->event
);
1327 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "find_selection",
1328 ((XmAnyCallbackStruct
*)callData
)->event
,
1329 shiftKeyToDir(callData
), 1);
1332 static void findIncrCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1334 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1335 ((XmAnyCallbackStruct
*)callData
)->event
);
1336 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
,
1337 "start_incremental_find", ((XmAnyCallbackStruct
*)callData
)->event
,
1338 shiftKeyToDir(callData
), 1);
1341 static void replaceCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1343 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1344 ((XmAnyCallbackStruct
*)callData
)->event
);
1345 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "replace_dialog",
1346 ((XmAnyCallbackStruct
*)callData
)->event
,
1347 shiftKeyToDir(callData
), 1);
1350 static void replaceSameCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1352 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1353 ((XmAnyCallbackStruct
*)callData
)->event
);
1354 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "replace_again",
1355 ((XmAnyCallbackStruct
*)callData
)->event
,
1356 shiftKeyToDir(callData
), 1);
1359 static void replaceFindSameCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1361 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1362 ((XmAnyCallbackStruct
*)callData
)->event
);
1363 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "replace_find_same",
1364 ((XmAnyCallbackStruct
*)callData
)->event
,
1365 shiftKeyToDir(callData
), 1);
1368 static void markCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1370 XEvent
*event
= ((XmAnyCallbackStruct
*)callData
)->event
;
1371 WindowInfo
*window
= (WindowInfo
*)clientData
;
1373 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1374 ((XmAnyCallbackStruct
*)callData
)->event
);
1375 if (event
->type
== KeyPress
|| event
->type
== KeyRelease
)
1376 BeginMarkCommand(window
);
1378 XtCallActionProc(window
->lastFocus
, "mark_dialog", event
, NULL
, 0);
1381 static void gotoMarkCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1383 XEvent
*event
= ((XmAnyCallbackStruct
*)callData
)->event
;
1384 WindowInfo
*window
= (WindowInfo
*)clientData
;
1385 int extend
= event
->xbutton
.state
& ShiftMask
;
1386 static char *params
[1] = {"extend"};
1388 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1389 ((XmAnyCallbackStruct
*)callData
)->event
);
1390 if (event
->type
== KeyPress
|| event
->type
== KeyRelease
)
1391 BeginGotoMarkCommand(window
, extend
);
1393 XtCallActionProc(window
->lastFocus
, "goto_mark_dialog", event
, params
,
1397 static void gotoMatchingCB(Widget w
, XtPointer clientData
, XtPointer callData
)
1399 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1400 ((XmAnyCallbackStruct
*)callData
)->event
);
1401 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
,
1402 ((XmAnyCallbackStruct
*)callData
)->event
->xbutton
.state
& ShiftMask
1403 ? "select_to_matching" : "goto_matching",
1404 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1407 static void autoIndentOffCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1409 static char *params
[1] = {"off"};
1410 Widget menu
= MENU_WIDGET(w
);
1412 if (shortPrefAskDefault(window
->shell
, w
, "Auto Indent Off")) {
1413 autoIndentOffDefCB(w
, window
, callData
);
1414 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1417 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1418 ((XmAnyCallbackStruct
*)callData
)->event
);
1419 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_auto_indent",
1420 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1423 static void autoIndentCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1425 static char *params
[1] = {"on"};
1426 Widget menu
= MENU_WIDGET(w
);
1428 if (shortPrefAskDefault(window
->shell
, w
, "Auto Indent")) {
1429 autoIndentDefCB(w
, window
, callData
);
1430 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1433 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1434 ((XmAnyCallbackStruct
*)callData
)->event
);
1435 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_auto_indent",
1436 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1439 static void smartIndentCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1441 static char *params
[1] = {"smart"};
1442 Widget menu
= MENU_WIDGET(w
);
1444 if (shortPrefAskDefault(window
->shell
, w
, "Smart Indent")) {
1445 smartIndentDefCB(w
, window
, callData
);
1446 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1449 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1450 ((XmAnyCallbackStruct
*)callData
)->event
);
1451 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_auto_indent",
1452 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1455 static void autoSaveCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1457 Widget menu
= MENU_WIDGET(w
);
1459 if (shortPrefAskDefault(window
->shell
, w
, "Incremental Backup")) {
1460 autoSaveDefCB(w
, window
, callData
);
1461 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1464 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1465 ((XmAnyCallbackStruct
*)callData
)->event
);
1466 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_incremental_backup",
1467 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1470 static void preserveCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1472 Widget menu
= MENU_WIDGET(w
);
1474 if (shortPrefAskDefault(window
->shell
, w
, "Make Backup Copy")) {
1475 preserveDefCB(w
, window
, callData
);
1476 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1479 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1480 ((XmAnyCallbackStruct
*)callData
)->event
);
1481 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_make_backup_copy",
1482 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1485 static void showMatchingOffCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1487 static char *params
[1] = {NO_FLASH_STRING
};
1488 Widget menu
= MENU_WIDGET(w
);
1490 if (shortPrefAskDefault(window
->shell
, w
, "Show Matching Off")) {
1491 showMatchingOffDefCB(w
, window
, callData
);
1492 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1495 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1496 ((XmAnyCallbackStruct
*)callData
)->event
);
1497 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_show_matching",
1498 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1501 static void showMatchingDelimitCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1503 static char *params
[1] = {FLASH_DELIMIT_STRING
};
1504 Widget menu
= MENU_WIDGET(w
);
1506 if (shortPrefAskDefault(window
->shell
, w
, "Show Matching Delimiter")) {
1507 showMatchingDelimitDefCB(w
, window
, callData
);
1508 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1511 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1512 ((XmAnyCallbackStruct
*)callData
)->event
);
1513 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_show_matching",
1514 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1517 static void showMatchingRangeCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1519 static char *params
[1] = {FLASH_RANGE_STRING
};
1520 Widget menu
= MENU_WIDGET(w
);
1522 if (shortPrefAskDefault(window
->shell
, w
, "Show Matching Range")) {
1523 showMatchingRangeDefCB(w
, window
, callData
);
1524 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1527 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1528 ((XmAnyCallbackStruct
*)callData
)->event
);
1529 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_show_matching",
1530 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1533 static void matchSyntaxBasedCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1535 Widget menu
= MENU_WIDGET(w
);
1537 if (shortPrefAskDefault(window
->shell
, w
, "Match Syntax Based")) {
1538 matchSyntaxBasedDefCB(w
, window
, callData
);
1539 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1542 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1543 ((XmAnyCallbackStruct
*)callData
)->event
);
1544 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_match_syntax_based",
1545 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1548 static void fontCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1550 ChooseFonts(window
, True
);
1553 static void noWrapCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1555 static char *params
[1] = {"none"};
1556 Widget menu
= MENU_WIDGET(w
);
1558 if (shortPrefAskDefault(window
->shell
, w
, "No Wrap")) {
1559 noWrapDefCB(w
, window
, callData
);
1560 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1563 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1564 ((XmAnyCallbackStruct
*)callData
)->event
);
1565 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_wrap_text",
1566 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1569 static void newlineWrapCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1571 static char *params
[1] = {"auto"};
1572 Widget menu
= MENU_WIDGET(w
);
1574 if (shortPrefAskDefault(window
->shell
, w
, "Auto Newline Wrap")) {
1575 newlineWrapDefCB(w
, window
, callData
);
1576 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1579 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1580 ((XmAnyCallbackStruct
*)callData
)->event
);
1581 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_wrap_text",
1582 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1585 static void continuousWrapCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1587 static char *params
[1] = {"continuous"};
1588 Widget menu
= MENU_WIDGET(w
);
1590 if (shortPrefAskDefault(window
->shell
, w
, "Continuous Wrap")) {
1591 contWrapDefCB(w
, window
, callData
);
1592 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1595 HidePointerOnKeyedEvent(WidgetToWindow(menu
)->lastFocus
,
1596 ((XmAnyCallbackStruct
*)callData
)->event
);
1597 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_wrap_text",
1598 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
1601 static void wrapMarginCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1603 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1604 ((XmAnyCallbackStruct
*)callData
)->event
);
1605 WrapMarginDialog(window
->shell
, window
);
1608 static void backlightCharsCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1610 int applyBacklight
= XmToggleButtonGetState(w
);
1611 SetBacklightChars(window
, applyBacklight
?GetPrefBacklightCharTypes():NULL
);
1614 static void tabsCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1616 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1617 ((XmAnyCallbackStruct
*)callData
)->event
);
1618 TabsPrefDialog(window
->shell
, window
);
1621 static void statsCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1623 Widget menu
= MENU_WIDGET(w
);
1625 if (shortPrefAskDefault(window
->shell
, w
, "Statistics Line")) {
1626 statsLineDefCB(w
, window
, callData
);
1627 SaveNEditPrefs(window
->shell
, GetPrefShortMenus());
1630 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1631 ((XmAnyCallbackStruct
*)callData
)->event
);
1632 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "set_statistics_line",
1633 ((XmAnyCallbackStruct
*)callData
)->event
, NULL
, 0);
1636 static void autoIndentOffDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1640 /* Set the preference and make the other windows' menus agree */
1641 SetPrefAutoIndent(NO_AUTO_INDENT
);
1642 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1643 XmToggleButtonSetState(win
->autoIndentOffDefItem
, True
, False
);
1644 XmToggleButtonSetState(win
->autoIndentDefItem
, False
, False
);
1645 XmToggleButtonSetState(win
->smartIndentDefItem
, False
, False
);
1649 static void autoIndentDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1653 /* Set the preference and make the other windows' menus agree */
1654 SetPrefAutoIndent(AUTO_INDENT
);
1655 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1656 XmToggleButtonSetState(win
->autoIndentDefItem
, True
, False
);
1657 XmToggleButtonSetState(win
->autoIndentOffDefItem
, False
, False
);
1658 XmToggleButtonSetState(win
->smartIndentDefItem
, False
, False
);
1662 static void smartIndentDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1666 /* Set the preference and make the other windows' menus agree */
1667 SetPrefAutoIndent(SMART_INDENT
);
1668 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1669 XmToggleButtonSetState(win
->smartIndentDefItem
, True
, False
);
1670 XmToggleButtonSetState(win
->autoIndentOffDefItem
, False
, False
);
1671 XmToggleButtonSetState(win
->autoIndentDefItem
, False
, False
);
1675 static void autoSaveDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1678 int state
= XmToggleButtonGetState(w
);
1680 /* Set the preference and make the other windows' menus agree */
1681 SetPrefAutoSave(state
);
1682 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
1683 XmToggleButtonSetState(win
->autoSaveDefItem
, state
, False
);
1686 static void preserveDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1689 int state
= XmToggleButtonGetState(w
);
1691 /* Set the preference and make the other windows' menus agree */
1692 SetPrefSaveOldVersion(state
);
1693 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
1694 XmToggleButtonSetState(win
->saveLastDefItem
, state
, False
);
1697 static void fontDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1699 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1700 ((XmAnyCallbackStruct
*)callData
)->event
);
1701 ChooseFonts(window
, False
);
1704 static void noWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1708 /* Set the preference and make the other windows' menus agree */
1709 SetPrefWrap(NO_WRAP
);
1710 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1711 XmToggleButtonSetState(win
->noWrapDefItem
, True
, False
);
1712 XmToggleButtonSetState(win
->newlineWrapDefItem
, False
, False
);
1713 XmToggleButtonSetState(win
->contWrapDefItem
, False
, False
);
1717 static void newlineWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1721 /* Set the preference and make the other windows' menus agree */
1722 SetPrefWrap(NEWLINE_WRAP
);
1723 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1724 XmToggleButtonSetState(win
->newlineWrapDefItem
, True
, False
);
1725 XmToggleButtonSetState(win
->contWrapDefItem
, False
, False
);
1726 XmToggleButtonSetState(win
->noWrapDefItem
, False
, False
);
1730 static void contWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1734 /* Set the preference and make the other windows' menus agree */
1735 SetPrefWrap(CONTINUOUS_WRAP
);
1736 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1737 XmToggleButtonSetState(win
->contWrapDefItem
, True
, False
);
1738 XmToggleButtonSetState(win
->newlineWrapDefItem
, False
, False
);
1739 XmToggleButtonSetState(win
->noWrapDefItem
, False
, False
);
1743 static void wrapMarginDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1745 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1746 ((XmAnyCallbackStruct
*)callData
)->event
);
1747 WrapMarginDialog(window
->shell
, NULL
);
1750 static void smartTagsDefCB(Widget w
, XtPointer client_data
, XtPointer callData
)
1754 SetPrefSmartTags(True
);
1755 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1756 XmToggleButtonSetState(win
->smartTagsDefItem
, True
, False
);
1757 XmToggleButtonSetState(win
->allTagsDefItem
, False
, False
);
1761 static void showAllTagsDefCB(Widget w
, XtPointer client_data
, XtPointer callData
)
1765 SetPrefSmartTags(False
);
1766 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1767 XmToggleButtonSetState(win
->smartTagsDefItem
, False
, False
);
1768 XmToggleButtonSetState(win
->allTagsDefItem
, True
, False
);
1772 static void tabsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1774 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1775 ((XmAnyCallbackStruct
*)callData
)->event
);
1776 TabsPrefDialog(window
->shell
, NULL
);
1779 static void showMatchingOffDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1783 /* Set the preference and make the other windows' menus agree */
1784 SetPrefShowMatching(NO_FLASH
);
1785 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1786 XmToggleButtonSetState(win
->showMatchingOffDefItem
, True
, False
);
1787 XmToggleButtonSetState(win
->showMatchingDelimitDefItem
, False
, False
);
1788 XmToggleButtonSetState(win
->showMatchingRangeDefItem
, False
, False
);
1792 static void showMatchingDelimitDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1796 /* Set the preference and make the other windows' menus agree */
1797 SetPrefShowMatching(FLASH_DELIMIT
);
1798 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1799 XmToggleButtonSetState(win
->showMatchingOffDefItem
, False
, False
);
1800 XmToggleButtonSetState(win
->showMatchingDelimitDefItem
, True
, False
);
1801 XmToggleButtonSetState(win
->showMatchingRangeDefItem
, False
, False
);
1805 static void showMatchingRangeDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1809 /* Set the preference and make the other windows' menus agree */
1810 SetPrefShowMatching(FLASH_RANGE
);
1811 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1812 XmToggleButtonSetState(win
->showMatchingOffDefItem
, False
, False
);
1813 XmToggleButtonSetState(win
->showMatchingDelimitDefItem
, False
, False
);
1814 XmToggleButtonSetState(win
->showMatchingRangeDefItem
, True
, False
);
1818 static void matchSyntaxBasedDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1822 int state
= XmToggleButtonGetState(w
);
1824 /* Set the preference and make the other windows' menus agree */
1825 SetPrefMatchSyntaxBased(state
);
1826 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1827 XmToggleButtonSetState(win
->matchSyntaxBasedDefItem
, state
, False
);
1831 static void backlightCharsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1834 int state
= XmToggleButtonGetState(w
);
1836 /* Set the preference and make the other windows' menus agree */
1837 SetPrefBacklightChars(state
);
1838 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
1839 XmToggleButtonSetState(win
->backlightCharsDefItem
, state
, False
);
1842 static void backlightCharTypesDefCB(Widget w
, WindowInfo
*window
,
1845 BacklightUseCurrCharTypesAsPref(window
, False
);
1848 static void highlightOffDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1852 /* Set the preference and make the other windows' menus agree */
1853 SetPrefHighlightSyntax(False
);
1854 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1855 XmToggleButtonSetState(win
->highlightOffDefItem
, True
, False
);
1856 XmToggleButtonSetState(win
->highlightDefItem
, False
, False
);
1860 static void highlightDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1864 /* Set the preference and make the other windows' menus agree */
1865 SetPrefHighlightSyntax(True
);
1866 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1867 XmToggleButtonSetState(win
->highlightOffDefItem
, False
, False
);
1868 XmToggleButtonSetState(win
->highlightDefItem
, True
, False
);
1872 static void highlightingDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1874 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1875 ((XmAnyCallbackStruct
*)callData
)->event
);
1876 EditHighlightPatterns(window
);
1879 static void smartMacrosDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1881 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1882 ((XmAnyCallbackStruct
*)callData
)->event
);
1883 EditSmartIndentMacros(window
);
1886 static void stylesDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1888 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1889 ((XmAnyCallbackStruct
*)callData
)->event
);
1890 EditHighlightStyles(window
->shell
, NULL
);
1893 static void languageDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1895 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1896 ((XmAnyCallbackStruct
*)callData
)->event
);
1897 EditLanguageModes(window
->shell
);
1901 static void shellDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1903 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1904 ((XmAnyCallbackStruct
*)callData
)->event
);
1905 EditShellMenu(window
);
1909 static void macroDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1911 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1912 ((XmAnyCallbackStruct
*)callData
)->event
);
1913 EditMacroMenu(window
);
1916 static void bgMenuDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1918 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1919 ((XmAnyCallbackStruct
*)callData
)->event
);
1923 static void customizeTitleDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1925 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
1926 ((XmAnyCallbackStruct
*)callData
)->event
);
1927 EditCustomTitleFormat(window
->shell
, window
);
1930 static void searchDlogsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1933 int state
= XmToggleButtonGetState(w
);
1935 /* Set the preference and make the other windows' menus agree */
1936 SetPrefSearchDlogs(state
);
1937 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
1938 XmToggleButtonSetState(win
->searchDlogsDefItem
, state
, False
);
1941 static void beepOnSearchWrapDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1944 int state
= XmToggleButtonGetState(w
);
1946 /* Set the preference and make the other windows' menus agree */
1947 SetPrefBeepOnSearchWrap(state
);
1948 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
1949 XmToggleButtonSetState(win
->beepOnSearchWrapDefItem
, state
, False
);
1952 static void keepSearchDlogsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1955 int state
= XmToggleButtonGetState(w
);
1957 /* Set the preference and make the other windows' menus agree */
1958 SetPrefKeepSearchDlogs(state
);
1959 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
1960 XmToggleButtonSetState(win
->keepSearchDlogsDefItem
, state
, False
);
1963 static void searchWrapsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1966 int state
= XmToggleButtonGetState(w
);
1968 /* Set the preference and make the other windows' menus agree */
1969 SetPrefSearchWraps(state
);
1970 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
1971 XmToggleButtonSetState(win
->searchWrapsDefItem
, state
, False
);
1974 static void appendLFCB(Widget w
, WindowInfo
* window
, caddr_t callData
)
1977 int state
= XmToggleButtonGetState(w
);
1979 SetPrefAppendLF(state
);
1980 for (win
= WindowList
; win
!= NULL
; win
= win
->next
)
1982 XmToggleButtonSetState(win
->appendLFItem
, state
, False
);
1986 static void sortOpenPrevDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
1989 int state
= XmToggleButtonGetState(w
);
1991 /* Set the preference, make the other windows' menus agree,
1992 and invalidate their Open Previous menus */
1993 SetPrefSortOpenPrevMenu(state
);
1994 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
1995 win
->prevOpenMenuValid
= False
;
1996 XmToggleButtonSetState(win
->sortOpenPrevDefItem
, state
, False
);
2000 static void reposDlogsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2003 int state
= XmToggleButtonGetState(w
);
2005 /* Set the preference and make the other windows' menus agree */
2006 SetPrefRepositionDialogs(state
);
2007 SetPointerCenteredDialogs(state
);
2008 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
2009 XmToggleButtonSetState(win
->reposDlogsDefItem
, state
, False
);
2012 static void modWarnDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2015 int state
= XmToggleButtonGetState(w
);
2017 /* Set the preference and make the other windows' menus agree */
2018 SetPrefWarnFileMods(state
);
2019 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
2020 XmToggleButtonSetState(win
->modWarnDefItem
, state
, False
);
2021 XtSetSensitive(win
->modWarnRealDefItem
, state
);
2025 static void modWarnRealDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2028 int state
= XmToggleButtonGetState(w
);
2030 /* Set the preference and make the other windows' menus agree */
2031 SetPrefWarnRealFileMods(state
);
2032 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
2033 XmToggleButtonSetState(win
->modWarnRealDefItem
, state
, False
);
2036 static void exitWarnDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2039 int state
= XmToggleButtonGetState(w
);
2041 /* Set the preference and make the other windows' menus agree */
2042 SetPrefWarnExit(state
);
2043 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
2044 XmToggleButtonSetState(win
->exitWarnDefItem
, state
, False
);
2047 static void statsLineDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2050 int state
= XmToggleButtonGetState(w
);
2052 /* Set the preference and make the other windows' menus agree */
2053 SetPrefStatsLine(state
);
2054 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
2055 XmToggleButtonSetState(win
->statsLineDefItem
, state
, False
);
2058 static void iSearchLineDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2061 int state
= XmToggleButtonGetState(w
);
2063 /* Set the preference and make the other windows' menus agree */
2064 SetPrefISearchLine(state
);
2065 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
2066 XmToggleButtonSetState(win
->iSearchLineDefItem
, state
, False
);
2069 static void lineNumsDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2072 int state
= XmToggleButtonGetState(w
);
2074 /* Set the preference and make the other windows' menus agree */
2075 SetPrefLineNums(state
);
2076 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
2077 XmToggleButtonSetState(win
->lineNumsDefItem
, state
, False
);
2080 static void pathInWindowsMenuDefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2083 int state
= XmToggleButtonGetState(w
);
2085 /* Set the preference and make the other windows' menus agree */
2086 SetPrefShowPathInWindowsMenu(state
);
2087 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
2088 XmToggleButtonSetState(win
->pathInWindowsMenuDefItem
, state
, False
);
2091 static void searchLiteralCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2095 /* Set the preference and make the other windows' menus agree */
2096 if (XmToggleButtonGetState(w
)) {
2097 SetPrefSearch(SEARCH_LITERAL
);
2098 for (win
=WindowList
; win
!=NULL
; win
=win
->next
){
2099 XmToggleButtonSetState(win
->searchLiteralDefItem
, True
, False
);
2100 XmToggleButtonSetState(win
->searchCaseSenseDefItem
, False
, False
);
2101 XmToggleButtonSetState(win
->searchLiteralWordDefItem
, False
, False
);
2102 XmToggleButtonSetState(win
->searchCaseSenseWordDefItem
, False
, False
);
2103 XmToggleButtonSetState(win
->searchRegexDefItem
, False
, False
);
2104 XmToggleButtonSetState(win
->searchRegexNoCaseDefItem
, False
, False
);
2109 static void searchCaseSenseCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2113 /* Set the preference and make the other windows' menus agree */
2114 if (XmToggleButtonGetState(w
)) {
2115 SetPrefSearch(SEARCH_CASE_SENSE
);
2116 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
2117 XmToggleButtonSetState(win
->searchLiteralDefItem
, False
, False
);
2118 XmToggleButtonSetState(win
->searchCaseSenseDefItem
, True
, False
);
2119 XmToggleButtonSetState(win
->searchLiteralWordDefItem
, False
, False
);
2120 XmToggleButtonSetState(win
->searchCaseSenseWordDefItem
, False
, False
);
2121 XmToggleButtonSetState(win
->searchRegexDefItem
, False
, False
);
2122 XmToggleButtonSetState(win
->searchRegexNoCaseDefItem
, False
, False
);
2127 static void searchLiteralWordCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2131 /* Set the preference and make the other windows' menus agree */
2132 if (XmToggleButtonGetState(w
)) {
2133 SetPrefSearch(SEARCH_LITERAL_WORD
);
2134 for (win
=WindowList
; win
!=NULL
; win
=win
->next
){
2135 XmToggleButtonSetState(win
->searchLiteralDefItem
, False
, False
);
2136 XmToggleButtonSetState(win
->searchCaseSenseDefItem
, False
, False
);
2137 XmToggleButtonSetState(win
->searchLiteralWordDefItem
, True
, False
);
2138 XmToggleButtonSetState(win
->searchCaseSenseWordDefItem
, False
, False
);
2139 XmToggleButtonSetState(win
->searchRegexDefItem
, False
, False
);
2140 XmToggleButtonSetState(win
->searchRegexNoCaseDefItem
, False
, False
);
2145 static void searchCaseSenseWordCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2149 /* Set the preference and make the other windows' menus agree */
2150 if (XmToggleButtonGetState(w
)) {
2151 SetPrefSearch(SEARCH_CASE_SENSE_WORD
);
2152 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
2153 XmToggleButtonSetState(win
->searchLiteralDefItem
, False
, False
);
2154 XmToggleButtonSetState(win
->searchCaseSenseDefItem
, False
, False
);
2155 XmToggleButtonSetState(win
->searchLiteralWordDefItem
, False
, False
);
2156 XmToggleButtonSetState(win
->searchCaseSenseWordDefItem
, True
, False
);
2157 XmToggleButtonSetState(win
->searchRegexDefItem
, False
, False
);
2158 XmToggleButtonSetState(win
->searchRegexNoCaseDefItem
, False
, False
);
2163 static void searchRegexCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2167 /* Set the preference and make the other windows' menus agree */
2168 if (XmToggleButtonGetState(w
)) {
2169 SetPrefSearch(SEARCH_REGEX
);
2170 for (win
=WindowList
; win
!=NULL
; win
=win
->next
){
2171 XmToggleButtonSetState(win
->searchLiteralDefItem
, False
, False
);
2172 XmToggleButtonSetState(win
->searchCaseSenseDefItem
, False
, False
);
2173 XmToggleButtonSetState(win
->searchLiteralWordDefItem
, False
, False
);
2174 XmToggleButtonSetState(win
->searchCaseSenseWordDefItem
, False
, False
);
2175 XmToggleButtonSetState(win
->searchRegexDefItem
, True
, False
);
2176 XmToggleButtonSetState(win
->searchRegexNoCaseDefItem
, False
, False
);
2181 static void searchRegexNoCaseCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2185 /* Set the preference and make the other windows' menus agree */
2186 if (XmToggleButtonGetState(w
)) {
2187 SetPrefSearch(SEARCH_REGEX_NOCASE
);
2188 for (win
=WindowList
; win
!=NULL
; win
=win
->next
){
2189 XmToggleButtonSetState(win
->searchLiteralDefItem
, False
, False
);
2190 XmToggleButtonSetState(win
->searchCaseSenseDefItem
, False
, False
);
2191 XmToggleButtonSetState(win
->searchLiteralWordDefItem
, False
, False
);
2192 XmToggleButtonSetState(win
->searchCaseSenseWordDefItem
, False
, False
);
2193 XmToggleButtonSetState(win
->searchRegexDefItem
, False
, False
);
2194 XmToggleButtonSetState(win
->searchRegexNoCaseDefItem
, True
, False
);
2199 #ifdef REPLACE_SCOPE
2200 static void replaceScopeWindowCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2204 /* Set the preference and make the other windows' menus agree */
2205 if (XmToggleButtonGetState(w
)) {
2206 SetPrefReplaceDefScope(REPL_DEF_SCOPE_WINDOW
);
2207 for (win
=WindowList
; win
!=NULL
; win
=win
->next
){
2208 XmToggleButtonSetState(win
->replScopeWinDefItem
, True
, False
);
2209 XmToggleButtonSetState(win
->replScopeSelDefItem
, False
, False
);
2210 XmToggleButtonSetState(win
->replScopeSmartDefItem
, False
, False
);
2215 static void replaceScopeSelectionCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2219 /* Set the preference and make the other windows' menus agree */
2220 if (XmToggleButtonGetState(w
)) {
2221 SetPrefReplaceDefScope(REPL_DEF_SCOPE_SELECTION
);
2222 for (win
=WindowList
; win
!=NULL
; win
=win
->next
){
2223 XmToggleButtonSetState(win
->replScopeWinDefItem
, False
, False
);
2224 XmToggleButtonSetState(win
->replScopeSelDefItem
, True
, False
);
2225 XmToggleButtonSetState(win
->replScopeSmartDefItem
, False
, False
);
2230 static void replaceScopeSmartCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2234 /* Set the preference and make the other windows' menus agree */
2235 if (XmToggleButtonGetState(w
)) {
2236 SetPrefReplaceDefScope(REPL_DEF_SCOPE_SMART
);
2237 for (win
=WindowList
; win
!=NULL
; win
=win
->next
){
2238 XmToggleButtonSetState(win
->replScopeWinDefItem
, False
, False
);
2239 XmToggleButtonSetState(win
->replScopeSelDefItem
, False
, False
);
2240 XmToggleButtonSetState(win
->replScopeSmartDefItem
, True
, False
);
2246 static void size24x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2248 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2249 ((XmAnyCallbackStruct
*)callData
)->event
);
2250 setWindowSizeDefault(24, 80);
2253 static void size40x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2255 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2256 ((XmAnyCallbackStruct
*)callData
)->event
);
2257 setWindowSizeDefault(40, 80);
2260 static void size60x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2262 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2263 ((XmAnyCallbackStruct
*)callData
)->event
);
2264 setWindowSizeDefault(60, 80);
2267 static void size80x80CB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2269 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2270 ((XmAnyCallbackStruct
*)callData
)->event
);
2271 setWindowSizeDefault(80, 80);
2274 static void sizeCustomCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2276 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2277 ((XmAnyCallbackStruct
*)callData
)->event
);
2278 RowColumnPrefDialog(window
->shell
);
2279 updateWindowSizeMenus();
2282 static void savePrefCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2284 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2285 ((XmAnyCallbackStruct
*)callData
)->event
);
2286 SaveNEditPrefs(window
->shell
, False
);
2289 static void formFeedCB(Widget w
, XtPointer clientData
, XtPointer callData
)
2291 static char *params
[1] = {"\f"};
2293 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2294 ((XmAnyCallbackStruct
*)callData
)->event
);
2295 XtCallActionProc(((WindowInfo
*)clientData
)->lastFocus
, "insert_string",
2296 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
2299 static void cancelShellCB(Widget w
, WindowInfo
*window
, XtPointer callData
)
2302 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2303 ((XmAnyCallbackStruct
*)callData
)->event
);
2304 AbortShellCommand(window
);
2308 static void learnCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2310 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2311 ((XmAnyCallbackStruct
*)callData
)->event
);
2315 static void finishLearnCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2317 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2318 ((XmAnyCallbackStruct
*)callData
)->event
);
2322 static void cancelLearnCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2324 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2325 ((XmAnyCallbackStruct
*)callData
)->event
);
2326 CancelMacroOrLearn(window
);
2329 static void replayCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2331 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
2332 ((XmAnyCallbackStruct
*)callData
)->event
);
2336 static void windowMenuCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2338 if (!window
->windowMenuValid
) {
2339 updateWindowMenu(window
);
2340 window
->windowMenuValid
= True
;
2344 static void prevOpenMenuCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2346 if (!window
->prevOpenMenuValid
) {
2347 updatePrevOpenMenu(window
);
2348 window
->prevOpenMenuValid
= True
;
2352 static void unloadTagsFileMenuCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2354 updateTagsFileMenu(window
);
2357 static void unloadTipsFileMenuCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
2359 updateTipsFileMenu(window
);
2363 ** Action Procedures for menu item commands
2365 static void newAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2367 EditNewFile(NULL
, False
, NULL
, WidgetToWindow(w
)->path
);
2371 static void openDialogAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2373 WindowInfo
*window
= WidgetToWindow(w
);
2374 char fullname
[MAXPATHLEN
], *params
[1];
2377 response
= PromptForExistingFile(window
, "File to Edit", fullname
);
2378 if (response
!= GFN_OK
)
2380 params
[0] = fullname
;
2381 XtCallActionProc(window
->lastFocus
, "open", event
, params
, 1);
2385 static void openAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2387 WindowInfo
*window
= WidgetToWindow(w
);
2388 char filename
[MAXPATHLEN
], pathname
[MAXPATHLEN
];
2391 fprintf(stderr
, "NEdit: open action requires file argument\n");
2394 if (ParseFilename(args
[0], filename
, pathname
) != 0) {
2395 fprintf(stderr
, "NEdit: invalid file name for open action: %s\n",
2399 EditExistingFile(window
, filename
, pathname
, 0, NULL
, False
, NULL
);
2403 static void openSelectedAP(Widget w
, XEvent
*event
, String
*args
,
2406 OpenSelectedFile(WidgetToWindow(w
), event
->xbutton
.time
);
2410 static void closeAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2412 int preResponse
= PROMPT_SBC_DIALOG_RESPONSE
;
2415 if (strcmp(args
[0], "prompt") == 0) {
2416 preResponse
= PROMPT_SBC_DIALOG_RESPONSE
;
2418 else if (strcmp(args
[0], "save") == 0) {
2419 preResponse
= YES_SBC_DIALOG_RESPONSE
;
2421 else if (strcmp(args
[0], "nosave") == 0) {
2422 preResponse
= NO_SBC_DIALOG_RESPONSE
;
2425 CloseFileAndWindow(WidgetToWindow(w
), preResponse
);
2429 static void saveAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2431 WindowInfo
*window
= WidgetToWindow(w
);
2433 if (CheckReadOnly(window
))
2438 static void saveAsDialogAP(Widget w
, XEvent
*event
, String
*args
,
2441 WindowInfo
*window
= WidgetToWindow(w
);
2442 int response
, addWrap
, fileFormat
;
2443 char fullname
[MAXPATHLEN
], *params
[2];
2445 response
= PromptForNewFile(window
, "Save File As", fullname
,
2446 &fileFormat
, &addWrap
);
2447 if (response
!= GFN_OK
)
2449 window
->fileFormat
= fileFormat
;
2450 params
[0] = fullname
;
2451 params
[1] = "wrapped";
2452 XtCallActionProc(window
->lastFocus
, "save_as", event
, params
, addWrap
?2:1);
2455 static void saveAsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2458 fprintf(stderr
, "NEdit: save_as action requires file argument\n");
2461 SaveWindowAs(WidgetToWindow(w
), args
[0],
2462 *nArgs
== 2 && !strCaseCmp(args
[1], "wrapped"));
2465 static void revertDialogAP(Widget w
, XEvent
*event
, String
*args
,
2468 WindowInfo
*window
= WidgetToWindow(w
);
2471 /* re-reading file is irreversible, prompt the user first */
2472 if (window
->fileChanged
)
2473 b
= DialogF(DF_QUES
, window
->shell
, 2, "Discard changes to\n%s%s?",
2474 "OK", "Cancel", window
->path
, window
->filename
);
2476 b
= DialogF(DF_QUES
, window
->shell
, 2, "Re-load file\n%s%s?",
2477 "Re-read", "Cancel", window
->path
, window
->filename
);
2480 XtCallActionProc(window
->lastFocus
, "revert_to_saved", event
, NULL
, 0);
2484 static void revertAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2486 RevertToSaved(WidgetToWindow(w
));
2489 static void includeDialogAP(Widget w
, XEvent
*event
, String
*args
,
2492 WindowInfo
*window
= WidgetToWindow(w
);
2493 char filename
[MAXPATHLEN
], *params
[1];
2496 if (CheckReadOnly(window
))
2498 response
= PromptForExistingFile(window
, "File to Include", filename
);
2499 if (response
!= GFN_OK
)
2501 params
[0] = filename
;
2502 XtCallActionProc(window
->lastFocus
, "include_file", event
, params
, 1);
2505 static void includeAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2507 WindowInfo
*window
= WidgetToWindow(w
);
2509 if (CheckReadOnly(window
))
2512 fprintf(stderr
, "NEdit: include action requires file argument\n");
2515 IncludeFile(WidgetToWindow(w
), args
[0]);
2518 static void loadMacroDialogAP(Widget w
, XEvent
*event
, String
*args
,
2521 WindowInfo
*window
= WidgetToWindow(w
);
2522 char filename
[MAXPATHLEN
], *params
[1];
2525 response
= PromptForExistingFile(window
, "NEdit Macro File", filename
);
2526 if (response
!= GFN_OK
)
2528 params
[0] = filename
;
2529 XtCallActionProc(window
->lastFocus
, "load_macro_file", event
, params
, 1);
2532 static void loadMacroAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2535 fprintf(stderr
,"NEdit: load_macro_file action requires file argument\n");
2538 ReadMacroFile(WidgetToWindow(w
), args
[0], True
);
2541 static void loadTagsDialogAP(Widget w
, XEvent
*event
, String
*args
,
2544 WindowInfo
*window
= WidgetToWindow(w
);
2545 char filename
[MAXPATHLEN
], *params
[1];
2548 response
= PromptForExistingFile(window
, "ctags File", filename
);
2549 if (response
!= GFN_OK
)
2551 params
[0] = filename
;
2552 XtCallActionProc(window
->lastFocus
, "load_tags_file", event
, params
, 1);
2555 static void loadTagsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2558 fprintf(stderr
,"NEdit: load_tags_file action requires file argument\n");
2561 if (!AddTagsFile(args
[0], TAG
)) {
2562 DialogF(DF_WARN
, WidgetToWindow(w
)->shell
, 1,
2563 "Error reading ctags file:\n'%s'\ntags not loaded", "Dismiss",
2568 static void unloadTagsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2572 "NEdit: unload_tags_file action requires file argument\n");
2575 DeleteTagsFile(args
[0], TAG
);
2578 static void loadTipsDialogAP(Widget w
, XEvent
*event
, String
*args
,
2581 WindowInfo
*window
= WidgetToWindow(w
);
2582 char filename
[MAXPATHLEN
], *params
[1];
2585 response
= PromptForExistingFile(window
, "Calltips File", filename
);
2586 if (response
!= GFN_OK
)
2588 params
[0] = filename
;
2589 XtCallActionProc(window
->lastFocus
, "load_tips_file", event
, params
, 1);
2592 static void loadTipsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2595 fprintf(stderr
,"NEdit: load_tips_file action requires file argument\n");
2598 if (!AddTagsFile(args
[0], TIP
)) {
2599 DialogF(DF_WARN
, WidgetToWindow(w
)->shell
, 1,
2600 "Error reading tips file:\n'%s'\ntips not loaded", "Dismiss",
2605 static void unloadTipsAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2609 "NEdit: unload_tips_file action requires file argument\n");
2612 DeleteTagsFile(args
[0], TIP
);
2615 static void printAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2617 PrintWindow(WidgetToWindow(w
), False
);
2620 static void printSelAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2622 PrintWindow(WidgetToWindow(w
), True
);
2625 static void exitAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2627 WindowInfo
*window
= WidgetToWindow(w
);
2629 if (!CheckPrefsChangesSaved(window
->shell
))
2632 /* If this is not the last window (more than one window is open),
2633 confirm with the user before exiting. */
2634 if (GetPrefWarnExit() && !(window
== WindowList
&& window
->next
== NULL
)) {
2635 int resp
, titleLen
, lineLen
;
2636 char exitMsg
[DF_MAX_MSG_LENGTH
], *ptr
, *title
;
2639 /* List the windows being edited and make sure the
2640 user really wants to exit */
2643 strcpy(ptr
, "Editing: "); ptr
+= 9; lineLen
+= 9;
2644 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
2645 XtVaGetValues(win
->shell
, XmNiconName
, &title
, NULL
);
2646 titleLen
= strlen(title
);
2647 if (ptr
- exitMsg
+ titleLen
+ 30 >= DF_MAX_MSG_LENGTH
) {
2648 strcpy(ptr
, "..."); ptr
+= 3;
2651 if (lineLen
+ titleLen
+ (win
->next
==NULL
?5:2) > 50) {
2655 if (win
->next
== NULL
) {
2656 sprintf(ptr
, "and %s.", title
);
2657 ptr
+= 5 + titleLen
;
2658 lineLen
+= 5 + titleLen
;
2660 sprintf(ptr
, "%s, ", title
);
2661 ptr
+= 2 + titleLen
;
2662 lineLen
+= 2 + titleLen
;
2665 sprintf(ptr
, "\n\nExit NEdit?");
2666 resp
= DialogF(DF_QUES
, window
->shell
, 2, "%s", "Exit", "Cancel", exitMsg
);
2671 /* Close all files and exit when the last one is closed */
2672 if (CloseAllFilesAndWindows())
2676 static void undoAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2678 WindowInfo
*window
= WidgetToWindow(w
);
2680 if (CheckReadOnly(window
))
2685 static void redoAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2687 WindowInfo
*window
= WidgetToWindow(w
);
2689 if (CheckReadOnly(window
))
2694 static void clearAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2696 WindowInfo
*window
= WidgetToWindow(w
);
2698 if (CheckReadOnly(window
))
2700 BufRemoveSelected(window
->buffer
);
2703 static void selAllAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2705 WindowInfo
*window
= WidgetToWindow(w
);
2707 BufSelect(window
->buffer
, 0, window
->buffer
->length
);
2710 static void shiftLeftAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2712 WindowInfo
*window
= WidgetToWindow(w
);
2714 if (CheckReadOnly(window
))
2716 ShiftSelection(window
, SHIFT_LEFT
, False
);
2719 static void shiftLeftTabAP(Widget w
, XEvent
*event
, String
*args
,
2722 WindowInfo
*window
= WidgetToWindow(w
);
2724 if (CheckReadOnly(window
))
2726 ShiftSelection(window
, SHIFT_LEFT
, True
);
2729 static void shiftRightAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2731 WindowInfo
*window
= WidgetToWindow(w
);
2733 if (CheckReadOnly(window
))
2735 ShiftSelection(window
, SHIFT_RIGHT
, False
);
2738 static void shiftRightTabAP(Widget w
, XEvent
*event
, String
*args
,
2741 WindowInfo
*window
= WidgetToWindow(w
);
2743 if (CheckReadOnly(window
))
2745 ShiftSelection(window
, SHIFT_RIGHT
, True
);
2748 static void findDialogAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2750 DoFindDlog(WidgetToWindow(w
), searchDirection(0, args
, nArgs
),
2751 searchType(0, args
, nArgs
), searchKeepDialogs(0, args
, nArgs
),
2752 event
->xbutton
.time
);
2755 static void findAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2758 fprintf(stderr
, "NEdit: find action requires search string argument\n");
2761 SearchAndSelect(WidgetToWindow(w
), searchDirection(1, args
, nArgs
), args
[0],
2762 searchType(1, args
, nArgs
), searchWrap(1, args
, nArgs
));
2765 static void findSameAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2767 SearchAndSelectSame(WidgetToWindow(w
), searchDirection(0, args
, nArgs
),
2768 searchWrap(0, args
, nArgs
));
2771 static void findSelAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2773 SearchForSelected(WidgetToWindow(w
), searchDirection(0, args
, nArgs
),
2774 searchType(0, args
, nArgs
), searchWrap(0, args
, nArgs
),
2775 event
->xbutton
.time
);
2778 static void startIncrFindAP(Widget w
, XEvent
*event
, String
*args
,
2781 BeginISearch(WidgetToWindow(w
), searchDirection(0, args
, nArgs
));
2784 static void findIncrAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2786 int i
, continued
= FALSE
;
2788 fprintf(stderr
, "NEdit: find action requires search string argument\n");
2791 for (i
=1; i
<(int)*nArgs
; i
++)
2792 if (!strCaseCmp(args
[i
], "continued"))
2794 SearchAndSelectIncremental(WidgetToWindow(w
),
2795 searchDirection(1, args
, nArgs
), args
[0],
2796 searchType(1, args
, nArgs
), searchWrap(1, args
, nArgs
), continued
);
2799 static void replaceDialogAP(Widget w
, XEvent
*event
, String
*args
,
2802 WindowInfo
*window
= WidgetToWindow(w
);
2804 if (CheckReadOnly(window
))
2806 DoFindReplaceDlog(window
, searchDirection(0, args
, nArgs
),
2807 searchType(0, args
, nArgs
), searchKeepDialogs(0, args
, nArgs
),
2808 event
->xbutton
.time
);
2811 static void replaceAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2813 WindowInfo
*window
= WidgetToWindow(w
);
2815 if (CheckReadOnly(window
))
2819 "NEdit: replace action requires search and replace string arguments\n");
2822 SearchAndReplace(window
, searchDirection(2, args
, nArgs
),
2823 args
[0], args
[1], searchType(2, args
, nArgs
), searchWrap(2, args
, nArgs
));
2826 static void replaceAllAP(Widget w
, XEvent
*event
, String
*args
,
2829 WindowInfo
*window
= WidgetToWindow(w
);
2831 if (CheckReadOnly(window
))
2835 "NEdit: replace_all action requires search and replace string arguments\n");
2838 ReplaceAll(window
, args
[0], args
[1], searchType(2, args
, nArgs
));
2841 static void replaceInSelAP(Widget w
, XEvent
*event
, String
*args
,
2844 WindowInfo
*window
= WidgetToWindow(w
);
2846 if (CheckReadOnly(window
))
2850 "NEdit: replace_in_selection requires search and replace string arguments\n");
2853 ReplaceInSelection(window
, args
[0], args
[1],
2854 searchType(2, args
, nArgs
));
2857 static void replaceSameAP(Widget w
, XEvent
*event
, String
*args
,
2860 WindowInfo
*window
= WidgetToWindow(w
);
2862 if (CheckReadOnly(window
))
2864 ReplaceSame(window
, searchDirection(0, args
, nArgs
), searchWrap(0, args
, nArgs
));
2867 static void replaceFindAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2869 WindowInfo
*window
= WidgetToWindow(w
);
2871 if (CheckReadOnly(window
))
2874 DialogF(DF_WARN
, window
->shell
, 1, "replace_find action requires search and replace string arguments", "OK");
2877 ReplaceAndSearch(window
, searchDirection(2, args
, nArgs
),
2878 args
[0], args
[1], searchType(2, args
, nArgs
),
2879 searchWrap(0, args
, nArgs
));
2882 static void replaceFindSameAP(Widget w
, XEvent
*event
, String
*args
,
2885 WindowInfo
*window
= WidgetToWindow(w
);
2887 if (CheckReadOnly(window
))
2889 ReplaceFindSame(window
, searchDirection(0, args
, nArgs
), searchWrap(0, args
, nArgs
));
2892 static void gotoAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2894 int lineNum
, column
, position
, curCol
;
2896 if (*nArgs
== 0 || StringToLineAndCol( args
[0], &lineNum
, &column
) == -1) {
2897 fprintf(stderr
,"NEdit: goto_line_number action requires line and/or column number\n");
2900 /* User specified column, but not line number */
2901 if ( lineNum
== -1 ) {
2902 position
= TextGetCursorPos(w
);
2903 if (TextPosToLineAndCol(w
, position
, &lineNum
,
2904 &curCol
) == False
) {
2908 /* User didn't specify a column */
2909 else if ( column
== -1 ) {
2910 SelectNumberedLine(WidgetToWindow(w
), lineNum
);
2914 position
= TextLineAndColToPos(w
, lineNum
, column
);
2915 if ( position
== -1 ) {
2918 TextSetCursorPos(w
, position
);
2922 static void gotoDialogAP(Widget w
, XEvent
*event
, String
*args
,
2925 GotoLineNumber(WidgetToWindow(w
));
2928 static void gotoSelectedAP(Widget w
, XEvent
*event
, String
*args
,
2931 GotoSelectedLineNumber(WidgetToWindow(w
), event
->xbutton
.time
);
2934 static void repeatDialogAP(Widget w
, XEvent
*event
, String
*args
,
2937 RepeatDialog(WidgetToWindow(w
));
2940 static void repeatMacroAP(Widget w
, XEvent
*event
, String
*args
,
2946 fprintf(stderr
, "NEdit: repeat_macro requires two arguments\n");
2949 if (!strcmp(args
[0], "in_selection"))
2950 how
= REPEAT_IN_SEL
;
2951 else if (!strcmp(args
[0], "to_end"))
2952 how
= REPEAT_TO_END
;
2953 else if (sscanf(args
[0], "%d", &how
) != 1) {
2954 fprintf(stderr
, "NEdit: repeat_macro requires method/count\n");
2957 RepeatMacro(WidgetToWindow(w
), args
[1], how
);
2960 static void markAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2962 if (*nArgs
== 0 || strlen(args
[0]) != 1 ||
2963 !isalnum((unsigned char)args
[0][0])) {
2964 fprintf(stderr
,"NEdit: mark action requires a single-letter label\n");
2967 AddMark(WidgetToWindow(w
), w
, args
[0][0]);
2970 static void markDialogAP(Widget w
, XEvent
*event
, String
*args
,
2973 MarkDialog(WidgetToWindow(w
));
2976 static void gotoMarkAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
2978 if (*nArgs
== 0 || strlen(args
[0]) != 1 ||
2979 !isalnum((unsigned char)args
[0][0])) {
2981 "NEdit: goto_mark action requires a single-letter label\n");
2984 GotoMark(WidgetToWindow(w
), w
, args
[0][0], *nArgs
> 1 &&
2985 !strcmp(args
[1], "extend"));
2988 static void gotoMarkDialogAP(Widget w
, XEvent
*event
, String
*args
,
2991 GotoMarkDialog(WidgetToWindow(w
), *nArgs
!=0 && !strcmp(args
[0], "extend"));
2994 static void selectToMatchingAP(Widget w
, XEvent
*event
, String
*args
,
2997 SelectToMatchingCharacter(WidgetToWindow(w
));
3000 static void gotoMatchingAP(Widget w
, XEvent
*event
, String
*args
,
3003 GotoMatchingCharacter(WidgetToWindow(w
));
3006 static void findDefAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3008 FindDefinition(WidgetToWindow(w
), event
->xbutton
.time
,
3009 *nArgs
== 0 ? NULL
: args
[0]);
3012 static void showTipAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3014 FindDefCalltip(WidgetToWindow(w
), event
->xbutton
.time
,
3015 *nArgs
== 0 ? NULL
: args
[0]);
3018 static void splitWindowAP(Widget w
, XEvent
*event
, String
*args
,
3021 WindowInfo
*window
= WidgetToWindow(w
);
3023 SplitWindow(window
);
3024 XtSetSensitive(window
->splitWindowItem
, window
->nPanes
< MAX_PANES
);
3025 XtSetSensitive(window
->closePaneItem
, window
->nPanes
> 0);
3028 static void closePaneAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3030 WindowInfo
*window
= WidgetToWindow(w
);
3033 XtSetSensitive(window
->splitWindowItem
, window
->nPanes
< MAX_PANES
);
3034 XtSetSensitive(window
->closePaneItem
, window
->nPanes
> 0);
3037 static void capitalizeAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3039 WindowInfo
*window
= WidgetToWindow(w
);
3041 if (CheckReadOnly(window
))
3043 UpcaseSelection(window
);
3046 static void lowercaseAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3048 WindowInfo
*window
= WidgetToWindow(w
);
3050 if (CheckReadOnly(window
))
3052 DowncaseSelection(window
);
3055 static void fillAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3057 WindowInfo
*window
= WidgetToWindow(w
);
3059 if (CheckReadOnly(window
))
3061 FillSelection(window
);
3064 static void controlDialogAP(Widget w
, XEvent
*event
, String
*args
,
3067 WindowInfo
*window
= WidgetToWindow(w
);
3068 unsigned char charCodeString
[2];
3069 char charCodeText
[DF_MAX_PROMPT_LENGTH
], dummy
[DF_MAX_PROMPT_LENGTH
];
3071 int charCode
, nRead
, response
;
3073 if (CheckReadOnly(window
))
3075 response
= DialogF(DF_PROMPT
, window
->shell
, 2,
3076 "ASCII Character Code:", charCodeText
, "OK", "Cancel");
3079 /* If we don't scan for a trailing string invalid input
3080 would be accepted sometimes. */
3081 nRead
= sscanf(charCodeText
, "%i%s", &charCode
, dummy
);
3082 if (nRead
!= 1 || charCode
< 0 || charCode
> 255) {
3083 XBell(TheDisplay
, 0);
3086 charCodeString
[0] = (unsigned char)charCode
;
3087 charCodeString
[1] = '\0';
3088 params
[0] = (char *)charCodeString
;
3089 if (!BufSubstituteNullChars((char *)charCodeString
, 1, window
->buffer
)) {
3090 DialogF(DF_ERR
, window
->shell
, 1, "Too much binary data","Dismiss");
3093 XtCallActionProc(w
, "insert_string", event
, params
, 1);
3097 static void filterDialogAP(Widget w
, XEvent
*event
, String
*args
,
3100 WindowInfo
*window
= WidgetToWindow(w
);
3101 char *params
[1], cmdText
[DF_MAX_PROMPT_LENGTH
];
3103 static char **cmdHistory
= NULL
;
3104 static int nHistoryCmds
= 0;
3106 if (CheckReadOnly(window
))
3108 if (!window
->buffer
->primary
.selected
) {
3109 XBell(TheDisplay
, 0);
3113 SetDialogFPromptHistory(cmdHistory
, nHistoryCmds
);
3114 resp
= DialogF(DF_PROMPT
, window
->shell
, 2,
3115 "Shell command: (use up arrow key to recall previous)",
3116 cmdText
, "OK", "Cancel");
3119 AddToHistoryList(cmdText
, &cmdHistory
, &nHistoryCmds
);
3120 params
[0] = cmdText
;
3121 XtCallActionProc(w
, "filter_selection", event
, params
, 1);
3124 static void shellFilterAP(Widget w
, XEvent
*event
, String
*args
,
3127 WindowInfo
*window
= WidgetToWindow(w
);
3129 if (CheckReadOnly(window
))
3133 "NEdit: filter_selection requires shell command argument\n");
3136 FilterSelection(window
, args
[0],
3137 event
->xany
.send_event
== MACRO_EVENT_MARKER
);
3140 static void execDialogAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3142 WindowInfo
*window
= WidgetToWindow(w
);
3143 char *params
[1], cmdText
[DF_MAX_PROMPT_LENGTH
];
3145 static char **cmdHistory
= NULL
;
3146 static int nHistoryCmds
= 0;
3148 if (CheckReadOnly(window
))
3150 SetDialogFPromptHistory(cmdHistory
, nHistoryCmds
);
3151 resp
= DialogF(DF_PROMPT
, window
->shell
, 2,
3152 "Shell command: (use up arrow key to recall previous;\n" \
3153 "%% expands to current filename, # to line number)",
3154 cmdText
, "OK", "Cancel");
3157 AddToHistoryList(cmdText
, &cmdHistory
, &nHistoryCmds
);
3158 params
[0] = cmdText
;
3159 XtCallActionProc(w
, "execute_command", event
, params
, 1);;
3162 static void execAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3164 WindowInfo
*window
= WidgetToWindow(w
);
3166 if (CheckReadOnly(window
))
3170 "NEdit: execute_command requires shell command argument\n");
3173 ExecShellCommand(window
, args
[0],
3174 event
->xany
.send_event
== MACRO_EVENT_MARKER
);
3177 static void execLineAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3179 WindowInfo
*window
= WidgetToWindow(w
);
3181 if (CheckReadOnly(window
))
3183 ExecCursorLine(window
, event
->xany
.send_event
== MACRO_EVENT_MARKER
);
3186 static void shellMenuAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3190 "NEdit: shell_menu_command requires item-name argument\n");
3193 HidePointerOnKeyedEvent(w
, event
);
3194 DoNamedShellMenuCmd(WidgetToWindow(w
), args
[0],
3195 event
->xany
.send_event
== MACRO_EVENT_MARKER
);
3199 static void macroMenuAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3203 "NEdit: macro_menu_command requires item-name argument\n");
3206 /* Don't allow users to execute a macro command from the menu (or accel)
3207 if there's already a macro command executing, UNLESS the macro is
3208 directly called from another one. NEdit can't handle
3209 running multiple, independent uncoordinated, macros in the same
3210 window. Macros may invoke macro menu commands recursively via the
3211 macro_menu_command action proc, which is important for being able to
3212 repeat any operation, and to embed macros within eachother at any
3213 level, however, a call here with a macro running means that THE USER
3214 is explicitly invoking another macro via the menu or an accelerator,
3215 UNLESS the macro event marker is set */
3216 if (event
->xany
.send_event
!= MACRO_EVENT_MARKER
) {
3217 if (WidgetToWindow(w
)->macroCmdData
!= NULL
) {
3218 XBell(TheDisplay
, 0);
3222 HidePointerOnKeyedEvent(w
, event
);
3223 DoNamedMacroMenuCmd(WidgetToWindow(w
), args
[0]);
3226 static void bgMenuAP(Widget w
, XEvent
*event
, String
*args
, Cardinal
*nArgs
)
3230 "NEdit: bg_menu_command requires item-name argument\n");
3233 /* Same remark as for macro menu commands (see above). */
3234 if (event
->xany
.send_event
!= MACRO_EVENT_MARKER
) {
3235 if (WidgetToWindow(w
)->macroCmdData
!= NULL
) {
3236 XBell(TheDisplay
, 0);
3240 HidePointerOnKeyedEvent(w
, event
);
3241 DoNamedBGMenuCmd(WidgetToWindow(w
), args
[0]);
3244 static void beginningOfSelectionAP(Widget w
, XEvent
*event
, String
*args
,
3247 textBuffer
*buf
= TextGetBuffer(w
);
3248 int start
, end
, isRect
, rectStart
, rectEnd
;
3250 if (!BufGetSelectionPos(buf
, &start
, &end
, &isRect
, &rectStart
, &rectEnd
))
3253 TextSetCursorPos(w
, start
);
3255 TextSetCursorPos(w
, BufCountForwardDispChars(buf
,
3256 BufStartOfLine(buf
, start
), rectStart
));
3259 static void endOfSelectionAP(Widget w
, XEvent
*event
, String
*args
,
3262 textBuffer
*buf
= TextGetBuffer(w
);
3263 int start
, end
, isRect
, rectStart
, rectEnd
;
3265 if (!BufGetSelectionPos(buf
, &start
, &end
, &isRect
, &rectStart
, &rectEnd
))
3268 TextSetCursorPos(w
, end
);
3270 TextSetCursorPos(w
, BufCountForwardDispChars(buf
,
3271 BufStartOfLine(buf
, end
), rectEnd
));
3274 static void raiseWindowAP(Widget w
, XEvent
*event
, String
*args
,
3277 WindowInfo
*window
= WidgetToWindow(w
);
3278 WindowInfo
*nextWindow
;
3279 WindowInfo
*tmpWindow
;
3283 if (strcmp(args
[0], "last") == 0) {
3284 window
= WindowList
;
3286 else if (strcmp(args
[0], "first") == 0) {
3287 window
= WindowList
;
3288 if (window
!= NULL
) {
3289 nextWindow
= window
->next
;
3290 while (nextWindow
!= NULL
) {
3291 window
= nextWindow
;
3292 nextWindow
= nextWindow
->next
;
3296 else if (strcmp(args
[0], "previous") == 0) {
3298 window
= WindowList
;
3299 if (window
!= NULL
) {
3300 nextWindow
= window
->next
;
3301 while (nextWindow
!= NULL
&& nextWindow
!= tmpWindow
) {
3302 window
= nextWindow
;
3303 nextWindow
= nextWindow
->next
;
3305 if (nextWindow
== NULL
&& tmpWindow
!= WindowList
) {
3310 else if (strcmp(args
[0], "next") == 0) {
3311 if (window
!= NULL
) {
3312 window
= window
->next
;
3313 if (window
== NULL
) {
3314 window
= WindowList
;
3319 if (sscanf(args
[0], "%d", &windowIndex
) == 1) {
3320 if (windowIndex
> 0) {
3321 for (window
= WindowList
; window
!= NULL
&& windowIndex
> 1;
3323 window
= window
->next
;
3326 else if (windowIndex
< 0) {
3327 for (window
= WindowList
; window
!= NULL
;
3328 window
= window
->next
) {
3331 if (windowIndex
>= 0) {
3332 for (window
= WindowList
; window
!= NULL
&&
3333 windowIndex
> 0; window
= window
->next
) {
3350 if (window
!= NULL
) {
3351 RaiseShellWindow(window
->shell
);
3354 XBell(TheDisplay
, 0);
3358 static void focusPaneAP(Widget w
, XEvent
*event
, String
*args
,
3361 WindowInfo
*window
= WidgetToWindow(w
);
3362 Widget newFocusPane
= NULL
;
3366 if (strcmp(args
[0], "first") == 0) {
3369 else if (strcmp(args
[0], "last") == 0) {
3370 paneIndex
= window
->nPanes
;
3372 else if (strcmp(args
[0], "next") == 0) {
3373 paneIndex
= WidgetToPaneIndex(window
, window
->lastFocus
) + 1;
3374 if (paneIndex
> window
->nPanes
) {
3378 else if (strcmp(args
[0], "previous") == 0) {
3379 paneIndex
= WidgetToPaneIndex(window
, window
->lastFocus
) - 1;
3380 if (paneIndex
< 0) {
3381 paneIndex
= window
->nPanes
;
3385 if (sscanf(args
[0], "%d", &paneIndex
) == 1) {
3386 if (paneIndex
> 0) {
3387 paneIndex
= paneIndex
- 1;
3389 else if (paneIndex
< 0) {
3390 paneIndex
= window
->nPanes
+ (paneIndex
+ 1);
3397 if (paneIndex
>= 0 && paneIndex
<= window
->nPanes
) {
3398 newFocusPane
= GetPaneByIndex(window
, paneIndex
);
3400 if (newFocusPane
!= NULL
) {
3401 window
->lastFocus
= newFocusPane
;
3402 XmProcessTraversal(window
->lastFocus
, XmTRAVERSE_CURRENT
);
3405 XBell(TheDisplay
, 0);
3409 fprintf(stderr
, "NEdit: focus_pane requires argument\n");
3413 #define ACTION_BOOL_PARAM_OR_TOGGLE(newState, numArgs, argvVal, oValue, actionName) \
3414 if ((numArgs) > 0) { \
3417 if (sscanf(argvVal[0], "%d", &intState) == 1) { \
3418 (newState) = (intState != 0); \
3421 fprintf(stderr, "NEdit: %s requires 0 or 1 argument\n", actionName); \
3426 (newState) = !(oValue); \
3429 static void setStatisticsLineAP(Widget w
, XEvent
*event
, String
*args
,
3432 WindowInfo
*window
= WidgetToWindow(w
);
3435 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->showStats
, "set_statistics_line");
3437 XmToggleButtonSetState(window
->statsLineItem
, newState
, False
);
3438 ShowStatsLine(window
, newState
);
3441 static void setIncrementalSearchLineAP(Widget w
, XEvent
*event
, String
*args
,
3444 WindowInfo
*window
= WidgetToWindow(w
);
3447 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->showISearchLine
, "set_incremental_search_line");
3449 XmToggleButtonSetState(window
->iSearchLineItem
, newState
, False
);
3450 ShowISearchLine(window
, newState
);
3453 static void setShowLineNumbersAP(Widget w
, XEvent
*event
, String
*args
,
3456 WindowInfo
*window
= WidgetToWindow(w
);
3459 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->showLineNumbers
, "set_show_line_numbers");
3461 XmToggleButtonSetState(window
->lineNumsItem
, newState
, False
);
3462 ShowLineNumbers(window
, newState
);
3465 static void setAutoIndentAP(Widget w
, XEvent
*event
, String
*args
,
3468 WindowInfo
*window
= WidgetToWindow(w
);
3470 if (strcmp(args
[0], "off") == 0) {
3471 SetAutoIndent(window
, NO_AUTO_INDENT
);
3473 else if (strcmp(args
[0], "on") == 0) {
3474 SetAutoIndent(window
, AUTO_INDENT
);
3476 else if (strcmp(args
[0], "smart") == 0) {
3477 SetAutoIndent(window
, SMART_INDENT
);
3480 fprintf(stderr
, "NEdit: set_auto_indent invalid argument\n");
3484 fprintf(stderr
, "NEdit: set_auto_indent requires argument\n");
3488 static void setWrapTextAP(Widget w
, XEvent
*event
, String
*args
,
3491 WindowInfo
*window
= WidgetToWindow(w
);
3493 if (strcmp(args
[0], "none") == 0) {
3494 SetAutoWrap(window
, NO_WRAP
);
3496 else if (strcmp(args
[0], "auto") == 0) {
3497 SetAutoWrap(window
, NEWLINE_WRAP
);
3499 else if (strcmp(args
[0], "continuous") == 0) {
3500 SetAutoWrap(window
, CONTINUOUS_WRAP
);
3503 fprintf(stderr
, "NEdit: set_wrap_text invalid argument\n");
3507 fprintf(stderr
, "NEdit: set_wrap_text requires argument\n");
3511 static void setWrapMarginAP(Widget w
, XEvent
*event
, String
*args
,
3514 WindowInfo
*window
= WidgetToWindow(w
);
3518 if (sscanf(args
[0], "%d", &newMargin
) == 1 &&
3523 XtVaSetValues(window
->textArea
, textNwrapMargin
, newMargin
, NULL
);
3524 for (i
= 0; i
< window
->nPanes
; ++i
) {
3525 XtVaSetValues(window
->textPanes
[i
], textNwrapMargin
, newMargin
, NULL
);
3530 "NEdit: set_wrap_margin requires integer argument >= 0 and < 1000\n");
3534 fprintf(stderr
, "NEdit: set_wrap_margin requires argument\n");
3538 static void setHighlightSyntaxAP(Widget w
, XEvent
*event
, String
*args
,
3541 WindowInfo
*window
= WidgetToWindow(w
);
3544 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->highlightSyntax
, "set_highlight_syntax");
3546 XmToggleButtonSetState(window
->highlightItem
, newState
, False
);
3547 window
->highlightSyntax
= newState
;
3548 if (window
->highlightSyntax
) {
3549 StartHighlighting(window
, True
);
3551 StopHighlighting(window
);
3555 static void setMakeBackupCopyAP(Widget w
, XEvent
*event
, String
*args
,
3558 WindowInfo
*window
= WidgetToWindow(w
);
3561 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->saveOldVersion
, "set_make_backup_copy");
3563 XmToggleButtonSetState(window
->saveLastItem
, newState
, False
);
3564 window
->saveOldVersion
= newState
;
3567 static void setIncrementalBackupAP(Widget w
, XEvent
*event
, String
*args
,
3570 WindowInfo
*window
= WidgetToWindow(w
);
3573 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->autoSave
, "set_incremental_backup");
3575 XmToggleButtonSetState(window
->autoSaveItem
, newState
, False
);
3576 window
->autoSave
= newState
;
3579 static void setShowMatchingAP(Widget w
, XEvent
*event
, String
*args
,
3582 WindowInfo
*window
= WidgetToWindow(w
);
3584 if (strcmp(args
[0], NO_FLASH_STRING
) == 0) {
3585 SetShowMatching(window
, NO_FLASH
);
3587 else if (strcmp(args
[0], FLASH_DELIMIT_STRING
) == 0) {
3588 SetShowMatching(window
, FLASH_DELIMIT
);
3590 else if (strcmp(args
[0], FLASH_RANGE_STRING
) == 0) {
3591 SetShowMatching(window
, FLASH_RANGE
);
3593 /* For backward compatibility with pre-5.2 versions, we also
3594 accept 0 and 1 as aliases for NO_FLASH and FLASH_DELIMIT.
3595 It is quite unlikely, though, that anyone ever used this
3596 action procedure via the macro language or a key binding,
3597 so this can probably be left out safely. */
3598 else if (strcmp(args
[0], "0") == 0) {
3599 SetShowMatching(window
, NO_FLASH
);
3601 else if (strcmp(args
[0], "1") == 0) {
3602 SetShowMatching(window
, FLASH_DELIMIT
);
3605 fprintf(stderr
, "NEdit: Invalid argument for set_show_matching\n");
3609 fprintf(stderr
, "NEdit: set_show_matching requires argument\n");
3613 static void setMatchSyntaxBasedAP(Widget w
, XEvent
*event
, String
*args
,
3616 WindowInfo
*window
= WidgetToWindow(w
);
3619 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->matchSyntaxBased
, "set_match_syntax_based");
3621 XmToggleButtonSetState(window
->matchSyntaxBasedItem
, newState
, False
);
3622 window
->matchSyntaxBased
= newState
;
3625 static void setOvertypeModeAP(Widget w
, XEvent
*event
, String
*args
,
3628 WindowInfo
*window
= WidgetToWindow(w
);
3631 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->overstrike
, "set_overtype_mode");
3633 XmToggleButtonSetState(window
->overtypeModeItem
, newState
, False
);
3634 SetOverstrike(window
, newState
);
3637 static void setLockedAP(Widget w
, XEvent
*event
, String
*args
,
3640 WindowInfo
*window
= WidgetToWindow(w
);
3643 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, IS_USER_LOCKED(window
->lockReasons
), "set_locked");
3645 SET_USER_LOCKED(window
->lockReasons
, newState
);
3646 XmToggleButtonSetState(window
->readOnlyItem
, IS_ANY_LOCKED(window
->lockReasons
), False
);
3647 UpdateWindowTitle(window
);
3648 UpdateWindowReadOnly(window
);
3651 static void setTabDistAP(Widget w
, XEvent
*event
, String
*args
,
3654 WindowInfo
*window
= WidgetToWindow(w
);
3658 if (sscanf(args
[0], "%d", &newTabDist
) == 1 &&
3660 newTabDist
<= MAX_EXP_CHAR_LEN
) {
3661 SetTabDist(window
, newTabDist
);
3665 "NEdit: set_tab_dist requires integer argument > 0 and <= %d\n",
3670 fprintf(stderr
, "NEdit: set_tab_dist requires argument\n");
3674 static void setEmTabDistAP(Widget w
, XEvent
*event
, String
*args
,
3677 WindowInfo
*window
= WidgetToWindow(w
);
3680 int newEmTabDist
= 0;
3681 if (sscanf(args
[0], "%d", &newEmTabDist
) == 1 &&
3682 newEmTabDist
>= -1 &&
3683 newEmTabDist
< 1000) {
3684 if (newEmTabDist
< 0) {
3687 SetEmTabDist(window
, newEmTabDist
);
3691 "NEdit: set_em_tab_dist requires integer argument >= -1 and < 1000\n");
3695 fprintf(stderr
, "NEdit: set_em_tab_dist requires argument\n");
3699 static void setUseTabsAP(Widget w
, XEvent
*event
, String
*args
,
3702 WindowInfo
*window
= WidgetToWindow(w
);
3705 ACTION_BOOL_PARAM_OR_TOGGLE(newState
, *nArgs
, args
, window
->buffer
->useTabs
, "set_use_tabs");
3707 window
->buffer
->useTabs
= newState
;
3710 static void setFontsAP(Widget w
, XEvent
*event
, String
*args
,
3713 WindowInfo
*window
= WidgetToWindow(w
);
3715 SetFonts(window
, args
[0], args
[1], args
[2], args
[3]);
3718 fprintf(stderr
, "NEdit: set_fonts requires 4 arguments\n");
3722 static void setLanguageModeAP(Widget w
, XEvent
*event
, String
*args
,
3725 WindowInfo
*window
= WidgetToWindow(w
);
3728 SetLanguageMode(window
, FindLanguageMode(args
[0]), FALSE
);
3731 fprintf(stderr
, "NEdit: set_language_mode requires argument\n");
3736 ** Same as AddSubMenu from libNUtil.a but 1) mnemonic is optional (NEdit
3737 ** users like to be able to re-arrange the mnemonics so they can set Alt
3738 ** key combinations as accelerators), 2) supports the short/full option
3739 ** of SGI_CUSTOM mode, 3) optionally returns the cascade button widget
3740 ** in "cascadeBtn" if "cascadeBtn" is non-NULL.
3742 static Widget
createMenu(Widget parent
, char *name
, char *label
,
3743 char mnemonic
, Widget
*cascadeBtn
, int mode
)
3745 Widget menu
, cascade
;
3748 menu
= CreatePulldownMenu(parent
, name
, NULL
, 0);
3749 cascade
= XtVaCreateWidget(name
, xmCascadeButtonWidgetClass
, parent
,
3750 XmNlabelString
, st1
=XmStringCreateSimple(label
),
3751 XmNsubMenuId
, menu
, NULL
);
3754 XtVaSetValues(cascade
, XmNmnemonic
, mnemonic
, NULL
);
3756 if (mode
== SHORT
|| !GetPrefShortMenus())
3757 XtManageChild(cascade
);
3759 addToToggleShortList(cascade
);
3761 XtManageChild(cascade
);
3763 if (cascadeBtn
!= NULL
)
3764 *cascadeBtn
= cascade
;
3769 ** Same as AddMenuItem from libNUtil.a without setting the accelerator
3770 ** (these are set in the fallback app-defaults so users can change them),
3771 ** and with the short/full option required in SGI_CUSTOM mode.
3773 static Widget
createMenuItem(Widget parent
, char *name
, char *label
,
3774 char mnemonic
, menuCallbackProc callback
, void *cbArg
, int mode
)
3780 button
= XtVaCreateWidget(name
, xmPushButtonWidgetClass
, parent
,
3781 XmNlabelString
, st1
=XmStringCreateSimple(label
),
3782 XmNmnemonic
, mnemonic
, NULL
);
3783 XtAddCallback(button
, XmNactivateCallback
, (XtCallbackProc
)callback
, cbArg
);
3786 if (mode
== SHORT
|| !GetPrefShortMenus())
3787 XtManageChild(button
);
3789 addToToggleShortList(button
);
3790 XtVaSetValues(button
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
3792 XtManageChild(button
);
3798 ** "fake" menu items allow accelerators to be attached, but don't show up
3799 ** in the menu. They are necessary to process the shifted menu items because
3800 ** Motif does not properly process the event descriptions in accelerator
3801 ** resources, and you can't specify "shift key is optional"
3803 static Widget
createFakeMenuItem(Widget parent
, char *name
,
3804 menuCallbackProc callback
, void *cbArg
)
3809 button
= XtVaCreateManagedWidget(name
, xmPushButtonWidgetClass
, parent
,
3810 XmNlabelString
, st1
=XmStringCreateSimple(""),
3811 XmNshadowThickness
, 0,
3813 XmNheight
, 0, NULL
);
3814 XtAddCallback(button
, XmNactivateCallback
, (XtCallbackProc
)callback
, cbArg
);
3816 XtVaSetValues(button
, XmNtraversalOn
, False
, NULL
);
3822 ** Add a toggle button item to an already established pull-down or pop-up
3823 ** menu, including mnemonics, accelerators and callbacks.
3825 static Widget
createMenuToggle(Widget parent
, char *name
, char *label
,
3826 char mnemonic
, menuCallbackProc callback
, void *cbArg
, int set
,
3832 button
= XtVaCreateWidget(name
, xmToggleButtonWidgetClass
, parent
,
3833 XmNlabelString
, st1
=XmStringCreateSimple(label
),
3834 XmNmnemonic
, mnemonic
,
3836 XtAddCallback(button
, XmNvalueChangedCallback
, (XtCallbackProc
)callback
,
3840 if (mode
== SHORT
|| !GetPrefShortMenus())
3841 XtManageChild(button
);
3843 addToToggleShortList(button
);
3844 XtVaSetValues(button
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
3846 XtManageChild(button
);
3852 ** Create a toggle button with a diamond (radio-style) appearance
3854 static Widget
createMenuRadioToggle(Widget parent
, char *name
, char *label
,
3855 char mnemonic
, menuCallbackProc callback
, void *cbArg
, int set
,
3859 button
= createMenuToggle(parent
, name
, label
, mnemonic
, callback
, cbArg
,
3861 XtVaSetValues(button
, XmNindicatorType
, XmONE_OF_MANY
, NULL
);
3865 static Widget
createMenuSeparator(Widget parent
, char *name
, int mode
)
3869 button
= XmCreateSeparator(parent
, name
, NULL
, 0);
3871 if (mode
== SHORT
|| !GetPrefShortMenus())
3872 XtManageChild(button
);
3874 addToToggleShortList(button
);
3875 XtVaSetValues(button
, XmNuserData
, PERMANENT_MENU_ITEM
, NULL
);
3877 XtManageChild(button
);
3883 ** Make sure the close menu item is dimmed appropriately for the current
3884 ** set of windows. It should be dim only for the last Untitled, unmodified,
3885 ** editor window, and sensitive otherwise.
3887 void CheckCloseDim(void)
3891 if (WindowList
== NULL
)
3893 if (WindowList
->next
==NULL
&&
3894 !WindowList
->filenameSet
&& !WindowList
->fileChanged
) {
3895 XtSetSensitive(WindowList
->closeItem
, FALSE
);
3899 for (window
=WindowList
; window
!=NULL
; window
=window
->next
)
3900 XtSetSensitive(window
->closeItem
, True
);
3904 ** Invalidate the Window menus of all NEdit windows to but don't change
3905 ** the menus until they're needed (Originally, this was "UpdateWindowMenus",
3906 ** but creating and destroying manu items for every window every time a
3907 ** new window was created or something changed, made things move very
3908 ** slowly with more than 10 or so windows).
3910 void InvalidateWindowMenus(void)
3914 /* Mark the window menus invalid (to be updated when the user pulls one
3915 down), unless the menu is torn off, meaning it is visible to the user
3916 and should be updated immediately */
3917 for (w
=WindowList
; w
!=NULL
; w
=w
->next
) {
3918 if (!XmIsMenuShell(XtParent(w
->windowMenuPane
)))
3919 updateWindowMenu(w
);
3921 w
->windowMenuValid
= False
;
3926 ** Mark the Previously Opened Files menus of all NEdit windows as invalid.
3927 ** Since actually changing the menus is slow, they're just marked and updated
3928 ** when the user pulls one down.
3930 static void invalidatePrevOpenMenus(void)
3934 /* Mark the menus invalid (to be updated when the user pulls one
3935 down), unless the menu is torn off, meaning it is visible to the user
3936 and should be updated immediately */
3937 for (w
=WindowList
; w
!=NULL
; w
=w
->next
) {
3938 if (!XmIsMenuShell(XtParent(w
->prevOpenMenuPane
)))
3939 updatePrevOpenMenu(w
);
3941 w
->prevOpenMenuValid
= False
;
3946 ** Add a file to the list of previously opened files for display in the
3949 void AddToPrevOpenMenu(const char *filename
)
3955 /* If the Open Previous command is disabled, just return */
3956 if (GetPrefMaxPrevOpenFiles() == 0)
3959 /* If the name is already in the list, move it to the start */
3960 for (i
=0; i
<NPrevOpen
; i
++) {
3961 if (!strcmp(filename
, PrevOpen
[i
])) {
3962 nameCopy
= PrevOpen
[i
];
3963 memmove(&PrevOpen
[1], &PrevOpen
[0], sizeof(char *) * i
);
3964 PrevOpen
[0] = nameCopy
;
3965 invalidatePrevOpenMenus();
3971 /* If the list is already full, make room */
3972 if (NPrevOpen
== GetPrefMaxPrevOpenFiles())
3973 XtFree(PrevOpen
[--NPrevOpen
]);
3975 /* Add it to the list */
3976 nameCopy
= XtMalloc(strlen(filename
) + 1);
3977 strcpy(nameCopy
, filename
);
3978 memmove(&PrevOpen
[1], &PrevOpen
[0], sizeof(char *) * NPrevOpen
);
3979 PrevOpen
[0] = nameCopy
;
3982 /* Mark the Previously Opened Files menu as invalid in all windows */
3983 invalidatePrevOpenMenus();
3985 /* Undim the menu in all windows if it was previously empty */
3987 for (w
=WindowList
; w
!=NULL
; w
=w
->next
)
3988 XtSetSensitive(w
->prevOpenMenuItem
, True
);
3990 /* Write the menu contents to disk to restore in later sessions */
3994 static char* getWindowsMenuEntry(const WindowInfo
* thisWindow
, const WindowInfo
* window
)
3996 static char fullTitle
[MAXPATHLEN
* 2 + 3+ 1];
3999 XtVaGetValues(window
->shell
, XmNiconName
, &title
, NULL
);
4001 title
= title
+ SGI_WINDOW_TITLE_LEN
;
4003 strcpy(fullTitle
, title
);
4004 if (thisWindow
->showPathInWindowsMenu
&& window
->filenameSet
)
4006 strcat(fullTitle
, " - ");
4007 strcat(fullTitle
, window
->path
);
4014 ** Update the Window menu of a single window to reflect the current state of
4015 ** all NEdit windows as determined by the global WindowList.
4017 static void updateWindowMenu(const WindowInfo
*window
)
4022 int i
, n
, nWindows
, windowIndex
;
4023 WindowInfo
**windows
;
4025 /* Make a sorted list of windows */
4026 for (w
=WindowList
, nWindows
=0; w
!=NULL
; w
=w
->next
, nWindows
++);
4027 windows
= (WindowInfo
**)XtMalloc(sizeof(WindowInfo
*) * nWindows
);
4028 for (w
=WindowList
, i
=0; w
!=NULL
; w
=w
->next
, i
++)
4030 qsort(windows
, nWindows
, sizeof(WindowInfo
*), compareWindowNames
);
4032 /* While it is not possible on some systems (ibm at least) to substitute
4033 a new menu pane, it is possible to substitute menu items, as long as
4034 at least one remains in the menu at all times. This routine assumes
4035 that the menu contains permanent items marked with the value
4036 PERMANENT_MENU_ITEM in the userData resource, and adds and removes items
4037 which it marks with the value TEMPORARY_MENU_ITEM */
4039 /* Go thru all of the items in the menu and rename them to
4040 match the window list. Delete any extras */
4041 XtVaGetValues(window
->windowMenuPane
, XmNchildren
, &items
,
4042 XmNnumChildren
, &nItems
, NULL
);
4044 for (n
=0; n
<(int)nItems
; n
++) {
4046 XtVaGetValues(items
[n
], XmNuserData
, &userData
, NULL
);
4047 if (userData
== TEMPORARY_MENU_ITEM
) {
4048 if (windowIndex
>= nWindows
) {
4049 /* unmanaging before destroying stops parent from displaying */
4050 XtUnmanageChild(items
[n
]);
4051 XtDestroyWidget(items
[n
]);
4054 char* title
= getWindowsMenuEntry(window
, windows
[windowIndex
]);
4055 XtVaSetValues(items
[n
], XmNlabelString
,
4056 st1
=XmStringCreateSimple(title
), NULL
);
4057 XtRemoveAllCallbacks(items
[n
], XmNactivateCallback
);
4058 XtAddCallback(items
[n
], XmNactivateCallback
,
4059 (XtCallbackProc
)raiseCB
, windows
[windowIndex
]);
4066 /* Add new items for the titles of the remaining windows to the menu */
4067 for (; windowIndex
<nWindows
; windowIndex
++) {
4069 char* title
= getWindowsMenuEntry(window
, windows
[windowIndex
]);
4070 Widget btn
= XtVaCreateManagedWidget("win", xmPushButtonWidgetClass
,
4071 window
->windowMenuPane
,
4072 XmNlabelString
, st1
=XmStringCreateSimple(title
),
4074 XmNuserData
, TEMPORARY_MENU_ITEM
, NULL
);
4075 XtAddCallback(btn
, XmNactivateCallback
, (XtCallbackProc
)raiseCB
,
4076 windows
[windowIndex
]);
4079 XtFree((char *)windows
);
4083 ** Update the Previously Opened Files menu of a single window to reflect the
4084 ** current state of the list as retrieved from GetPrevOpenFiles.
4085 ** Thanks to Markus Schwarzenberg for the sorting part.
4087 static void updatePrevOpenMenu(WindowInfo
*window
)
4094 char **prevOpenSorted
;
4096 /* Sort the previously opened file list if requested */
4097 prevOpenSorted
= (char **)XtMalloc(NPrevOpen
* sizeof(char*));
4098 memcpy(prevOpenSorted
, PrevOpen
, NPrevOpen
* sizeof(char*));
4099 if (GetPrefSortOpenPrevMenu())
4100 qsort(prevOpenSorted
, NPrevOpen
, sizeof(char*), cmpStrPtr
);
4102 /* Go thru all of the items in the menu and rename them to match the file
4103 list. In older Motifs (particularly ibm), it was dangerous to replace
4104 a whole menu pane, which would be much simpler. However, since the
4105 code was already written for the Windows menu and is well tested, I'll
4106 stick with this weird method of re-naming the items */
4107 XtVaGetValues(window
->prevOpenMenuPane
, XmNchildren
, &items
,
4108 XmNnumChildren
, &nItems
, NULL
);
4110 for (n
=0; n
<(int)nItems
; n
++) {
4111 if (index
>= NPrevOpen
) {
4112 /* unmanaging before destroying stops parent from displaying */
4113 XtUnmanageChild(items
[n
]);
4114 XtDestroyWidget(items
[n
]);
4116 XtVaSetValues(items
[n
], XmNlabelString
,
4117 st1
=XmStringCreateSimple(prevOpenSorted
[index
]), NULL
);
4118 XtRemoveAllCallbacks(items
[n
], XmNactivateCallback
);
4119 XtAddCallback(items
[n
], XmNactivateCallback
,
4120 (XtCallbackProc
)openPrevCB
, prevOpenSorted
[index
]);
4126 /* Add new items for the remaining file names to the menu */
4127 for (; index
<NPrevOpen
; index
++) {
4128 btn
= XtVaCreateManagedWidget("win", xmPushButtonWidgetClass
,
4129 window
->prevOpenMenuPane
,
4130 XmNlabelString
, st1
=XmStringCreateSimple(prevOpenSorted
[index
]),
4132 XmNuserData
, TEMPORARY_MENU_ITEM
, NULL
);
4133 XtAddCallback(btn
, XmNactivateCallback
, (XtCallbackProc
)openPrevCB
,
4134 prevOpenSorted
[index
]);
4138 XtFree((char*)prevOpenSorted
);
4142 ** This function manages the display of the Tags File Menu, which is displayed
4143 ** when the user selects Un-load Tags File.
4145 static void updateTagsFileMenu(WindowInfo
*window
)
4154 /* Go thru all of the items in the menu and rename them to match the file
4155 list. In older Motifs (particularly ibm), it was dangerous to replace
4156 a whole menu pane, which would be much simpler. However, since the
4157 code was already written for the Windows menu and is well tested, I'll
4158 stick with this weird method of re-naming the items */
4159 XtVaGetValues(window
->unloadTagsMenuPane
, XmNchildren
, &items
,
4160 XmNnumChildren
, &nItems
, NULL
);
4162 for (n
=0; n
<(int)nItems
; n
++) {
4164 /* unmanaging before destroying stops parent from displaying */
4165 XtUnmanageChild(items
[n
]);
4166 XtDestroyWidget(items
[n
]);
4168 XtVaSetValues(items
[n
], XmNlabelString
,
4169 st1
=XmStringCreateSimple(tf
->filename
), NULL
);
4170 XtRemoveAllCallbacks(items
[n
], XmNactivateCallback
);
4171 XtAddCallback(items
[n
], XmNactivateCallback
,
4172 (XtCallbackProc
)unloadTagsFileCB
, tf
->filename
);
4178 /* Add new items for the remaining file names to the menu */
4180 btn
= XtVaCreateManagedWidget("win", xmPushButtonWidgetClass
,
4181 window
->unloadTagsMenuPane
, XmNlabelString
,
4182 st1
=XmStringCreateSimple(tf
->filename
),XmNmarginHeight
, 0,
4183 XmNuserData
, TEMPORARY_MENU_ITEM
, NULL
);
4184 XtAddCallback(btn
, XmNactivateCallback
,
4185 (XtCallbackProc
)unloadTagsFileCB
, tf
->filename
);
4192 ** This function manages the display of the Tips File Menu, which is displayed
4193 ** when the user selects Un-load Calltips File.
4195 static void updateTipsFileMenu(WindowInfo
*window
)
4204 /* Go thru all of the items in the menu and rename them to match the file
4205 list. In older Motifs (particularly ibm), it was dangerous to replace
4206 a whole menu pane, which would be much simpler. However, since the
4207 code was already written for the Windows menu and is well tested, I'll
4208 stick with this weird method of re-naming the items */
4209 XtVaGetValues(window
->unloadTipsMenuPane
, XmNchildren
, &items
,
4210 XmNnumChildren
, &nItems
, NULL
);
4212 for (n
=0; n
<(int)nItems
; n
++) {
4214 /* unmanaging before destroying stops parent from displaying */
4215 XtUnmanageChild(items
[n
]);
4216 XtDestroyWidget(items
[n
]);
4218 XtVaSetValues(items
[n
], XmNlabelString
,
4219 st1
=XmStringCreateSimple(tf
->filename
), NULL
);
4220 XtRemoveAllCallbacks(items
[n
], XmNactivateCallback
);
4221 XtAddCallback(items
[n
], XmNactivateCallback
,
4222 (XtCallbackProc
)unloadTipsFileCB
, tf
->filename
);
4228 /* Add new items for the remaining file names to the menu */
4230 btn
= XtVaCreateManagedWidget("win", xmPushButtonWidgetClass
,
4231 window
->unloadTipsMenuPane
, XmNlabelString
,
4232 st1
=XmStringCreateSimple(tf
->filename
),XmNmarginHeight
, 0,
4233 XmNuserData
, TEMPORARY_MENU_ITEM
, NULL
);
4234 XtAddCallback(btn
, XmNactivateCallback
,
4235 (XtCallbackProc
)unloadTipsFileCB
, tf
->filename
);
4242 ** Comparison function for sorting file names for the Open Previous submenu
4244 static int cmpStrPtr(const void *strA
, const void *strB
)
4246 return strcmp(*((char**)strA
), *((char**)strB
));
4250 ** Write dynamic database of file names for "Open Previous". Eventually,
4251 ** this may hold window positions, and possibly file marks, in which case,
4252 ** it should be moved to a different module, but for now it's just a list
4253 ** of previously opened files.
4255 void WriteNEditDB(void)
4257 const char* fullName
= GetRCFileName(NEDIT_HISTORY
);
4260 static char fileHeader
[] =
4261 "# File name database for NEdit Open Previous command\n";
4263 /* If the Open Previous command is disabled, just return */
4264 if (GetPrefMaxPrevOpenFiles() == 0)
4268 if ((fp
= fopen(fullName
, "w")) == NULL
)
4271 /* write the file header text to the file */
4272 fprintf(fp
, "%s", fileHeader
);
4274 /* Write the list of file names */
4275 for (i
=0; i
<NPrevOpen
; i
++)
4276 fprintf(fp
, "%s\n", PrevOpen
[i
]);
4278 /* Close the file */
4283 ** Read dynamic database of file names for "Open Previous". Eventually,
4284 ** this may hold window positions, and possibly file marks, in which case,
4285 ** it should be moved to a different module, but for now it's just a list
4286 ** of previously opened files. This routine should only be called once,
4287 ** at startup time, before any windows are open.
4289 void ReadNEditDB(void)
4291 const char* fullName
= GetRCFileName(NEDIT_HISTORY
);
4292 char line
[MAXPATHLEN
];
4297 static char badFilenameChars
[] = "\n\t*?()[]{}!@#%^&:;' ";
4299 static char badFilenameChars
[] = "\n\t*?()[]{}";
4302 /* If the Open Previous command is disabled, just return */
4303 if (GetPrefMaxPrevOpenFiles() == 0)
4306 /* Initialize the files list and allocate a (permanent) block memory
4307 of the size prescribed by the maxPrevOpenFiles resource */
4308 PrevOpen
= (char **)XtMalloc(sizeof(char *) * GetPrefMaxPrevOpenFiles());
4312 if ((fp
= fopen(fullName
, "r")) == NULL
)
4315 /* read lines of the file, lines beginning with # are considered to be
4316 comments and are thrown away. Lines are subject to cursory checking,
4317 then just copied to the Open Previous file menu list */
4319 if (fgets(line
, (int)MAXPATHLEN
, fp
) == NULL
) {
4321 return; /* end of file */
4325 lineLen
= strlen(line
); /* comment */
4326 if (line
[lineLen
-1] != '\n') {
4327 fprintf(stderr
, ".neditdb line too long\n");
4329 return; /* no newline, probably truncated */
4331 line
[--lineLen
] = '\0';
4333 continue; /* blank line */
4334 if ((int)strcspn(line
, badFilenameChars
) != lineLen
) {
4335 fprintf(stderr
, ".neditdb file is corrupted\n");
4337 return; /* non-filename characters */
4339 nameCopy
= XtMalloc(lineLen
+1);
4340 strcpy(nameCopy
, line
);
4341 PrevOpen
[NPrevOpen
++] = nameCopy
;
4342 if (NPrevOpen
>= GetPrefMaxPrevOpenFiles()) {
4344 return; /* too many entries */
4349 static void setWindowSizeDefault(int rows
, int cols
)
4353 updateWindowSizeMenus();
4356 static void updateWindowSizeMenus(void)
4360 for (win
=WindowList
; win
!=NULL
; win
=win
->next
)
4361 updateWindowSizeMenu(win
);
4364 static void updateWindowSizeMenu(WindowInfo
*win
)
4366 int rows
= GetPrefRows(), cols
= GetPrefCols();
4370 XmToggleButtonSetState(win
->size24x80DefItem
, rows
==24&&cols
==80,False
);
4371 XmToggleButtonSetState(win
->size40x80DefItem
, rows
==40&&cols
==80,False
);
4372 XmToggleButtonSetState(win
->size60x80DefItem
, rows
==60&&cols
==80,False
);
4373 XmToggleButtonSetState(win
->size80x80DefItem
, rows
==80&&cols
==80,False
);
4374 if ((rows
!=24 && rows
!=40 && rows
!=60 && rows
!=80) || cols
!=80) {
4375 XmToggleButtonSetState(win
->sizeCustomDefItem
, True
, False
);
4376 sprintf(title
, "Custom... (%d x %d)", rows
, cols
);
4377 XtVaSetValues(win
->sizeCustomDefItem
,
4378 XmNlabelString
, st1
=XmStringCreateSimple(title
), NULL
);
4381 XmToggleButtonSetState(win
->sizeCustomDefItem
, False
, False
);
4382 XtVaSetValues(win
->sizeCustomDefItem
,
4383 XmNlabelString
, st1
=XmStringCreateSimple("Custom..."), NULL
);
4389 ** Scans action argument list for arguments "forward" or "backward" to
4390 ** determine search direction for search and replace actions. "ignoreArgs"
4391 ** tells the routine how many required arguments there are to ignore before
4392 ** looking for keywords
4394 static int searchDirection(int ignoreArgs
, String
*args
, Cardinal
*nArgs
)
4398 for (i
=ignoreArgs
; i
<(int)*nArgs
; i
++) {
4399 if (!strCaseCmp(args
[i
], "forward"))
4400 return SEARCH_FORWARD
;
4401 if (!strCaseCmp(args
[i
], "backward"))
4402 return SEARCH_BACKWARD
;
4404 return SEARCH_FORWARD
;
4408 ** Scans action argument list for arguments "keep" or "nokeep" to
4409 ** determine whether to keep dialogs up for search and replace. "ignoreArgs"
4410 ** tells the routine how many required arguments there are to ignore before
4411 ** looking for keywords
4413 static int searchKeepDialogs(int ignoreArgs
, String
*args
, Cardinal
*nArgs
)
4417 for (i
=ignoreArgs
; i
<(int)*nArgs
; i
++) {
4418 if (!strCaseCmp(args
[i
], "keep"))
4420 if (!strCaseCmp(args
[i
], "nokeep"))
4423 return GetPrefKeepSearchDlogs();
4427 ** Scans action argument list for arguments "wrap" or "nowrap" to
4428 ** determine search direction for search and replace actions. "ignoreArgs"
4429 ** tells the routine how many required arguments there are to ignore before
4430 ** looking for keywords
4432 static int searchWrap(int ignoreArgs
, String
*args
, Cardinal
*nArgs
)
4436 for (i
=ignoreArgs
; i
<(int)*nArgs
; i
++) {
4437 if (!strCaseCmp(args
[i
], "wrap"))
4439 if (!strCaseCmp(args
[i
], "nowrap"))
4442 return GetPrefSearchWraps();
4446 ** Scans action argument list for arguments "literal", "case" or "regex" to
4447 ** determine search type for search and replace actions. "ignoreArgs"
4448 ** tells the routine how many required arguments there are to ignore before
4449 ** looking for keywords
4451 static int searchType(int ignoreArgs
, String
*args
, Cardinal
*nArgs
)
4453 int i
, tmpSearchType
;
4455 for (i
=ignoreArgs
; i
<(int)*nArgs
; i
++) {
4456 if (StringToSearchType(args
[i
], &tmpSearchType
))
4457 return tmpSearchType
;
4459 return GetPrefSearch();
4463 ** Return a pointer to the string describing search direction for search action
4464 ** routine parameters given a callback XmAnyCallbackStruct pointed to by
4465 ** "callData", by checking if the shift key is pressed (for search callbacks).
4467 static char **shiftKeyToDir(XtPointer callData
)
4469 static char *backwardParam
[1] = {"backward"};
4470 static char *forwardParam
[1] = {"forward"};
4471 if (((XmAnyCallbackStruct
*)callData
)->event
->xbutton
.state
& ShiftMask
)
4472 return backwardParam
;
4473 return forwardParam
;
4476 static void raiseCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
4478 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
4479 ((XmAnyCallbackStruct
*)callData
)->event
);
4480 RaiseShellWindow(window
->shell
);
4483 static void openPrevCB(Widget w
, char *name
, caddr_t callData
)
4486 Widget menu
= MENU_WIDGET(w
);
4488 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
4489 ((XmAnyCallbackStruct
*)callData
)->event
);
4491 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "open",
4492 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
4496 static void unloadTagsFileCB(Widget w
, char *name
, caddr_t callData
)
4499 Widget menu
= MENU_WIDGET(w
);
4501 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
4502 ((XmAnyCallbackStruct
*)callData
)->event
);
4504 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "unload_tags_file",
4505 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
4508 static void unloadTipsFileCB(Widget w
, char *name
, caddr_t callData
)
4511 #if XmVersion >= 1002
4512 Widget menu
= XmGetPostedFromWidget(XtParent(w
)); /* If menu is torn off */
4518 XtCallActionProc(WidgetToWindow(menu
)->lastFocus
, "unload_tips_file",
4519 ((XmAnyCallbackStruct
*)callData
)->event
, params
, 1);
4523 ** strCaseCmp compares its arguments and returns 0 if the two strings
4524 ** are equal IGNORING case differences. Otherwise returns 1.
4526 static int strCaseCmp(const char *str1
, const char *str2
)
4528 const char *c1
, *c2
;
4530 for (c1
=str1
, c2
=str2
; *c1
!='\0' && *c2
!='\0'; c1
++, c2
++)
4531 if (toupper((unsigned char)*c1
) != toupper((unsigned char)*c2
))
4542 ** Comparison function for sorting windows by title for the window menu.
4543 ** Windows are sorted by Untitled and then alphabetically by filename and
4544 ** then alphabetically by path.
4546 static int compareWindowNames(const void *windowA
, const void *windowB
)
4549 const WindowInfo
*a
= *((WindowInfo
**)windowA
);
4550 const WindowInfo
*b
= *((WindowInfo
**)windowB
);
4551 /* Untitled first */
4552 rc
= a
->filenameSet
== b
->filenameSet
? 0 :
4553 a
->filenameSet
&& !b
->filenameSet
? 1 : -1;
4556 rc
= strcmp(a
->filename
, b
->filename
);
4559 rc
= strcmp(a
->path
, b
->path
);
4564 ** Create popup for right button programmable menu
4566 Widget
CreateBGMenu(WindowInfo
*window
)
4570 /* There is still some mystery here. It's important to get the XmNmenuPost
4571 resource set to the correct menu button, or the menu will not post
4572 properly, but there's also some danger that it will take over the entire
4573 button and interfere with text widget translations which use the button
4574 with modifiers. I don't entirely understand why it works properly now
4575 when it failed often in development, and certainly ignores the ~ syntax
4576 in translation event specifications. */
4577 XtSetArg(args
[0], XmNmenuPost
, GetPrefBGMenuBtn());
4578 return CreatePopupMenu(window
->textArea
, "bgMenu", args
, 1);
4582 ** Add a translation to the text widget to trigger the background menu using
4583 ** the mouse-button + modifier combination specified in the resource:
4586 void AddBGMenuAction(Widget widget
)
4588 static XtTranslations table
= NULL
;
4590 if (table
== NULL
) {
4591 char translations
[MAX_ACCEL_LEN
+ 25];
4592 sprintf(translations
, "%s: post_window_bg_menu()\n",GetPrefBGMenuBtn());
4593 table
= XtParseTranslationTable(translations
);
4595 XtOverrideTranslations(widget
, table
);
4598 static void bgMenuPostAP(Widget w
, XEvent
*event
, String
*args
,
4601 WindowInfo
*window
= WidgetToWindow(w
);
4603 /* The Motif popup handling code BLOCKS events while the menu is posted,
4604 including the matching btn-up events which complete various dragging
4605 operations which it may interrupt. Cancel to head off problems */
4606 XtCallActionProc(window
->lastFocus
, "process_cancel", event
, NULL
, 0);
4608 /* Pop up the menu */
4609 XmMenuPosition(window
->bgMenuPane
, (XButtonPressedEvent
*)event
);
4610 XtManageChild(window
->bgMenuPane
);
4613 These statements have been here for a very long time, but seem
4614 unnecessary and are even dangerous: when any of the lock keys are on,
4615 Motif thinks it shouldn't display the background menu, but this
4616 callback is called anyway. When we then grab the focus and force the
4617 menu to be drawn, bad things can happen (like a total lockup of the X
4620 XtPopup(XtParent(window->bgMenuPane), XtGrabNonexclusive);
4621 XtMapWidget(XtParent(window->bgMenuPane));
4622 XtMapWidget(window->bgMenuPane);
4627 static void shortMenusCB(Widget w
, WindowInfo
*window
, caddr_t callData
)
4630 int i
, state
= XmToggleButtonGetState(w
);
4633 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w
))->lastFocus
,
4634 ((XmAnyCallbackStruct
*)callData
)->event
);
4635 /* Set the preference */
4636 SetPrefShortMenus(state
);
4638 /* Re-create the menus for all windows */
4639 for (win
=WindowList
; win
!=NULL
; win
=win
->next
) {
4640 for (i
=0; i
<win
->nToggleShortItems
; i
++) {
4642 XtUnmanageChild(win
->toggleShortItems
[i
]);
4644 XtManageChild(win
->toggleShortItems
[i
]);
4647 if (GetPrefShortMenus())
4648 SaveNEditPrefs(window
->shell
, True
);
4651 static void addToToggleShortList(Widget w
)
4653 if (ShortMenuWindow
->nToggleShortItems
>= MAX_SHORTENED_ITEMS
) {
4654 fprintf(stderr
,"NEdit, internal error: increase MAX_SHORTENED_ITEMS\n");
4657 ShortMenuWindow
->toggleShortItems
[ShortMenuWindow
->nToggleShortItems
++] = w
;
4661 ** Present the user a dialog for specifying whether or not a short
4662 ** menu mode preference should be applied toward the default setting.
4663 ** Return True if user requested to reset and save the default value.
4664 ** If operation was canceled, will return toggle widget "w" to it's
4665 ** original (opposite) state.
4667 static int shortPrefAskDefault(Widget parent
, Widget w
, const char *settingName
)
4671 if (!GetPrefShortMenus()) {
4675 sprintf(msg
, "%s: %s\nSave as default for future windows as well?",
4676 settingName
, XmToggleButtonGetState(w
) ? "On" : "Off");
4677 switch(DialogF (DF_QUES
, parent
, 3, msg
, "Yes", "No", "Cancel")) {
4682 case 3: /* cancel */
4683 XmToggleButtonSetState(w
, !XmToggleButtonGetState(w
), False
);
4686 return False
; /* not reached */