Introduced easier highlighting for words and charachtes.
authorUlrich Dangel <mru@grml.org>
Sun, 3 Apr 2011 23:20:03 +0000 (01:20 +0200)
committerUlrich Dangel <mru@grml.org>
Sun, 3 Apr 2011 23:20:03 +0000 (01:20 +0200)
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

grml-quickconfig
grml-quickconfig.8
quickconfig/001-heading.sh
quickconfig/005-language.sh
quickconfig/010-network.sh
quickconfig/015-netcardconfig.sh
quickconfig/025-info.sh
quickconfig/030-wm.sh
quickconfig/035-menu.sh
quickconfig/040-grml-debootstrap.sh

index 1a6e254..de47f21 100755 (executable)
@@ -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
 
index 59d4d25..1082174 100644 (file)
@@ -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
 
index 1f5647a..6d9aba2 100644 (file)
@@ -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;
 '
 
index 4548960..e5c75f9 100644 (file)
@@ -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
 
index 76e3cd3..3eaab5e 100644 (file)
@@ -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'
 
index d96dd30..7019de4 100644 (file)
@@ -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'
 
index 33533f9..e808304 100644 (file)
@@ -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"
 
index 6165411..af89083 100644 (file)
@@ -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'
 
index 9987b46..e104197 100644 (file)
@@ -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"
index b8af48b..3eec7b3 100644 (file)
@@ -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"