update .gitignore
[nedit-bw.git] / transient-documents.patch
blob4098c2e712664d655e29f7e7ee802454e29aeaa8
1 ---
3 doc/help.etx | 18 +++++++++++
4 source/file.c | 74 +++++++++++++++++++++++++++++++++----------------
5 source/file.h | 4 +-
6 source/highlightData.c | 4 +-
7 source/macro.c | 14 +++++++++
8 source/menu.c | 51 +++++++++++++++++++++++++++++----
9 source/nedit.c | 2 -
10 source/nedit.h | 2 +
11 source/window.c | 18 ++++++++---
12 source/windowTitle.c | 51 ++++++++++++++++++++++++++-------
13 source/windowTitle.h | 1
14 11 files changed, 187 insertions(+), 52 deletions(-)
16 diff --quilt old/doc/help.etx new/doc/help.etx
17 --- old/doc/help.etx
18 +++ new/doc/help.etx
19 @@ -3242,11 +3242,11 @@ Action Routines
20 3>Menu Action Routine Arguments
22 Arguments are text strings enclosed in quotes. Below are the menu action
23 routines which take arguments. Optional arguments are enclosed in [].
25 - **new**( ["tab" | "window" | "prefs" | "opposite"] )
26 + **new**( ["tab" | "window" | "prefs" | "opposite"] [, "transient"] )
28 **close**( ["prompt" | "save" | "nosave"] )
30 **execute_command**( shell-command )
32 @@ -3309,10 +3309,19 @@ Action Routines
33 preference
34 "opposite": Opposite of user's tab/window
35 preference
36 Default behaviour is "prefs".
38 + "transient" [EXPERIMENTAL]: Open the new
39 + document in transient mode. This disables the
40 + warning NEdit usually gives when you try to
41 + close a file which is not saved.
43 + WARNING: This is an experimental feature.
44 + Make sure to use this setting only for
45 + documents which can easily be recreated.
47 ~filename~ Path names are relative to the directory from
48 which NEdit was started. Shell interpreted
49 wildcards and `~' are not expanded.
51 ~keep-dialog~ Either "keep" or "nokeep".
52 @@ -3943,10 +3952,17 @@ Preferences
53 **Read Only**
54 Lock the file against accidental modification. This temporarily prevents the
55 file from being modified in this NEdit session. Note that this is different
56 from setting the file protection.
58 +**Transient [EXPERIMENTAL]**
59 + Flags the document as transient. This disables the warning NEdit usually
60 + gives when you try to close a file which is not saved.
62 + WARNING: This is an experimental feature. Make sure to use this setting
63 + only for documents which can easily be recreated.
65 3>Preferences -> Default Settings Menu
67 Options in the Preferences -> Default Settings menu have the same meaning as
68 those in the top-level Preferences menu, except that they apply to future
69 NEdit windows and future NEdit sessions if saved with the Save Defaults
70 diff --quilt old/source/file.h new/source/file.h
71 --- old/source/file.h
72 +++ new/source/file.h
73 @@ -40,11 +40,11 @@
74 #define PROMPT_SBC_DIALOG_RESPONSE 0
75 #define YES_SBC_DIALOG_RESPONSE 1
76 #define NO_SBC_DIALOG_RESPONSE 2
78 WindowInfo *EditNewFile(WindowInfo *inWindow, char *geometry, int iconic,
79 - const char *languageMode, const char *defaultPath);
80 + const char *languageMode, const char *defaultPath, Boolean transient);
81 WindowInfo *EditExistingFile(WindowInfo *inWindow, const char *name,
82 const char *path, int flags, char *geometry, int iconic,
83 const char *languageMode, int tabbed, int bgOpen);
84 void RevertToSaved(WindowInfo *window);
85 int SaveWindow(WindowInfo *window);
86 @@ -58,9 +58,9 @@ int IncludeFile(WindowInfo *window, cons
87 int PromptForExistingFile(WindowInfo *window, char *prompt, char *fullname);
88 int PromptForNewFile(WindowInfo *window, char *prompt, char *fullname,
89 int *fileFormat, int *addWrap);
90 int CheckReadOnly(WindowInfo *window);
91 void RemoveBackupFile(WindowInfo *window);
92 -void UniqueUntitledName(char *name);
93 +void UniqueUntitledName(char *name, Boolean transient);
94 void CheckForChangesToFile(WindowInfo *window);
96 #endif /* NEDIT_FILE_H_INCLUDED */
97 diff --quilt old/source/file.c new/source/file.c
98 --- old/source/file.c
99 +++ new/source/file.c
100 @@ -108,19 +108,19 @@ static void forceShowLineNumbers(WindowI
101 #ifdef VMS
102 void removeVersionNumber(char *fileName);
103 #endif /*VMS*/
105 WindowInfo *EditNewFile(WindowInfo *inWindow, char *geometry, int iconic,
106 - const char *languageMode, const char *defaultPath)
107 + const char *languageMode, const char *defaultPath, Boolean transient)
109 char name[MAXPATHLEN];
110 WindowInfo *window;
112 /*... test for creatability? */
114 /* Find a (relatively) unique name for the new file */
115 - UniqueUntitledName(name);
116 + UniqueUntitledName(name, transient);
118 /* create new window/document */
119 if (inWindow)
120 window = CreateDocument(inWindow, name);
121 else
122 @@ -145,10 +145,18 @@ WindowInfo *EditNewFile(WindowInfo *inWi
123 if (iconic && IsIconic(window))
124 RaiseDocument(window);
125 else
126 RaiseDocumentWindow(window);
128 + if (transient) {
129 + /* Set the window to transient mode. */
130 + String apParams[1];
132 + apParams[0] = "1";
133 + XtCallActionProc(window->lastFocus, "set_transient", NULL, apParams, 1);
136 SortTabBar(window);
137 return window;
141 @@ -708,21 +716,26 @@ int CloseFileAndWindow(WindowInfo *windo
143 /* Make sure that the window is not in iconified state */
144 if (window->fileChanged)
145 RaiseDocumentWindow(window);
147 - /* If the window is a normal & unmodified file or an empty new file,
148 - or if the user wants to ignore external modifications then
149 - just close it. Otherwise ask for confirmation first. */
150 - if (!window->fileChanged &&
151 + /* If the document is transient, belongs to a normal & unmodified file
152 + or is empty and unchanged, or if the user wants to ignore external
153 + modifications then just close it. Otherwise ask for confirmation
154 + first. */
155 + if (
157 + window->transient ||
158 + (!window->fileChanged &&
159 /* Normal File */
160 ((!window->fileMissing && window->lastModTime > 0) ||
161 /* New File*/
162 (window->fileMissing && window->lastModTime == 0) ||
163 /* File deleted/modified externally, ignored by user. */
164 - !GetPrefWarnFileMods()))
165 + !GetPrefWarnFileMods())))
167 + RemoveBackupFile(window);
168 CloseWindow(window);
169 /* up-to-date windows don't have outstanding backup files to close */
170 } else
172 if (preResponse == PROMPT_SBC_DIALOG_RESPONSE)
173 @@ -1060,10 +1073,20 @@ static int doSave(WindowInfo *window)
174 window->fileMissing = TRUE;
175 window->device = 0;
176 window->inode = 0;
179 + /* If the window was previously transient and the user saves it, than he
180 + obviously don't want the window to be transient anymore */
181 + if (window->transient) {
182 + /* Unset the window to transient mode. */
183 + String apParams[1];
185 + apParams[0] = "0";
186 + XtCallActionProc(window->lastFocus, "set_transient", NULL, apParams, 1);
189 /* call "post_save_hook" */
190 MacroApplyHook(window, "post_save_hook", 0, NULL, NULL);
192 return TRUE;
194 @@ -1158,14 +1181,10 @@ int WriteBackupFile(WindowInfo *window)
196 void RemoveBackupFile(WindowInfo *window)
198 char name[MAXPATHLEN];
200 - /* Don't delete backup files when backups aren't activated. */
201 - if (window->autoSave == FALSE)
202 - return;
204 backupFileName(window, name, sizeof(name));
205 remove(name);
209 @@ -1590,28 +1609,35 @@ int PromptForNewFile(WindowInfo *window,
213 ** Find a name for an untitled file, unique in the name space of in the opened
214 ** files in this session, i.e. Untitled or Untitled_nn, and write it into
215 -** the string "name".
216 +** the string "name" (at least MAXPATHLEN).
218 -void UniqueUntitledName(char *name)
219 +void UniqueUntitledName(char *name, Boolean transient)
221 WindowInfo *w;
222 int i;
223 + const char *base = transient ? "Transient" : "Untitled";
224 + char *tail;
225 + size_t baseLen = strlen(base);
226 + size_t totalSpace = MAXPATHLEN;
228 + snprintf(name, MAXPATHLEN, "%s", base);
229 + tail = name + baseLen;
230 + totalSpace -= baseLen;
232 + i = 0;
233 + do {
234 + for (w = WindowList; w != NULL; w = w->next)
235 + if (!strcmp(w->filename, name))
236 + break;
237 + if (w == NULL)
238 + break;
240 - for (i=0; i<INT_MAX; i++) {
241 - if (i == 0)
242 - sprintf(name, "Untitled");
243 - else
244 - sprintf(name, "Untitled_%d", i);
245 - for (w=WindowList; w!=NULL; w=w->next)
246 - if (!strcmp(w->filename, name))
247 - break;
248 - if (w == NULL)
249 - break;
251 + snprintf(tail, totalSpace, "_%d", ++i);
252 + } while (i < INT_MAX);
256 ** Callback that guards us from trying to access a window after it has
257 ** been destroyed while a modal dialog is up.
258 diff --quilt old/source/highlightData.c new/source/highlightData.c
259 --- old/source/highlightData.c
260 +++ new/source/highlightData.c
261 @@ -546,14 +546,14 @@ static char *DefaultPatternSets[] = {
262 Wrong logical ops:\"&&|\\|\\|\":::Plain::\n\
263 Logical operators:\"~|&|\\|\":::Text Arg2::}",
264 "NEdit Macro:2:0{\n\
265 README:\"NEdit Macro syntax highlighting patterns, version 2.6, maintainer Thorsten Haude, nedit at thorstenhau.de\":::Flag::D\n\
266 Comment:\"#\":\"$\"::Comment::\n\
267 - Built-in Misc Vars:\"(?<!\\Y)\\$(?:active_pane|args|calltip_ID|column|cursor|display_width|empty_array|file_name|file_path|language_mode|line|locked|max_font_width|min_font_width|modified|n_display_lines|n_panes|rangeset_list|read_only|selection_(?:start|end|left|right)|server_name|text_length|top_line|VERSION|NEDIT_HOME)>\":::Identifier::\n\
268 + Built-in Misc Vars:\"(?<!\\Y)\\$(?:active_pane|args|calltip_ID|column|cursor|display_width|empty_array|file_name|file_path|language_mode|line|locked|max_font_width|min_font_width|modified|n_display_lines|n_panes|rangeset_list|read_only|selection_(?:start|end|left|right)|server_name|text_length|top_line|transient|VERSION|NEDIT_HOME)>\":::Identifier::\n\
269 Built-in Pref Vars:\"(?<!\\Y)\\$(?:auto_indent|em_tab_dist|file_format|font_name|font_name_bold|font_name_bold_italic|font_name_italic|highlight_syntax|incremental_backup|incremental_search_line|make_backup_copy|match_syntax_based|overtype_mode|show_line_numbers|show_matching|statistics_line|tab_dist|use_tabs|wrap_margin|wrap_text)>\":::Identifier2::\n\
270 Built-in Special Vars:\"(?<!\\Y)\\$(?:[1-9]|list_dialog_button|n_args|read_status|search_end|shell_cmd_status|string_dialog_button|sub_sep)>\":::String1::\n\
271 - Built-in Subrs:\"<(?:append_file|beep|call|calltip|clipboard_to_string|dialog|filename_dialog|focus_window|get_character|get_pattern_(by_name|at_pos)|get_range|get_selection|get_style_(by_name|at_pos)|getenv|highlight_calltip_line|kill_calltip|length|list_dialog|max|min|rangeset_(?:add|create|destroy|get_by_name|includes|info|invert|range|set_color|set_mode|set_name|subtract)|read_file|replace_in_string|replace_range|replace_selection|replace_substring|search|search_string|select|select_rectangle|set_cursor_pos|shell_command|split|string_compare|string_dialog|string_to_clipboard|substring|t_print|tolower|toupper|valid_number|write_file)(?=\\s*\\()\":::Subroutine::\n\
272 + Built-in Subrs:\"<(?:append_file|beep|call|calltip|clipboard_to_string|dialog|filename_dialog|focus_window|get_character|get_pattern_(by_name|at_pos)|get_range|get_selection|get_style_(by_name|at_pos)|getenv|highlight_calltip_line|kill_calltip|length|list_dialog|max|min|rangeset_(?:add|create|destroy|get_by_name|includes|info|invert|range|set_color|set_mode|set_name|subtract)|read_file|replace_in_string|replace_range|replace_selection|replace_substring|search|search_string|select|select_rectangle|set_cursor_pos|set_transient|shell_command|split|string_compare|string_dialog|string_to_clipboard|substring|t_print|tolower|toupper|valid_number|write_file)(?=\\s*\\()\":::Subroutine::\n\
273 Menu Actions:\"<(?:new(?:_tab|_opposite)?|open|open-dialog|open_dialog|open-selected|open_selected|close|save|save-as|save_as|save-as-dialog|save_as_dialog|revert-to-saved|revert_to_saved|revert_to_saved_dialog|include-file|include_file|include-file-dialog|include_file_dialog|load-macro-file|load_macro_file|load-macro-file-dialog|load_macro_file_dialog|load-tags-file|load_tags_file|load-tags-file-dialog|load_tags_file_dialog|unload_tags_file|load_tips_file|load_tips_file_dialog|unload_tips_file|print|print-selection|print_selection|exit|undo|redo|delete|select-all|select_all|shift-left|shift_left|shift-left-by-tab|shift_left_by_tab|shift-right|shift_right|shift-right-by-tab|shift_right_by_tab|find|find-dialog|find_dialog|find-again|find_again|find-selection|find_selection|find_incremental|start_incremental_find|replace|replace-dialog|replace_dialog|replace-all|replace_all|replace-in-selection|replace_in_selection|replace-again|replace_again|replace_find|replace_find_same|replace_find_again|goto-line-number|goto_line_number|goto-line-number-dialog|goto_line_number_dialog|goto-selected|goto_selected|mark|mark-dialog|mark_dialog|goto-mark|goto_mark|goto-mark-dialog|goto_mark_dialog|match|select_to_matching|goto_matching|find-definition|find_definition|show_tip|split-pane|split_pane|close-pane|close_pane|detach_document(?:_dialog)?|move_document_dialog|(?:next|previous|last)_document|uppercase|lowercase|fill-paragraph|fill_paragraph|control-code-dialog|control_code_dialog|filter-selection-dialog|filter_selection_dialog|filter-selection|filter_selection|execute-command|execute_command|execute-command-dialog|execute_command_dialog|execute-command-line|execute_command_line|shell-menu-command|shell_menu_command|macro-menu-command|macro_menu_command|bg_menu_command|post_window_bg_menu|post_tab_context_menu|beginning-of-selection|beginning_of_selection|end-of-selection|end_of_selection|repeat_macro|repeat_dialog|raise_window|focus_pane|set_statistics_line|set_incremental_search_line|set_show_line_numbers|set_auto_indent|set_wrap_text|set_wrap_margin|set_highlight_syntax|set_make_backup_copy|set_incremental_backup|set_show_matching|set_match_syntax_based|set_overtype_mode|set_locked|set_tab_dist|set_em_tab_dist|set_use_tabs|set_fonts|set_language_mode)(?=\\s*\\()\":::Subroutine::\n\
274 Text Actions:\"<(?:self-insert|self_insert|grab-focus|grab_focus|extend-adjust|extend_adjust|extend-start|extend_start|extend-end|extend_end|secondary-adjust|secondary_adjust|secondary-or-drag-adjust|secondary_or_drag_adjust|secondary-start|secondary_start|secondary-or-drag-start|secondary_or_drag_start|process-bdrag|process_bdrag|move-destination|move_destination|move-to|move_to|move-to-or-end-drag|move_to_or_end_drag|end_drag|copy-to|copy_to|copy-to-or-end-drag|copy_to_or_end_drag|exchange|process-cancel|process_cancel|paste-clipboard|paste_clipboard|copy-clipboard|copy_clipboard|cut-clipboard|cut_clipboard|copy-primary|copy_primary|cut-primary|cut_primary|newline|newline-and-indent|newline_and_indent|newline-no-indent|newline_no_indent|delete-selection|delete_selection|delete-previous-character|delete_previous_character|delete-next-character|delete_next_character|delete-previous-word|delete_previous_word|delete-next-word|delete_next_word|delete-to-start-of-line|delete_to_start_of_line|delete-to-end-of-line|delete_to_end_of_line|forward-character|forward_character|backward-character|backward_character|key-select|key_select|process-up|process_up|process-down|process_down|process-shift-up|process_shift_up|process-shift-down|process_shift_down|process-home|process_home|forward-word|forward_word|backward-word|backward_word|forward-paragraph|forward_paragraph|backward-paragraph|backward_paragraph|beginning-of-line|beginning_of_line|end-of-line|end_of_line|beginning-of-file|beginning_of_file|end-of-file|end_of_file|next-page|next_page|previous-page|previous_page|page-left|page_left|page-right|page_right|toggle-overstrike|toggle_overstrike|scroll-up|scroll_up|scroll-down|scroll_down|scroll_left|scroll_right|scroll-to-line|scroll_to_line|select-all|select_all|deselect-all|deselect_all|focusIn|focusOut|process-return|process_return|process-tab|process_tab|insert-string|insert_string|mouse_pan)(?=\\s*\\()\":::Subroutine::\n\
275 Macro Hooks:\"<(?:(?:pre|post)_(?open|save)|cursor_moved|modified|(?:losing_)?focus)_hook(?=\\s*\\()\":::Subroutine1::\n\
276 Keyword:\"<(?:break|continue|define|delete|else|for|if|in|return|while)>\":::Keyword::\n\
277 Braces:\"[{}\\[\\]]\":::Keyword::\n\
278 diff --quilt old/source/windowTitle.c new/source/windowTitle.c
279 --- old/source/windowTitle.c
280 +++ new/source/windowTitle.c
281 @@ -99,10 +99,11 @@ static struct {
283 Widget oDirW;
284 Widget oCcViewTagW;
285 Widget oServerNameW;
286 Widget oFileChangedW;
287 + Widget oTransientW;
288 Widget oFileLockedW;
289 Widget oFileReadOnlyW;
290 Widget oServerEqualViewW;
292 char filename[MAXPATHLEN];
293 @@ -111,15 +112,16 @@ static struct {
294 char serverName[MAXPATHLEN];
295 int isServer;
296 int filenameSet;
297 int lockReasons;
298 int fileChanged;
299 + int transient;
301 int suppressFormatUpdate;
302 } etDialog = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
303 - NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
304 - NULL,NULL,"","","","",0,0,0,0,0};
305 + NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
306 + NULL,NULL,"","","","",0,0,0,0,0,0};
310 static char* removeSequence(char* sourcePtr, char c)
312 @@ -257,10 +259,11 @@ char *FormatWindowTitle(const char* file
313 const char* serverName,
314 int isServer,
315 int filenameSet,
316 int lockReasons,
317 int fileChanged,
318 + int transient,
319 const char* titleFormat)
321 static char title[WINDOWTITLE_MAX_LEN];
322 char *titlePtr = title;
323 char* titleEnd = title + WINDOWTITLE_MAX_LEN - 1;
324 @@ -359,18 +362,20 @@ char *FormatWindowTitle(const char* file
325 titlePtr = safeStrCpy(titlePtr, titleEnd, GetNameOfHost());
326 break;
328 case 'S': /* file status */
329 fileStatusPresent = True;
330 - if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged)
331 + if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged && !transient)
332 titlePtr = safeStrCpy(titlePtr, titleEnd, "read only, modified");
333 else if (IS_ANY_LOCKED_IGNORING_USER(lockReasons))
334 titlePtr = safeStrCpy(titlePtr, titleEnd, "read only");
335 - else if (IS_USER_LOCKED(lockReasons) && fileChanged)
336 + else if (IS_USER_LOCKED(lockReasons) && fileChanged && !transient)
337 titlePtr = safeStrCpy(titlePtr, titleEnd, "locked, modified");
338 else if (IS_USER_LOCKED(lockReasons))
339 titlePtr = safeStrCpy(titlePtr, titleEnd, "locked");
340 + else if (transient)
341 + titlePtr = safeStrCpy(titlePtr, titleEnd, "transient");
342 else if (fileChanged)
343 titlePtr = safeStrCpy(titlePtr, titleEnd, "modified");
344 break;
346 case 'u': /* user name */
347 @@ -386,18 +391,20 @@ char *FormatWindowTitle(const char* file
348 fileStatusPresent = True;
349 if (*titleFormat && *titleFormat == 'S')
351 ++titleFormat;
352 shortStatus = True;
353 - if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged)
354 + if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged && !transient)
355 titlePtr = safeStrCpy(titlePtr, titleEnd, "RO*");
356 else if (IS_ANY_LOCKED_IGNORING_USER(lockReasons))
357 titlePtr = safeStrCpy(titlePtr, titleEnd, "RO");
358 - else if (IS_USER_LOCKED(lockReasons) && fileChanged)
359 + else if (IS_USER_LOCKED(lockReasons) && fileChanged && !transient)
360 titlePtr = safeStrCpy(titlePtr, titleEnd, "LO*");
361 else if (IS_USER_LOCKED(lockReasons))
362 titlePtr = safeStrCpy(titlePtr, titleEnd, "LO");
363 + else if (transient)
364 + titlePtr = safeStrCpy(titlePtr, titleEnd, "TR");
365 else if (fileChanged)
366 titlePtr = safeStrCpy(titlePtr, titleEnd, "*");
367 break;
369 /* fall-through */
370 @@ -462,10 +469,11 @@ char *FormatWindowTitle(const char* file
374 /* Enable/disable test buttons, depending on presence of codes */
375 XtSetSensitive(etDialog.oFileChangedW, fileStatusPresent);
376 + XtSetSensitive(etDialog.oTransientW, fileStatusPresent);
377 XtSetSensitive(etDialog.oFileReadOnlyW, fileStatusPresent);
378 XtSetSensitive(etDialog.oFileLockedW, fileStatusPresent &&
379 !IS_PERM_LOCKED(etDialog.lockReasons));
381 XtSetSensitive(etDialog.oServerNameW, serverNamePresent);
382 @@ -491,10 +499,12 @@ static void setToggleButtons(void)
384 XmToggleButtonSetState(etDialog.oDirW,
385 etDialog.filenameSet == True, False);
386 XmToggleButtonSetState(etDialog.oFileChangedW,
387 etDialog.fileChanged == True, False);
388 + XmToggleButtonSetState(etDialog.oTransientW,
389 + etDialog.transient == True, False);
390 XmToggleButtonSetState(etDialog.oFileReadOnlyW,
391 IS_PERM_LOCKED(etDialog.lockReasons), False);
392 XmToggleButtonSetState(etDialog.oFileLockedW,
393 IS_USER_LOCKED(etDialog.lockReasons), False);
394 /* Read-only takes precedence on locked */
395 @@ -557,10 +567,11 @@ static void formatChangedCB(Widget w, Xt
396 serverName,
397 etDialog.isServer,
398 filenameSet,
399 etDialog.lockReasons,
400 XmToggleButtonGetState(etDialog.oFileChangedW),
401 + XmToggleButtonGetState(etDialog.oTransientW),
402 format);
403 XtFree(format);
404 XmTextFieldSetString(etDialog.previewW, title);
407 @@ -587,10 +598,16 @@ static void fileChangedCB(Widget w, XtPo
409 etDialog.fileChanged = XmToggleButtonGetState(w);
410 formatChangedCB(w, clientData, callData);
413 +static void transientCB(Widget w, XtPointer clientData, XtPointer callData)
415 + etDialog.transient = XmToggleButtonGetState(w);
416 + formatChangedCB(w, clientData, callData);
419 static void fileLockedCB(Widget w, XtPointer clientData, XtPointer callData)
421 SET_USER_LOCKED(etDialog.lockReasons, XmToggleButtonGetState(w));
422 formatChangedCB(w, clientData, callData);
424 @@ -1274,39 +1291,50 @@ static void createEditTitleDialog(Widget
425 XmNtopWidget, testLbl,
426 XmNlabelString, s1=XmStringCreateSimple("File modified"),
427 XmNmnemonic, 'o', NULL);
428 XtAddCallback(etDialog.oFileChangedW, XmNvalueChangedCallback, fileChangedCB, NULL);
429 XmStringFree(s1);
431 - etDialog.oFileReadOnlyW = XtVaCreateManagedWidget("fileReadOnly",
432 - xmToggleButtonWidgetClass, previewBox,
434 + etDialog.oTransientW = XtVaCreateManagedWidget("transient",
435 + xmToggleButtonWidgetClass, previewBox,
436 XmNleftAttachment, XmATTACH_WIDGET,
437 XmNleftWidget, etDialog.oFileChangedW,
438 XmNtopAttachment, XmATTACH_WIDGET,
439 XmNtopWidget, testLbl,
440 + XmNlabelString, s1=XmStringCreateSimple("File transient"),
441 + XmNmnemonic, 't', NULL);
442 + XtAddCallback(etDialog.oTransientW, XmNvalueChangedCallback, transientCB, NULL);
443 + XmStringFree(s1);
445 + etDialog.oFileReadOnlyW = XtVaCreateManagedWidget("fileReadOnly",
446 + xmToggleButtonWidgetClass, previewBox,
447 + XmNleftAttachment, XmATTACH_POSITION,
448 + XmNleftPosition, RADIO_INDENT,
449 + XmNtopAttachment, XmATTACH_WIDGET,
450 + XmNtopWidget, etDialog.oFileChangedW,
451 XmNlabelString, s1=XmStringCreateSimple("File read only"),
452 XmNmnemonic, 'n', NULL);
453 XtAddCallback(etDialog.oFileReadOnlyW, XmNvalueChangedCallback, fileReadOnlyCB, NULL);
454 XmStringFree(s1);
456 etDialog.oFileLockedW = XtVaCreateManagedWidget("fileLocked",
457 xmToggleButtonWidgetClass, previewBox,
458 XmNleftAttachment, XmATTACH_WIDGET,
459 XmNleftWidget, etDialog.oFileReadOnlyW,
460 XmNtopAttachment, XmATTACH_WIDGET,
461 - XmNtopWidget, testLbl,
462 + XmNtopWidget, etDialog.oFileChangedW,
463 XmNlabelString, s1=XmStringCreateSimple("File locked"),
464 XmNmnemonic, 'l', NULL);
465 XtAddCallback(etDialog.oFileLockedW, XmNvalueChangedCallback, fileLockedCB, NULL);
466 XmStringFree(s1);
468 etDialog.oServerNameW = XtVaCreateManagedWidget("servernameSet",
469 xmToggleButtonWidgetClass, previewBox,
470 XmNleftAttachment, XmATTACH_POSITION,
471 XmNleftPosition, RADIO_INDENT,
472 XmNtopAttachment, XmATTACH_WIDGET,
473 - XmNtopWidget, etDialog.oFileChangedW,
474 + XmNtopWidget, etDialog.oFileReadOnlyW,
475 XmNlabelString, s1=XmStringCreateSimple("Server name present"),
476 XmNmnemonic, 'v', NULL);
477 XtAddCallback(etDialog.oServerNameW, XmNvalueChangedCallback, serverNameCB, NULL);
478 XmStringFree(s1);
480 @@ -1455,10 +1483,11 @@ void EditCustomTitleFormat(WindowInfo *w
481 "servername");
482 etDialog.isServer = IsServer;
483 etDialog.filenameSet = window->filenameSet;
484 etDialog.lockReasons = window->lockReasons;
485 etDialog.fileChanged = window->fileChanged;
486 + etDialog.transient = window->transient;
488 if (etDialog.window != window && etDialog.form)
490 /* Destroy the dialog owned by the other window.
491 Note: don't rely on the destroy event handler to reset the
492 diff --quilt old/source/windowTitle.h new/source/windowTitle.h
493 --- old/source/windowTitle.h
494 +++ new/source/windowTitle.h
495 @@ -40,10 +40,11 @@ char *FormatWindowTitle(const char* file
496 const char* serverName,
497 int isServer,
498 int filenameSet,
499 int lockReasons,
500 int fileChanged,
501 + int transient,
502 const char* titleFormat);
504 void EditCustomTitleFormat(WindowInfo *window);
506 #endif /* NEDIT_WINDOWTITLE_H_INCLUDED */
507 diff --quilt old/source/macro.c new/source/macro.c
508 --- old/source/macro.c
509 +++ new/source/macro.c
510 @@ -365,10 +365,12 @@ static int rangesetListMV(WindowInfo *wi
511 int nArgs, DataValue *result, char **errMsg);
512 static int versionMV(WindowInfo* window, DataValue* argList, int nArgs,
513 DataValue* result, char** errMsg);
514 static int neditHomeMV(WindowInfo *window, DataValue *argList, int nArgs,
515 DataValue *result, char **errMsg);
516 +static int transientMV(WindowInfo *window, DataValue *argList, int nArgs,
517 + DataValue *result, char **errMsg);
518 static int rangesetCreateMS(WindowInfo *window, DataValue *argList, int nArgs,
519 DataValue *result, char **errMsg);
520 static int rangesetDestroyMS(WindowInfo *window, DataValue *argList, int nArgs,
521 DataValue *result, char **errMsg);
522 static int rangesetGetByNameMS(WindowInfo *window, DataValue *argList, int nArgs,
523 @@ -525,10 +527,11 @@ static const BuiltInSubrName SpecialVars
524 { "$backlight_string", backlightStringMV },
526 { "$rangeset_list", rangesetListMV },
527 { "$VERSION", versionMV },
528 { "$NEDIT_HOME", neditHomeMV },
529 + { "$transient", transientMV },
530 { NULL, NULL } /* sentinel */
533 /* Global symbols for "returning" secondary values from built-in functions */
534 static int STRING_DIALOG_BUTTON, SEARCH_END, READ_STATUS,
535 @@ -4845,10 +4848,21 @@ static int neditHomeMV(WindowInfo *windo
537 return True;
541 +** Returns the transient status of the current window
543 +static int transientMV(WindowInfo *window, DataValue *argList, int nArgs,
544 + DataValue *result, char **errMsg)
546 + result->tag = INT_TAG;
547 + result->val.n = !!window->transient;
548 + return True;
552 ** Built-in macro subroutine to create a new rangeset or rangesets.
553 ** If called with one argument: $1 is the number of rangesets required and
554 ** return value is an array indexed 0 to n, with the rangeset labels as values;
555 ** (or an empty array if the requested number of rangesets are not available).
556 ** If called with no arguments, returns a single rangeset label (not an array),
557 diff --quilt old/source/menu.c new/source/menu.c
558 --- old/source/menu.c
559 +++ new/source/menu.c
560 @@ -413,10 +413,12 @@ static void setMatchSyntaxBasedAP(Widget
561 Cardinal *nArgs);
562 static void setOvertypeModeAP(Widget w, XEvent *event, String *args,
563 Cardinal *nArgs);
564 static void setLockedAP(Widget w, XEvent *event, String *args,
565 Cardinal *nArgs);
566 +static void setTransientAP(Widget text, XEvent *event, String *args,
567 + Cardinal *nArgs);
568 static void setUseTabsAP(Widget w, XEvent *event, String *args,
569 Cardinal *nArgs);
570 static void setEmTabDistAP(Widget w, XEvent *event, String *args,
571 Cardinal *nArgs);
572 static void setTabDistAP(Widget w, XEvent *event, String *args,
573 @@ -583,10 +585,11 @@ static XtActionsRec Actions[] = {
574 {"set_incremental_backup", setIncrementalBackupAP},
575 {"set_show_matching", setShowMatchingAP},
576 {"set_match_syntax_based", setMatchSyntaxBasedAP},
577 {"set_overtype_mode", setOvertypeModeAP},
578 {"set_locked", setLockedAP},
579 + {"set_transient", setTransientAP},
580 {"set_tab_dist", setTabDistAP},
581 {"set_em_tab_dist", setEmTabDistAP},
582 {"set_use_tabs", setUseTabsAP},
583 {"set_fonts", setFontsAP},
584 {"set_language_mode", setLanguageModeAP}
585 @@ -768,10 +771,12 @@ Widget CreateMenuBar(Widget parent, Wind
586 createMenuSeparator(menuPane, "sep4", SHORT);
587 window->overtypeModeItem = createMenuToggle(menuPane, "overtype", "Overtype", 'O',
588 doActionCB, "set_overtype_mode", False, SHORT);
589 window->readOnlyItem = createMenuToggle(menuPane, "readOnly", "Read Only",
590 'y', doActionCB, "set_locked", IS_USER_LOCKED(window->lockReasons), FULL);
591 + window->transientItem = createMenuToggle(menuPane, "transient", "Transient",
592 + 'r', doActionCB, "set_transient", window->transient, FULL);
593 #endif
596 ** "Search" pull down menu.
598 @@ -1158,10 +1163,12 @@ Widget CreateMenuBar(Widget parent, Wind
599 createMenuSeparator(menuPane, "sep2", SHORT);
600 window->overtypeModeItem = createMenuToggle(menuPane, "overtype", "Overtype", 'O',
601 doActionCB, "set_overtype_mode", False, SHORT);
602 window->readOnlyItem = createMenuToggle(menuPane, "readOnly", "Read Only",
603 'y', doActionCB, "set_locked", IS_USER_LOCKED(window->lockReasons), FULL);
604 + window->transientItem = createMenuToggle(menuPane, "transient", "Transient",
605 + 'r', doActionCB, "set_transient", window->transient, FULL);
606 #endif
608 #ifndef VMS
610 ** Create the Shell menu
611 @@ -2780,10 +2787,11 @@ static void unloadTipsFileMenuCB(Widget
613 static void newAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
615 WindowInfo *window = WidgetToWindow(w);
616 int openInTab = GetPrefOpenInTab();
617 + Boolean transient = False;
619 if (*nArgs > 0) {
620 if (strcmp(args[0], "prefs") == 0) {
621 /* accept default */;
623 @@ -2794,16 +2802,25 @@ static void newAP(Widget w, XEvent *even
624 openInTab = 0;
626 else if (strcmp(args[0], "opposite") == 0) {
627 openInTab = !openInTab;
629 + else if (strcmp(args[0], "transient") == 0) {
630 + transient = True;
632 else {
633 fprintf(stderr, "nedit: Unknown argument to action procedure \"new\": %s\n", args[0]);
637 - EditNewFile(openInTab? window : NULL, NULL, False, NULL, window->path);
638 + /* Catch transient if it comes after a window type argument. */
639 + if (2 == *nArgs && strcmp(args[1], "transient") == 0) {
640 + transient = True;
643 + EditNewFile(openInTab? window : NULL, NULL, False, NULL, window->path,
644 + transient);
645 CheckCloseDim();
649 ** These are just here because our techniques make it hard to bind a menu item
650 @@ -2813,18 +2830,18 @@ static void newAP(Widget w, XEvent *even
651 static void newOppositeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
653 WindowInfo *window = WidgetToWindow(w);
655 EditNewFile(GetPrefOpenInTab()? NULL : window, NULL, False, NULL,
656 - window->path);
657 + window->path, False);
658 CheckCloseDim();
660 static void newTabAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
662 WindowInfo *window = WidgetToWindow(w);
664 - EditNewFile(window, NULL, False, NULL, window->path);
665 + EditNewFile(window, NULL, False, NULL, window->path, False);
666 CheckCloseDim();
669 static void openDialogAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
671 @@ -2956,11 +2973,11 @@ static void revertDialogAP(Widget w, XEv
673 WindowInfo *window = WidgetToWindow(w);
674 int b;
676 /* re-reading file is irreversible, prompt the user first */
677 - if (window->fileChanged)
678 + if (window->fileChanged && !window->transient)
680 b = DialogF(DF_QUES, window->shell, 2, "Discard Changes",
681 "Discard changes to\n%s%s?", "OK", "Cancel", window->path,
682 window->filename);
683 } else
684 @@ -3184,11 +3201,12 @@ static void exitAP(Widget w, XEvent *eve
685 user really wants to exit */
686 ptr = exitMsg;
687 lineLen = 0;
688 strcpy(ptr, "Editing: "); ptr += 9; lineLen += 9;
689 for (win=WindowList; win!=NULL; win=win->next) {
690 - sprintf(filename, "%s%s", win->filename, win->fileChanged? "*": "");
691 + sprintf(filename, "%s%s", win->filename,
692 + (win->fileChanged && !win->transient) ? "*": "");
693 title = filename;
694 titleLen = strlen(title);
695 if (ptr - exitMsg + titleLen + 30 >= DF_MAX_MSG_LENGTH) {
696 strcpy(ptr, "..."); ptr += 3;
697 break;
698 @@ -4312,10 +4330,31 @@ static void setLockedAP(Widget w, XEvent
699 XmToggleButtonSetState(window->readOnlyItem, IS_ANY_LOCKED(window->lockReasons), False);
700 UpdateWindowTitle(window);
701 UpdateWindowReadOnly(window);
705 +** Action procedure for setting or toggling the transient flag.
707 +static void setTransientAP(Widget text, XEvent *event, String *args,
708 + Cardinal *nArgs)
710 + WindowInfo *window = WidgetToWindow(text);
711 + Boolean newState;
713 + ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args,
714 + window->transient, "set_transient");
716 + window->transient = newState;
717 + if (IsTopDocument(window)) {
718 + XmToggleButtonSetState(window->transientItem, window->transient, False);
721 + UpdateWindowTitle(window);
722 + RefreshTabState(window);
725 static void setTabDistAP(Widget w, XEvent *event, String *args,
726 Cardinal *nArgs)
728 WindowInfo *window = WidgetToWindow(w);
730 @@ -4697,11 +4736,11 @@ void AddToPrevOpenMenu(const char *filen
731 static char* getWindowsMenuEntry(const WindowInfo* window)
733 static char fullTitle[MAXPATHLEN * 2 + 3+ 1];
735 sprintf(fullTitle, "%s%s", window->filename,
736 - window->fileChanged? "*" : "");
737 + (window->fileChanged && !window->transient) ? "*" : "");
739 if (GetPrefShowPathInWindowsMenu() && window->filenameSet)
741 strcat(fullTitle, " - ");
742 strcat(fullTitle, window->path);
743 diff --quilt old/source/nedit.h new/source/nedit.h
744 --- old/source/nedit.h
745 +++ new/source/nedit.h
746 @@ -330,10 +330,11 @@ typedef struct _WindowInfo {
747 Widget replaceMultiFileList;
748 Widget replaceMultiFilePathBtn;
749 Widget fontDialog; /* NULL, unless font dialog is up */
750 Widget colorDialog; /* NULL, unless color dialog is up */
751 Widget readOnlyItem; /* menu bar settable widgets... */
752 + Widget transientItem;
753 Widget autoSaveItem;
754 Widget saveLastItem;
755 Widget openSelItem;
756 Widget newOppositeItem;
757 Widget closeItem;
758 @@ -497,10 +498,11 @@ typedef struct _WindowInfo {
759 of selection related menu items */
760 Boolean filenameSet; /* is the window still "Untitled"? */
761 Boolean fileChanged; /* has window been modified? */
762 Boolean fileMissing; /* is the window's file gone? */
763 int lockReasons; /* all ways a file can be locked */
764 + Boolean transient; /* buffer is transient */
765 Boolean autoSave; /* is autosave turned on? */
766 Boolean saveOldVersion; /* keep old version in filename.bck */
767 char indentStyle; /* whether/how to auto indent */
768 char wrapMode; /* line wrap style: NO_WRAP,
769 NEWLINE_WRAP or CONTINUOUS_WRAP */
770 diff --quilt old/source/window.c new/source/window.c
771 --- old/source/window.c
772 +++ new/source/window.c
773 @@ -264,10 +264,11 @@ WindowInfo *CreateWindow(const char *nam
774 window->autoSaveCharCount = 0;
775 window->autoSaveOpCount = 0;
776 window->undoOpCount = 0;
777 window->undoMemUsed = 0;
778 CLEAR_ALL_LOCKS(window->lockReasons);
779 + window->transient = False;
780 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
781 window->autoSave = GetPrefAutoSave();
782 window->saveOldVersion = GetPrefSaveOldVersion();
783 window->wrapMode = GetPrefWrap(PLAIN_LANGUAGE_MODE);
784 window->showWrapMargin = GetPrefShowWrapMargin();
785 @@ -974,12 +975,13 @@ void CloseWindow(WindowInfo *window)
787 /* if this is the last window, or must be kept alive temporarily because
788 it's running the macro calling us, don't close it, make it Untitled */
789 if (keepWindow || (WindowList == window && window->next == NULL)) {
790 window->filename[0] = '\0';
791 - UniqueUntitledName(name);
792 + UniqueUntitledName(name, False);
793 CLEAR_ALL_LOCKS(window->lockReasons);
794 + window->transient = False;
795 window->fileMode = 0;
796 window->fileUid = 0;
797 window->fileGid = 0;
798 strcpy(window->filename, name);
799 strcpy(window->path, "");
800 @@ -2088,16 +2090,17 @@ void UpdateWindowTitle(const WindowInfo
801 GetPrefServerName(),
802 IsServer,
803 window->filenameSet,
804 window->lockReasons,
805 window->fileChanged,
806 + window->transient,
807 GetPrefTitleFormat());
809 iconTitle = XtMalloc(strlen(window->filename) + 2); /* strlen("*")+1 */
811 strcpy(iconTitle, window->filename);
812 - if (window->fileChanged)
813 + if (window->fileChanged && !window->transient)
814 strcat(iconTitle, "*");
815 XtVaSetValues(window->shell, XmNtitle, title, XmNiconName, iconTitle, NULL);
817 /* If there's a find or replace dialog up in "Keep Up" mode, with a
818 file name in the title, update it too */
819 @@ -2422,11 +2425,12 @@ static void modifiedCB(int pos, int nIns
820 SaveUndoInformation(window, pos, nInserted, nDeleted, deletedText);
822 /* Trigger automatic backup if operation or character limits reached */
823 if (window->autoSave &&
824 (window->autoSaveCharCount > AUTOSAVE_CHAR_LIMIT ||
825 - window->autoSaveOpCount > AUTOSAVE_OP_LIMIT)) {
826 + window->autoSaveOpCount > AUTOSAVE_OP_LIMIT)
827 + && !window->transient) {
828 WriteBackupFile(window);
829 window->autoSaveCharCount = 0;
830 window->autoSaveOpCount = 0;
833 @@ -3418,10 +3422,11 @@ WindowInfo* CreateDocument(WindowInfo* s
834 window->autoSaveCharCount = 0;
835 window->autoSaveOpCount = 0;
836 window->undoOpCount = 0;
837 window->undoMemUsed = 0;
838 CLEAR_ALL_LOCKS(window->lockReasons);
839 + window->transient = False;
840 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
841 window->autoSave = GetPrefAutoSave();
842 window->saveOldVersion = GetPrefSaveOldVersion();
843 window->wrapMode = GetPrefWrap(PLAIN_LANGUAGE_MODE);
844 window->showWrapMargin = GetPrefShowWrapMargin();
845 @@ -3707,22 +3712,23 @@ void RefreshTabState(WindowInfo *win)
847 XmString s1, tipString;
848 char labelString[MAXPATHLEN];
849 char *tag = XmFONTLIST_DEFAULT_TAG;
850 unsigned char alignment;
851 + const char *star = (win->fileChanged && !win->transient) ? "*" : "";
853 /* Set tab label to document's filename. Position of
854 "*" (modified) will change per label alignment setting */
855 XtVaGetValues(win->tab, XmNalignment, &alignment, NULL);
856 if (alignment != XmALIGNMENT_END) {
857 sprintf(labelString, "%s%s",
858 - win->fileChanged? "*" : "",
859 + star,
860 win->filename);
861 } else {
862 sprintf(labelString, "%s%s",
863 win->filename,
864 - win->fileChanged? "*" : "");
865 + star);
868 /* Make the top document stand out a little more */
869 if (IsTopDocument(win))
870 tag = "BOLD";
871 @@ -3858,10 +3864,11 @@ void RefreshMenuToggleStates(WindowInfo
872 #endif
873 XmToggleButtonSetState(window->autoSaveItem, window->autoSave, False);
874 XmToggleButtonSetState(window->overtypeModeItem, window->overstrike, False);
875 XmToggleButtonSetState(window->matchSyntaxBasedItem, window->matchSyntaxBased, False);
876 XmToggleButtonSetState(window->readOnlyItem, IS_USER_LOCKED(window->lockReasons), False);
877 + XmToggleButtonSetState(window->transientItem, window->transient, False);
879 XtSetSensitive(window->smartIndentItem,
880 SmartIndentMacrosAvailable(LanguageModeName(window->languageMode)));
882 SetAutoIndent(window, window->indentStyle);
883 @@ -4426,10 +4433,11 @@ static void cloneDocument(WindowInfo *wi
884 window->fileFormat = orgWin->fileFormat;
885 window->lastModTime = orgWin->lastModTime;
886 window->fileChanged = orgWin->fileChanged;
887 window->fileMissing = orgWin->fileMissing;
888 window->lockReasons = orgWin->lockReasons;
889 + window->transient = orgWin->transient;
890 window->autoSaveCharCount = orgWin->autoSaveCharCount;
891 window->autoSaveOpCount = orgWin->autoSaveOpCount;
892 window->undoOpCount = orgWin->undoOpCount;
893 window->undoMemUsed = orgWin->undoMemUsed;
894 window->lockReasons = orgWin->lockReasons;
895 diff --quilt old/source/nedit.c new/source/nedit.c
896 --- old/source/nedit.c
897 +++ new/source/nedit.c
898 @@ -565,11 +565,11 @@ int main(int argc, char **argv)
900 if (strcmp(GetPrefServerName(), "") != 0) {
901 IsServer = True;
904 - EditNewFile(NULL, geometry, iconic, langMode, NULL);
905 + EditNewFile(NULL, geometry, iconic, langMode, NULL, False);
906 ReadMacroInitFile(WindowList);
907 CheckCloseDim();
909 /* Process any command line arguments (-tags, -do, -read, -create,
910 +<line_number>, -line, -server, and files to edit) not already