From e313f5b2c803165e77f4c6540f624ec221a97b16 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 20 Apr 2006 22:29:02 +0000 Subject: [PATCH] reorganize the global toggle list to make it easier for new users, per Benno Schulenberg's suggestion git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3404 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 14 ++++++--- src/global.c | 89 +++++++++++++++++++++++++++++++++------------------- src/help.c | 28 +++++++++++------ src/nano.h | 7 ++++- src/winio.c | 6 ++-- 5 files changed, 94 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index b588f685..fc328152 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,10 +44,11 @@ CVS code - width isn't a clean multiple of the column width. Changes to do_mouseinput() and bottombars(). (Benno Schulenberg, minor tweaks by DLR) - - Add several blank entries to the main shortcut list, in order - to make its help text easier to read. Changes to - sc_init_one() and shortcut_init(). (DLR, suggested by Benno - Schulenberg) + - Add several blank entries to the main shortcut list and the + global toggle list, in order to make the help text easier to + read. Changes to sc_init_one(), toggle_init(), + toggle_init_one(), shortcut_init(), get_toggle(), and + help_init(). (DLR, suggested by Benno Schulenberg) - files.c: open_file() - Remove redundant wording in the error message when we try to @@ -76,6 +77,11 @@ CVS code - - In the global toggle list, move the "Constant cursor position display" toggle up to after the "Use more space for editing" toggle, for consistency. (DLR) + - Reorganize the global toggle list to make it easier for new + users. It now lists toggles that affect the way things are + displayed, followed by toggles that affect editing, followed + by toggles that have to do with peripheral things. (DLR, + suggested by Benno Schulenberg) - nano.c: renumber() - Remove invalid assert. (DLR, found by Filipe Moreira) diff --git a/src/global.c b/src/global.c index ed19deec..2bbd6ce3 100644 --- a/src/global.c +++ b/src/global.c @@ -1196,7 +1196,7 @@ void toggle_init_one(int val, const char *desc, long flag) } u->val = val; - u->desc = _(desc); + u->desc = (desc == NULL) ? "" : _(desc); u->flag = flag; u->next = NULL; } @@ -1210,55 +1210,78 @@ void toggle_init(void) return; toggle_init_one(TOGGLE_NOHELP_KEY, N_("Help mode"), NO_HELP); - toggle_init_one(TOGGLE_MORESPACE_KEY, - N_("Use of more space for editing"), MORE_SPACE); + toggle_init_one(TOGGLE_CONST_KEY, N_("Constant cursor position display"), CONST_UPDATE); -#ifdef ENABLE_MULTIBUFFER - /* If we're using restricted mode, the multibuffer toggle is - * disabled. It's useless since inserting files is disabled. */ - if (!ISSET(RESTRICTED)) - toggle_init_one(TOGGLE_MULTIBUFFER_KEY, - N_("Multiple file buffers"), MULTIBUFFER); + + toggle_init_one(TOGGLE_MORESPACE_KEY, + N_("Use of more space for editing"), MORE_SPACE); + + toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"), + SMOOTH_SCROLL); + +#ifdef ENABLE_NANORC + toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"), + WHITESPACE_DISPLAY); #endif + +#ifdef ENABLE_COLOR + toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"), + NO_COLOR_SYNTAX); +#endif + + /* This entry is blank, in order to make the help text easier to + * read. */ + toggle_init_one(TOGGLE_NO_KEY, NULL, 0); + + toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"), + SMART_HOME); + + toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"), + AUTOINDENT); + toggle_init_one(TOGGLE_CUTTOEND_KEY, N_("Cut to end"), CUT_TO_END); + #ifndef DISABLE_WRAPPING toggle_init_one(TOGGLE_WRAP_KEY, N_("Long line wrapping"), NO_WRAP); #endif -#ifndef DISABLE_MOUSE - toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE); -#endif - /* If we're using restricted mode, the suspend toggle is disabled. - * It's useless since suspending is disabled. */ - if (!ISSET(RESTRICTED)) - toggle_init_one(TOGGLE_SUSPEND_KEY, N_("Suspend"), SUSPEND); - toggle_init_one(TOGGLE_AUTOINDENT_KEY, N_("Auto indent"), - AUTOINDENT); + toggle_init_one(TOGGLE_TABSTOSPACES_KEY, N_("Conversion of typed tabs to spaces"), TABS_TO_SPACES); - /* If we're using restricted mode, the DOS/Mac conversion toggle is - * disabled. It's useless since inserting files is disabled. */ - if (!ISSET(RESTRICTED)) - toggle_init_one(TOGGLE_NOCONVERT_KEY, - N_("No conversion from DOS/Mac format"), NO_CONVERT); + + /* This entry is blank, in order to make the help text easier to + * read. */ + toggle_init_one(TOGGLE_NO_KEY, NULL, 0); + /* If we're using restricted mode, the backup toggle is disabled. * It's useless since backups are disabled. */ if (!ISSET(RESTRICTED)) toggle_init_one(TOGGLE_BACKUP_KEY, N_("Backup files"), BACKUP_FILE); - toggle_init_one(TOGGLE_SMOOTH_KEY, N_("Smooth scrolling"), - SMOOTH_SCROLL); - toggle_init_one(TOGGLE_SMARTHOME_KEY, N_("Smart home key"), - SMART_HOME); -#ifdef ENABLE_COLOR - toggle_init_one(TOGGLE_SYNTAX_KEY, N_("Color syntax highlighting"), - NO_COLOR_SYNTAX); + +#ifdef ENABLE_MULTIBUFFER + /* If we're using restricted mode, the multibuffer toggle is + * disabled. It's useless since inserting files is disabled. */ + if (!ISSET(RESTRICTED)) + toggle_init_one(TOGGLE_MULTIBUFFER_KEY, + N_("Multiple file buffers"), MULTIBUFFER); #endif -#ifdef ENABLE_NANORC - toggle_init_one(TOGGLE_WHITESPACE_KEY, N_("Whitespace display"), - WHITESPACE_DISPLAY); + + /* If we're using restricted mode, the DOS/Mac conversion toggle is + * disabled. It's useless since inserting files is disabled. */ + if (!ISSET(RESTRICTED)) + toggle_init_one(TOGGLE_NOCONVERT_KEY, + N_("No conversion from DOS/Mac format"), NO_CONVERT); + +#ifndef DISABLE_MOUSE + toggle_init_one(TOGGLE_MOUSE_KEY, N_("Mouse support"), USE_MOUSE); #endif + + /* If we're using restricted mode, the suspend toggle is disabled. + * It's useless since suspending is disabled. */ + if (!ISSET(RESTRICTED)) + toggle_init_one(TOGGLE_SUSPEND_KEY, N_("Suspend"), SUSPEND); } #endif /* !NANO_TINY */ diff --git a/src/help.c b/src/help.c index 6fd21388..fa3f2961 100644 --- a/src/help.c +++ b/src/help.c @@ -371,13 +371,16 @@ void help_init(void) #ifndef NANO_TINY /* If we're on the main list, we also count the toggle help text. - * Each line has "M-%c\t\t\t", which fills 24 columns, plus a space, - * plus translated text, plus '\n'. */ + * Each non-blank entry has "M-%c\t\t\t", which fills 24 columns, + * plus a space, plus translated text, plus '\n'. Each blank entry + * has just '\n'. */ if (currshortcut == main_list) { size_t endis_len = strlen(_("enable/disable")); for (t = toggles; t != NULL; t = t->next) - allocsize += 8 + strlen(t->desc) + endis_len; + if (t->val != TOGGLE_NO_KEY) + allocsize += strlen(t->desc) + endis_len + 7; + allocsize++; } #endif @@ -475,10 +478,15 @@ void help_init(void) *(ptr++) = '\t'; } - /* Make sure all the help text starts at the same place. */ - while (entries < 3) { - entries++; - *(ptr++) = '\t'; + /* If this entry isn't blank, make sure all the help text starts + * at the same place. */ + if (s->ctrlval != NANO_NO_KEY || s->funcval != NANO_NO_KEY || + s->metaval != NANO_NO_KEY || s->miscval != + NANO_NO_KEY) { + while (entries < 3) { + entries++; + *(ptr++) = '\t'; + } } assert(s->help != NULL); @@ -501,8 +509,10 @@ void help_init(void) for (t = toggles; t != NULL; t = t->next) { assert(t->desc != NULL); - ptr += sprintf(ptr, "M-%c\t\t\t%s %s\n", toupper(t->val), - t->desc, _("enable/disable")); + if (t->val != TOGGLE_NO_KEY) + ptr += sprintf(ptr, "M-%c\t\t\t%s %s", + toupper(t->val), t->desc, _("enable/disable")); + ptr += sprintf(ptr, "\n"); } } diff --git a/src/nano.h b/src/nano.h index 86a61c06..6d171fe4 100644 --- a/src/nano.h +++ b/src/nano.h @@ -547,8 +547,13 @@ typedef struct rcoption { #define NANO_FULLJUSTIFY_ALTKEY NANO_ALT_J #define NANO_VERBATIM_KEY NANO_ALT_V +/* Toggles do not exist if NANO_TINY is defined. */ #ifndef NANO_TINY -/* Toggles do not exist with NANO_TINY. */ + +/* No toggle at all. */ +#define TOGGLE_NO_KEY -2 + +/* Normal toggles. */ #define TOGGLE_CONST_KEY NANO_ALT_C #define TOGGLE_AUTOINDENT_KEY NANO_ALT_I #define TOGGLE_SUSPEND_KEY NANO_ALT_Z diff --git a/src/winio.c b/src/winio.c index 54c1ccae..f0d821bb 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1711,9 +1711,9 @@ const toggle *get_toggle(int kbinput, bool meta_key) /* Check for toggles. */ for (; t != NULL; t = t->next) { - /* We've found a toggle if meta_key is TRUE and the key is in - * the meta key toggle list. */ - if (meta_key && kbinput == t->val) + /* We've found a toggle if the key exists, meta_key is TRUE, and + * the key is in the meta key toggle list. */ + if (t->val != TOGGLE_NO_KEY && meta_key && kbinput == t->val) break; } -- 2.39.5