+2014-04-07 Benno Schulenberg <bensberg@justemail.net>
+ * 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 <bensberg@justemail.net>
* 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.
/* 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;
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. */
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. */
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;
extern sc *sclist;
extern subnfunc *allfuncs;
+extern subnfunc *uncutfunc;
#ifndef DISABLE_COLOR
extern syntaxtype *syntaxes;
extern char *syntaxstr;
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
blank_statusbar();
/* Display the shortcut list with UnCut. */
- shortcut_init(FALSE);
+ uncutfunc->desc = uncut_tag;
display_main_list();
#ifndef NANO_TINY