summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-08-31 21:52:34 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-08-31 21:52:34 -0700
commit01f154bae839e37bfb7090eb90fb660a2639f954 (patch)
tree2adb1f77773494be26561b2184aaf942ce154624
parent3926b5fd360146a3eebc4baccf60df221ffb3fed (diff)
downloadsyslinux-01f154bae839e37bfb7090eb90fb660a2639f954.tar.gz
ansicon support for SOH # color table handling
-rw-r--r--com32/lib/sys/ansicon_write.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/com32/lib/sys/ansicon_write.c b/com32/lib/sys/ansicon_write.c
index 29f9d838..31f3e1aa 100644
--- a/com32/lib/sys/ansicon_write.c
+++ b/com32/lib/sys/ansicon_write.c
@@ -51,6 +51,9 @@ enum ansi_state {
st_init, /* Normal (no ESC seen) */
st_esc, /* ESC seen */
st_csi, /* CSI seen */
+ st_soh, /* SOH seen */
+ st_sohc, /* SOH # seen */
+ st_sohc1, /* SOH # digit seen */
};
#define MAX_PARMS 16
@@ -181,6 +184,9 @@ static void ansicon_putchar(int ch)
switch ( st.state ) {
case st_init:
switch ( ch ) {
+ case 1:
+ st.state = st_soh;
+ break;
case '\b':
if ( xy.x > 0 ) xy.x--;
break;
@@ -501,6 +507,45 @@ static void ansicon_putchar(int ch)
}
}
break;
+
+ case st_soh:
+ if ( ch == '#' )
+ state = st_sohc;
+ else
+ state = st_init;
+ break;
+
+ case st_sohc:
+ {
+ int n = (unsigned char)ch - '0';
+ if (n < 10) {
+ st.param[0] = n*10;
+ state = st_sohc1;
+ } else {
+ state = st_init;
+ }
+ }
+ break;
+
+ case st_sohc1:
+ {
+ int n = (unsigned char)ch - '0';
+ const char *p;
+
+ if (n < 10) {
+ st.param[0] += n;
+ /* Emulate the appropriate CSI m sequence */
+ if (st.param[0] < console_color_table_size) {
+ state = st_csi;
+ for (p = console_color_table[st.param[0]]; *p; p++)
+ ansicon_putchar(*p);
+ ansicon_putchar('m');
+ }
+ }
+
+ state = st_init;
+ }
+ break;
}
/* If we fell off the end of the screen, adjust */