Sponsored Content
Top Forums Shell Programming and Scripting Coloring cli output, screws up 'alignment' Post 302928245 by sea on Wednesday 10th of December 2014 06:54:40 AM
Old 12-10-2014
Coloring cli output, screws up 'alignment'

Heyas

I'm trying to add color 'support' to my TUI.
It works, but behaves weird.

Code in question: (status.conf)
Code:
		R="\033[0m"
		r="\033[31m"
		y="\033[33m"
		p="\033[35m"
		g="\033[32m"
		b="\033[1m"

		TUI_TODO="[  ${p}${b}≡${R}   ]" 	;	TUI_WORK="[  ${y}${b}∞${R}   ]"
		TUI_DONE="[  $(printf ${g}${b}√${R})   ]" 	;	TUI_FAIL="[  ${r}${b}✗${R}   ]"

		TUI_SKIP="[  »   ]" 	;	TUI_NEXT="[  ⇒   ]"
		TUI_BACK="[  ⇐   ]" 	;	TUI_CANC="[  ✘   ]"
		TUI_ON="[  ◆   ]" 	;	TUI_OFF="[  ◇   ]"
		TUI_INFO="[ ⚠ⅈ⚠  ]" 	;	TUI_HELP="[ HELP ]"

The middleware: (tui-status)
Code:
#
#	Fill array according to return value
#
	unset retvalue[@]
	retvalue[0]="$TUI_DONE" ;	retvalue[1]="$TUI_FAIL"
	retvalue[2]="$TUI_WORK" ;	retvalue[3]="$TUI_TODO"
	retvalue[4]="$TUI_SKIP" ;	retvalue[5]="$TUI_NEXT"
	retvalue[6]="$TUI_BACK" ;	retvalue[7]="$TUI_CANC"
	
	retvalue[10]="$TUI_ON"	;	retvalue[11]="$TUI_OFF"
	
	retvalue[99]="$TUI_HELP";	retvalue[111]="$TUI_INFO"
#
#	Display
#	
	[[ -z "$1" ]] && ( tui-status 1 "Usage: tui-status ERRORLEVEL [ \"Message to user\" ]" ; exit 1)
	if [[ "$1" = "-h" ]]
	then	printf "
$ME ($script_version)
Usage: $ME \$? [ \"Message to user\" ]
Interpreted numbers:\n"
		for num in $(seq 0 1 120)
		do	str="${retvalue[$num]}"
			[[ ! "" = "$(printf '%s' $str)" ]] && \
				printf "\t$str : $num\n"
		done
		printf "\n"
		exit $RET_HELP
	else	if [[ ! "" = "${retvalue[$1]}" ]]
		then	case $count in	
			1)	tui-printf -E " " "${retvalue[$1]}"		;;
			2)	tui-printf -E "$2" "${retvalue[$1]}"		;;
			3)	tui-printf -E "$2" "$3" "${retvalue[$1]}"	;;
			4)	tui-status 1 "Too many args: $@"		;;
			esac
		else	tui-printf -E  "$2" "$3"  "ErrNr: $1"
		fi
	fi

I do not understand the mis-alignment of the colord values, they were placed proplerly (right aligned, like the lowest one) before that.
All other values still work, so its clear its 'just the colors' making the difference.

Any ideas please?
Thank you in advance
Coloring cli output, screws up 'alignment'-tui-status_color_try1jpg
Coloring cli output, screws up 'alignment'-tui-status_color_try2jpg

Last edited by sea; 12-10-2014 at 08:01 AM..
 

9 More Discussions You Might Find Interesting

1. Programming

Capturing cli Program output

A few years ago I took a C programming class and used both Linux and FreeBSD as my operating systems and gcc as the compiler. I ran a Command-line utility to to capture what happened as I ran the code, the output was saved to a file that I specified when I ran the utility command (that I can't... (1 Reply)
Discussion started by: Christopher
1 Replies

2. Cybersecurity

ISS screws up.

Seems that security company ISS who brought us products such as BlackICE defender, released to the public, information concerning a vulnerability in apache that effects all versions on all platforms before telling the developers at Apache about it. This forced the people at Apache to work quickly... (1 Reply)
Discussion started by: ThePreacher
1 Replies

3. Shell Programming and Scripting

output display alignment !!

Hi I'm trying to display the output of my script in a friendly viewable format. it's something like this.. i have this while loop... in which i get some records from a file where fields are delimitered with a pipe. so i'm extacting each field and replacing the pipe with a \t, tab !!.. cat... (7 Replies)
Discussion started by: rosh0623
7 Replies

4. UNIX for Dummies Questions & Answers

'export TERM=xterm-color' pretty much screws up clear command

I like using VIM with color tagging (using putty to SunOS). However, when I do an "export TERM=xterm-color", I can't make use of the clear command. Clear just has the same effect as pressing enter now. How can I fix this? Also, does anyone know how to get the directories and file colors... (6 Replies)
Discussion started by: mrwatkin
6 Replies

5. Shell Programming and Scripting

Complex coloring in script

My script prints lines in which the entire line may be colored, and portions may also be colored. e.g. Consider this to be one line: $red some text in red $yellow abcd $end_yellow red text 1234 $blue some text $end_blue more red text $end_red So using sed, I may based on condition 1,... (5 Replies)
Discussion started by: sentinel
5 Replies

6. Shell Programming and Scripting

Formatting output alignment

Hi Gurus, I've the following output from my scripting as shown below. 0.48 GB 0.29 GB 0.19 GB 60% 0.48 GB 0.29 GB 0.19 GB 60% 228.90 GB 89.47 GB 139.42 GB 39% 228.76 GB 72.37 GB 156.39 GB 31% Is it possible to format this output into a proper... (16 Replies)
Discussion started by: superHonda123
16 Replies

7. Shell Programming and Scripting

Output alignment problem

Hi Gurus, This is my raw data. How would I able to format this output into a better alignment? /dev/vg00/lvol5 /home 0.12 GB 0.02 GB 0.10 GB 19% /dev/vg00/misc /misc 28.43 GB 4.92 GB 23.51 GB 17% /dev/vg00/lvol6 /opt 8.25 GB 5.43 GB 2.82 GB 65% /dev/vgsap/ora10264 ... (10 Replies)
Discussion started by: superHonda123
10 Replies

8. Shell Programming and Scripting

Shell script output alignment

Hi How can I alaign the output of a script. Exaplme my script has assigned values to two variables, VAR1 and VAR2 VAR1=This is RAJ working as a DB2 UDB DBA for VISA Corporation, Need your help in Shell scripting VAR2= This is RAM working as a ORACLE DEVELOPER for TARGET... (1 Reply)
Discussion started by: thriloka
1 Replies

9. Shell Programming and Scripting

Not the correct output, works fine via CLI, not inside the script.

Guys, I need you help please. The script below is not working correclty for checking via a awk/if statement . Can you tell me what i am doing wrong in the script code "if($1 == "$RETENTION_LEVEL") " Syntax RETENTION_LEVEL=`echo $LINE | cut -f2 -d" "` echo " ==============... (4 Replies)
Discussion started by: Junes
4 Replies
All times are GMT -4. The time now is 08:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy