diff options
author | hpa <hpa> | 1999-03-05 14:58:26 +0000 |
---|---|---|
committer | hpa <hpa> | 1999-03-05 14:58:26 +0000 |
commit | 944454360874dc411891225c40d1bef206f43fc8 (patch) | |
tree | bf93fa805dfcf6c82625329786d38d64fe1160ec | |
parent | 8677a24eb6370d832d1aa4043d46ced168bcbc5f (diff) | |
download | syslinux-944454360874dc411891225c40d1bef206f43fc8.tar.gz |
Script to convert syslinux -> ANSI
-rwxr-xr-x | sys2ansi.pl | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys2ansi.pl b/sys2ansi.pl new file mode 100755 index 00000000..bcd07cca --- /dev/null +++ b/sys2ansi.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl +# +# Perl script to convert a Syslinux-format screen to PC-ANSI +# +@ansicol = (0,4,2,6,1,5,3,7); + +while ( read(STDIN, $ch, 1) > 0 ) { + if ( $ch == '\x1A' ) { # <SUB> <Ctrl-Z> EOF + last; + } elsif ( $ch == '\x13' ) { # <SI> <Ctrl-O> Attribute change + if ( read(STDIN, $attr, 2) == 2 ) { + $attr = hex $attr; + print "\x1b[0;"; + if ( $attr & 0x80 ) { + print "7;"; + $attr &= ~0x80; + } + if ( $attr & 0x08 ) { + print "1;"; + $attr &= ~0x08; + } + printf "%d;%dm", + $ansicol[$attr >> 4] + 40, $ansicol[$attr & 7] + 30; + } + } else { + print $ch; + } +} + |