add the ability to move to the first and last line of the help text via
Meta-\ (Meta-|) and Meta-/ (Meta-?) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
3f77c77f11
commit
6e7d24dcdc
|
@ -65,6 +65,9 @@ CVS code -
|
||||||
do_indent_marked(), do_indent_marked_void(), and
|
do_indent_marked(), do_indent_marked_void(), and
|
||||||
do_unindent_marked_void(); changes to shortcut_init(). (Chris
|
do_unindent_marked_void(); changes to shortcut_init(). (Chris
|
||||||
and DLR)
|
and DLR)
|
||||||
|
- Add the ability to move to the first and last line of the help
|
||||||
|
text via Meta-\ (Meta-|) and Meta-/ (Meta-?). Changes to
|
||||||
|
shortcut_init() and do_help(). (DLR)
|
||||||
- files.c:
|
- files.c:
|
||||||
open_file()
|
open_file()
|
||||||
- Remove redundant wording in the error message when we try to
|
- Remove redundant wording in the error message when we try to
|
||||||
|
|
|
@ -1067,6 +1067,14 @@ void shortcut_init(bool unjustify)
|
||||||
sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
|
sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
|
||||||
IFHELP(nano_nextline_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
|
IFHELP(nano_nextline_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
|
||||||
NANO_NO_KEY, VIEW, NULL);
|
NANO_NO_KEY, VIEW, NULL);
|
||||||
|
|
||||||
|
sc_init_one(&help_list, NANO_NO_KEY, first_line_msg,
|
||||||
|
IFHELP(nano_firstline_msg, FALSE), NANO_FIRSTLINE_ALTKEY,
|
||||||
|
NANO_NO_KEY, NANO_FIRSTLINE_ALTKEY2, VIEW, NULL);
|
||||||
|
|
||||||
|
sc_init_one(&help_list, NANO_NO_KEY, last_line_msg,
|
||||||
|
IFHELP(nano_lastline_msg, TRUE), NANO_LASTLINE_ALTKEY,
|
||||||
|
NANO_NO_KEY, NANO_LASTLINE_ALTKEY2, VIEW, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
|
|
50
src/help.c
50
src/help.c
|
@ -36,21 +36,21 @@ static char *help_text = NULL;
|
||||||
* the function we will call to refresh the edit window.*/
|
* the function we will call to refresh the edit window.*/
|
||||||
void do_help(void (*refresh_func)(void))
|
void do_help(void (*refresh_func)(void))
|
||||||
{
|
{
|
||||||
int line = 0;
|
size_t line = 0;
|
||||||
/* The line number in help_text of the first displayed help
|
/* The line number in help_text of the first displayed help
|
||||||
* line. This variable is zero-based. */
|
* line. This variable is zero-based. */
|
||||||
bool no_more = FALSE;
|
size_t last_line;
|
||||||
/* no_more means the end of the help text is shown, so don't go
|
/* The line number in help_text of the last help line. This
|
||||||
* down any more. */
|
* variable is zero-based. */
|
||||||
int kbinput = ERR;
|
int kbinput = ERR;
|
||||||
bool meta_key, func_key;
|
bool meta_key, func_key;
|
||||||
|
|
||||||
bool old_no_help = ISSET(NO_HELP);
|
bool old_no_help = ISSET(NO_HELP);
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
const shortcut *oldshortcut = currshortcut;
|
const shortcut *oldshortcut = currshortcut;
|
||||||
/* We will set currshortcut to allow clicking on the help
|
/* We will set currshortcut to allow clicking on the help
|
||||||
* screen's shortcut list. */
|
* screen's shortcut list. */
|
||||||
#endif
|
#endif
|
||||||
|
const char *ptr;
|
||||||
|
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
blank_edit();
|
blank_edit();
|
||||||
|
@ -77,11 +77,22 @@ void do_help(void (*refresh_func)(void))
|
||||||
|
|
||||||
bottombars(help_list);
|
bottombars(help_list);
|
||||||
|
|
||||||
|
/* Get the last line of the help text. */
|
||||||
|
ptr = help_text;
|
||||||
|
|
||||||
|
for (last_line = (size_t)-1; *ptr != '\0'; last_line++) {
|
||||||
|
ptr += help_line_len(ptr);
|
||||||
|
if (*ptr == '\n')
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int i;
|
size_t i;
|
||||||
int old_line = line;
|
/* Generic loop variable. */
|
||||||
|
size_t old_line = line;
|
||||||
/* We redisplay the help only if it moved. */
|
/* We redisplay the help only if it moved. */
|
||||||
const char *ptr = help_text;
|
|
||||||
|
ptr = help_text;
|
||||||
|
|
||||||
switch (kbinput) {
|
switch (kbinput) {
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
|
@ -92,15 +103,17 @@ void do_help(void (*refresh_func)(void))
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case NANO_REFRESH_KEY:
|
||||||
|
total_redraw();
|
||||||
|
break;
|
||||||
case NANO_PREVPAGE_KEY:
|
case NANO_PREVPAGE_KEY:
|
||||||
if (line > 0) {
|
if (line > editwinrows - 2)
|
||||||
line -= editwinrows - 2;
|
line -= editwinrows - 2;
|
||||||
if (line < 0)
|
else
|
||||||
line = 0;
|
line = 0;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NANO_NEXTPAGE_KEY:
|
case NANO_NEXTPAGE_KEY:
|
||||||
if (!no_more)
|
if (line + (editwinrows - 2) <= last_line)
|
||||||
line += editwinrows - 2;
|
line += editwinrows - 2;
|
||||||
break;
|
break;
|
||||||
case NANO_PREVLINE_KEY:
|
case NANO_PREVLINE_KEY:
|
||||||
|
@ -108,11 +121,15 @@ void do_help(void (*refresh_func)(void))
|
||||||
line--;
|
line--;
|
||||||
break;
|
break;
|
||||||
case NANO_NEXTLINE_KEY:
|
case NANO_NEXTLINE_KEY:
|
||||||
if (!no_more)
|
if (line + editwinrows <= last_line)
|
||||||
line++;
|
line++;
|
||||||
break;
|
break;
|
||||||
case NANO_REFRESH_KEY:
|
case NANO_FIRSTLINE_ALTKEY:
|
||||||
total_redraw();
|
line = 0;
|
||||||
|
break;
|
||||||
|
case NANO_LASTLINE_ALTKEY:
|
||||||
|
if (last_line > editwinrows)
|
||||||
|
line = last_line - (editwinrows - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +155,6 @@ void do_help(void (*refresh_func)(void))
|
||||||
if (*ptr == '\n')
|
if (*ptr == '\n')
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
no_more = (*ptr == '\0');
|
|
||||||
|
|
||||||
skip_redisplay:
|
skip_redisplay:
|
||||||
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
||||||
|
|
Loading…
Reference in New Issue