Making ^O work the same way as under Pico when option -t is given:
writing out the file immediately, without prompting. Patch by David Lawrence Ramsey. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5378 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
d0b72552bf
Коммит
0d9397e5b0
@ -1,3 +1,9 @@
|
||||
2015-10-29 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* src/files.c (do_writeout), src/nano.c (no_current_file_name_warning,
|
||||
do_exit): When option -t is given, make ^O work the same way as under
|
||||
Pico, writing out the file without prompting. And make it work even
|
||||
better than Pico when the current file doesn't yet have a name.
|
||||
|
||||
2015-10-28 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_redo): For an INSERT, 'u->mark_begin_lineno' is not
|
||||
an actual line number, so spoof it. It can be spoofed, because 'f'
|
||||
|
10
src/files.c
10
src/files.c
@ -2225,7 +2225,7 @@ bool do_writeout(bool exiting)
|
||||
#endif
|
||||
bool retval = FALSE;
|
||||
|
||||
if (exiting && openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
|
||||
if (openfile->filename[0] != '\0' && ISSET(TEMP_FILE)) {
|
||||
retval = write_file(openfile->filename, NULL, FALSE, OVERWRITE,
|
||||
FALSE);
|
||||
|
||||
@ -2264,6 +2264,14 @@ bool do_writeout(bool exiting)
|
||||
(append == APPEND) ? _("File Name to Append to") :
|
||||
_("File Name to Write");
|
||||
|
||||
/* If we're not exiting, and the TEMP_FILE flag is set, and
|
||||
* the current file doesn't have a name, warn the user before
|
||||
* prompting for a name. If we are exiting, we've already
|
||||
* warned the user just before the "Save modified buffer"
|
||||
* prompt, so we don't need to do it again. */
|
||||
if (!exiting && openfile->filename[0] == '\0' && ISSET(TEMP_FILE))
|
||||
no_current_file_name_warning();
|
||||
|
||||
/* If we're using restricted mode, the filename isn't blank,
|
||||
* and we're at the "Write File" prompt, disable tab
|
||||
* completion. */
|
||||
|
35
src/nano.c
35
src/nano.c
@ -1088,6 +1088,24 @@ int no_help(void)
|
||||
return ISSET(NO_HELP) ? 2 : 0;
|
||||
}
|
||||
|
||||
/* Indicate that the current file has no name, in a way that gets the
|
||||
* user's attention. This is used when trying to save a file with no
|
||||
* name with the TEMP_FILE flag set, just before the filename prompt. */
|
||||
void no_current_file_name_warning(void)
|
||||
{
|
||||
curs_set(0);
|
||||
|
||||
/* Warn that the current file has no name. */
|
||||
statusbar(_("No file name"));
|
||||
beep();
|
||||
|
||||
/* Ensure that we see the warning. */
|
||||
doupdate();
|
||||
napms(1800);
|
||||
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
/* If the current file buffer has been modified, and the TEMP_FILE flag
|
||||
* isn't set, ask whether or not to save the file buffer. If the
|
||||
* TEMP_FILE flag is set and the current file has a name, save it
|
||||
@ -1109,20 +1127,9 @@ void do_exit(void)
|
||||
/* Otherwise, ask the user whether or not to save. */
|
||||
else {
|
||||
/* If the TEMP_FILE flag is set, and the current file doesn't
|
||||
* have a name, handle it the same way Pico does. */
|
||||
if (ISSET(TEMP_FILE)) {
|
||||
curs_set(0);
|
||||
|
||||
/* Warn that the current file has no name. */
|
||||
statusbar(_("No file name"));
|
||||
beep();
|
||||
|
||||
/* Ensure that we see the warning. */
|
||||
doupdate();
|
||||
napms(2000);
|
||||
|
||||
curs_set(1);
|
||||
}
|
||||
* have a name, warn the user before prompting for a name. */
|
||||
if (ISSET(TEMP_FILE))
|
||||
no_current_file_name_warning();
|
||||
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
|
||||
|
@ -475,6 +475,7 @@ void usage(void);
|
||||
void version(void);
|
||||
int more_space(void);
|
||||
int no_help(void);
|
||||
void no_current_file_name_warning(void);
|
||||
void do_exit(void);
|
||||
void signal_init(void);
|
||||
RETSIGTYPE handle_hupterm(int signal);
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user