From: Ulrich Dangel Date: Sun, 3 Apr 2011 23:20:03 +0000 (+0200) Subject: Introduced easier highlighting for words and charachtes. X-Git-Tag: v0.10~1 X-Git-Url: http://git.grml.org/?p=grml-quickconfig.git;a=commitdiff_plain;h=2ba27405e8784fd2742b88ac5d3a6ef85c39461f Introduced easier highlighting for words and charachtes. As its quite common to highlight single charactes and words in a menu a shortcut for generating these highlights was introduced. Added ^ to highlight a single character and /WORD/ to highlight a word between two slashes --- diff --git a/grml-quickconfig b/grml-quickconfig index 1a6e254..de47f21 100755 --- a/grml-quickconfig +++ b/grml-quickconfig @@ -134,6 +134,9 @@ for file in ${MENUDIR}/*.sh ; do if display_entry ; then setopt noglob if [ -n "$LINE" ] ; then + LINE=$(echo "$LINE" | sed 's#\([^\]\)/\([[:alnum:]_-]*\)/#\1${HIGHLIGHT_NAME}\2${NORMAL}#g') + LINE=$(echo "$LINE" | sed 's#\([^\]\)^\([[:alnum:]]\)#\1${HIGHLIGHT}\2${NORMAL}#g') + LINE=$(echo "$LINE" | sed 's#\\\([^/]\)#\1#g') info+="$(eval $LINE)" fi diff --git a/grml-quickconfig.8 b/grml-quickconfig.8 index 59d4d25..1082174 100644 --- a/grml-quickconfig.8 +++ b/grml-quickconfig.8 @@ -100,6 +100,22 @@ Highlight the used key inside the menu. .TP .B Example print_line "Configure ${HIGHLIGHT}n${NORMAL}etwork" + +.SS Shortcuts +As highlighting the name as well as the keyboard shortcuts is common +in a menu entry there are two shortcuts for highlighting. +.SS Highlight a single character +To highlight a single character, for example the shortcut, use +.B ^ +and the next character will be highlighted. If you want to just write ^ escape the +character with a backslash. + print_line "Configure ^network \\^ is nice" +.SS Highlight a word +To highlight a range, for example the command, use +.B /word/ +and the text between / wll be highlighted. If you want to just write / escape the +character with a backslash. + print_line "Configure ^network (/grml-network/)" .SS MUST Provide .TP .B display_entry @@ -127,7 +143,7 @@ used in combination with print_line. Only used if display_entry returns 0. .RS .B \ Example # print Configure network (grml-network) - LINE='print_line "Configure ${HIGHLIGHT}n${NORMAL}etwork (${HIGHLIGHT_NAME}grml-network${NORMAL})"' + LINE='print_line "Configure ^network (/grml-network/)"' .RE 1 .SS Optional entries The following variables are optional and can be defined in a script but do not have to. @@ -154,8 +170,7 @@ KEY=(c d e) .SS Complete Example # language module for grml-quickconfig - LINE='print_line "Set keyboard layout (${HIGHLIGHT_NAME}grml-lang${NORMAL}): \\ - ${HIGHLIGHT}d${NORMAL}e ${HIGHLIGHT}a${NORMAL}t ${HIGHLIGHT}c${NORMAL}h e${HIGHLIGHT}s${NORMAL} ${HIGHLIGHT}u${NORMAL}s"' + LINE='print_line "Set keyboard layout (/grml-lang/): ^de ^at ^ch e^s ^us"' typeset -A lang_mapping diff --git a/quickconfig/001-heading.sh b/quickconfig/001-heading.sh index 1f5647a..6d9aba2 100644 --- a/quickconfig/001-heading.sh +++ b/quickconfig/001-heading.sh @@ -2,7 +2,7 @@ # print the heading LINE='print_line "Welcome to grml-quickconfig"; print_line "Press a highlighted key to perform an action, or press"; -print_line "${HIGHLIGHT}Return${NORMAL} or ${HIGHLIGHT}q${NORMAL} to go back to the shell."; +print_line "/Return/ or ^q to go back to the shell."; print_delim; ' diff --git a/quickconfig/005-language.sh b/quickconfig/005-language.sh index 4548960..e5c75f9 100644 --- a/quickconfig/005-language.sh +++ b/quickconfig/005-language.sh @@ -1,6 +1,5 @@ # language module for grml-quickconfig -LINE='print_line "Set keyboard layout (${HIGHLIGHT_NAME}grml-lang${NORMAL}): \ -${HIGHLIGHT}d${NORMAL}e ${HIGHLIGHT}a${NORMAL}t ${HIGHLIGHT}c${NORMAL}h e${HIGHLIGHT}s${NORMAL} ${HIGHLIGHT}u${NORMAL}s"' +LINE='print_line "Set keyboard layout (/grml-lang/): ^de ^at ^ch e^s ^us"' typeset -A lang_mapping diff --git a/quickconfig/010-network.sh b/quickconfig/010-network.sh index 76e3cd3..3eaab5e 100644 --- a/quickconfig/010-network.sh +++ b/quickconfig/010-network.sh @@ -1,5 +1,5 @@ # grml-network module for grml-quickconfig -LINE='print_line "Configure ${HIGHLIGHT}n${NORMAL}etwork (${HIGHLIGHT_NAME}grml-network${NORMAL})"' +LINE='print_line "Configure ^network (/grml-network/)"' KEY=(n) FUNCTION='run grml-network' diff --git a/quickconfig/015-netcardconfig.sh b/quickconfig/015-netcardconfig.sh index d96dd30..7019de4 100644 --- a/quickconfig/015-netcardconfig.sh +++ b/quickconfig/015-netcardconfig.sh @@ -1,5 +1,5 @@ # netcardconfig module for grml-quickconfig -LINE='print_line "-> Configure ${HIGHLIGHT}e${NORMAL}thernet card directly (${HIGHLIGHT_NAME}netcardconfig${NORMAL})"' +LINE='print_line "-> Configure ^ethernet card directly (/netcardconfig/)"' KEY=(e) FUNCTION='run netcardconfig' diff --git a/quickconfig/025-info.sh b/quickconfig/025-info.sh index 33533f9..e808304 100644 --- a/quickconfig/025-info.sh +++ b/quickconfig/025-info.sh @@ -1,5 +1,5 @@ # grml-info module for grml-quickconfig -LINE='print_line "Show ${HIGHLIGHT}i${NORMAL}nformation about grml (${HIGHLIGHT_NAME}grml-info${NORMAL})"' +LINE='print_line "Show ^information about grml (/grml-info/)"' KEY=(i) FUNCTION="run grml-info" diff --git a/quickconfig/030-wm.sh b/quickconfig/030-wm.sh index 6165411..af89083 100644 --- a/quickconfig/030-wm.sh +++ b/quickconfig/030-wm.sh @@ -1,5 +1,5 @@ # window manager module for grml-quickconfig -LINE='print_line "Start ${HIGHLIGHT}x${NORMAL} (${HIGHLIGHT_NAME}grml-x${NORMAL})"' +LINE='print_line "Start ^x (/grml-x/)"' KEY=(x) FUNCTION='wm_menu' diff --git a/quickconfig/035-menu.sh b/quickconfig/035-menu.sh index 9987b46..e104197 100644 --- a/quickconfig/035-menu.sh +++ b/quickconfig/035-menu.sh @@ -1,6 +1,6 @@ # application menu module for grml-quickconfig -LINE='print_line "Show an application ${HIGHLIGHT}m${NORMAL}enu (${HIGHLIGHT_NAME}pdmenu${NORMAL})"' +LINE='print_line "Show an application ^menu (/pdmenu/)"' KEY=(m) MENU_PROGNAME=pdmenu FUNCTION="run $MENU_PROGNAME" diff --git a/quickconfig/040-grml-debootstrap.sh b/quickconfig/040-grml-debootstrap.sh index b8af48b..3eec7b3 100644 --- a/quickconfig/040-grml-debootstrap.sh +++ b/quickconfig/040-grml-debootstrap.sh @@ -1,4 +1,4 @@ -LINE='print_line "Install Debian to ${HIGHLIGHT}h${NORMAL}ard disk (${HIGHLIGHT_NAME}grml-debootstrap${NORMAL})"' +LINE='print_line "Install Debian to ^hard disk (/grml-debootstrap/)"' KEY=(h) HD_APP=grml-debootstrap FUNCTION="run $HD_APP"