mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-17 23:09:30 +03:00
help: use a dedicated syntax to color shortcuts in a help text
This avoids applying the default syntax, or the syntax specified with --syntax, to a ^G help text.
This commit is contained in:
parent
ae15fc9bb2
commit
9cff7a1689
@ -108,6 +108,9 @@ void do_help(void)
|
||||
int saved_margin = margin;
|
||||
/* For avoiding the line numbers on the help screen. */
|
||||
ssize_t was_tabsize = tabsize;
|
||||
#ifndef DISABLE_COLOR
|
||||
char *was_syntax = syntaxstr;
|
||||
#endif
|
||||
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
|
||||
/* Store current answer when user invokes help at the prompt. */
|
||||
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||
@ -173,6 +176,9 @@ void do_help(void)
|
||||
++ptr;
|
||||
start_of_text = ptr;
|
||||
|
||||
#ifndef DISABLE_COLOR
|
||||
syntaxstr = "nanohelp";
|
||||
#endif
|
||||
display_the_help_text(FALSE);
|
||||
curs_set(0);
|
||||
edit_refresh();
|
||||
@ -270,6 +276,9 @@ void do_help(void)
|
||||
free(answer);
|
||||
answer = saved_answer;
|
||||
tabsize = was_tabsize;
|
||||
#ifndef DISABLE_COLOR
|
||||
syntaxstr = was_syntax;
|
||||
#endif
|
||||
|
||||
remove(tempfilename);
|
||||
free(tempfilename);
|
||||
|
@ -22,6 +22,7 @@ pkgdata_DATA = asm.nanorc \
|
||||
man.nanorc \
|
||||
mgp.nanorc \
|
||||
mutt.nanorc \
|
||||
nanohelp.nanorc \
|
||||
nanorc.nanorc \
|
||||
nftables.nanorc \
|
||||
objc.nanorc \
|
||||
|
12
syntax/nanohelp.nanorc
Normal file
12
syntax/nanohelp.nanorc
Normal file
@ -0,0 +1,12 @@
|
||||
## This is meant for highlighting key combos in a nano help text.
|
||||
|
||||
# It should not apply to any normal file, so no fileregex.
|
||||
syntax "nanohelp"
|
||||
|
||||
# Key combos:
|
||||
color brightblue "\^([]A-Z^\_←→↑↓]|Home|End)" "[←→↑↓]"
|
||||
color brightblue "\<(Tab|Enter|Home|End|Ins|Del|Bsp|PgUp|PgDn)\>"
|
||||
color brightblue "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
|
||||
|
||||
# Quoted indicators:
|
||||
color brightred "'(\^|M-)'"
|
Loading…
Reference in New Issue
Block a user