1 From: Thorsten Haude <yoo@vranx.de>
2 Subject: transient documents
4 Transient documents ignore the modified flag.
8 doc/help.etx | 18 ++++++++++-
9 source/file.c | 77 +++++++++++++++++++++++++++++++++----------------
11 source/highlightData.c | 4 +-
12 source/macro.c | 14 ++++++++
13 source/menu.c | 51 ++++++++++++++++++++++++++++----
16 source/server.c | 5 +--
18 source/window.c | 18 ++++++++---
19 source/windowTitle.c | 51 +++++++++++++++++++++++++-------
20 source/windowTitle.h | 1
21 13 files changed, 194 insertions(+), 56 deletions(-)
23 diff --quilt old/doc/help.etx new/doc/help.etx
26 @@ -3243,7 +3243,7 @@ Action Routines
27 Arguments are text strings enclosed in quotes. Below are the menu action
28 routines which take arguments. Optional arguments are enclosed in [].
30 - **new**( ["tab" | "window" | "prefs" | "opposite"] )
31 + **new**( ["tab" | "window" | "prefs" | "opposite"] [, "transient"] )
33 **close**( ["prompt" | "save" | "nosave"] )
35 @@ -3310,6 +3310,15 @@ Action Routines
37 Default behaviour is "prefs".
39 + "transient" [EXPERIMENTAL]: Open the new
40 + document in transient mode. This disables the
41 + warning NEdit usually gives when you try to
42 + close a file which is not saved.
44 + WARNING: This is an experimental feature.
45 + Make sure to use this setting only for
46 + documents which can easily be recreated.
48 ~filename~ Path names are relative to the directory from
49 which NEdit was started. Shell interpreted
50 wildcards and `~' are not expanded.
51 @@ -3944,6 +3953,13 @@ Preferences
52 file from being modified in this NEdit session. Note that this is different
53 from setting the file protection.
55 +**Transient [EXPERIMENTAL]**
56 + Flags the document as transient. This disables the warning NEdit usually
57 + gives when you try to close a file which is not saved.
59 + WARNING: This is an experimental feature. Make sure to use this setting
60 + only for documents which can easily be recreated.
62 3>Preferences -> Default Settings Menu
64 Options in the Preferences -> Default Settings menu have the same meaning as
65 diff --quilt old/source/file.h new/source/file.h
69 #define NO_SBC_DIALOG_RESPONSE 2
71 WindowInfo *EditNewFile(WindowInfo *inWindow, char *geometry, int iconic,
72 - const char *languageMode, const char *defaultPath);
73 + const char *languageMode, const char *defaultPath, Boolean transient);
74 WindowInfo *EditExistingFile(WindowInfo *inWindow, const char *name,
75 const char *path, int flags, char *geometry, int iconic,
76 const char *languageMode, int tabbed, int bgOpen);
77 @@ -60,7 +60,7 @@ int PromptForNewFile(WindowInfo *window,
78 int *fileFormat, int *addWrap);
79 int CheckReadOnly(WindowInfo *window);
80 void RemoveBackupFile(WindowInfo *window);
81 -void UniqueUntitledName(char *name);
82 +void UniqueUntitledName(char *name, Boolean transient);
83 void CheckForChangesToFile(WindowInfo *window);
85 #endif /* NEDIT_FILE_H_INCLUDED */
86 diff --quilt old/source/file.c new/source/file.c
89 @@ -110,7 +110,7 @@ void removeVersionNumber(char *fileName)
92 WindowInfo *EditNewFile(WindowInfo *inWindow, char *geometry, int iconic,
93 - const char *languageMode, const char *defaultPath)
94 + const char *languageMode, const char *defaultPath, Boolean transient)
96 char name[MAXPATHLEN];
98 @@ -120,7 +120,7 @@ WindowInfo *EditNewFile(WindowInfo *inWi
99 /*... test for creatability? */
101 /* Find a (relatively) unique name for the new file */
102 - UniqueUntitledName(name);
103 + UniqueUntitledName(name, transient);
105 /* create new window/document */
107 @@ -169,6 +169,14 @@ WindowInfo *EditNewFile(WindowInfo *inWi
109 RaiseDocumentWindow(window);
112 + /* Set the window to transient mode. */
113 + String apParams[1];
116 + XtCallActionProc(window->lastFocus, "set_transient", NULL, apParams, 1);
122 @@ -732,17 +740,22 @@ int CloseFileAndWindow(WindowInfo *windo
123 if (window->fileChanged)
124 RaiseDocumentWindow(window);
126 - /* If the window is a normal & unmodified file or an empty new file,
127 - or if the user wants to ignore external modifications then
128 - just close it. Otherwise ask for confirmation first. */
129 - if (!window->fileChanged &&
130 + /* If the document is transient, belongs to a normal & unmodified file
131 + or is empty and unchanged, or if the user wants to ignore external
132 + modifications then just close it. Otherwise ask for confirmation
136 + window->transient ||
137 + (!window->fileChanged &&
139 ((!window->fileMissing && window->lastModTime > 0) ||
141 (window->fileMissing && window->lastModTime == 0) ||
142 /* File deleted/modified externally, ignored by user. */
143 - !GetPrefWarnFileMods()))
144 + !GetPrefWarnFileMods())))
146 + RemoveBackupFile(window);
148 /* up-to-date windows don't have outstanding backup files to close */
150 @@ -1084,6 +1097,16 @@ static int doSave(WindowInfo *window)
154 + /* If the window was previously transient and the user saves it, than he
155 + obviously don't want the window to be transient anymore */
156 + if (window->transient) {
157 + /* Unset the window to transient mode. */
158 + String apParams[1];
161 + XtCallActionProc(window->lastFocus, "set_transient", NULL, apParams, 1);
164 /* call "post_save_hook" */
165 MacroApplyHook(window, "post_save_hook", 0, NULL, NULL);
167 @@ -1182,10 +1205,6 @@ void RemoveBackupFile(WindowInfo *window
169 char name[MAXPATHLEN];
171 - /* Don't delete backup files when backups aren't activated. */
172 - if (window->autoSave == FALSE)
175 backupFileName(window, name, sizeof(name));
178 @@ -1614,29 +1633,37 @@ int PromptForNewFile(WindowInfo *window,
180 ** Find a name for an untitled file, unique in the name space of in the opened
181 ** files in this session, i.e. Untitled or Untitled_nn, and write it into
182 -** the string "name".
183 +** the string "name" (at least MAXPATHLEN).
185 -void UniqueUntitledName(char *name)
186 +void UniqueUntitledName(char *name, Boolean transient)
191 - for (i=0; i<INT_MAX; i++) {
193 - sprintf(name, "Untitled");
195 - sprintf(name, "Untitled_%d", i);
196 - for (w=WindowList; w!=NULL; w=w->next) {
197 + const char *base = transient ? "Transient" : "Untitled";
199 + size_t baseLen = strlen(base);
200 + size_t totalSpace = MAXPATHLEN;
202 + snprintf(name, MAXPATHLEN, "%s", base);
203 + tail = name + baseLen;
204 + totalSpace -= baseLen;
208 + for (w = WindowList; w != NULL; w = w->next) {
209 if (&w->filename[0] == name) {
210 /* skip the window, for what we need a new name */
213 - if (!strcmp(w->filename, name))
215 + if (!strcmp(w->filename, name)) {
225 + snprintf(tail, totalSpace, "_%d", ++i);
226 + } while (i < INT_MAX);
230 diff --quilt old/source/highlightData.c new/source/highlightData.c
231 --- old/source/highlightData.c
232 +++ new/source/highlightData.c
233 @@ -548,10 +548,10 @@ static char *DefaultPatternSets[] = {
235 README:\"NEdit Macro syntax highlighting patterns, version 2.6, maintainer Thorsten Haude, nedit at thorstenhau.de\":::Flag::D\n\
236 Comment:\"#\":\"$\"::Comment::\n\
237 - 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\
238 + 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\
239 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\
240 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\
241 - Built-in Subrs:\"<(?:args|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|n_args|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\
242 + Built-in Subrs:\"<(?:args|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|n_args|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\
243 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\
244 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\
245 Macro Hooks:\"<(?:(?:pre|post)_(?:open|save)|cursor_moved|modified|(?:losing_)?focus)_hook(?=\\s*\\()\":::Subroutine1::\n\
246 diff --quilt old/source/windowTitle.c new/source/windowTitle.c
247 --- old/source/windowTitle.c
248 +++ new/source/windowTitle.c
249 @@ -101,6 +101,7 @@ static struct {
252 Widget oFileChangedW;
253 + Widget oTransientW;
255 Widget oFileReadOnlyW;
256 Widget oServerEqualViewW;
257 @@ -113,11 +114,12 @@ static struct {
263 int suppressFormatUpdate;
264 } etDialog = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
265 - NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
266 - NULL,NULL,"","","","",0,0,0,0,0};
267 + NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
268 + NULL,NULL,"","","","",0,0,0,0,0,0};
272 @@ -259,6 +261,7 @@ char *FormatWindowTitle(const char* file
277 const char* titleFormat)
279 static char title[WINDOWTITLE_MAX_LEN];
280 @@ -361,14 +364,16 @@ char *FormatWindowTitle(const char* file
282 case 'S': /* file status */
283 fileStatusPresent = True;
284 - if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged)
285 + if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged && !transient)
286 titlePtr = safeStrCpy(titlePtr, titleEnd, "read only, modified");
287 else if (IS_ANY_LOCKED_IGNORING_USER(lockReasons))
288 titlePtr = safeStrCpy(titlePtr, titleEnd, "read only");
289 - else if (IS_USER_LOCKED(lockReasons) && fileChanged)
290 + else if (IS_USER_LOCKED(lockReasons) && fileChanged && !transient)
291 titlePtr = safeStrCpy(titlePtr, titleEnd, "locked, modified");
292 else if (IS_USER_LOCKED(lockReasons))
293 titlePtr = safeStrCpy(titlePtr, titleEnd, "locked");
294 + else if (transient)
295 + titlePtr = safeStrCpy(titlePtr, titleEnd, "transient");
296 else if (fileChanged)
297 titlePtr = safeStrCpy(titlePtr, titleEnd, "modified");
299 @@ -388,14 +393,16 @@ char *FormatWindowTitle(const char* file
303 - if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged)
304 + if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged && !transient)
305 titlePtr = safeStrCpy(titlePtr, titleEnd, "RO*");
306 else if (IS_ANY_LOCKED_IGNORING_USER(lockReasons))
307 titlePtr = safeStrCpy(titlePtr, titleEnd, "RO");
308 - else if (IS_USER_LOCKED(lockReasons) && fileChanged)
309 + else if (IS_USER_LOCKED(lockReasons) && fileChanged && !transient)
310 titlePtr = safeStrCpy(titlePtr, titleEnd, "LO*");
311 else if (IS_USER_LOCKED(lockReasons))
312 titlePtr = safeStrCpy(titlePtr, titleEnd, "LO");
313 + else if (transient)
314 + titlePtr = safeStrCpy(titlePtr, titleEnd, "TR");
315 else if (fileChanged)
316 titlePtr = safeStrCpy(titlePtr, titleEnd, "*");
318 @@ -464,6 +471,7 @@ char *FormatWindowTitle(const char* file
320 /* Enable/disable test buttons, depending on presence of codes */
321 XtSetSensitive(etDialog.oFileChangedW, fileStatusPresent);
322 + XtSetSensitive(etDialog.oTransientW, fileStatusPresent);
323 XtSetSensitive(etDialog.oFileReadOnlyW, fileStatusPresent);
324 XtSetSensitive(etDialog.oFileLockedW, fileStatusPresent &&
325 !IS_PERM_LOCKED(etDialog.lockReasons));
326 @@ -493,6 +501,8 @@ static void setToggleButtons(void)
327 etDialog.filenameSet == True, False);
328 XmToggleButtonSetState(etDialog.oFileChangedW,
329 etDialog.fileChanged == True, False);
330 + XmToggleButtonSetState(etDialog.oTransientW,
331 + etDialog.transient == True, False);
332 XmToggleButtonSetState(etDialog.oFileReadOnlyW,
333 IS_PERM_LOCKED(etDialog.lockReasons), False);
334 XmToggleButtonSetState(etDialog.oFileLockedW,
335 @@ -559,6 +569,7 @@ static void formatChangedCB(Widget w, Xt
337 etDialog.lockReasons,
338 XmToggleButtonGetState(etDialog.oFileChangedW),
339 + XmToggleButtonGetState(etDialog.oTransientW),
342 XmTextFieldSetString(etDialog.previewW, title);
343 @@ -589,6 +600,12 @@ static void fileChangedCB(Widget w, XtPo
344 formatChangedCB(w, clientData, callData);
347 +static void transientCB(Widget w, XtPointer clientData, XtPointer callData)
349 + etDialog.transient = XmToggleButtonGetState(w);
350 + formatChangedCB(w, clientData, callData);
353 static void fileLockedCB(Widget w, XtPointer clientData, XtPointer callData)
355 SET_USER_LOCKED(etDialog.lockReasons, XmToggleButtonGetState(w));
356 @@ -1276,13 +1293,24 @@ static void createEditTitleDialog(Widget
357 XmNmnemonic, 'o', NULL);
358 XtAddCallback(etDialog.oFileChangedW, XmNvalueChangedCallback, fileChangedCB, NULL);
361 - etDialog.oFileReadOnlyW = XtVaCreateManagedWidget("fileReadOnly",
362 - xmToggleButtonWidgetClass, previewBox,
364 + etDialog.oTransientW = XtVaCreateManagedWidget("transient",
365 + xmToggleButtonWidgetClass, previewBox,
366 XmNleftAttachment, XmATTACH_WIDGET,
367 XmNleftWidget, etDialog.oFileChangedW,
368 XmNtopAttachment, XmATTACH_WIDGET,
369 XmNtopWidget, testLbl,
370 + XmNlabelString, s1=XmStringCreateSimple("File transient"),
371 + XmNmnemonic, 't', NULL);
372 + XtAddCallback(etDialog.oTransientW, XmNvalueChangedCallback, transientCB, NULL);
375 + etDialog.oFileReadOnlyW = XtVaCreateManagedWidget("fileReadOnly",
376 + xmToggleButtonWidgetClass, previewBox,
377 + XmNleftAttachment, XmATTACH_POSITION,
378 + XmNleftPosition, RADIO_INDENT,
379 + XmNtopAttachment, XmATTACH_WIDGET,
380 + XmNtopWidget, etDialog.oFileChangedW,
381 XmNlabelString, s1=XmStringCreateSimple("File read only"),
382 XmNmnemonic, 'n', NULL);
383 XtAddCallback(etDialog.oFileReadOnlyW, XmNvalueChangedCallback, fileReadOnlyCB, NULL);
384 @@ -1293,7 +1321,7 @@ static void createEditTitleDialog(Widget
385 XmNleftAttachment, XmATTACH_WIDGET,
386 XmNleftWidget, etDialog.oFileReadOnlyW,
387 XmNtopAttachment, XmATTACH_WIDGET,
388 - XmNtopWidget, testLbl,
389 + XmNtopWidget, etDialog.oFileChangedW,
390 XmNlabelString, s1=XmStringCreateSimple("File locked"),
391 XmNmnemonic, 'l', NULL);
392 XtAddCallback(etDialog.oFileLockedW, XmNvalueChangedCallback, fileLockedCB, NULL);
393 @@ -1304,7 +1332,7 @@ static void createEditTitleDialog(Widget
394 XmNleftAttachment, XmATTACH_POSITION,
395 XmNleftPosition, RADIO_INDENT,
396 XmNtopAttachment, XmATTACH_WIDGET,
397 - XmNtopWidget, etDialog.oFileChangedW,
398 + XmNtopWidget, etDialog.oFileReadOnlyW,
399 XmNlabelString, s1=XmStringCreateSimple("Server name present"),
400 XmNmnemonic, 'v', NULL);
401 XtAddCallback(etDialog.oServerNameW, XmNvalueChangedCallback, serverNameCB, NULL);
402 @@ -1457,6 +1485,7 @@ void EditCustomTitleFormat(WindowInfo *w
403 etDialog.filenameSet = window->filenameSet;
404 etDialog.lockReasons = window->lockReasons;
405 etDialog.fileChanged = window->fileChanged;
406 + etDialog.transient = window->transient;
408 if (etDialog.window != window && etDialog.form)
410 diff --quilt old/source/windowTitle.h new/source/windowTitle.h
411 --- old/source/windowTitle.h
412 +++ new/source/windowTitle.h
413 @@ -42,6 +42,7 @@ char *FormatWindowTitle(const char* file
418 const char* titleFormat);
420 void EditCustomTitleFormat(WindowInfo *window);
421 diff --quilt old/source/macro.c new/source/macro.c
422 --- old/source/macro.c
423 +++ new/source/macro.c
424 @@ -382,6 +382,8 @@ static int versionMV(WindowInfo* window,
425 DataValue* result, char** errMsg);
426 static int neditHomeMV(WindowInfo *window, DataValue *argList, int nArgs,
427 DataValue *result, char **errMsg);
428 +static int transientMV(WindowInfo *window, DataValue *argList, int nArgs,
429 + DataValue *result, char **errMsg);
430 static int rangesetCreateMS(WindowInfo *window, DataValue *argList, int nArgs,
431 DataValue *result, char **errMsg);
432 static int rangesetDestroyMS(WindowInfo *window, DataValue *argList, int nArgs,
433 @@ -544,6 +546,7 @@ static const BuiltInSubrName SpecialVars
434 { "$rangeset_list", rangesetListMV },
435 { "$VERSION", versionMV },
436 { "$NEDIT_HOME", neditHomeMV },
437 + { "$transient", transientMV },
438 { NULL, NULL } /* sentinel */
441 @@ -4843,6 +4846,17 @@ static int neditHomeMV(WindowInfo *windo
445 +** Returns the transient status of the current window
447 +static int transientMV(WindowInfo *window, DataValue *argList, int nArgs,
448 + DataValue *result, char **errMsg)
450 + result->tag = INT_TAG;
451 + result->val.n = !!window->transient;
456 ** Built-in macro subroutine to create a new rangeset or rangesets.
457 ** If called with one argument: $1 is the number of rangesets required and
458 ** return value is an array indexed 0 to n, with the rangeset labels as values;
459 diff --quilt old/source/menu.c new/source/menu.c
460 --- old/source/menu.c
461 +++ new/source/menu.c
462 @@ -415,6 +415,8 @@ static void setOvertypeModeAP(Widget w,
464 static void setLockedAP(Widget w, XEvent *event, String *args,
466 +static void setTransientAP(Widget text, XEvent *event, String *args,
468 static void setUseTabsAP(Widget w, XEvent *event, String *args,
470 static void setEmTabDistAP(Widget w, XEvent *event, String *args,
471 @@ -585,6 +587,7 @@ static XtActionsRec Actions[] = {
472 {"set_match_syntax_based", setMatchSyntaxBasedAP},
473 {"set_overtype_mode", setOvertypeModeAP},
474 {"set_locked", setLockedAP},
475 + {"set_transient", setTransientAP},
476 {"set_tab_dist", setTabDistAP},
477 {"set_em_tab_dist", setEmTabDistAP},
478 {"set_use_tabs", setUseTabsAP},
479 @@ -770,6 +773,8 @@ Widget CreateMenuBar(Widget parent, Wind
480 doActionCB, "set_overtype_mode", False, SHORT);
481 window->readOnlyItem = createMenuToggle(menuPane, "readOnly", "Read Only",
482 'y', doActionCB, "set_locked", IS_USER_LOCKED(window->lockReasons), FULL);
483 + window->transientItem = createMenuToggle(menuPane, "transient", "Transient",
484 + 'r', doActionCB, "set_transient", window->transient, FULL);
488 @@ -1160,6 +1165,8 @@ Widget CreateMenuBar(Widget parent, Wind
489 doActionCB, "set_overtype_mode", False, SHORT);
490 window->readOnlyItem = createMenuToggle(menuPane, "readOnly", "Read Only",
491 'y', doActionCB, "set_locked", IS_USER_LOCKED(window->lockReasons), FULL);
492 + window->transientItem = createMenuToggle(menuPane, "transient", "Transient",
493 + 'r', doActionCB, "set_transient", window->transient, FULL);
497 @@ -2782,6 +2789,7 @@ static void newAP(Widget w, XEvent *even
499 WindowInfo *window = WidgetToWindow(w);
500 int openInTab = GetPrefOpenInTab();
501 + Boolean transient = False;
504 if (strcmp(args[0], "prefs") == 0) {
505 @@ -2796,12 +2804,21 @@ static void newAP(Widget w, XEvent *even
506 else if (strcmp(args[0], "opposite") == 0) {
507 openInTab = !openInTab;
509 + else if (strcmp(args[0], "transient") == 0) {
513 fprintf(stderr, "nedit: Unknown argument to action procedure \"new\": %s\n", args[0]);
517 - EditNewFile(openInTab? window : NULL, NULL, False, NULL, window->path);
518 + /* Catch transient if it comes after a window type argument. */
519 + if (2 == *nArgs && strcmp(args[1], "transient") == 0) {
523 + EditNewFile(openInTab? window : NULL, NULL, False, NULL, window->path,
528 @@ -2815,14 +2832,14 @@ static void newOppositeAP(Widget w, XEve
529 WindowInfo *window = WidgetToWindow(w);
531 EditNewFile(GetPrefOpenInTab()? NULL : window, NULL, False, NULL,
533 + window->path, False);
536 static void newTabAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
538 WindowInfo *window = WidgetToWindow(w);
540 - EditNewFile(window, NULL, False, NULL, window->path);
541 + EditNewFile(window, NULL, False, NULL, window->path, False);
545 @@ -2958,7 +2975,7 @@ static void revertDialogAP(Widget w, XEv
548 /* re-reading file is irreversible, prompt the user first */
549 - if (window->fileChanged)
550 + if (window->fileChanged && !window->transient)
552 b = DialogF(DF_QUES, window->shell, 2, "Discard Changes",
553 "Discard changes to\n%s%s?", "OK", "Cancel", window->path,
554 @@ -3186,7 +3203,8 @@ static void exitAP(Widget w, XEvent *eve
556 strcpy(ptr, "Editing: "); ptr += 9; lineLen += 9;
557 for (win=WindowList; win!=NULL; win=win->next) {
558 - sprintf(filename, "%s%s", win->filename, win->fileChanged? "*": "");
559 + sprintf(filename, "%s%s", win->filename,
560 + (win->fileChanged && !win->transient) ? "*": "");
562 titleLen = strlen(title);
563 if (ptr - exitMsg + titleLen + 30 >= DF_MAX_MSG_LENGTH) {
564 @@ -4314,6 +4332,27 @@ static void setLockedAP(Widget w, XEvent
565 UpdateWindowReadOnly(window);
569 +** Action procedure for setting or toggling the transient flag.
571 +static void setTransientAP(Widget text, XEvent *event, String *args,
574 + WindowInfo *window = WidgetToWindow(text);
577 + ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args,
578 + window->transient, "set_transient");
580 + window->transient = newState;
581 + if (IsTopDocument(window)) {
582 + XmToggleButtonSetState(window->transientItem, window->transient, False);
585 + UpdateWindowTitle(window);
586 + RefreshTabState(window);
589 static void setTabDistAP(Widget w, XEvent *event, String *args,
592 @@ -4699,7 +4738,7 @@ static char* getWindowsMenuEntry(const W
593 static char fullTitle[MAXPATHLEN * 2 + 3+ 1];
595 sprintf(fullTitle, "%s%s", window->filename,
596 - window->fileChanged? "*" : "");
597 + (window->fileChanged && !window->transient) ? "*" : "");
599 if (GetPrefShowPathInWindowsMenu() && window->filenameSet)
601 diff --quilt old/source/nedit.h new/source/nedit.h
602 --- old/source/nedit.h
603 +++ new/source/nedit.h
604 @@ -332,6 +332,7 @@ typedef struct _WindowInfo {
605 Widget fontDialog; /* NULL, unless font dialog is up */
606 Widget colorDialog; /* NULL, unless color dialog is up */
607 Widget readOnlyItem; /* menu bar settable widgets... */
608 + Widget transientItem;
612 @@ -499,6 +500,7 @@ typedef struct _WindowInfo {
613 Boolean fileChanged; /* has window been modified? */
614 Boolean fileMissing; /* is the window's file gone? */
615 int lockReasons; /* all ways a file can be locked */
616 + Boolean transient; /* buffer is transient */
617 Boolean autoSave; /* is autosave turned on? */
618 Boolean saveOldVersion; /* keep old version in filename.bck */
619 char indentStyle; /* whether/how to auto indent */
620 diff --quilt old/source/window.c new/source/window.c
621 --- old/source/window.c
622 +++ new/source/window.c
623 @@ -269,6 +269,7 @@ WindowInfo *CreateWindow(const char *nam
624 window->undoOpCount = 0;
625 window->undoMemUsed = 0;
626 CLEAR_ALL_LOCKS(window->lockReasons);
627 + window->transient = False;
628 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
629 window->autoSave = GetPrefAutoSave();
630 window->saveOldVersion = GetPrefSaveOldVersion();
631 @@ -996,8 +997,9 @@ void CloseWindow(WindowInfo *window)
632 it's running the macro calling us, don't close it, make it Untitled */
633 if (keepWindow || (WindowList == window && window->next == NULL)) {
634 /* keep the path from the old window */
635 - UniqueUntitledName(window->filename);
636 + UniqueUntitledName(window->filename, False);
637 CLEAR_ALL_LOCKS(window->lockReasons);
638 + window->transient = False;
639 window->fileMode = 0;
642 @@ -2108,12 +2110,13 @@ void UpdateWindowTitle(const WindowInfo
647 GetPrefTitleFormat());
649 iconTitle = XtMalloc(strlen(window->filename) + 2); /* strlen("*")+1 */
651 strcpy(iconTitle, window->filename);
652 - if (window->fileChanged)
653 + if (window->fileChanged && !window->transient)
654 strcat(iconTitle, "*");
655 XtVaSetValues(window->shell, XmNtitle, title, XmNiconName, iconTitle, NULL);
657 @@ -2442,7 +2445,8 @@ static void modifiedCB(int pos, int nIns
658 /* Trigger automatic backup if operation or character limits reached */
659 if (window->autoSave &&
660 (window->autoSaveCharCount > AUTOSAVE_CHAR_LIMIT ||
661 - window->autoSaveOpCount > AUTOSAVE_OP_LIMIT)) {
662 + window->autoSaveOpCount > AUTOSAVE_OP_LIMIT)
663 + && !window->transient) {
664 WriteBackupFile(window);
665 window->autoSaveCharCount = 0;
666 window->autoSaveOpCount = 0;
667 @@ -3438,6 +3442,7 @@ WindowInfo* CreateDocument(WindowInfo* s
668 window->undoOpCount = 0;
669 window->undoMemUsed = 0;
670 CLEAR_ALL_LOCKS(window->lockReasons);
671 + window->transient = False;
672 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
673 window->autoSave = GetPrefAutoSave();
674 window->saveOldVersion = GetPrefSaveOldVersion();
675 @@ -3727,18 +3732,19 @@ void RefreshTabState(WindowInfo *win)
676 char labelString[MAXPATHLEN];
677 char *tag = XmFONTLIST_DEFAULT_TAG;
678 unsigned char alignment;
679 + const char *star = (win->fileChanged && !win->transient) ? "*" : "";
681 /* Set tab label to document's filename. Position of
682 "*" (modified) will change per label alignment setting */
683 XtVaGetValues(win->tab, XmNalignment, &alignment, NULL);
684 if (alignment != XmALIGNMENT_END) {
685 sprintf(labelString, "%s%s",
686 - win->fileChanged? "*" : "",
690 sprintf(labelString, "%s%s",
692 - win->fileChanged? "*" : "");
696 /* Make the top document stand out a little more */
697 @@ -3878,6 +3884,7 @@ void RefreshMenuToggleStates(WindowInfo
698 XmToggleButtonSetState(window->overtypeModeItem, window->overstrike, False);
699 XmToggleButtonSetState(window->matchSyntaxBasedItem, window->matchSyntaxBased, False);
700 XmToggleButtonSetState(window->readOnlyItem, IS_USER_LOCKED(window->lockReasons), False);
701 + XmToggleButtonSetState(window->transientItem, window->transient, False);
703 XtSetSensitive(window->smartIndentItem,
704 SmartIndentMacrosAvailable(LanguageModeName(window->languageMode)));
705 @@ -4446,6 +4453,7 @@ static void cloneDocument(WindowInfo *wi
706 window->fileChanged = orgWin->fileChanged;
707 window->fileMissing = orgWin->fileMissing;
708 window->lockReasons = orgWin->lockReasons;
709 + window->transient = orgWin->transient;
710 window->autoSaveCharCount = orgWin->autoSaveCharCount;
711 window->autoSaveOpCount = orgWin->autoSaveOpCount;
712 window->undoOpCount = orgWin->undoOpCount;
713 diff --quilt old/source/nedit.c new/source/nedit.c
714 --- old/source/nedit.c
715 +++ new/source/nedit.c
716 @@ -567,7 +567,7 @@ int main(int argc, char **argv)
720 - EditNewFile(NULL, geometry, iconic, langMode, NULL);
721 + EditNewFile(NULL, geometry, iconic, langMode, NULL, False);
722 ReadMacroInitFile(WindowList);
725 diff --quilt old/source/server.c new/source/server.c
726 --- old/source/server.c
727 +++ new/source/server.c
728 @@ -356,7 +356,7 @@ static void processServerCommandString(c
730 if (window == NULL) {
731 EditNewFile(findWindowOnDesktop(tabbed, currentDesktop), NULL,
732 - False, NULL, NULL);
733 + False, NULL, NULL, False);
737 @@ -420,7 +420,8 @@ static void processServerCommandString(c
738 if (*doCommand == '\0') {
739 if (window == NULL) {
740 EditNewFile(findWindowOnDesktop(tabbed, currentDesktop),
741 - NULL, iconicFlag, lmLen==0?NULL:langMode, NULL);
742 + NULL, iconicFlag, lmLen==0?NULL:langMode, NULL,
746 RaiseDocument(window);
747 diff --quilt old/source/shell.c new/source/shell.c
748 --- old/source/shell.c
749 +++ new/source/shell.c
750 @@ -389,7 +389,8 @@ void DoShellMenuCmd(WindowInfo *window,
751 flags |= OUTPUT_TO_DIALOG;
753 } else if (output == TO_NEW_WINDOW) {
754 - EditNewFile(GetPrefOpenInTab()?inWindow:NULL, NULL, False, NULL, window->path);
755 + EditNewFile(GetPrefOpenInTab()?inWindow:NULL, NULL, False, NULL,
756 + window->path, False);
757 outWidget = WindowList->textArea;
758 inWindow = WindowList;