From 11d76449d2a0da1b1da3f9f4559f7715ee494056 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 26 Apr 2014 19:01:18 +0000 Subject: [PATCH] Make help lines show "Close" again when more than one buffer is open. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4816 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/files.c | 6 +++++- src/global.c | 14 ++++++++------ src/proto.h | 3 +++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ec6f7a0..adbdd2f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * src/global.c (add_to_funcs): Add a pointer to the tail of the functions list, to simplify and speed up adding new items. And make use of it to remember the location of the Uncut item. + * src/global.c, src/files.c (make_new_buffer, close_buffer): Make + help lines show "Close" again when more than one buffer is open. 2014-04-24 Benno Schulenberg * doc/faq.html: Update a few URLs, delete some obsolete ones, update diff --git a/src/files.c b/src/files.c index 27799fa6..219641c4 100644 --- a/src/files.c +++ b/src/files.c @@ -47,6 +47,8 @@ void make_new_buffer(void) } else { splice_opennode(openfile, make_new_opennode(), openfile->next); openfile = openfile->next; + /* More than one file open, show Close in help lines. */ + exitfunc->desc = close_tag; } /* Initialize the new buffer. */ @@ -485,7 +487,9 @@ bool close_buffer(void) /* Close the file buffer we had open before. */ unlink_opennode(openfile->prev); - display_main_list(); + /* If only one buffer is open now, show Exit in the help lines. */ + if (openfile == openfile->next) + exitfunc->desc = exit_tag; return TRUE; } diff --git a/src/global.c b/src/global.c index 7e89b59b..2f66bb2f 100644 --- a/src/global.c +++ b/src/global.c @@ -172,6 +172,8 @@ subnfunc *allfuncs = NULL; /* Pointer to the start of the functions list. */ subnfunc *tailfunc; /* Pointer to the last function in the list. */ +subnfunc *exitfunc; + /* Pointer to the special Exit/Close item. */ subnfunc *uncutfunc; /* Pointer to the special Uncut/Unjustify item. */ @@ -460,7 +462,9 @@ void print_sclist(void) } #endif -/* TRANSLATORS: Try to keep the next two strings at most 10 characters. */ +/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */ +const char *exit_tag = N_("Exit"); +const char *close_tag = N_("Close"); const char *uncut_tag = N_("Uncut Text"); #ifndef DISABLE_JUSITIFY const char *unjust_tag = N_("Unjustify"); @@ -473,8 +477,7 @@ const char *whereis_next_tag = N_("WhereIs Next"); /* Initialize the list of functions and the list of shortcuts. */ void shortcut_init(void) { - /* TRANSLATORS: Try to keep the next seven strings at most 10 characters. */ - const char *exit_tag = N_("Exit"); + /* TRANSLATORS: Try to keep the next six strings at most 10 characters. */ const char *whereis_tag = N_("Where Is"); const char *prev_line_tag = N_("Prev Line"); const char *next_line_tag = N_("Next Line"); @@ -666,10 +669,9 @@ void shortcut_init(void) N_("Cancel"), IFSCHELP(nano_cancel_msg), FALSE, VIEW); add_to_funcs(do_exit, MMAIN, -#ifndef DISABLE_MULTIBUFFER - openfile != NULL && openfile != openfile->next ? N_("Close") : -#endif exit_tag, IFSCHELP(nano_exit_msg), FALSE, VIEW); + /* Remember the entry for Exit, to be able to replace it with Close. */ + exitfunc = tailfunc; #ifndef DISABLE_BROWSER add_to_funcs(do_exit, MBROWSER, exit_tag, IFSCHELP(nano_exitbrowser_msg), FALSE, VIEW); diff --git a/src/proto.h b/src/proto.h index 0ee6a046..a4254ddd 100644 --- a/src/proto.h +++ b/src/proto.h @@ -66,6 +66,8 @@ extern int whitespace_len[2]; extern undo_type last_action; #endif +extern const char *exit_tag; +extern const char *close_tag; extern const char *uncut_tag; #ifndef DISABLE_JUSTIFY extern const char *unjust_tag; @@ -101,6 +103,7 @@ extern char *alt_speller; extern sc *sclist; extern subnfunc *allfuncs; +extern subnfunc *exitfunc; extern subnfunc *uncutfunc; #ifndef DISABLE_COLOR extern syntaxtype *syntaxes; -- 2.39.5