remote nc
[nedit-bw.git] / transient-documents.patch
blob84013433417bb94013206f02d9dca8b3c75bc58e
1 From: Thorsten Haude <yoo@vranx.de>
2 Subject: transient documents
4 Transient documents ignore the modified flag.
6 ---
8 doc/help.etx | 18 ++++++++++-
9 source/built-ins.h | 1
10 source/file.c | 77 +++++++++++++++++++++++++++++++++----------------
11 source/file.h | 4 +-
12 source/highlightData.c | 4 +-
13 source/macro.c | 11 +++++++
14 source/menu.c | 51 ++++++++++++++++++++++++++++----
15 source/nedit.c | 2 -
16 source/nedit.h | 2 +
17 source/server.c | 5 +--
18 source/shell.c | 3 +
19 source/window.c | 18 ++++++++---
20 source/windowTitle.c | 51 +++++++++++++++++++++++++-------
21 source/windowTitle.h | 1
22 14 files changed, 192 insertions(+), 56 deletions(-)
24 diff --quilt old/doc/help.etx new/doc/help.etx
25 --- old/doc/help.etx
26 +++ new/doc/help.etx
27 @@ -3243,7 +3243,7 @@ Action Routines
28 Arguments are text strings enclosed in quotes. Below are the menu action
29 routines which take arguments. Optional arguments are enclosed in [].
31 - **new**( ["tab" | "window" | "prefs" | "opposite"] )
32 + **new**( ["tab" | "window" | "prefs" | "opposite"] [, "transient"] )
34 **close**( ["prompt" | "save" | "nosave"] )
36 @@ -3310,6 +3310,15 @@ Action Routines
37 preference
38 Default behaviour is "prefs".
40 + "transient" [EXPERIMENTAL]: Open the new
41 + document in transient mode. This disables the
42 + warning NEdit usually gives when you try to
43 + close a file which is not saved.
45 + WARNING: This is an experimental feature.
46 + Make sure to use this setting only for
47 + documents which can easily be recreated.
49 ~filename~ Path names are relative to the directory from
50 which NEdit was started. Shell interpreted
51 wildcards and `~' are not expanded.
52 @@ -3948,6 +3957,13 @@ Preferences
53 file from being modified in this NEdit session. Note that this is different
54 from setting the file protection.
56 +**Transient [EXPERIMENTAL]**
57 + Flags the document as transient. This disables the warning NEdit usually
58 + gives when you try to close a file which is not saved.
60 + WARNING: This is an experimental feature. Make sure to use this setting
61 + only for documents which can easily be recreated.
63 3>Preferences -> Default Settings Menu
65 Options in the Preferences -> Default Settings menu have the same meaning as
66 diff --quilt old/source/file.h new/source/file.h
67 --- old/source/file.h
68 +++ new/source/file.h
69 @@ -42,7 +42,7 @@
70 #define NO_SBC_DIALOG_RESPONSE 2
72 WindowInfo *EditNewFile(WindowInfo *inWindow, char *geometry, int iconic,
73 - const char *languageMode, const char *defaultPath);
74 + const char *languageMode, const char *defaultPath, Boolean transient);
75 WindowInfo *EditExistingFile(WindowInfo *inWindow, const char *name,
76 const char *path, int flags, char *geometry, int iconic,
77 const char *languageMode, int tabbed, int bgOpen);
78 @@ -60,7 +60,7 @@ int PromptForNewFile(WindowInfo *window,
79 int *fileFormat, int *addWrap);
80 int CheckReadOnly(WindowInfo *window);
81 void RemoveBackupFile(WindowInfo *window);
82 -void UniqueUntitledName(char *name);
83 +void UniqueUntitledName(char *name, Boolean transient);
84 void CheckForChangesToFile(WindowInfo *window);
86 #endif /* NEDIT_FILE_H_INCLUDED */
87 diff --quilt old/source/file.c new/source/file.c
88 --- old/source/file.c
89 +++ new/source/file.c
90 @@ -110,7 +110,7 @@ void removeVersionNumber(char *fileName)
91 #endif /*VMS*/
93 WindowInfo *EditNewFile(WindowInfo *inWindow, char *geometry, int iconic,
94 - const char *languageMode, const char *defaultPath)
95 + const char *languageMode, const char *defaultPath, Boolean transient)
97 char name[MAXPATHLEN];
98 WindowInfo *window;
99 @@ -120,7 +120,7 @@ WindowInfo *EditNewFile(WindowInfo *inWi
100 /*... test for creatability? */
102 /* Find a (relatively) unique name for the new file */
103 - UniqueUntitledName(name);
104 + UniqueUntitledName(name, transient);
106 /* create new window/document */
107 if (inWindow)
108 @@ -169,6 +169,14 @@ WindowInfo *EditNewFile(WindowInfo *inWi
109 else
110 RaiseDocumentWindow(window);
112 + if (transient) {
113 + /* Set the window to transient mode. */
114 + String apParams[1];
116 + apParams[0] = "1";
117 + XtCallActionProc(window->lastFocus, "set_transient", NULL, apParams, 1);
120 SortTabBar(window);
121 return window;
123 @@ -732,17 +740,22 @@ int CloseFileAndWindow(WindowInfo *windo
124 if (window->fileChanged)
125 RaiseDocumentWindow(window);
127 - /* If the window is a normal & unmodified file or an empty new file,
128 - or if the user wants to ignore external modifications then
129 - just close it. Otherwise ask for confirmation first. */
130 - if (!window->fileChanged &&
131 + /* If the document is transient, belongs to a normal & unmodified file
132 + or is empty and unchanged, or if the user wants to ignore external
133 + modifications then just close it. Otherwise ask for confirmation
134 + first. */
135 + if (
137 + window->transient ||
138 + (!window->fileChanged &&
139 /* Normal File */
140 ((!window->fileMissing && window->lastModTime > 0) ||
141 /* New File*/
142 (window->fileMissing && window->lastModTime == 0) ||
143 /* File deleted/modified externally, ignored by user. */
144 - !GetPrefWarnFileMods()))
145 + !GetPrefWarnFileMods())))
147 + RemoveBackupFile(window);
148 CloseWindow(window);
149 /* up-to-date windows don't have outstanding backup files to close */
150 } else
151 @@ -1101,6 +1114,16 @@ static int doSave(WindowInfo *window)
152 window->inode = 0;
155 + /* If the window was previously transient and the user saves it, than he
156 + obviously don't want the window to be transient anymore */
157 + if (window->transient) {
158 + /* Unset the window to transient mode. */
159 + String apParams[1];
161 + apParams[0] = "0";
162 + XtCallActionProc(window->lastFocus, "set_transient", NULL, apParams, 1);
165 /* call "post_save_hook" */
166 PostSaveHook(window);
168 @@ -1215,10 +1238,6 @@ void RemoveBackupFile(WindowInfo *window
170 char name[MAXPATHLEN];
172 - /* Don't delete backup files when backups aren't activated. */
173 - if (window->autoSave == FALSE)
174 - return;
176 backupFileName(window, name, sizeof(name));
177 remove(name);
179 @@ -1671,29 +1690,37 @@ int PromptForNewFile(WindowInfo *window,
181 ** Find a name for an untitled file, unique in the name space of in the opened
182 ** files in this session, i.e. Untitled or Untitled_nn, and write it into
183 -** the string "name".
184 +** the string "name" (at least MAXPATHLEN).
186 -void UniqueUntitledName(char *name)
187 +void UniqueUntitledName(char *name, Boolean transient)
189 WindowInfo *w;
190 int i;
192 - for (i=0; i<INT_MAX; i++) {
193 - if (i == 0)
194 - sprintf(name, "Untitled");
195 - else
196 - sprintf(name, "Untitled_%d", i);
197 - for (w=WindowList; w!=NULL; w=w->next) {
198 + const char *base = transient ? "Transient" : "Untitled";
199 + char *tail;
200 + size_t baseLen = strlen(base);
201 + size_t totalSpace = MAXPATHLEN;
203 + snprintf(name, MAXPATHLEN, "%s", base);
204 + tail = name + baseLen;
205 + totalSpace -= baseLen;
207 + i = 0;
208 + do {
209 + for (w = WindowList; w != NULL; w = w->next) {
210 if (&w->filename[0] == name) {
211 /* skip the window, for what we need a new name */
212 continue;
214 - if (!strcmp(w->filename, name))
215 - break;
216 + if (!strcmp(w->filename, name)) {
217 + break;
220 - if (w == NULL)
221 - break;
223 + if (w == NULL)
224 + break;
226 + snprintf(tail, totalSpace, "_%d", ++i);
227 + } while (i < INT_MAX);
231 diff --quilt old/source/highlightData.c new/source/highlightData.c
232 --- old/source/highlightData.c
233 +++ new/source/highlightData.c
234 @@ -548,10 +548,10 @@ static char *DefaultPatternSets[] = {
235 "NEdit Macro:2:0{\n\
236 README:\"NEdit Macro syntax highlighting patterns, version 2.6, maintainer Thorsten Haude, nedit at thorstenhau.de\":::Flag::D\n\
237 Comment:\"#\":\"$\"::Comment::\n\
238 - Built-in Misc Vars:\"(?<!\\Y)\\$(?:active_pane|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\
239 + Built-in Misc Vars:\"(?<!\\Y)\\$(?:active_pane|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\
240 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\
241 Built-in Special Vars:\"(?<!\\Y)\\$(?:args|[1-9]|list_dialog_button|n_args|read_status|search_end|shell_cmd_status|string_dialog_button|sub_sep)>\":::String1::\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|shell_command|split|string_compare|string_dialog|string_to_clipboard|substring|t_print|tolower|toupper|valid_number|write_file)(?=\\s*\\()\":::Subroutine::\n\
243 + 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\
244 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\
245 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\
246 Macro Hooks:\"<(?:(?:pre|post)_(?:open|save)|cursor_moved|modified|(?:losing_)?focus|language_mode)_hook(?=\\s*\\()\":::Subroutine1::\n\
247 diff --quilt old/source/windowTitle.c new/source/windowTitle.c
248 --- old/source/windowTitle.c
249 +++ new/source/windowTitle.c
250 @@ -101,6 +101,7 @@ static struct {
251 Widget oCcViewTagW;
252 Widget oServerNameW;
253 Widget oFileChangedW;
254 + Widget oTransientW;
255 Widget oFileLockedW;
256 Widget oFileReadOnlyW;
257 Widget oServerEqualViewW;
258 @@ -113,11 +114,12 @@ static struct {
259 int filenameSet;
260 int lockReasons;
261 int fileChanged;
262 + int transient;
264 int suppressFormatUpdate;
265 } etDialog = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
266 - NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
267 - NULL,NULL,"","","","",0,0,0,0,0};
268 + NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
269 + NULL,NULL,"","","","",0,0,0,0,0,0};
273 @@ -259,6 +261,7 @@ char *FormatWindowTitle(const char* file
274 int filenameSet,
275 int lockReasons,
276 int fileChanged,
277 + int transient,
278 const char* titleFormat)
280 static char title[WINDOWTITLE_MAX_LEN];
281 @@ -361,14 +364,16 @@ char *FormatWindowTitle(const char* file
283 case 'S': /* file status */
284 fileStatusPresent = True;
285 - if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged)
286 + if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged && !transient)
287 titlePtr = safeStrCpy(titlePtr, titleEnd, "read only, modified");
288 else if (IS_ANY_LOCKED_IGNORING_USER(lockReasons))
289 titlePtr = safeStrCpy(titlePtr, titleEnd, "read only");
290 - else if (IS_USER_LOCKED(lockReasons) && fileChanged)
291 + else if (IS_USER_LOCKED(lockReasons) && fileChanged && !transient)
292 titlePtr = safeStrCpy(titlePtr, titleEnd, "locked, modified");
293 else if (IS_USER_LOCKED(lockReasons))
294 titlePtr = safeStrCpy(titlePtr, titleEnd, "locked");
295 + else if (transient)
296 + titlePtr = safeStrCpy(titlePtr, titleEnd, "transient");
297 else if (fileChanged)
298 titlePtr = safeStrCpy(titlePtr, titleEnd, "modified");
299 break;
300 @@ -388,14 +393,16 @@ char *FormatWindowTitle(const char* file
302 ++titleFormat;
303 shortStatus = True;
304 - if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged)
305 + if (IS_ANY_LOCKED_IGNORING_USER(lockReasons) && fileChanged && !transient)
306 titlePtr = safeStrCpy(titlePtr, titleEnd, "RO*");
307 else if (IS_ANY_LOCKED_IGNORING_USER(lockReasons))
308 titlePtr = safeStrCpy(titlePtr, titleEnd, "RO");
309 - else if (IS_USER_LOCKED(lockReasons) && fileChanged)
310 + else if (IS_USER_LOCKED(lockReasons) && fileChanged && !transient)
311 titlePtr = safeStrCpy(titlePtr, titleEnd, "LO*");
312 else if (IS_USER_LOCKED(lockReasons))
313 titlePtr = safeStrCpy(titlePtr, titleEnd, "LO");
314 + else if (transient)
315 + titlePtr = safeStrCpy(titlePtr, titleEnd, "TR");
316 else if (fileChanged)
317 titlePtr = safeStrCpy(titlePtr, titleEnd, "*");
318 break;
319 @@ -464,6 +471,7 @@ char *FormatWindowTitle(const char* file
321 /* Enable/disable test buttons, depending on presence of codes */
322 XtSetSensitive(etDialog.oFileChangedW, fileStatusPresent);
323 + XtSetSensitive(etDialog.oTransientW, fileStatusPresent);
324 XtSetSensitive(etDialog.oFileReadOnlyW, fileStatusPresent);
325 XtSetSensitive(etDialog.oFileLockedW, fileStatusPresent &&
326 !IS_PERM_LOCKED(etDialog.lockReasons));
327 @@ -493,6 +501,8 @@ static void setToggleButtons(void)
328 etDialog.filenameSet == True, False);
329 XmToggleButtonSetState(etDialog.oFileChangedW,
330 etDialog.fileChanged == True, False);
331 + XmToggleButtonSetState(etDialog.oTransientW,
332 + etDialog.transient == True, False);
333 XmToggleButtonSetState(etDialog.oFileReadOnlyW,
334 IS_PERM_LOCKED(etDialog.lockReasons), False);
335 XmToggleButtonSetState(etDialog.oFileLockedW,
336 @@ -559,6 +569,7 @@ static void formatChangedCB(Widget w, Xt
337 filenameSet,
338 etDialog.lockReasons,
339 XmToggleButtonGetState(etDialog.oFileChangedW),
340 + XmToggleButtonGetState(etDialog.oTransientW),
341 format);
342 XtFree(format);
343 XmTextFieldSetString(etDialog.previewW, title);
344 @@ -589,6 +600,12 @@ static void fileChangedCB(Widget w, XtPo
345 formatChangedCB(w, clientData, callData);
348 +static void transientCB(Widget w, XtPointer clientData, XtPointer callData)
350 + etDialog.transient = XmToggleButtonGetState(w);
351 + formatChangedCB(w, clientData, callData);
354 static void fileLockedCB(Widget w, XtPointer clientData, XtPointer callData)
356 SET_USER_LOCKED(etDialog.lockReasons, XmToggleButtonGetState(w));
357 @@ -1276,13 +1293,24 @@ static void createEditTitleDialog(Widget
358 XmNmnemonic, 'o', NULL);
359 XtAddCallback(etDialog.oFileChangedW, XmNvalueChangedCallback, fileChangedCB, NULL);
360 XmStringFree(s1);
362 - etDialog.oFileReadOnlyW = XtVaCreateManagedWidget("fileReadOnly",
363 - xmToggleButtonWidgetClass, previewBox,
365 + etDialog.oTransientW = XtVaCreateManagedWidget("transient",
366 + xmToggleButtonWidgetClass, previewBox,
367 XmNleftAttachment, XmATTACH_WIDGET,
368 XmNleftWidget, etDialog.oFileChangedW,
369 XmNtopAttachment, XmATTACH_WIDGET,
370 XmNtopWidget, testLbl,
371 + XmNlabelString, s1=XmStringCreateSimple("File transient"),
372 + XmNmnemonic, 't', NULL);
373 + XtAddCallback(etDialog.oTransientW, XmNvalueChangedCallback, transientCB, NULL);
374 + XmStringFree(s1);
376 + etDialog.oFileReadOnlyW = XtVaCreateManagedWidget("fileReadOnly",
377 + xmToggleButtonWidgetClass, previewBox,
378 + XmNleftAttachment, XmATTACH_POSITION,
379 + XmNleftPosition, RADIO_INDENT,
380 + XmNtopAttachment, XmATTACH_WIDGET,
381 + XmNtopWidget, etDialog.oFileChangedW,
382 XmNlabelString, s1=XmStringCreateSimple("File read only"),
383 XmNmnemonic, 'n', NULL);
384 XtAddCallback(etDialog.oFileReadOnlyW, XmNvalueChangedCallback, fileReadOnlyCB, NULL);
385 @@ -1293,7 +1321,7 @@ static void createEditTitleDialog(Widget
386 XmNleftAttachment, XmATTACH_WIDGET,
387 XmNleftWidget, etDialog.oFileReadOnlyW,
388 XmNtopAttachment, XmATTACH_WIDGET,
389 - XmNtopWidget, testLbl,
390 + XmNtopWidget, etDialog.oFileChangedW,
391 XmNlabelString, s1=XmStringCreateSimple("File locked"),
392 XmNmnemonic, 'l', NULL);
393 XtAddCallback(etDialog.oFileLockedW, XmNvalueChangedCallback, fileLockedCB, NULL);
394 @@ -1304,7 +1332,7 @@ static void createEditTitleDialog(Widget
395 XmNleftAttachment, XmATTACH_POSITION,
396 XmNleftPosition, RADIO_INDENT,
397 XmNtopAttachment, XmATTACH_WIDGET,
398 - XmNtopWidget, etDialog.oFileChangedW,
399 + XmNtopWidget, etDialog.oFileReadOnlyW,
400 XmNlabelString, s1=XmStringCreateSimple("Server name present"),
401 XmNmnemonic, 'v', NULL);
402 XtAddCallback(etDialog.oServerNameW, XmNvalueChangedCallback, serverNameCB, NULL);
403 @@ -1457,6 +1485,7 @@ void EditCustomTitleFormat(WindowInfo *w
404 etDialog.filenameSet = window->filenameSet;
405 etDialog.lockReasons = window->lockReasons;
406 etDialog.fileChanged = window->fileChanged;
407 + etDialog.transient = window->transient;
409 if (etDialog.window != window && etDialog.form)
411 diff --quilt old/source/windowTitle.h new/source/windowTitle.h
412 --- old/source/windowTitle.h
413 +++ new/source/windowTitle.h
414 @@ -42,6 +42,7 @@ char *FormatWindowTitle(const char* file
415 int filenameSet,
416 int lockReasons,
417 int fileChanged,
418 + int transient,
419 const char* titleFormat);
421 void EditCustomTitleFormat(WindowInfo *window);
422 diff --quilt old/source/macro.c new/source/macro.c
423 --- old/source/macro.c
424 +++ new/source/macro.c
425 @@ -4526,6 +4526,17 @@ static int neditHomeMV(WindowInfo *windo
429 +** Returns the transient status of the current window
431 +static int transientMV(WindowInfo *window, DataValue *argList, int nArgs,
432 + DataValue *result, char **errMsg)
434 + result->tag = INT_TAG;
435 + result->val.n = !!window->transient;
436 + return True;
440 ** Built-in macro subroutine to create a new rangeset or rangesets.
441 ** If called with one argument: $1 is the number of rangesets required and
442 ** return value is an array indexed 0 to n, with the rangeset labels as values;
443 diff --quilt old/source/menu.c new/source/menu.c
444 --- old/source/menu.c
445 +++ new/source/menu.c
446 @@ -416,6 +416,8 @@ static void setOvertypeModeAP(Widget w,
447 Cardinal *nArgs);
448 static void setLockedAP(Widget w, XEvent *event, String *args,
449 Cardinal *nArgs);
450 +static void setTransientAP(Widget text, XEvent *event, String *args,
451 + Cardinal *nArgs);
452 static void setUseTabsAP(Widget w, XEvent *event, String *args,
453 Cardinal *nArgs);
454 static void setEmTabDistAP(Widget w, XEvent *event, String *args,
455 @@ -586,6 +588,7 @@ static XtActionsRec Actions[] = {
456 {"set_match_syntax_based", setMatchSyntaxBasedAP},
457 {"set_overtype_mode", setOvertypeModeAP},
458 {"set_locked", setLockedAP},
459 + {"set_transient", setTransientAP},
460 {"set_tab_dist", setTabDistAP},
461 {"set_em_tab_dist", setEmTabDistAP},
462 {"set_use_tabs", setUseTabsAP},
463 @@ -771,6 +774,8 @@ Widget CreateMenuBar(Widget parent, Wind
464 doActionCB, "set_overtype_mode", False, SHORT);
465 window->readOnlyItem = createMenuToggle(menuPane, "readOnly", "Read Only",
466 'y', doActionCB, "set_locked", IS_USER_LOCKED(window->lockReasons), FULL);
467 + window->transientItem = createMenuToggle(menuPane, "transient", "Transient",
468 + 'r', doActionCB, "set_transient", window->transient, FULL);
469 #endif
472 @@ -1161,6 +1166,8 @@ Widget CreateMenuBar(Widget parent, Wind
473 doActionCB, "set_overtype_mode", False, SHORT);
474 window->readOnlyItem = createMenuToggle(menuPane, "readOnly", "Read Only",
475 'y', doActionCB, "set_locked", IS_USER_LOCKED(window->lockReasons), FULL);
476 + window->transientItem = createMenuToggle(menuPane, "transient", "Transient",
477 + 'r', doActionCB, "set_transient", window->transient, FULL);
478 #endif
480 #ifndef VMS
481 @@ -2783,6 +2790,7 @@ static void newAP(Widget w, XEvent *even
483 WindowInfo *window = WidgetToWindow(w);
484 int openInTab = GetPrefOpenInTab();
485 + Boolean transient = False;
487 if (*nArgs > 0) {
488 if (strcmp(args[0], "prefs") == 0) {
489 @@ -2797,12 +2805,21 @@ static void newAP(Widget w, XEvent *even
490 else if (strcmp(args[0], "opposite") == 0) {
491 openInTab = !openInTab;
493 + else if (strcmp(args[0], "transient") == 0) {
494 + transient = True;
496 else {
497 fprintf(stderr, "nedit: Unknown argument to action procedure \"new\": %s\n", args[0]);
501 - EditNewFile(openInTab? window : NULL, NULL, False, NULL, window->path);
502 + /* Catch transient if it comes after a window type argument. */
503 + if (2 == *nArgs && strcmp(args[1], "transient") == 0) {
504 + transient = True;
507 + EditNewFile(openInTab? window : NULL, NULL, False, NULL, window->path,
508 + transient);
509 CheckCloseDim();
512 @@ -2816,14 +2833,14 @@ static void newOppositeAP(Widget w, XEve
513 WindowInfo *window = WidgetToWindow(w);
515 EditNewFile(GetPrefOpenInTab()? NULL : window, NULL, False, NULL,
516 - window->path);
517 + window->path, False);
518 CheckCloseDim();
520 static void newTabAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
522 WindowInfo *window = WidgetToWindow(w);
524 - EditNewFile(window, NULL, False, NULL, window->path);
525 + EditNewFile(window, NULL, False, NULL, window->path, False);
526 CheckCloseDim();
529 @@ -2937,7 +2954,7 @@ static void revertDialogAP(Widget w, XEv
530 int b;
532 /* re-reading file is irreversible, prompt the user first */
533 - if (window->fileChanged)
534 + if (window->fileChanged && !window->transient)
536 b = DialogF(DF_QUES, window->shell, 2, "Discard Changes",
537 "Discard changes to\n%s%s?", "OK", "Cancel", window->path,
538 @@ -3165,7 +3182,8 @@ static void exitAP(Widget w, XEvent *eve
539 lineLen = 0;
540 strcpy(ptr, "Editing: "); ptr += 9; lineLen += 9;
541 for (win=WindowList; win!=NULL; win=win->next) {
542 - sprintf(filename, "%s%s", win->filename, win->fileChanged? "*": "");
543 + sprintf(filename, "%s%s", win->filename,
544 + (win->fileChanged && !win->transient) ? "*": "");
545 title = filename;
546 titleLen = strlen(title);
547 if (ptr - exitMsg + titleLen + 30 >= DF_MAX_MSG_LENGTH) {
548 @@ -4293,6 +4311,27 @@ static void setLockedAP(Widget w, XEvent
549 UpdateWindowReadOnly(window);
553 +** Action procedure for setting or toggling the transient flag.
555 +static void setTransientAP(Widget text, XEvent *event, String *args,
556 + Cardinal *nArgs)
558 + WindowInfo *window = WidgetToWindow(text);
559 + Boolean newState;
561 + ACTION_BOOL_PARAM_OR_TOGGLE(newState, *nArgs, args,
562 + window->transient, "set_transient");
564 + window->transient = newState;
565 + if (IsTopDocument(window)) {
566 + XmToggleButtonSetState(window->transientItem, window->transient, False);
569 + UpdateWindowTitle(window);
570 + RefreshTabState(window);
573 static void setTabDistAP(Widget w, XEvent *event, String *args,
574 Cardinal *nArgs)
576 @@ -4678,7 +4717,7 @@ static char* getWindowsMenuEntry(const W
577 static char fullTitle[MAXPATHLEN * 2 + 3+ 1];
579 sprintf(fullTitle, "%s%s", window->filename,
580 - window->fileChanged? "*" : "");
581 + (window->fileChanged && !window->transient) ? "*" : "");
583 if (GetPrefShowPathInWindowsMenu() && window->filenameSet)
585 diff --quilt old/source/nedit.h new/source/nedit.h
586 --- old/source/nedit.h
587 +++ new/source/nedit.h
588 @@ -332,6 +332,7 @@ typedef struct _WindowInfo {
589 Widget fontDialog; /* NULL, unless font dialog is up */
590 Widget colorDialog; /* NULL, unless color dialog is up */
591 Widget readOnlyItem; /* menu bar settable widgets... */
592 + Widget transientItem;
593 Widget autoSaveItem;
594 Widget saveLastItem;
595 Widget openSelItem;
596 @@ -499,6 +500,7 @@ typedef struct _WindowInfo {
597 Boolean fileChanged; /* has window been modified? */
598 Boolean fileMissing; /* is the window's file gone? */
599 int lockReasons; /* all ways a file can be locked */
600 + Boolean transient; /* buffer is transient */
601 Boolean autoSave; /* is autosave turned on? */
602 Boolean saveOldVersion; /* keep old version in filename.bck */
603 char indentStyle; /* whether/how to auto indent */
604 diff --quilt old/source/window.c new/source/window.c
605 --- old/source/window.c
606 +++ new/source/window.c
607 @@ -269,6 +269,7 @@ WindowInfo *CreateWindow(const char *nam
608 window->undoOpCount = 0;
609 window->undoMemUsed = 0;
610 CLEAR_ALL_LOCKS(window->lockReasons);
611 + window->transient = False;
612 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
613 window->autoSave = GetPrefAutoSave();
614 window->saveOldVersion = GetPrefSaveOldVersion();
615 @@ -996,8 +997,9 @@ void CloseWindow(WindowInfo *window)
616 it's running the macro calling us, don't close it, make it Untitled */
617 if (keepWindow || (WindowList == window && window->next == NULL)) {
618 /* keep the path from the old window */
619 - UniqueUntitledName(window->filename);
620 + UniqueUntitledName(window->filename, False);
621 CLEAR_ALL_LOCKS(window->lockReasons);
622 + window->transient = False;
623 window->fileMode = 0;
624 window->fileUid = 0;
625 window->fileGid = 0;
626 @@ -2108,12 +2110,13 @@ void UpdateWindowTitle(const WindowInfo
627 window->filenameSet,
628 window->lockReasons,
629 window->fileChanged,
630 + window->transient,
631 GetPrefTitleFormat());
633 iconTitle = XtMalloc(strlen(window->filename) + 2); /* strlen("*")+1 */
635 strcpy(iconTitle, window->filename);
636 - if (window->fileChanged)
637 + if (window->fileChanged && !window->transient)
638 strcat(iconTitle, "*");
639 XtVaSetValues(window->shell, XmNtitle, title, XmNiconName, iconTitle, NULL);
641 @@ -2440,7 +2443,8 @@ static void modifiedCB(int pos, int nIns
642 /* Trigger automatic backup if operation or character limits reached */
643 if (window->autoSave &&
644 (window->autoSaveCharCount > AUTOSAVE_CHAR_LIMIT ||
645 - window->autoSaveOpCount > AUTOSAVE_OP_LIMIT)) {
646 + window->autoSaveOpCount > AUTOSAVE_OP_LIMIT)
647 + && !window->transient) {
648 WriteBackupFile(window);
649 window->autoSaveCharCount = 0;
650 window->autoSaveOpCount = 0;
651 @@ -3430,6 +3434,7 @@ WindowInfo* CreateDocument(WindowInfo* s
652 window->undoOpCount = 0;
653 window->undoMemUsed = 0;
654 CLEAR_ALL_LOCKS(window->lockReasons);
655 + window->transient = False;
656 window->indentStyle = GetPrefAutoIndent(PLAIN_LANGUAGE_MODE);
657 window->autoSave = GetPrefAutoSave();
658 window->saveOldVersion = GetPrefSaveOldVersion();
659 @@ -3719,18 +3724,19 @@ void RefreshTabState(WindowInfo *win)
660 char labelString[MAXPATHLEN];
661 char *tag = XmFONTLIST_DEFAULT_TAG;
662 unsigned char alignment;
663 + const char *star = (win->fileChanged && !win->transient) ? "*" : "";
665 /* Set tab label to document's filename. Position of
666 "*" (modified) will change per label alignment setting */
667 XtVaGetValues(win->tab, XmNalignment, &alignment, NULL);
668 if (alignment != XmALIGNMENT_END) {
669 sprintf(labelString, "%s%s",
670 - win->fileChanged? "*" : "",
671 + star,
672 win->filename);
673 } else {
674 sprintf(labelString, "%s%s",
675 win->filename,
676 - win->fileChanged? "*" : "");
677 + star);
680 /* Make the top document stand out a little more */
681 @@ -3870,6 +3876,7 @@ void RefreshMenuToggleStates(WindowInfo
682 XmToggleButtonSetState(window->overtypeModeItem, window->overstrike, False);
683 XmToggleButtonSetState(window->matchSyntaxBasedItem, window->matchSyntaxBased, False);
684 XmToggleButtonSetState(window->readOnlyItem, IS_USER_LOCKED(window->lockReasons), False);
685 + XmToggleButtonSetState(window->transientItem, window->transient, False);
687 XtSetSensitive(window->smartIndentItem,
688 SmartIndentMacrosAvailable(LanguageModeName(window->languageMode)));
689 @@ -4438,6 +4445,7 @@ static void cloneDocument(WindowInfo *wi
690 window->fileChanged = orgWin->fileChanged;
691 window->fileMissing = orgWin->fileMissing;
692 window->lockReasons = orgWin->lockReasons;
693 + window->transient = orgWin->transient;
694 window->autoSaveCharCount = orgWin->autoSaveCharCount;
695 window->autoSaveOpCount = orgWin->autoSaveOpCount;
696 window->undoOpCount = orgWin->undoOpCount;
697 diff --quilt old/source/nedit.c new/source/nedit.c
698 --- old/source/nedit.c
699 +++ new/source/nedit.c
700 @@ -578,7 +578,7 @@ int main(int argc, char **argv)
701 IsServer = True;
704 - EditNewFile(NULL, geometry, iconic, langMode, NULL);
705 + EditNewFile(NULL, geometry, iconic, langMode, NULL, False);
706 ReadMacroInitFile(WindowList);
707 CheckCloseDim();
709 diff --quilt old/source/server.c new/source/server.c
710 --- old/source/server.c
711 +++ new/source/server.c
712 @@ -348,7 +348,7 @@ static void processServerCommandString(c
713 break;
714 if (window == NULL) {
715 EditNewFile(findWindowOnDesktop(tabbed, currentDesktop), NULL,
716 - False, NULL, NULL);
717 + False, NULL, NULL, False);
718 CheckCloseDim();
720 else {
721 @@ -414,7 +414,8 @@ static void processServerCommandString(c
722 if (*doCommand == '\0') {
723 if (window == NULL) {
724 EditNewFile(findWindowOnDesktop(tabbed, currentDesktop),
725 - NULL, iconicFlag, lmLen==0?NULL:langMode, NULL);
726 + NULL, iconicFlag, lmLen==0?NULL:langMode, NULL,
727 + False);
728 } else {
729 if (iconicFlag)
730 RaiseDocument(window);
731 diff --quilt old/source/shell.c new/source/shell.c
732 --- old/source/shell.c
733 +++ new/source/shell.c
734 @@ -389,7 +389,8 @@ void DoShellMenuCmd(WindowInfo *window,
735 flags |= OUTPUT_TO_DIALOG;
736 left = right = 0;
737 } else if (output == TO_NEW_WINDOW) {
738 - EditNewFile(GetPrefOpenInTab()?inWindow:NULL, NULL, False, NULL, window->path);
739 + EditNewFile(GetPrefOpenInTab()?inWindow:NULL, NULL, False, NULL,
740 + window->path, False);
741 outWidget = WindowList->textArea;
742 inWindow = WindowList;
743 left = right = 0;
744 diff --quilt old/source/built-ins.h new/source/built-ins.h
745 --- old/source/built-ins.h
746 +++ new/source/built-ins.h
747 @@ -114,3 +114,4 @@ MV($backlight_string, backlightString)
748 MV(rangeset_list, rangesetList)
749 MV(VERSION, version)
750 MV(NEDIT_HOME, neditHome)
751 +MV(transient, transient)