Mercurial > octave-nkf
diff scripts/miscellaneous/edit.m @ 17884:766ad9be2966
Prompt for non-existent new file when using edit.m from GUI (bug #40450)
* libgui/src/octave-qt-link.cc(do_prompt_new_edit_file): New function to
display question dialog.
* libgui/src/octave-qt-link.h(do_prompt_new_edit_file): Add function to header
file.
* libinterp/corefcn/octave-link.cc(__octave_link_edit_file__): If 2nd argument
present, display prompt dialog.
* libinterp/corefcn/octave-link.h(prompt_new_edit_file): If octave-link enabled,
use prompt dialog box.
* scripts/miscellaneous/edit.m: Modify to use new prompt routine. CLI behavior
is unchanged.
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 08 Nov 2013 07:40:36 -0800 |
parents | 674e5eb2c709 |
children | 22187db555cf |
line wrap: on
line diff
--- a/scripts/miscellaneous/edit.m Thu Nov 07 10:39:30 2013 -0500 +++ b/scripts/miscellaneous/edit.m Fri Nov 08 07:40:36 2013 -0800 @@ -353,14 +353,30 @@ endif endif - ## If editing a new file that is neither an m-file or an oct-file, + ## If editing a new file, prompt for creation if gui is running + if (isguirunning ()) + if (! __octave_link_edit_file__ (file,"prompt")); + return; + endif + endif + + ## If editing a new file that is neither an m-file nor an oct-file, ## just edit it. + ## If in gui-mode, create it before or editor would prompt again. fileandpath = file; idx = rindex (file, "."); name = file(1:idx-1); ext = file(idx+1:end); if (! any (strcmp (ext, {"cc", "m"}))) - ## Some unknown file. Just open it up. + ## Some unknown file. Create and open it or just open it. + if (isguirunning ()) + ## Write the initial file (if there is anything to write) + fid = fopen (fileandpath, "wt"); + if (fid < 0) + error ("edit: could not create %s", fileandpath); + endif + fclose (fid); + endif do_edit (FUNCTION.EDITOR, fileandpath, FUNCTION.MODE); return; endif