Linux: Visual Color test

86 views
Skip to first unread message

S.E. Mitchell

unread,
Nov 8, 2023, 5:44:48 AM11/8/23
to TSEPro Support
Can you run the following script, and let me know:
1) does it show colors
2) what is the value of your COLORTERM and TERM environment variables
If the mailer mangles the script, you can get the original here:
https://unix.stackexchange.com/a/696756


#!/bin/bash
# From: https://unix.stackexchange.com/a/696756
# Based on: https://gist.github.com/XVilka/8346728 and
https://unix.stackexchange.com/a/404415/395213

awk -v term_cols="${width:-$(tput cols || echo 80)}" -v
term_lines="${height:-1}" 'BEGIN{
s="/\\";
total_cols=term_cols*term_lines;
for (colnum = 0; colnum<total_cols; colnum++) {
r = 255-(colnum*255/total_cols);
g = (colnum*510/total_cols);
b = (colnum*255/total_cols);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum%2+1,1);
if (colnum%term_cols==term_cols) printf "\n";
}
printf "\n";
}'

Fred H Olson

unread,
Nov 8, 2023, 7:08:13 AM11/8/23
to TSEPro Support
On Wed, 8 Nov 2023, S.E. Mitchell wrote:

> Can you run the following script, and let me know:
> 1) does it show colors
> 2) what is the value of your COLORTERM and TERM environment variables
> If the mailer mangles the script, you can get the original here:
> https://unix.stackexchange.com/a/696756

1) I get the one line color response as shown on the web page.

2)
$ echo $COLORTERM

$ echo $TERM
xterm-256color

I guess that means COLORTERM is not defined on my system.

Fred

--
Fred H. Olson Minneapolis,MN 55411 USA (near north Mpls)
Email: fholson at cohousing.org 612-588-9532
My Link Pg: http://fholson.cohousing.org

Carlo Hogeveen

unread,
Nov 8, 2023, 9:58:28 AM11/8/23
to sem...@googlegroups.com

Debian in WSL:
1) Yes, a line of gradually changing colors.
2) COLORTERM = , TERM = xterm-256color .

Centos 7 server via Putty:
1) Yes, a line of gradually changing colors.
2) COLORTERM = , TERM = xterm .

Centos 7 server direct:
1) A line of mangled, mostly-half block characters with random colors.
Linux now presents unreadable prompts with "random" characters and any further Linux commands I give are invisible and produce output with "random" characters.
After giving "exit" I still get a mangled login prompt.
After logging in the new Linux session keeps the mangled prompts and command output.
Only fix that works: Restarting the computer.
2) COLORTERM = , TERM = linux .

Debian server via Putty:
1) Yes, a line of gradually changing colors.
2) COLORTERM = , TERM = xterm .

Debian server direct:
1) Yes, a line of gradually changing colors.
2) COLORTERM = , TERM = linux .

Carlo



Carlo Hogeveen

unread,
Nov 8, 2023, 1:46:11 PM11/8/23
to sem...@googlegroups.com

A correction and a fix.

> Debian server direct:
>1) Yes, a line of gradually changing colors.
> 2) COLORTERM = , TERM = linux .

I did not look well at 1).
It produces of only 4 colors.

About the script (and theoretically TSE) permanently mangling the Linux prompts and the output of its commands when I access a Centos 7 server directly.
Of the several solutions I found online, I found two "universal" ones, namely two Linux commands that universally work on all my tested Linux systems via all tested terminals/interfaces:
- reset
- printf "\ec"
These two commands clear and reset the screen of the Linux terminal/interface.
The latter might be a nice one to send to the screen when closing Linux TSE, just in case it messed up the screen with inappropriately selected ANSI escape codes.

Carlo



S.E. Mitchell

unread,
Nov 8, 2023, 3:14:57 PM11/8/23
to sem...@googlegroups.com
Thanks for the notes. I'll look into the printf "\ec".
Here are the notes for the next release. I'm trying to be pretty
conservative as far as picking which ansi color driver to use:

New in this release:

Support for 256 Ansi color mode.
-color command line option changed to -ansicolor
AnsiColor variable replaced with CurrAnsiColor and StartupAnsiColor

There are 4 Ansi video drivers:

8 - uses the 8 standard colors
16 - uses the 8 standard plus bright versions of the sam
256 - uses the 256 colors
1 - (rgb) uses the 24-bit color mode. 16,777,216 possible
colors.

CurrAnsiColor sets which Ansi video driver is currently being
used.

Valid values for the above are 1 for rgb/24-bit, 8, 16, 256.

Startup Ansi color driver determination:

CurrAnsiColor = 8

if the command_line contains "-ansicolor",
the next arg is taken as the ansi driver to use,
e.g., 1, 8, 16, 256.
Set CurrAnsiColor to that arg.

