Revision 12856
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/lib/sh/util.sh | ||
---|---|---|
506 | 506 |
starts_with 7 "$1" || starts_with 4 "$1" || starts_with 10 "$1" |
507 | 507 |
} |
508 | 508 |
|
509 |
format() # usage: format format_expr msg |
|
510 |
# format_expr: the #s in xfree86.org/current/ctlseqs.html#Character_Attributes |
|
511 |
{ |
|
512 |
local format="$1" msg="$2" |
|
513 |
if starts_with '[' "$msg"; then format=; fi #don't add padding if formatted |
|
514 |
if has_bg "$format"; then msg=" $msg "; fi # auto-add padding if has bg |
|
515 |
echo "${format:+[0;${format}m}$msg${format:+[0m}" |
|
516 |
} |
|
517 |
|
|
509 | 518 |
highlight_msg() # usage: [format=...] highlight_msg msg |
510 | 519 |
# format: the # in xfree86.org/current/ctlseqs.html#Character_Attributes |
511 | 520 |
{ |
512 | 521 |
kw_params format; local format="${format-1}" # bold |
513 | 522 |
if ! can_highlight_msg; then format=; fi |
514 |
if starts_with '[' "$1"; then format=; fi #already formatted->don't ' '-pad |
|
515 |
if has_bg "$format"; then set -- " $1 "; fi # auto-add padding if has bg |
|
516 |
echo "${format:+[0;${format}m}$1${format:+[0m}" |
|
523 |
format "$format" "$1" |
|
517 | 524 |
} |
518 | 525 |
|
519 | 526 |
log_line!() # highlights log_level 1 messages to stand out against other output |
Also available in: Unified diff
lib/sh/util.sh: highlight_msg(): moved formatting code into separate format() function