Showing posts with label ASCII. Show all posts
Showing posts with label ASCII. Show all posts

Sunday, June 14, 2020

VT100 Animations

https://www.ibiblio.org/archive/2020/04/vt100-animations/

Our ibiblio files include some of these neat VT100 animations (https://www.ibiblio.org/catalog/items/show/3566)  that were made in the 1980’s and early 1990’s for the VT100 terminals . The animations were created by writing code that instructs characters to appear on the screen in a specific order and time. Nothing fancy, but fun to watch. 
Assuming you don’t have a functioning VT100 terminal laying around to run these on, the next best thing is to run this in a Linux terminal using this pipe viewer , and this code:
curl -s [URL] | pv -q -L 2000
(thanks ).  Replace that url with any from ibiblio’s vt100 collection here:  http://www.ibiblio.org/pub/multimedia/animation/vt100-animation/ .  Example:
curl -s ibiblio.org/pub/multimedia/animation/vt100-animation/dont-worry.vt | pv -q -L 2000 
If you don’t have a Linux terminal you can run the code in your Mac terminal, leaving off the ‘|’ and everything after. The timing will be too fast, but you can see what it does. If you have Windows you can install a Linux app from the Microsoft store to run these.
You can find more .vt animation here: http://artscene.textfiles.com/vt100/

Thursday, July 28, 2011

Using sed and awk to highlight console output.

Using ANSI escape sequences in ASCII code I can use awk to highlight lines.

This is really useful for scanning output from make or reading logs.

$ cat TestInput
sdfasd
This is a test abcd test abcd
asdfsd test sdfasdfas

sdfasdffetestasdfasdfas

sdfs
daf
sdf

$ cat highlight
awk '/test/ {print "\033[30;47m" $0 "\033[37;40m"}' TestInput
$ ./highlight

This is a test abcd test abcd
asdfsd test sdfasdfas
sdfasdffetestasdfasdfas
$

I can change the colors.

$ cat highlight
awk '/test/ {print "\033[32;41m" $0 "\033[37;40m"}' TestInput
$ ./highlight

This is a test abcd test abcd
asdfsd test sdfasdfas
sdfasdffetestasdfasdfas

$

Here is a list of color codes.

Terminal Color changing come in the form of  esc , ASCII Decimal 27, hex 1B octal 33
esc[background ; foreground m
It's important there be no spaces.
 
"\033[32;41m"
 so \033 sends escape,   32;41 is background and foreground and "m" is the command.

I can do the same trick with SED also.

 
[jsokol]$ cat highlight2
sed  's/test/\d27[32;41m\0\d27[37;40m/g' TestInput
[jsokol]$ ./highlight2
sdfasd
This is a test abce test aaxx
asdfsd test sdfasdfas 
 
sdfasdffetestasdfasdfas
 
sdfs
daf
sdf
 
[jsokol]$

Friday, December 17, 2010

Ansi color codes in Ruby


#!/usr/bin/ruby
esc="\e["
st=""
x=30
 while x < 38 do
   y=40
   while y < 48 do
     st +=  esc+"#{x};#{y}m #{x};#{y} "
     y+=1
   end
   puts st+esc+"0m\a"
   st=""
   x += 1
 end
puts esc+"0m"



This output's



With a little work I am sure this can be made in to a simple function or library.
or just something you can send with a puts.