slitaz-base-files rev 279

libtaz.sh: non-bold colors starts with 0; add available color table to the testsuite
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Jul 01 01:01:17 2015 +0300 (2015-07-01)
parents 5979e3b76e5e
children 4ac9c14198c1
files rootfs/lib/libtaz.sh testsuite.sh
line diff
     1.1 --- a/rootfs/lib/libtaz.sh	Sat Jun 20 22:49:35 2015 +0300
     1.2 +++ b/rootfs/lib/libtaz.sh	Wed Jul 01 01:01:17 2015 +0300
     1.3 @@ -7,6 +7,7 @@
     1.4  #
     1.5  
     1.6  . /usr/bin/gettext.sh
     1.7 +alias sed="busybox sed"
     1.8  
     1.9  # Internal
    1.10  lgettext() { gettext -d 'slitaz-base' "$@"; }
    1.11 @@ -102,7 +103,10 @@
    1.12  	case $output in
    1.13  		raw|gtk) echo "$@";;
    1.14  		html)    echo -n "<span class=\"color$color\">$@</span>";;
    1.15 -		*)       echo -e "\\033[1;${color:-38}m$@\\033[0;39m" ;;
    1.16 +		*)  case $color in
    1.17 +				0*) echo -e "\\033[${color:-38}m$@\\033[39m";;
    1.18 +				*)  echo -e "\\033[1;${color:-38}m$@\\033[0;39m";;
    1.19 +			esac;;
    1.20  	esac
    1.21  	unset color
    1.22  }
    1.23 @@ -136,7 +140,8 @@
    1.24  				sep="${sep}="
    1.25  			done
    1.26  			echo -en "$(echo "$@" | sed -e 's|<b>|\\033[1m|g; s|</b>|\\033[0m|g;
    1.27 -			s|<c \([0-9]*\)>|\\033[1;\1m|g; s|</c>|\\033[0;39m|g; s|<n>|\n|g;
    1.28 +			s|<c 0\([0-9]*\)>|\\033[\1m|g; s|<c \([1-9][0-9]*\)>|\\033[1;\1m|g;
    1.29 +			s|</c>|\\033[0;39m|g; s|<n>|\n|g;
    1.30  			s|<->|'$sep'|g; s|<i \([0-9]*\)>|\\033[\1G|g')"
    1.31  			[ "$1" != "-n" ] && echo
    1.32  			;;
     2.1 --- a/testsuite.sh	Sat Jun 20 22:49:35 2015 +0300
     2.2 +++ b/testsuite.sh	Wed Jul 01 01:01:17 2015 +0300
     2.3 @@ -79,6 +79,25 @@
     2.4  
     2.5  	newline; echo 'Using itemize() in the tazpkg:'
     2.6  	tazpkg info gtk+
     2.7 +
     2.8 +	title "$(emsg '<c 31>C<c 32>o<c 33>l<c 34>o<c 35>r<c 36>s</c>')"
     2.9 +	for i in $(seq 0 7); do
    2.10 +		case $i in
    2.11 +			0) c='Gray   ';;
    2.12 +			1) c='Red    ';;
    2.13 +			2) c='Green  ';;
    2.14 +			3) c='Yellow ';;
    2.15 +			4) c='Blue   ';;
    2.16 +			5) c='Magenta';;
    2.17 +			6) c='Cyan   ';;
    2.18 +			7) c='White  ';;
    2.19 +		esac
    2.20 +		echo -n "$c "
    2.21 +		echo -n "$(colorize "03$i" "03$i") $(colorize "3$i" "3$i") " # test `colorize`: fg
    2.22 +		echo -n "$(colorize "04$i" "04$i") $(colorize "4$i" "4$i") " # test `colorize`: bg
    2.23 +		echo -n ": "
    2.24 +		emsg "<c 03$i>03$i $c</c> <c 3$i>3$i Bold $c</c> <c 04$i>04$i $c</c> <c 4$i>4$i Bold $c</c>" # test `emsg`
    2.25 +	done
    2.26  }
    2.27  
    2.28  # Usage: check_functions path/to/lib.sh