diff --git a/ChangeLog b/ChangeLog index 9f5119b6..1f975d33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-04-07 Benno Schulenberg + * src/{proto.h,global.c,text.c}: Keep a pointer to the Uncut item in + the functions list, to be able to change its description to Unjustify + at the appropriate moment. This avoids having to fully repopulate + the functions and shortcuts lists before and after every Justify. + Also, look for ^U only in the main menu, to which ^W M-J factually + returns and which shortcut_init() "sneakily" sets. + 2014-04-06 Benno Schulenberg * src/global.c (shortcut_init): Limit M-T (cut-till-end-of-file) to the main menu, and M-J (full-justify) to the main and search menus. diff --git a/src/global.c b/src/global.c index d7b2e8b6..4c7d689b 100644 --- a/src/global.c +++ b/src/global.c @@ -170,6 +170,8 @@ sc *sclist = NULL; /* Struct for the shortcut-key list. */ subnfunc *allfuncs = NULL; /* Struct for the function list. */ +subnfunc *uncutfunc; + /* Pointer to the special Uncut/Unjustify item. */ #ifndef NANO_TINY filestruct *search_history = NULL; @@ -510,8 +512,12 @@ const char *backwards_msg = N_("Backwards"); const char *regexp_msg = N_("Regexp"); #endif +/* TRANSLATORS: Try to keep the next four strings at most 10 characters. */ +const char *uncut_tag = N_("Uncut Text"); +#ifndef DISABLE_JUSITIFY +const char *unjust_tag = N_("Unjustify"); +#endif #ifndef NANO_TINY -/* TRANSLATORS: Try to keep the next two strings at most 10 characters. */ const char *prev_history_msg = N_("PrevHstory"); const char *next_history_msg = N_("NextHstory"); /* TRANSLATORS: Try to keep the next four strings at most 12 characters. */ @@ -804,14 +810,12 @@ void shortcut_init(bool unjustify) add_to_funcs(do_cut_text_void, MMAIN, N_("Cut Text"), IFSCHELP(nano_cut_msg), FALSE, NOVIEW); - if (unjustify) - /* TRANSLATORS: Try to keep this at most 10 characters. */ - add_to_funcs(do_uncut_text, MMAIN, N_("Unjustify"), "", - FALSE, NOVIEW); - else - /* TRANSLATORS: Try to keep this at most 10 characters. */ - add_to_funcs(do_uncut_text, MMAIN, N_("Uncut Text"), IFSCHELP(nano_uncut_msg), - FALSE, NOVIEW); + add_to_funcs(do_uncut_text, MMAIN, uncut_tag, IFSCHELP(nano_uncut_msg), + FALSE, NOVIEW); + + /* Remember the entry for Uncut, to be able to replace it with Unjustify. */ + for (uncutfunc = allfuncs; uncutfunc->next != NULL; uncutfunc = uncutfunc->next) + ; #ifndef NANO_TINY /* TRANSLATORS: Try to keep this at most 10 characters. */ diff --git a/src/proto.h b/src/proto.h index be38858b..801e14bf 100644 --- a/src/proto.h +++ b/src/proto.h @@ -66,7 +66,9 @@ extern int whitespace_len[2]; extern undo_type last_action; #endif +extern const char *uncut_tag; #ifndef DISABLE_JUSTIFY +extern const char *unjust_tag; extern char *punct; extern char *brackets; extern char *quotestr; @@ -99,6 +101,7 @@ extern char *alt_speller; extern sc *sclist; extern subnfunc *allfuncs; +extern subnfunc *uncutfunc; #ifndef DISABLE_COLOR extern syntaxtype *syntaxes; extern char *syntaxstr; diff --git a/src/text.c b/src/text.c index 503605d1..82ce5369 100644 --- a/src/text.c +++ b/src/text.c @@ -2281,14 +2281,14 @@ void do_justify(bool full_justify) do_cursorpos(TRUE); /* Display the shortcut list with UnJustify. */ - shortcut_init(TRUE); + uncutfunc->desc = unjust_tag; display_main_list(); /* Now get a keystroke and see if it's unjustify. If not, put back * the keystroke and return. */ kbinput = do_input(&meta_key, &func_key, &s_or_t, &ran_func, &finished, FALSE); - s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key); + s = get_shortcut(MMAIN, &kbinput, &meta_key, &func_key); if (s && s->scfunc == do_uncut_text) { /* Splice the justify buffer back into the file, but only if we @@ -2351,7 +2351,7 @@ void do_justify(bool full_justify) blank_statusbar(); /* Display the shortcut list with UnCut. */ - shortcut_init(FALSE); + uncutfunc->desc = uncut_tag; display_main_list(); #ifndef NANO_TINY