summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2001-04-09 23:12:06 +0000
committerhpa <hpa>2001-04-09 23:12:06 +0000
commit562e0e2d3d55b6fe0c3787987fdee5623f09bf5f (patch)
treed37bc48dc2c1ef1b621c5df23f7e91097a2ab9d2
parent0083cb9d5e8647a4ecd485211f4d15bf8e046e2a (diff)
downloadsyslinux-562e0e2d3d55b6fe0c3787987fdee5623f09bf5f.tar.gz
Support mode controls.
-rwxr-xr-xsys2ansi.pl36
1 files changed, 22 insertions, 14 deletions
diff --git a/sys2ansi.pl b/sys2ansi.pl
index 7c39e7ed..d9bec7f7 100755
--- a/sys2ansi.pl
+++ b/sys2ansi.pl
@@ -7,39 +7,47 @@
@ansicol = (0,4,2,6,1,5,3,7);
$getting_file = 0;
+$enable = 1;
while ( read(STDIN, $ch, 1) > 0 ) {
if ( $ch eq "\x1A" ) { # <SUB> <Ctrl-Z> EOF
last;
} elsif ( $ch eq "\x0C" ) { # <FF> <Ctrl-L> Clear screen
- print "\x1b[2J" if ( !$getting_file );
+ print "\x1b[2J" if ( $enable && !$getting_file );
} elsif ( $ch eq "\x0F" ) { # <SI> <Ctrl-O> Attribute change
if ( !$getting_file ) {
if ( read(STDIN, $attr, 2) == 2 ) {
$attr = hex $attr;
- print "\x1b[0;";
- if ( $attr & 0x80 ) {
- print "5;";
- $attr &= ~0x80;
+ if ( $enable ) {
+ print "\x1b[0;";
+ if ( $attr & 0x80 ) {
+ print "5;";
+ $attr &= ~0x80;
+ }
+ if ( $attr & 0x08 ) {
+ print "1;";
+ $attr &= ~0x08;
+ }
+ printf "%d;%dm",
+ $ansicol[$attr >> 4] + 40, $ansicol[$attr & 7] + 30;
}
- if ( $attr & 0x08 ) {
- print "1;";
- $attr &= ~0x08;
- }
- printf "%d;%dm",
- $ansicol[$attr >> 4] + 40, $ansicol[$attr & 7] + 30;
}
}
} elsif ( $ch eq "\x18" ) { # <CAN> <Ctrl-X> Display image
# We can't display an image; pretend to be a text screen
# Ignore all input until end of line
$getting_file = 1;
+ } elsif ( (ord($ch) & ~07) == 0x10 ) { # Mode controls
+ $enable = (ord($ch) & 0x01); # Emulate the text screen
} elsif ( $ch eq "\x0D" ) { # <CR> <Ctrl-M> Carriage return
# Ignore
} elsif ( $ch eq "\x0A" ) { # <LF> <Ctrl-J> Line feed
- $getting_file = 0;
- print $ch;
+ if ( $getting_file ) {
+ $getting_file = 0;
+ } else {
+ print $ch if ( $enable );
+ }
} else {
- print $ch if ( !$getting_file );
+ print $ch if ( $enable && !$getting_file );
}
}