make the help menu shortcut display more flexible, add more intuitive

aliases for moving to the beginning and end of a paragraph and
justifying the entire file, and make those aliases available in the main
shortcut list too, since Pico's practice of putting them in the search
menu is rather odd


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1934 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-09-11 21:41:13 +00:00
parent fd73c462f4
commit db6015c7d7
5 changed files with 123 additions and 44 deletions

View File

@ -39,6 +39,11 @@ CVS code -
edit_update(), rename open_the_file() to open_file() since the
latter has been removed, and rename load_a_file() to
load_buffer().
- Add alternative shortcuts for moving to the beginning and end
of a paragraph and justifying the entire file: Meta-(
(Meta-9), Meta-) (Meta-0), and Meta-J, respectively. Also add
these functions to the main shortcut list, as Pico's practice
of putting them in the search menu is rather odd. (DLR)
- files.c:
do_insertfile()
- Readd the NANO_SMALL #ifdef around the start_again: label to
@ -50,6 +55,14 @@ CVS code -
die_save_file()
- Clarify the error message when there are too many backup files
and the current one can't be written. (DLR)
help_init()
- Rework to be a bit more flexible. Only add tabs for shortcut
key entries if those entries exist, and if there's only one
entry left but there's room for more than one, add enough tabs
to put that entry at the end. These changes allow e.g. the
miscellaneous meta key sequence to be displayed in a shortcut
that has a control key, a primary meta key sequence, and a
miscellaneous meta key sequence, but no function key. (DLR)
justify_format()
- For more compatibility with Pico, remove extra space after a
character in punct if that character is the same as the one

View File

@ -235,6 +235,11 @@ void shortcut_init(int unjustify)
const char *cancel_msg = N_("Cancel");
const char *first_line_msg = N_("First Line");
const char *last_line_msg = N_("Last Line");
#ifndef DISABLE_JUSTIFY
const char *beg_of_par_msg = N_("Beg of Par");
const char *end_of_par_msg = N_("End of Par");
const char *fulljstify_msg = N_("FullJstify");
#endif
#ifndef NANO_SMALL
const char *case_sens_msg = N_("Case Sens");
const char *direction_msg = N_("Direction");
@ -289,10 +294,19 @@ void shortcut_init(int unjustify)
const char *nano_nextword_msg = N_("Move forward one word");
const char *nano_prevword_msg = N_("Move backward one word");
#endif
const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
#ifndef DISABLE_JUSTIFY
const char *nano_parabegin_msg =
N_("Go to the beginning of the current paragraph");
const char *nano_paraend_msg =
N_("Go to the end of the current paragraph");
#endif
#ifdef ENABLE_MULTIBUFFER
const char *nano_openprev_msg = N_("Switch to previous file buffer");
const char *nano_opennext_msg = N_("Switch to next file buffer");
const char *nano_openprev_msg = N_("Switch to the previous file buffer");
const char *nano_opennext_msg = N_("Switch to the next file buffer");
#endif
const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
#ifndef DISABLE_JUSTIFY
const char *nano_fulljustify_msg = N_("Justify the entire file");
#endif
#ifndef NANO_SMALL
#ifdef HAVE_REGEX_H
@ -303,13 +317,6 @@ void shortcut_init(int unjustify)
const char *nano_cancel_msg = N_("Cancel the current function");
const char *nano_firstline_msg = N_("Go to the first line of the file");
const char *nano_lastline_msg = N_("Go to the last line of the file");
#ifndef DISABLE_JUSTIFY
const char *nano_parabegin_msg =
N_("Go to the beginning of the current paragraph");
const char *nano_paraend_msg =
N_("Go to the end of the current paragraph");
const char *nano_fulljustify_msg = N_("Justify the entire file");
#endif
#ifndef NANO_SMALL
const char *nano_case_msg =
N_("Make the current search/replace case (in)sensitive");
@ -532,9 +539,17 @@ void shortcut_init(int unjustify)
NANO_NO_KEY, VIEW, do_prev_word);
#endif
sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_verbatim_input);
#ifndef DISABLE_JUSTIFY
/* Translators: try to keep this string under 10 characters long */
sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin);
/* Translators: try to keep this string under 10 characters long */
sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
NANO_PARAEND_ALTKEY2, VIEW, do_para_end);
#endif
#ifdef ENABLE_MULTIBUFFER
sc_init_one(&main_list, NANO_NO_KEY, N_("Previous File"),
@ -546,6 +561,17 @@ void shortcut_init(int unjustify)
NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
#endif
sc_init_one(&main_list, NANO_NO_KEY, N_("Verbatim Input"),
IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_verbatim_input);
#ifndef DISABLE_JUSTIFY
/* Translators: try to keep this string under 10 characters long */
sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_full_justify);
#endif
#ifndef NANO_SMALL
#ifdef HAVE_REGEX_H
sc_init_one(&main_list, NANO_NO_KEY, N_("Find Other Bracket"),
@ -597,18 +623,18 @@ void shortcut_init(int unjustify)
#ifndef DISABLE_JUSTIFY
/* Translators: try to keep this string under 10 characters long */
sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, N_("Beg of Par"),
IFHELP(nano_parabegin_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, do_para_begin);
sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin);
/* Translators: try to keep this string under 10 characters long */
sc_init_one(&whereis_list, NANO_PARAEND_KEY, N_("End of Par"),
IFHELP(nano_paraend_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, do_para_end);
sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
NANO_PARAEND_ALTKEY2, VIEW, do_para_end);
/* Translators: try to keep this string under 10 characters long */
sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, N_("FullJstify"),
IFHELP(nano_fulljustify_msg, NANO_NO_KEY), NANO_NO_KEY,
sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, fulljstify_msg,
IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_full_justify);
#endif

