libmsgmng.lib: allow users to modify ESC, CRIT, NOTE, WARN, EXIT, and NORM color codes

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-11-08 21:07:55 +01:00
parent 8b6e2b2c50
commit 924f2b2cab
2 changed files with 13 additions and 6 deletions

View File

@ -30,6 +30,13 @@ Fri Nov 09 2012 Davide Madrisan <davide.madrisan(a)gmail.com>
Postpone the load of libcfg.lib to allow users to set a different Postpone the load of libcfg.lib to allow users to set a different
configuration file (will be done in a following patch). configuration file (will be done in a following patch).
+ improvement
* lib/libmsgmng.lib - Davide Madrisan:
Do not set ESC, CRIT, NOTE, WARN, EXIT, and NORM when already defined by
the user. This will permit users to redefine the terminal colors or even
define very different color sequences, like the colors used in web pages.
(A feature asked by Silvan for openmamba webbuild).
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Changes in version 1.14.0 Changes in version 1.14.0

View File

@ -17,12 +17,12 @@ TEXTDOMAIN="libmsgmng"; export TEXTDOMAIN
# none # none
function notify.enable_colors() { function notify.enable_colors() {
if [[ -t 1 && "$TERM" != raw && "$TERM" != dumb ]]; then if [[ -t 1 && "$TERM" != raw && "$TERM" != dumb ]]; then
ESC=$(echo -en "\033") # ascii ESCape ESC=$(echo -en "\033") # ascii ESCape
CRIT="${ESC}[1;31m" # switch on red [ "$CRIT" ] || CRIT="${ESC}[1;31m" # switch on red
NOTE="${ESC}[1;33m" # switch on yellow [ "$NOTE" ] || NOTE="${ESC}[1;33m" # switch on yellow
WARN="${ESC}[1;31m" [ "$WARN" ] || WARN="${ESC}[1;31m"
EXIT="${ESC}[1;31m" [ "$EXIT" ] || EXIT="${ESC}[1;31m"
NORM=$(echo -en "${ESC}[m\017") [ "$NORM" ] || NORM=$(echo -en "${ESC}[m\017")
else else
ESC= CRIT= NOTE= WARN= EXIT= NORM= ESC= CRIT= NOTE= WARN= EXIT= NORM=
fi fi