aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--libs/output.bash.in30
2 files changed, 21 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index f6f9fef..5f30d32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,11 @@
(space): Declare n as local variable.
(highlight, highlight_warning, highlight_marker): Use plain echo
instead of "echo -e".
+ (write_list_start, write_kv_list_entry)
+ (write_numbered_list_entry): Don't change colours on restore if
+ called with the -p option.
+ (apply_text_highlights): Restore NORMAL_COLOUR if called with an
+ empty first argument.
2009-08-15 Ulrich Mueller <ulm@gentoo.org>
diff --git a/libs/output.bash.in b/libs/output.bash.in
index 0b9a8b0..8d4c724 100644
--- a/libs/output.bash.in
+++ b/libs/output.bash.in
@@ -59,14 +59,14 @@ write_warning_msg() {
# Write a list heading. Args may include text highlighting. If -p is passed,
# use 'plain' highlighting.
write_list_start() {
- local colour=${COLOUR_LIST_HEADER}
+ local colour=${COLOUR_LIST_HEADER} normal=${COLOUR_NORMAL}
if [[ ${1} == "-p" ]] ; then
- colour=
+ colour=; normal=
shift
fi
echo -n -e "${colour}"
echo -n -e "$(apply_text_highlights "${colour}" "$*")"
- echo -n -e "${COLOUR_NORMAL}"
+ echo -n -e "${normal}"
echo
}
@@ -75,14 +75,14 @@ write_list_start() {
# Args may include text highlighting. If -p is passed, use 'plain'
# highlighting rather than bold.
write_kv_list_entry() {
- local n text left=${COLOUR_LIST_LEFT} right=${COLOUR_LIST_RIGHT}
- local key val lindent rindent ifs_save=${IFS}
+ local n text key val lindent rindent ifs_save=${IFS}
+ local left=${COLOUR_LIST_LEFT} right=${COLOUR_LIST_RIGHT}
+ local normal=${COLOUR_NORMAL}
IFS=$' \t\n'
if [[ ${1} == "-p" ]] ; then
- left=
- right=
+ left=; right=; normal=
shift
fi
@@ -93,7 +93,7 @@ write_kv_list_entry() {
echo -n -e " ${lindent}${left}"
echo -n -e "$(apply_text_highlights "${left}" "${key}")"
- echo -n -e "${COLOUR_NORMAL}"
+ echo -n -e "${normal}"
text=${key//\%%%??%%%/}
n=$(( 26 + ${#rindent} - ${#lindent} - ${#text} ))
@@ -136,7 +136,7 @@ write_kv_list_entry() {
else
echo -n -e "${cwords}"
fi
- echo -e "${COLOUR_NORMAL}"
+ echo -e "${normal}"
IFS=${ifs_save}
}
@@ -145,18 +145,20 @@ write_kv_list_entry() {
# include text highlighting. If -p is passed, use 'plain' highlighting.
write_numbered_list_entry() {
local left=${COLOUR_LIST_LEFT} right=${COLOUR_LIST_RIGHT}
+ local normal=${COLOUR_NORMAL}
+
if [[ ${1} == "-p" ]] ; then
- left=""
- right=""
+ left=; right=; normal=
shift
fi
+
echo -n -e " ${left}"
echo -n -e "[$(apply_text_highlights "${left}" "$1")]"
- echo -n -e "${COLOUR_NORMAL}"
+ echo -n -e "${normal}"
space $(( 4 - ${#1} ))
echo -n -e "${right}"
echo -n -e "$(apply_text_highlights "${right}" "$2")"
- echo -n -e "${COLOUR_NORMAL}"
+ echo -n -e "${normal}"
echo
}
@@ -185,7 +187,7 @@ write_numbered_list() {
# Apply text highlights. First arg is the 'restore' colour, second arg
# is the text.
apply_text_highlights() {
- local restore=${1} text=${2}
+ local restore=${1:-${COLOUR_NORMAL}} text=${2}
text="${text//?%%HI%%%/${COLOUR_HI}}"
text="${text//?%%WA%%%/${COLOUR_WARN}}"
text="${text//?%%RE%%%/${restore}}"