View File

@ -412,13 +412,17 @@ void help_init(void)
strcpy(help_text, htx);
ptr = help_text + strlen(help_text);
/* Now add our shortcut info. */
/* Now add our shortcut info. Assume that each shortcut has, at the
* very least, an equivalent control key, an equivalent primary meta
* key sequence, or both. Also assume that the meta key values are
* not control characters. We can display a maximum of 3 shortcut
* entries. */
for (s = currshortcut; s != NULL; s = s->next) {
bool meta_shortcut = FALSE;
/* TRUE if the character in s->metaval is shown in the
* first column. */
int entries = 0;
/* Control key. */
if (s->ctrlval != NANO_NO_KEY) {
entries++;
#ifndef NANO_SMALL
if (s->ctrlval == NANO_HISTORY_KEY)
ptr += sprintf(ptr, "%.7s", _("Up"));
@ -430,30 +434,51 @@ void help_init(void)
ptr += sprintf(ptr, "^?");
else
ptr += sprintf(ptr, "^%c", s->ctrlval + 64);
*(ptr++) = '\t';
}
#ifndef NANO_SMALL
else if (s->metaval != NANO_NO_KEY) {
meta_shortcut = TRUE;
if (s->metaval == NANO_ALT_SPACE)
/* Function key. */
if (s->funcval != NANO_NO_KEY) {
entries++;
ptr += sprintf(ptr, "(F%d)", s->funcval - KEY_F0);
*(ptr++) = '\t';
}
/* Primary meta key sequence. */
if (s->metaval != NANO_NO_KEY) {
entries++;
/* If this is the last entry, put it at the end. */
if (entries == 2 && s->miscval == NANO_NO_KEY) {
entries++;
*(ptr++) = '\t';
}
/* If the primary meta key sequence is the first entry,
* don't put parentheses around it. */
if (entries == 1 && s->metaval == NANO_ALT_SPACE)
ptr += sprintf(ptr, "M-%.5s", _("Space"));
else
ptr += sprintf(ptr, "M-%c", toupper(s->metaval));
ptr += sprintf(ptr, entries == 1 ? "M-%c" : "(M-%c)",
toupper(s->metaval));
*(ptr++) = '\t';
}
#endif
*(ptr++) = '\t';
if (s->funcval != NANO_NO_KEY)
ptr += sprintf(ptr, "(F%d)", s->funcval - KEY_F0);
*(ptr++) = '\t';
if (!meta_shortcut && s->metaval != NANO_NO_KEY)
ptr += sprintf(ptr, "(M-%c)", toupper(s->metaval));
else if (meta_shortcut && s->miscval != NANO_NO_KEY)
/* Miscellaneous meta key sequence. */
if (entries < 3 && s->miscval != NANO_NO_KEY) {
entries++;
/* If this is the last entry, put it at the end. */
if (entries == 2) {
entries++;
*(ptr++) = '\t';
}
ptr += sprintf(ptr, "(M-%c)", toupper(s->miscval));
*(ptr++) = '\t';
}
*(ptr++) = '\t';
/* Make sure all the help text starts at the same place. */
while (entries < 3) {
entries++;
*(ptr++) = '\t';
}
assert(s->help != NULL);
ptr += sprintf(ptr, "%.*s\n", COLS > 24 ? COLS - 24 : 0, s->help);

View File

@ -330,6 +330,8 @@ typedef struct historyheadtype {
#define NANO_CONTROL_7 31
#define NANO_CONTROL_8 127
#define NANO_ALT_9 '9'
#define NANO_ALT_0 '0'
#define NANO_ALT_A 'a'
#define NANO_ALT_B 'b'
#define NANO_ALT_C 'c'
@ -358,6 +360,8 @@ typedef struct historyheadtype {
#define NANO_ALT_Z 'z'
#define NANO_ALT_PERIOD '.'
#define NANO_ALT_COMMA ','
#define NANO_ALT_LPAREN '('
#define NANO_ALT_RPAREN ')'
#define NANO_ALT_LCARAT '<'
#define NANO_ALT_RCARAT '>'
#define NANO_ALT_RBRACKET ']'
@ -441,8 +445,13 @@ typedef struct historyheadtype {
#define NANO_NEXTWORD_KEY NANO_CONTROL_SPACE
#define NANO_PREVWORD_KEY NANO_ALT_SPACE
#define NANO_PARABEGIN_KEY NANO_CONTROL_W
#define NANO_PARABEGIN_ALTKEY1 NANO_ALT_LPAREN
#define NANO_PARABEGIN_ALTKEY2 NANO_ALT_9
#define NANO_PARAEND_KEY NANO_CONTROL_O
#define NANO_PARAEND_ALTKEY1 NANO_ALT_RPAREN
#define NANO_PARAEND_ALTKEY2 NANO_ALT_0
#define NANO_FULLJUSTIFY_KEY NANO_CONTROL_U
#define NANO_FULLJUSTIFY_ALTKEY NANO_ALT_J
#define NANO_VERBATIM_KEY NANO_ALT_V
#ifndef NANO_SMALL

View File

@ -1322,8 +1322,9 @@ bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
for (; j > 0; j--)
s = s->next;
/* And put back the equivalent key. Assume that the shortcut
* has an equivalent control key, meta key sequence, or both. */
/* And put back the equivalent key. Assume that each shortcut
* has, at the very least, an equivalent control key, an
* equivalent primary meta key sequence, or both. */
if (s->ctrlval != NANO_NO_KEY)
unget_kbinput(s->ctrlval, FALSE);
else if (s->metaval != NANO_NO_KEY)
@ -3010,14 +3011,19 @@ int statusq(int allowtabs, const shortcut *s, const char *def,
break;
#ifndef DISABLE_JUSTIFY
case NANO_PARABEGIN_KEY:
case NANO_PARABEGIN_ALTKEY1:
case NANO_PARABEGIN_ALTKEY2:
do_para_begin();
resetstatuspos = 1;
break;
case NANO_PARAEND_KEY:
case NANO_PARAEND_ALTKEY1:
case NANO_PARAEND_ALTKEY2:
do_para_end();
resetstatuspos = 1;
break;
case NANO_FULLJUSTIFY_KEY:
case NANO_FULLJUSTIFY_ALTKEY:
if (!ISSET(VIEW_MODE))
do_full_justify();
resetstatuspos = 1;