elseif StartupAnsiColor is set,
Set CurrAnsiColor to that value

else
get the values for the COLORTERM and TERM environment values
if COLORTERM contains "truecolor", "24bit", "24-bit",
Set CurrAnsiColor to 1 (rgb)
elseif TERM contains "truecolor", "24bit", "iterm",
Set CurrAnsiColor to 1 (rgb)
elseif TERM contains "256color",
Set CurrAnsiColor to 256
elseif TERM contains "16color",
Set CurrAnsiColor to 16
elseif TERM contains "xterm",
Set CurrAnsiColor to 16
endif
endif
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/semware/000901da1273%24d471d5a0%247d5580e0%24%40ecarlo.nl.

Carlo Hogeveen

unread,
Nov 8, 2023, 4:47:19 PM11/8/23
to sem...@googlegroups.com

Sammy,

Looks good to me.
The part for TSE conservatively selecting a default ANSI driver based on a limited amount of responses remains a tiny bit risky, but now there will be a command line work-around: "reset" followed by "e -ansicoler 8".
And hopefully you will get more responses from people running your script.
Thank you,

Carlo




Guy Rouillier

unread,
Nov 9, 2023, 3:41:31 AM11/9/23
to Semware TSE Pro
I see others got results from this script.  When I tried to run it on Ubuntu MATE 23.04, I get:

awk: option requires an argument -- v

--
Guy Rouillier
--
 
---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.

Carlo Hogeveen

unread,
Nov 9, 2023, 3:57:12 AM11/9/23
to sem...@googlegroups.com

Guy,

Email probably broke one line in two lines, which makes the script not work.
Sammy mentioned a link for that case.
Alternatively: I put the script in a zip file with a line added that prints the requested environment variables:
https://ecarlo.nl/tse/files/LinuxVisualColorTest.zip

Carlo



S.E. Mitchell

unread,
Nov 9, 2023, 5:15:24 AM11/9/23
to sem...@googlegroups.com
>>- reset
>>- printf "\ec"
>>These two commands clear and reset the screen of the Linux terminal/interface.
>>The latter might be a nice one to send to the screen when closing Linux TSE, just in case it messed up the screen with inappropriately selected ANSI escape codes.

I tried adding the "printf "\ec"" to the editor, and while it works,
it also completely clears the thousands of lines of screen history one
might have :(
At this point, I won't be adding that to the editor - because of the
aforementioned behavior - but will add a note in the read.me.
I will consider other suggestions/arguments.
--
Sammy Mitchell

On Wed, Nov 8, 2023 at 1:46 PM Carlo Hogeveen <t...@ecarlo.nl> wrote:
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/semware/000901da1273%24d471d5a0%247d5580e0%24%40ecarlo.nl.

zhong zhao

unread,
Nov 9, 2023, 8:26:44 PM11/9/23
to SemWare TSE Pro text editor
tmp.png

zhong zhao

unread,
Nov 9, 2023, 8:27:56 PM11/9/23
to SemWare TSE Pro text editor
z.sh

Guy Rouillier

unread,
Nov 10, 2023, 3:59:58 PM11/10/23
to Semware TSE Pro
Carlo, thank you for this.  Sammy's initial message was missing the last line in your script: 

   echo COLORTERM = $COLORTERM , TERM = $TERM .

When I added that, the initial script worked.  Here is my result:

COLORTERM = truecolor , TERM = xterm-256color .

--
Guy Rouillier
--
 
---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.

Guy Rouillier

unread,
Nov 10, 2023, 8:28:40 PM11/10/23
to Semware TSE Pro
Oops, I missed the other part of the original request. Yes, I see the line of colors. I'm running this test in a 64-bit Ubuntu MATE 23.10 VM. 

Harald Mezger

unread,
Nov 11, 2023, 5:01:44 AM11/11/23
to sem...@googlegroups.com
Dear Sammy,

sorry for the delay - real life intervened.

Here's the output of your shell script from my MX Linux 23.1 XFCE VirtualBox, plus the values of the two terminal variables.
Appropriately (I hope) in the form of a screen shot.

Results from my Linux Mint Cinnamon machine will follow as soon as possible.

Best Wishes, Harald
Sammy-Output-MX_Linux_23.1_64bit-VirtualBox.png

--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.

Harald Mezger

unread,
Nov 11, 2023, 8:00:42 AM11/11/23
to sem...@googlegroups.com
And the Linux Cinnamon Mint 21.2 64-bit output of your shell script:
Sammy.sh-Mint-Cinnamon.png
Hope it helps,
Harald.

Am Mi., 8. Nov. 2023 um 11:44 Uhr schrieb S.E. Mitchell <sammy.m...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages