3 # Perl script to convert a Syslinux-format screen to PC-ANSI
4 # to display in a color xterm or on the Linux console
7 @ansicol = (0,4,2,6,1,5,3,7);
12 while ( read(STDIN
, $ch, 1) > 0 ) {
13 if ( $ch eq "\x1A" ) { # <SUB> <Ctrl-Z> EOF
15 } elsif ( $ch eq "\x0C" ) { # <FF> <Ctrl-L> Clear screen
16 print "\x1b[2J" if ( $enable && !$getting_file );
17 } elsif ( $ch eq "\x0F" ) { # <SI> <Ctrl-O> Attribute change
18 if ( !$getting_file ) {
19 if ( read(STDIN
, $attr, 2) == 2 ) {
32 $ansicol[$attr >> 4] + 40, $ansicol[$attr & 7] + 30;
36 } elsif ( $ch eq "\x18" ) { # <CAN> <Ctrl-X> Display image
37 # We can't display an image; pretend to be a text screen
38 # Ignore all input until end of line
40 } elsif ( (ord($ch) & ~07) == 0x10 ) { # Mode controls
41 $enable = (ord($ch) & 0x01); # Emulate the text screen
42 } elsif ( $ch eq "\x0D" ) { # <CR> <Ctrl-M> Carriage return
44 } elsif ( $ch eq "\x0A" ) { # <LF> <Ctrl-J> Line feed
45 if ( $getting_file ) {
48 print $ch if ( $enable );
51 print $ch if ( $enable && !$getting_file );