Commit 9cff7a16 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

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.
No related merge requests found
Showing with 22 additions and 0 deletions
+22 -0
......@@ -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 \
......
## 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-)'"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment