nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 7ce1f6d86d799d282b998394e54db7becbed16f2
parent 88087f2b2f7dcf340a843ae306f8bc12df2376ad
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun,  2 Feb 2020 12:54:34 +0100

locking: when finding a lock file at startup, quit when user cancels

When at startup the user presses Cancel at the "open anyway?" prompt,
cancel the whole startup: quit.  But when the user answers No, just
skip the file and continue starting up.

Diffstat:
Msrc/files.c | 4++++
Msrc/global.c | 3+++
Msrc/nano.c | 2++
Msrc/proto.h | 1+
4 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -335,6 +335,10 @@ int do_lockfile(const char *filename, bool ask_the_user) choice = do_yesno_prompt(FALSE, promptstr); free(promptstr); + /* When the user cancelled while we're still starting up, quit. */ + if (choice < 0 && !we_are_running) + finish(); + if (choice < 1) { retval = -1; wipe_statusbar(); diff --git a/src/global.c b/src/global.c @@ -59,6 +59,9 @@ bool started_curses = FALSE; bool suppress_cursorpos = FALSE; /* Should we skip constant position display for current keystroke? */ +bool we_are_running = FALSE; + /* Will become TRUE as soon as all options and files have been read. */ + message_type lastmessage = HUSH; /* Messages of type HUSH should not overwrite type MILD nor ALERT. */ diff --git a/src/nano.c b/src/nano.c @@ -2573,6 +2573,8 @@ int main(int argc, char **argv) statusbar(_("Welcome to nano. For basic help, type Ctrl+G.")); #endif + we_are_running = TRUE; + while (TRUE) { #ifdef ENABLE_LINENUMBERS confirm_margin(); diff --git a/src/proto.h b/src/proto.h @@ -43,6 +43,7 @@ extern bool control_C_was_pressed; extern bool suppress_cursorpos; extern bool started_curses; +extern bool we_are_running; extern message_type lastmessage;