Script to convert syslinux -> ANSI
authorhpa <hpa>
Fri, 5 Mar 1999 14:58:26 +0000 (14:58 +0000)
committerhpa <hpa>
Fri, 5 Mar 1999 14:58:26 +0000 (14:58 +0000)
sys2ansi.pl [new file with mode: 0755]

diff --git a/sys2ansi.pl b/sys2ansi.pl
new file mode 100755 (executable)
index 0000000..bcd07cc
--- /dev/null
@@ -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;
+    }
+}
+