From b2d5b135fa40925c5677705e12ac3347cdb1e839 Mon Sep 17 00:00:00 2001 From: hpa Date: Tue, 30 Nov 2004 23:58:00 +0000 Subject: [PATCH] Add a few more options, including the very useful autocr control code. --- com32/lib/sys/ansicon_write.c | 61 +++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/com32/lib/sys/ansicon_write.c b/com32/lib/sys/ansicon_write.c index 1e4e3cc..f7f0f86 100644 --- a/com32/lib/sys/ansicon_write.c +++ b/com32/lib/sys/ansicon_write.c @@ -72,6 +72,7 @@ static struct { int reverse; int fg; int bg; + int autocr; struct curxy saved_xy; enum ansi_state state; int nparms; /* Number of parameters seen */ @@ -84,6 +85,7 @@ static struct { .reverse = 0, .fg = 7, .bg = 0, + .autocr = 0, .saved_xy = { 0, 0 }, .state = st_init, .nparms = 0, @@ -114,9 +116,6 @@ static void ansicon_putchar(int ch) switch ( st.state ) { case st_init: switch ( ch ) { - case '\a': - /* Ignore beep */ - break; case '\b': if ( xy.x > 0 ) xy.x--; break; @@ -131,44 +130,58 @@ static void ansicon_putchar(int ch) case '\v': case '\f': xy.y++; + if ( st.autocr ) + xy.x = 0; break; case '\r': xy.x = 0; break; - case '\0': case 127: - /* Ignore null or delete */ + /* Ignore delete */ break; case 27: st.state = st_esc; break; default: /* Print character */ - ireg.eax.b[1] = 0x09; - ireg.eax.b[0] = ch; - ireg.ebx.b[1] = page; - ireg.ebx.b[0] = st.attr; - ireg.ecx.w[0] = 1; - __intcall(0x10, &ireg, NULL); - xy.x++; + if ( ch >= 32 ) { + ireg.eax.b[1] = 0x09; + ireg.eax.b[0] = ch; + ireg.ebx.b[1] = page; + ireg.ebx.b[0] = st.attr; + ireg.ecx.w[0] = 1; + __intcall(0x10, &ireg, NULL); + xy.x++; + } break; } break; case st_esc: - if ( ch == '[' ) { + switch ( ch ) { + case '%': + case '(': + case ')': + case '#': + /* Ignore this plus the subsequent character, allows + compatibility with Linux sequence to set charset */ + break; + case '[': st.state = st_csi; st.nparms = 0; memset(st.parms, 0, sizeof st.parms); - } else { - st.state = st_init; /* Discard ESC+other symbol */ + break; + default: + /* Ignore sequence */ + st.state = st_init; + break; } break; case st_csi: { int p0 = st.parms[0] ? st.parms[0] : 1; - + if ( ch >= '0' && ch <= '9' ) { st.parms[st.nparms] = st.parms[st.nparms]*10 + (ch-'0'); } else if ( ch == ';' ) { @@ -274,6 +287,20 @@ static void ansicon_putchar(int ch) } } break; + case 'h': + case 'l': + { + int set = (ch == 'h'); + switch ( st.parms[0] ) { + case 20: + st.autocr = set; + break; + default: + /* Ignore */ + break; + } + } + break; case 'm': { static const int ansi2pc[8] = { 0, 4, 2, 6, 1, 5, 3, 7 }; @@ -375,6 +402,8 @@ static void ansicon_putchar(int ch) case 'u': xy = st.saved_xy; break; + default: /* Includes CAN and SUB */ + break; /* Drop unknown sequence */ } st.state = st_init; } -- 2.7.4