From ab7acea35176c76dd24b3419ca6f63c6e394712d Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Wed, 10 May 2023 12:06:33 +1200 Subject: [PATCH 01/14] Add xterm emulation option Not enabled by default (build with CKF_XTERM_EMULATION=yes Also made it possible to build with VT420 and VT520 emulation options (in theory), though there is currently no VT520 stuff implemented and very little VT420 so not much point in turning these on. --- kermit/k95/ckoco3.c | 55 ++++++++++++++++++++++++------------ kermit/k95/ckocon.h | 4 ++- kermit/k95/ckokey.c | 6 ++++ kermit/k95/ckuus5.c | 11 +++++++- kermit/k95/ckuus7.c | 22 +++++++++++++-- kermit/k95/ckuusr.h | 54 +++++++++++++++++++++++++++-------- kermit/k95/feature_flags.mak | 12 ++++++++ 7 files changed, 130 insertions(+), 34 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index bde0c95f..1ff8a656 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -461,12 +461,14 @@ extern int send_c1_usr ; /* User default for send_c1 */ * 13 - Local editing 15 - Technical character set * 16 - Locator device port + ? 17 - Terminal state interrogation (is this an xterm extension??) * 18 - Windowing Capability * 19 - Dual sessions * 21 - Horizontal Scrolling 22 - Color 23 - Greek * 24 - Turkish + ? 28 - Rectangular editing (is this an xterm extension??) 42 - ISO Latin-2 44 - PC Term 45 - Soft-key mapping @@ -509,10 +511,12 @@ struct tt_info_rec tt_info[] = { /* Indexed by terminal type */ "WY370", {"WYSE-370","WYSE370","WY350",NULL},"[?63;1;2;6;8;9;15;44c", /* WYSE 370 (same as VT320) */ "97801", {"SNI-97801",NULL}, "[?62;1;2;6;8;9;15;44c", /* Sinix 97801 */ "AAA", { "ANNARBOR", "AMBASSADOR",NULL}, "11;00;00", /* Ann Arbor Ambassador */ -#ifdef COMMENT - "VT420", {"DEC-VT420","DEC-VT400","VT400",NULL}, "[?64;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT420 */ - "VT525", {"DEC-VT525","DEC-VT500","VT500",NULL}, "[?65;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT520 */ -#endif /* COMMENT */ + + "VT420", {"DEC-VT420","DEC-VT400","VT400",NULL}, "[?64;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT420 */ + "VT420PC", {"DEC-VT420","DEC-VT400","VT400",NULL}, "[?64;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT420 w/ PC keyboard*/ + "VT525", {"DEC-VT525","DEC-VT500","VT500",NULL}, "[?65;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT520 */ + "VT525PC", {"DEC-VT525","DEC-VT500","VT500",NULL}, "[?65;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT520 w/ PC keyboard*/ + "TVI910", {"TELEVIDEO-910","TVI910+""910",NULL}, "TVS 910 REV.I\r", /* TVI 910+ */ "TVI925", {"TELEVIDEO-925","925",NULL}, "TVS 925 REV.I\r", /* TVI 925 */ "TVI950", {"TELEVIDEO-950","950",NULL}, "1.0,0\r", /* TVI 950 */ @@ -520,6 +524,16 @@ struct tt_info_rec tt_info[] = { /* Indexed by terminal type */ "ADM5", {NULL}, "", /* LSI ADM 5 */ "VTNT", {NULL}, "", /* Microsoft NT VT */ "IBM3101",{"I3101",NULL}, "" /* IBM 31xx */ +#ifdef CK_XTERM_EMULATION + ,"XTERM", {NULL}, "[?64;1;2;6;8;9;15;22c", /* XTerm */ + /* TODO: Xterm also supports (as of 2023-05-08): + * 16; Locator port + * 17; Terminal state interrogation + * 18; User windows + * 21; Horizontal scrolling + * 28 Rectangular editing + * */ +#endif }; int max_tt = TT_MAX; /* Highest terminal type */ @@ -12900,12 +12914,14 @@ vtcsi(void) } else /* ANSI.SYS save cursor position */ if ( ISANSI(tt_type_mode) || - IS97801(tt_type_mode)) + IS97801(tt_type_mode) || + ISXTERM(tt_type_mode)) savecurpos(VTERM,0); break; case 'u': /* ANSI.SYS restore cursor position */ if ( ISANSI(tt_type_mode) || - IS97801(tt_type_mode)) + IS97801(tt_type_mode) || + ISXTERM(tt_type_mode)) restorecurpos(VTERM,0); break; case 'U': /* SCO ANSI Reset Initial Screen */ @@ -13210,7 +13226,7 @@ vtcsi(void) } break; case 'r': /* DECCARA - Change Attr in Rect Area */ - if ( ISVT420(tt_type_mode) ) + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode)) { int w, h, x, y, z; /* @@ -13333,7 +13349,7 @@ vtcsi(void) } break; case 't': /* DECRARA - Reverse Attr in Rect Area */ - if ( ISVT420(tt_type_mode) ) + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode)) { int w, h, x, y, z; /* @@ -13443,7 +13459,7 @@ vtcsi(void) } break; case 'v': /* DECCRA - Copy Rect Area */ - if ( ISVT420( tt_type_mode) ) + if ( ISVT420( tt_type_mode) || ISXTERM(tt_type_mode)) { USHORT * data = NULL; int w, h, x, y; @@ -13505,7 +13521,7 @@ vtcsi(void) } break; case 'x': /* DECFRA - Fill Rect Area */ - if ( ISVT420(tt_type_mode) ) { + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode) ) { /* pn[1] - fill char */ /* pn[2] - top-line border default=1 */ /* pn[3] - left-col border default=1 */ @@ -13530,7 +13546,7 @@ vtcsi(void) } break; case 'z': /* DECERA - Erase Rect Area */ - if ( ISVT420(tt_type_mode) ) { + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode) ) { /* pn[1] - top-line border default=1 */ /* pn[2] - left-col border default=1 */ /* pn[3] - bot-line border default=Height */ @@ -13552,7 +13568,7 @@ vtcsi(void) } break; case '{': /* DECSERA - Selective Erase Rect Area */ - if ( ISVT420(tt_type_mode) ) { + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode) ) { /* pn[1] - top-line border default=1 */ /* pn[2] - left-col border default=1 */ /* pn[3] - bot-line border default=Height */ @@ -13579,7 +13595,7 @@ vtcsi(void) achar = (escnext<=esclast)?escbuffer[escnext++]:0; switch (achar) { case 'x': /* DECSACE - Select Attribute Change Extent */ - if ( ISVT420(tt_type_mode) ) + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode) ) { /* * 0 - DECCARA or DECRARA affect the stream of character @@ -14004,7 +14020,8 @@ vtcsi(void) if ( ISHFT(tt_type_mode) || ISLINUX(tt_type_mode) || ISQANSI(tt_type_mode) || - ISANSI(tt_type_mode)) { + ISANSI(tt_type_mode) || + ISXTERM(tt_type_mode)) { if ( pn[1] < 1 || pn[1] > VscrnGetWidth(VTERM) ) break; lgotoxy(VTERM,pn[1],wherey[VTERM]); @@ -14218,7 +14235,8 @@ vtcsi(void) case 9: /* DECINLM - Interlace */ /* XTERM - Send Mouse X & Y on button press */ #ifdef OS2MOUSE - if (ISLINUX(tt_type_mode) || ISANSI(tt_type_mode)) { + if (ISLINUX(tt_type_mode) || ISANSI(tt_type_mode) || + ISXTERM(tt_type_mode)) { /* The linux console terminal, as well as many * other terminal emulators, implement XTERM * mouse tracking */ @@ -14830,7 +14848,8 @@ vtcsi(void) case 9: /* DECINLM - Interlace */ /* XTERM - Don't Send Mouse X&Y on button press */ #ifdef OS2MOUSE - if (ISLINUX(tt_type_mode) || ISANSI(tt_type_mode)) { + if (ISLINUX(tt_type_mode) || ISANSI(tt_type_mode) || + ISXTERM(tt_type_mode)) { /* The linux console terminal, as well as many * other terminal emulators, implement XTERM * mouse tracking */ @@ -18251,7 +18270,7 @@ vtcsi(void) achar = (escnext<=esclast)?escbuffer[escnext++]:0; switch (achar) { case '~': - if ( ISVT420(tt_type_mode) ) { + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode) ) { /* DECDC - Delete Column */ viocell cell ; cell.c = SP ; @@ -18273,7 +18292,7 @@ vtcsi(void) } break; case '}': - if ( ISVT420(tt_type_mode) ) { + if ( ISVT420(tt_type_mode) || ISXTERM(tt_type_mode) ) { /* DECIC - Insert Column */ viocell cell ; cell.c = SP ; diff --git a/kermit/k95/ckocon.h b/kermit/k95/ckocon.h index 13a9bb78..c8c003a9 100644 --- a/kermit/k95/ckocon.h +++ b/kermit/k95/ckocon.h @@ -263,7 +263,9 @@ typedef struct cell_struct { /* to be used with VioWrtNCell() */ #else /* CKOUNI_OUT */ unsigned char c ; /* character */ #endif /* CKOUNI_OUT */ - unsigned char a ; /* attribute */ + unsigned char a ; /* attribute (foreground & background + * color) - see comment further up by + * swapcolors and byteswapcolors */ } viocell ; typedef struct videoline_struct { diff --git a/kermit/k95/ckokey.c b/kermit/k95/ckokey.c index dd92c2d8..df902950 100644 --- a/kermit/k95/ckokey.c +++ b/kermit/k95/ckokey.c @@ -7688,6 +7688,8 @@ defaultkeymap( int terminal ) { return defvt100km(terminal); case TT_BEOS: return defbetermkm( terminal ); + case TT_XTERM: /* TODO: What should the default xterm keymap be? */ + return defvtpckm( terminal ); case TT_LINUX: return deflinuxkm( terminal ); case TT_SCOANSI: @@ -7700,10 +7702,14 @@ defaultkeymap( int terminal ) { return defannarbor( terminal ); case TT_VT220: case TT_VT320: + case TT_VT420: + case TT_VT520: case TT_WY370: return defvt200km( terminal ); case TT_VT220PC: case TT_VT320PC: + case TT_VT420PC: + case TT_VT520PC: return defvtpckm( terminal ); case TT_97801: return defsnikm( terminal ); diff --git a/kermit/k95/ckuus5.c b/kermit/k95/ckuus5.c index fb15aae2..08d30b5f 100644 --- a/kermit/k95/ckuus5.c +++ b/kermit/k95/ckuus5.c @@ -5205,6 +5205,12 @@ struct keytab shokeymtab[] = { "vt220pc", TT_VT220PC, 0, "vt320", TT_VT320, 0, "vt320pc", TT_VT320PC, 0, +#ifdef CK_VT420_520_EMULATION + "vt420", TT_VT420, 0, + "vt420pc", TT_VT420PC, 0, + "vt520", TT_VT520, 0, + "vt520pc", TT_VT520PC, 0 , +#endif /* CK_VT420_520_EMULATION */ "vt52", TT_VT52, 0, "wp", TT_KBM_WP, 0, "wy160", TT_WY160, 0, @@ -5215,7 +5221,10 @@ struct keytab shokeymtab[] = { "wyse30", TT_WY30, CM_INV, "wyse370", TT_WY370, CM_INV, "wyse50", TT_WY50, CM_INV, - "wyse60", TT_WY60, CM_INV + "wyse60", TT_WY60, CM_INV, +#ifdef CK_XTERM_EMULATION + "xterm", TT_XTERM, 0 +#endif }; int nshokeym = (sizeof(shokeymtab) / sizeof(struct keytab)); #endif /* OS2 */ diff --git a/kermit/k95/ckuus7.c b/kermit/k95/ckuus7.c index e9b22de4..e6c7ecb2 100644 --- a/kermit/k95/ckuus7.c +++ b/kermit/k95/ckuus7.c @@ -1588,6 +1588,12 @@ struct keytab ttyptab[] = { { "vt220pc", TT_VT220PC,0 }, { "vt320", TT_VT320, 0 }, { "vt320pc", TT_VT320PC,0 }, +#ifdef CK_VT420_520_EMULATION + { "vt420", TT_VT420, 0 }, + { "vt420pc", TT_VT420PC, 0 }, + { "vt520", TT_VT520, 0 }, + { "vt520pc", TT_VT520PC, 0 }, +#endif /* CK_VT420_520_EMULATION */ { "vt52", TT_VT52, 0 }, #ifdef NT { "vtnt", TT_VTNT, 0 }, @@ -1602,7 +1608,10 @@ struct keytab ttyptab[] = { { "wyse30", TT_WY30, CM_INV }, { "wyse370", TT_WY370, CM_INV }, { "wyse50", TT_WY50, CM_INV }, - { "wyse60", TT_WY60, CM_INV } + { "wyse60", TT_WY60, CM_INV }, +#ifdef CK_XTERM_EMULATION + { "xterm", TT_XTERM, 0 } +#endif }; int nttyp = (sizeof(ttyptab) / sizeof(struct keytab)); @@ -1659,6 +1668,12 @@ struct keytab ttkeytab[] = { { "vt220pc", TT_VT220PC, 0 }, { "vt320", TT_VT320, 0 }, { "vt320pc", TT_VT320PC, 0 }, +#ifdef CK_VT420_520_EMULATION + { "vt420", TT_VT420, 0 }, + { "vt420pc", TT_VT420PC, 0 }, + { "vt520", TT_VT520, 0 }, + { "vt520pc", TT_VT520PC, 0 }, +#endif /* CK_VT420_520_EMULATION */ { "vt52", TT_VT52, 0 }, { "vtnt", TT_VTNT, CM_INV }, { "wp", TT_KBM_WP, 0 }, /* Word Perfect mode */ @@ -1670,7 +1685,10 @@ struct keytab ttkeytab[] = { { "wyse30", TT_WY30, CM_INV }, { "wyse370", TT_WY370, CM_INV }, { "wyse50", TT_WY50, CM_INV }, - { "wyse60", TT_WY60, CM_INV } + { "wyse60", TT_WY60, CM_INV }, +#ifdef CK_XTERM_EMULATION + { "xterm", TT_XTERM, 0 } +#endif }; int nttkey = (sizeof(ttkeytab) / sizeof(struct keytab)); diff --git a/kermit/k95/ckuusr.h b/kermit/k95/ckuusr.h index d9b35ba9..fcede4d5 100644 --- a/kermit/k95/ckuusr.h +++ b/kermit/k95/ckuusr.h @@ -1056,15 +1056,44 @@ struct stringint { /* String and (wide) integer */ #define TT_WY370 33 /* WYSE 370 ANSI Terminal */ #define TT_97801 34 /* Sinix 97801-5xx terminal */ #define TT_AAA 35 /* Ann Arbor Ambassador */ -#define TT_TVI910 36 /* TVI 910+ */ -#define TT_TVI925 37 /* TVI 925 */ -#define TT_TVI950 38 /* TVI950 */ -#define TT_ADM3A 39 /* LSI ADM 3A */ -#define TT_ADM5 40 /* LSI ADM 5 */ -#define TT_VTNT 41 /* Microsoft NT Virtual Terminal */ + +#define TT_VT420 36 /* DEC VT-420 */ +#define TT_VT420PC 37 /* DEC VT-420 with PC keyboard */ +#define TT_VT520 38 /* DEC VT-520/525 */ +#define TT_VT520PC 39 /* DEC VT-520/525 with PC keyboard */ + +#define TT_TVI910 40 /* TVI 910+ */ +#define TT_TVI925 41 /* TVI 925 */ +#define TT_TVI950 42 /* TVI950 */ +#define TT_ADM3A 43 /* LSI ADM 3A */ +#define TT_ADM5 44 /* LSI ADM 5 */ +#define TT_VTNT 45 /* Microsoft NT Virtual Terminal */ +#define TT_IBM3101 46 /* IBM 3101 - not implemented */ +#define TT_XTERM 47 /* xterm! */ + +/* TODO: Graphics! + * -> This would be Windows/KUI only - no way of supporting it in + * the console or OS/2 versions + * -> Need to figure out how to implement graphics at all + * -> How do we represent graphics in the screen buffer? + * -> How do we render and scroll text + graphics? + * -> Sixel is the priority and probably the easiest. The rest are rarely used. + * -> The following graphics terminals require: + * VT125: ReGIS + * VT241: All of the above plus Sixel (VT240: no colour) + * VT340: All of the above plus Tektronix 4010 graphics (VT330: no colour) + * TEK40: 4010, 4014 emulation. If 4010 gets implemented for VT340 emulation + * we may as well go all the way and provide Tektronix emulation directly too. + * VT55, VT105: waveform graphics + * XTerm: Sixel, ReGIS, Tektronix 4015 + */ + +#ifdef CK_XTERM_EMULATION +#define TT_MAX TT_XTERM +#else #define TT_MAX TT_VTNT -#define TT_VT420 96 /* DEC VT-420 */ -#define TT_VT520 97 /* DEC VT-520/525 */ +#endif /* CK_XTERM_EMULATION */ + #define TT_TEK40 99 /* Tektronix 401x */ #define TT_KBM_EMACS TT_MAX+1 #define TT_KBM_HEBREW TT_MAX+2 @@ -1092,10 +1121,11 @@ struct stringint { /* String and (wide) integer */ #define ISTVI910(x) (x == TT_TVI910) #define ISTVI925(x) (x == TT_TVI925) #define ISTVI950(x) (x == TT_TVI950) +#define ISXTERM(x) (x == TT_XTERM) #define ISVT52(x) (x == TT_VT52 || x == TT_H19) -#ifdef COMMENT -#define ISVT520(x) (x == TT_VT520) -#define ISVT420(x) (x >= TT_VT420 && x <= TT_VT520) +#ifdef CK_VT420_520_EMULATION +#define ISVT520(x) (x == TT_VT520 || x == TT_VT520PC) +#define ISVT420(x) (x >= TT_VT420 && x <= TT_VT520PC) #else /* COMMENT */ /* Since we do not yet support 420/520 extend 320 */ #define ISVT520(x) (ISVT320(x)) @@ -1104,7 +1134,7 @@ struct stringint { /* String and (wide) integer */ #define ISVT320(x) (x >= TT_VT320 && x <= TT_AAA) #define ISVT220(x) (x >= TT_VT220 && x <= TT_AAA || \ ISBEOS(x) || ISQANSI(x) || \ - ISLINUX(x) || ISSUN(x)) + ISLINUX(x) || ISSUN(x) || ISXTERM(x)) #define ISVT102(x) (x >= TT_VIP7809 && x <= TT_BA80 || \ x == TT_VT102 || ISVT220(x)) #define ISVT100(x) (x == TT_VT100 || ISVT102(x)) diff --git a/kermit/k95/feature_flags.mak b/kermit/k95/feature_flags.mak index eac25780..cb75eb02 100644 --- a/kermit/k95/feature_flags.mak +++ b/kermit/k95/feature_flags.mak @@ -478,3 +478,15 @@ DISABLED_FEATURE_DEFS = $(DISABLED_FEATURE_DEFS) -DNOSCROLLWHEEL ENABLED_FEATURES = $(ENABLED_FEATURES) Windows-Unicode ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_NT_UNICODE -DUNICODE -D_UNICODE !endif + +# Enable xterm emulation option +!if "$(CKF_XTERM_EMULATION)" == "yes" +ENABLED_FEATURES = $(ENABLED_FEATURES) Xterm-emulation +ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_XTERM_EMULATION +!endif + +# Enable VT420 and VT520 emulation options +!if "$(CKF_VT420_520_EMULATION)" == "yes" +ENABLED_FEATURES = $(ENABLED_FEATURES) Xterm-emulation +ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_VT420_520_EMULATION +!endif From 625141bff886e560baa4a4af84680da82e6764e8 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Wed, 10 May 2023 12:08:03 +1200 Subject: [PATCH 02/14] Make sgrcols lookups safer Certain escape sequences were probably able to trigger and out-of-bounds array access. --- kermit/k95/ckoco3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 1ff8a656..938648ba 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -13630,7 +13630,7 @@ vtcsi(void) /* pn[1] contains new color */ if ( !sgrcolors ) break; - borderattribute = sgrcols[pn[1]%10]; + borderattribute = sgrcols[pn[1]%8]; setborder(); } else if ( ISBA80(tt_type_mode) ) { @@ -16342,7 +16342,7 @@ vtcsi(void) if ( 0 && ISQANSI(tt_type_mode) ) l = pn[j] - 30; else - l = sgrcols[pn[j] - 30]; + l = sgrcols[(pn[j] - 30)%8]; if (decscnm) { i = (attribute & 0x8F); attribute = (i | ((l << 4))); @@ -16415,7 +16415,7 @@ vtcsi(void) if ( 0 && ISQANSI(tt_type_mode) ) l = pn[j] - 40; else - l = sgrcols[pn[j] - 40]; + l = sgrcols[(pn[j] - 40)%8]; if (!decscnm) { i = (attribute & 0x8F); attribute = (i | ((l << 4))); @@ -16518,7 +16518,7 @@ vtcsi(void) if ( 0 && ISQANSI(tt_type_mode) ) l = pn[j] - 90; else - l = sgrcols[pn[j] - 90]; + l = sgrcols[(pn[j] - 90)%8]; l += 8; /* 8th bit high */ if (decscnm #ifdef COMMENT @@ -16578,7 +16578,7 @@ vtcsi(void) if ( 0 && ISQANSI(tt_type_mode) ) l = pn[j] - 100; else - l = sgrcols[pn[j] - 100]; + l = sgrcols[(pn[j] - 100)%8]; l += 8; /* 8th bit high */ if (!decscnm #ifdef COMMENT From 4a25be235ab01b1696866580ea333f131b276c04 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Wed, 10 May 2023 12:10:20 +1200 Subject: [PATCH 03/14] xterm handles these SGR codes differently Perhaps some later VT terminals do too? The xterm paths haven't been implemented yet but at least the wrong thing won't happen now if something tries to do, eg, double-underline. --- kermit/k95/ckoco3.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 938648ba..dbab6d78 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -16157,8 +16157,14 @@ vtcsi(void) /* 8 - 12 are ANSI X3.64 */ case 8: /* Turn on INVISIBLE */ - case 9: /* Turn on INVISIBLE (QANSI) */ attrib.invisible = TRUE; /* see wrtch */ + break; + case 9: + if (ISXTERM(tt_type_mode)) { /* ECMA-48 3rd edition */ + /* TODO: XTERM: crossed-out characters */ + } else { /* Turn on INVISIBLE (QANSI) */ + attrib.invisible = TRUE; /* see wrtch */ + } break; case 10: /* Select Primary font */ @@ -16276,11 +16282,15 @@ vtcsi(void) charset(cs94,'U',&G[i]); } - case 21: /* Set Normal Intensity */ - if (attrib.bold) - attrib.bold = FALSE; - if (attrib.dim) - attrib.dim = FALSE; + case 21: + if (ISXTERM(tt_type_mode)) { /* ECMA-48 3rd */ + /* TODO: XTERM: Doubly-underlined */ + } else { /* Set Normal Intensity */ + if (attrib.bold) + attrib.bold = FALSE; + if (attrib.dim) + attrib.dim = FALSE; + } break; case 22: /* Turn BOLD Off */ if (attrib.bold) @@ -16322,10 +16332,18 @@ vtcsi(void) attrib.reversed = FALSE; break; case 28:/* Turn INVISIBLE Off */ - case 29:/* QANSI */ if (!attrib.invisible) break; - attrib.invisible = FALSE; + attrib.invisible = FALSE; + break; + case 29: + if (ISXTERM(tt_type_mode)) { + /* TODO: XTERM: Not corssed-out (ECMA-48 3rd) */ + } else { /* QANSI - Turn INVISIBLE off */ + if (!attrib.invisible) + break; + attrib.invisible = FALSE; + } break; case 30: /* Colors */ @@ -16384,6 +16402,7 @@ vtcsi(void) case 38: /* enable underline option */ break; case 39: /* disable underline option */ + /* TODO: XTERM: Set foreground color to default, ECMA-48 */ /* Supported by SCO ANSI */ /* QANSI - restore fg color saved with */ /* CSI = Pn F */ @@ -16455,6 +16474,7 @@ vtcsi(void) } break; case 49: + /* TODO: XTERM: Set background color to default, ECMA-48 */ /* Supported by SCO ANSI */ /* QANSI - restore bg color saved with */ /* CSI = Pn G */ @@ -16504,7 +16524,7 @@ vtcsi(void) */ break; } - case 90: /* Colors */ + case 90: /* Bright Colors (aixterm?) */ case 91: case 92: case 93: @@ -16563,7 +16583,10 @@ vtcsi(void) } } break; - case 100: + case 100: /* TODO: For aixterm and perhaps others, these should set + * bright foreground/background colours ( + /* TODO: rxvt: set forground and background to default + * Aixterm (and probably others): set background to black */ case 101: case 102: case 103: From b77ebfa13c6f8985c302bd7ef6985faa312ced14 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Wed, 10 May 2023 12:10:50 +1200 Subject: [PATCH 04/14] Fix failure to handle DECERA with no parameters --- kermit/k95/ckoco3.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index dbab6d78..f0265895 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -12936,8 +12936,14 @@ vtcsi(void) break; } break; - case '$': - achar = (escnext<=esclast)?escbuffer[escnext++]:0; + case '$': {/* These things below should probably only appear in a DCS string */ + int acharTmp = (escnext <= esclast) ? escbuffer[escnext + 1] : 0; + if (acharTmp != '}' && acharTmp != '-' && acharTmp != '~') { + /* Next character isn't something we handle here - skip ahead */ + goto LB2003; + } + + achar = (escnext <= esclast) ? escbuffer[escnext++] : 0; switch (achar) { case '}': /* DECSASD - Select Active Status Display */ @@ -12950,6 +12956,7 @@ vtcsi(void) break; } break; + } case 'S': if ( private && ISAIXTERM(tt_type_mode) ) { /* Show Status Line */ From f7823921a4bc6961d468f7eefa4e2a026214aaf1 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Thu, 11 May 2023 07:52:53 +1200 Subject: [PATCH 05/14] Fix issues with DECERA Now passes all tests --- kermit/k95/ckoco3.c | 54 +++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index f0265895..1850ba44 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -13558,20 +13558,46 @@ vtcsi(void) /* pn[2] - left-col border default=1 */ /* pn[3] - bot-line border default=Height */ /* pn[4] - Right border default=Width */ - if ( k < 4 || pn[4] > VscrnGetWidth(VTERM) || - pn[4] < 1 ) - pn[4] = VscrnGetWidth(VTERM); - if ( k < 3 || pn[3] > VscrnGetHeight(VTERM) - -(tt_status[VTERM]?1:0) || pn[3] < 1 ) - pn[3] = VscrnGetHeight(VTERM) - -(tt_status[VTERM]?1:0); - if ( k < 2 || pn[2] < 1 ) - pn[2] = 1 ; - if ( k < 1 || pn[1] < 1 ) - pn[1] = 1 ; - clrrect_escape( VTERM, pn[1], pn[2], - pn[3], pn[4], SP ) ; - VscrnIsDirty(VTERM); + + int maxHeight, maxWidth; + int top, left, bot, right; + + maxHeight = VscrnGetHeight(VTERM) + -(tt_status[VTERM]?1:0); + maxWidth = VscrnGetWidth(VTERM); + + top = pn[1]; + left = pn[2]; + bot = pn[3]; + right = pn[4]; + + /* Defaults: the entire screen */ + if (k < 4 || right < 1) right = maxWidth; + if (k < 3 || bot < 1) bot = maxHeight; + if (k < 2 || left < 1) left = 1; + if (k < 1 || top < 1) top = 1; + + /* Coordinates are all relative to DECOM setting */ + if (relcursor) { + top += margintop - 1; + bot += margintop - 1; + left += marginleft - 1; + right += marginleft - 1; + } + + if (right > maxWidth) right = maxWidth; + if (bot > maxHeight) bot = maxHeight; + + /* Do nothing if the rect is invalid (bottom > top + * or left > right) */ + if (top <= bot && left <= right + && top > 0 && left > 0) { + clrrect_escape(VTERM, top, left, + bot, right, SP); + VscrnIsDirty(VTERM); + } else { + debug(F111, "DECERA", "bad parameter(s) - ignore", 0); + } } break; case '{': /* DECSERA - Selective Erase Rect Area */ From ba3840c0afe33b27e26d034309c037838f97f967 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Thu, 11 May 2023 07:53:17 +1200 Subject: [PATCH 06/14] typo --- kermit/k95/ckoco3.c | 2 +- kermit/k95/feature_flags.mak | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 1850ba44..d59cce46 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -6254,7 +6254,7 @@ doreset(int x) { /* x = 0 (soft), nonzero (hard) */ vtnt_index = 0; vtnt_read = VTNT_MIN_READ; - /* Disable y active mouse reporting modes */ + /* Disable any active mouse reporting modes */ mouse_reporting_mode &= ~(MOUSEREPORTING_ACTIVE | MOUSEREPORTING_UNSUPPORTED); dokverb(VTERM,K_ENDSCN); diff --git a/kermit/k95/feature_flags.mak b/kermit/k95/feature_flags.mak index cb75eb02..409f7951 100644 --- a/kermit/k95/feature_flags.mak +++ b/kermit/k95/feature_flags.mak @@ -487,6 +487,6 @@ ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_XTERM_EMULATION # Enable VT420 and VT520 emulation options !if "$(CKF_VT420_520_EMULATION)" == "yes" -ENABLED_FEATURES = $(ENABLED_FEATURES) Xterm-emulation +ENABLED_FEATURES = $(ENABLED_FEATURES) vt420-vt520-emulation ENABLED_FEATURE_DEFS = $(ENABLED_FEATURE_DEFS) -DCK_VT420_520_EMULATION !endif From 258a85dbdbab1b501c8e99461e73a62ee69cdc98 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Thu, 11 May 2023 08:12:52 +1200 Subject: [PATCH 07/14] XTWINOPS: Implement window state report --- kermit/k95/cknwin.c | 4 ++++ kermit/k95/ckoco3.c | 9 +++++++++ kermit/k95/ckuus3.c | 1 + kermit/k95/kui/ikui.cxx | 7 +++++++ kermit/k95/kui/ikui.h | 1 + 5 files changed, 22 insertions(+) diff --git a/kermit/k95/cknwin.c b/kermit/k95/cknwin.c index b2db8123..45b225d7 100644 --- a/kermit/k95/cknwin.c +++ b/kermit/k95/cknwin.c @@ -1539,6 +1539,10 @@ gui_win_run_mode(int x) return(1); } +int gui_get_win_run_mode() { + return KuiGetTerminalRunMode(); +} + int gui_file_dialog(char * preface, char * prompt, int fc, char * def, char * result, int rlength) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index d59cce46..bbdf31b4 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -18033,6 +18033,15 @@ vtcsi(void) } break; case 11: /* Report state of Window (normal/iconified) */ +#ifdef KUI + char buf[20]; + if (gui_get_win_run_mode() == 2) { + sprintf(buf, "%c%dt", _CSI, 2); /* Iconified */ + } else { + sprintf(buf, "%c%dt", _CSI, 1); /* Not iconified */ + } + sendchars(buf, strlen(buf)); +#endif break; } } diff --git a/kermit/k95/ckuus3.c b/kermit/k95/ckuus3.c index 8ea89bed..1839349b 100644 --- a/kermit/k95/ckuus3.c +++ b/kermit/k95/ckuus3.c @@ -2607,6 +2607,7 @@ _PROTOTYP(int gui_mtxt_dialog,(char *,int,struct txtbox [])); _PROTOTYP(int gui_position,(int, int)); _PROTOTYP(int gui_resize_mode,(int)); _PROTOTYP(int gui_win_run_mode,(int)); +_PROTOTYP(int gui_get_win_run_mode,()); _PROTOTYP(int gui_file_dialog,(char *,char *, int, char *, char *, int)); extern int gui_dialog; #endif /* KUI */ diff --git a/kermit/k95/kui/ikui.cxx b/kermit/k95/kui/ikui.cxx index fcf4adb2..df739b34 100644 --- a/kermit/k95/kui/ikui.cxx +++ b/kermit/k95/kui/ikui.cxx @@ -230,6 +230,13 @@ KuiSetTerminalRunMode(int x) } } +int KuiGetTerminalRunMode() { + long ret = GetWindowLong(kui->getTerminal()->hwnd(), GWL_STYLE); + + if (ret & WS_MINIMIZE) return 2; + return 1; +} + int KuiFileDialog(char * title, char * def, char * result, int rlen, BOOL downloadButton, BOOL openFile) diff --git a/kermit/k95/kui/ikui.h b/kermit/k95/kui/ikui.h index 77ad17f2..e6a30573 100644 --- a/kermit/k95/kui/ikui.h +++ b/kermit/k95/kui/ikui.h @@ -66,6 +66,7 @@ void KuiSetTerminalSize(int, int); void KuiSetTerminalResizeMode(int); int KuiGetTerminalResizeMode(void); void KuiSetTerminalRunMode(int); +int KuiGetTerminalRunMode(); #define STATUS_CMD_TERM 0 #define STATUS_LOCUS 1 #define STATUS_PROTO 2 From a5f88a783a657d13d6c339bc33936202885a09a0 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 12 May 2023 12:22:14 +1200 Subject: [PATCH 08/14] XTWINOPS: Report screen size in pixels and chars --- kermit/k95/ckoco3.c | 24 ++++++++++++++++++++++-- kermit/k95/kui/ikui.cxx | 22 ++++++++++++++++++++++ kermit/k95/kui/ikui.h | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index bbdf31b4..93dd3b0d 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -17971,12 +17971,32 @@ vtcsi(void) break; } } - case 15: /* Report size of the screen in pixels */ + case 15: { /* Report size of the screen in pixels */ + int w, h; + char buf[30]; + KuiGetTerminalMaximisedSize(FALSE, &w, &h); + + if (w < 50000 && h < 50000) { /* Limit response length */ + sprintf(buf, "%c5;%d;%dt", _CSI, h, w); + sendchars(buf, strlen(buf)); + } break; + } case 16: /* Report xterm character cell size in pixels */ break; - case 19: /* Report the size of the screen in characters */ + case 19: { /* Report the size of the screen in characters */ +#ifdef KUI + int w, h; + char buf[30]; + KuiGetTerminalMaximisedSize(TRUE, &w, &h); + + if (w < 50000 && h < 50000) { /* Limit response length */ + sprintf(buf, "%c9;%d;%dt", _CSI, h, w); + sendchars(buf, strlen(buf)); + } +#endif break; + } case 20: /* Report Icon Label */ break; case 21: /* Report Window Label */ diff --git a/kermit/k95/kui/ikui.cxx b/kermit/k95/kui/ikui.cxx index df739b34..7ee57a0e 100644 --- a/kermit/k95/kui/ikui.cxx +++ b/kermit/k95/kui/ikui.cxx @@ -237,6 +237,28 @@ int KuiGetTerminalRunMode() { return 1; } +int widthToChars(int width) { + return width / kui->getTerminal()->getKFont()->getFontW(); +} + +int heightToChars(int height) { + return height / kui->getTerminal()->getKFont()->getFontSpacedH(); +} + +void KuiGetTerminalMaximisedSize(BOOL inChars, int* width, int* height) { + RECT rec; + BOOL r = SystemParametersInfo( + SPI_GETWORKAREA,0, &rec, 0); + + *width = rec.right - rec.left; + *height = rec.bottom - rec.top; + + if (inChars) { + *width = widthToChars(*width); + *height = heightToChars(*height); + } +} + int KuiFileDialog(char * title, char * def, char * result, int rlen, BOOL downloadButton, BOOL openFile) diff --git a/kermit/k95/kui/ikui.h b/kermit/k95/kui/ikui.h index e6a30573..ef59765b 100644 --- a/kermit/k95/kui/ikui.h +++ b/kermit/k95/kui/ikui.h @@ -67,6 +67,7 @@ void KuiSetTerminalResizeMode(int); int KuiGetTerminalResizeMode(void); void KuiSetTerminalRunMode(int); int KuiGetTerminalRunMode(); +void KuiGetTerminalMaximisedSize(BOOL inChars, int* width, int* height); #define STATUS_CMD_TERM 0 #define STATUS_LOCUS 1 #define STATUS_PROTO 2 From ad643250062d242aa25f56ff0cb6535d2332fec1 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sun, 14 May 2023 10:26:57 +1200 Subject: [PATCH 09/14] Fix building with XTERM emulation turned off --- kermit/k95/ckoco3.c | 4 +++- kermit/k95/ckuusr.h | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 93dd3b0d..5d4107cd 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -522,8 +522,10 @@ struct tt_info_rec tt_info[] = { /* Indexed by terminal type */ "TVI950", {"TELEVIDEO-950","950",NULL}, "1.0,0\r", /* TVI 950 */ "ADM3A", {NULL}, "", /* LSI ADM 3A */ "ADM5", {NULL}, "", /* LSI ADM 5 */ - "VTNT", {NULL}, "", /* Microsoft NT VT */ + "VTNT", {NULL}, "" /* Microsoft NT VT */ +#ifdef COMMENT "IBM3101",{"I3101",NULL}, "" /* IBM 31xx */ +#endif #ifdef CK_XTERM_EMULATION ,"XTERM", {NULL}, "[?64;1;2;6;8;9;15;22c", /* XTerm */ /* TODO: Xterm also supports (as of 2023-05-08): diff --git a/kermit/k95/ckuusr.h b/kermit/k95/ckuusr.h index fcede4d5..31a199b4 100644 --- a/kermit/k95/ckuusr.h +++ b/kermit/k95/ckuusr.h @@ -1068,8 +1068,12 @@ struct stringint { /* String and (wide) integer */ #define TT_ADM3A 43 /* LSI ADM 3A */ #define TT_ADM5 44 /* LSI ADM 5 */ #define TT_VTNT 45 /* Microsoft NT Virtual Terminal */ -#define TT_IBM3101 46 /* IBM 3101 - not implemented */ -#define TT_XTERM 47 /* xterm! */ + +#ifdef CK_XTERM_EMULATION +#define TT_XTERM 46 /* xterm! */ +#else +#define TT_XTERM 97 /* xterm! */ +#endif /* TODO: Graphics! * -> This would be Windows/KUI only - no way of supporting it in @@ -1094,6 +1098,7 @@ struct stringint { /* String and (wide) integer */ #define TT_MAX TT_VTNT #endif /* CK_XTERM_EMULATION */ +#define TT_IBM3101 98 /* IBM 3101 - not implemented */ #define TT_TEK40 99 /* Tektronix 401x */ #define TT_KBM_EMACS TT_MAX+1 #define TT_KBM_HEBREW TT_MAX+2 From aeb3f2198e63980c0e092061b04f7c7cd79ea88b Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sun, 14 May 2023 17:49:17 +1200 Subject: [PATCH 10/14] Fix OS/2 build issue KUI is not available on OS/2 so KuiGetTerminalMaximisedSize isn't either. --- kermit/k95/ckoco3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 5d4107cd..ce4b13b3 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -17974,6 +17974,7 @@ vtcsi(void) } } case 15: { /* Report size of the screen in pixels */ +#ifdef KUI int w, h; char buf[30]; KuiGetTerminalMaximisedSize(FALSE, &w, &h); @@ -17982,6 +17983,7 @@ vtcsi(void) sprintf(buf, "%c5;%d;%dt", _CSI, h, w); sendchars(buf, strlen(buf)); } +#endif /* KUI */ break; } case 16: /* Report xterm character cell size in pixels */ From 52f020b3cc1bf47480d3f75bfeabb7703a63b680 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sun, 14 May 2023 20:22:36 +1200 Subject: [PATCH 11/14] Add missing curly braces --- kermit/k95/ckoco3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index ce4b13b3..62d7b6fd 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -18056,7 +18056,7 @@ vtcsi(void) /* Report xterm window position */ } break; - case 11: /* Report state of Window (normal/iconified) */ + case 11: { /* Report state of Window (normal/iconified) */ #ifdef KUI char buf[20]; if (gui_get_win_run_mode() == 2) { @@ -18068,6 +18068,7 @@ vtcsi(void) #endif break; } + } } break; case 'u': From 0f7095e204c241ea4ce04362ef31a0ae4124ec80 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 16 Feb 2024 22:20:12 +1300 Subject: [PATCH 12/14] Fix build error merge gone wrong? --- kermit/k95/ckoco3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 615e49ff..9ee85045 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -16584,7 +16584,7 @@ vtcsi(void) * branch is disabled -- DG if ( 0 && ISQANSI(tt_type_mode) ) l = pn[j] - 40; - else + else */ l = sgrcols[pn[j] - 40]; if (!decscnm) { i = (attribute & 0x8F); @@ -18189,7 +18189,7 @@ vtcsi(void) sendchars(buf, strlen(buf)); #endif break; - } + } } } break; From 50272a93318f953a12c56f14a348596b06482782 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 16 Feb 2024 22:44:36 +1300 Subject: [PATCH 13/14] Support DECRQCRA --- kermit/k95/ckoco3.c | 116 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 9ee85045..39da1f72 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -13757,6 +13757,122 @@ vtcsi(void) decsace = TRUE; } break; + case 'y': { /* DECRQCRA - Request Checksum of Rectangular Area */ + if ( (ISVT420( tt_type_mode) || ISXTERM(tt_type_mode)) && tt_senddata) { + /* pn[1] - Request Id + * pn[2] - Page number + * pn[3] - top. Default=1 + * pn[4] - left. + * pn[5] - bottom. Default=height of screen + * pn[6] - right. Width of screen + * + * If pn[2] is omitted (or 0), following parameters are ignored + * we're supposed to calculate the checksum for all pages in + * memory + * + * If pn[3-6] are omitted we calculate the checksum for the entire + * page. + * + * Constraints: + * pn[4] < pn[6] + * pn[3] < pn[5] + * + * Note: coordinates of the rectangular area are affected by + * setting of origin mode + */ + int checksum=0, pid=1; + int top, left, bot, right; + int row, col; + int x, y; + char buf[20]; + + if (k < 3) pn[3] = 1; + if (k < 4) pn[4] = 1; + if (k < 5) pn[5] = VscrnGetHeight(VTERM) - (tt_status[VTERM] ? 1 : 0); + if (k < 6) pn[6] = VscrnGetWidth(VTERM); + k = 6; + + /*checksum &= 0xffff;*/ + pid = pn[1]; + /* Ignore pn[2] - we don't support multiple pages */ + top = pn[3] + (margintop > 1 ? margintop : 0); + left = pn[4] + (marginleft > 1 ? marginleft : 0); + bot = pn[5]; + right = pn[6]; + + debug(F111, "DECRQCRA", "pid", pid); + debug(F111, "DECRQCRA", "init-top", pn[3]); + debug(F111, "DECRQCRA", "init-left", pn[4]); + debug(F111, "DECRQCRA", "init-bot", pn[5]); + debug(F111, "DECRQCRA", "init-right", pn[6]); + + + debug(F111, "DECRQCRA", "margintop", margintop); + debug(F111, "DECRQCRA", "marginleft", marginleft); + debug(F111, "DECRQCRA", "marginbot", marginbot); + debug(F111, "DECRQCRA", "marginright", marginright); + + if (top < margintop) top = margintop; + if (top > marginbot + 1) top = marginbot + 1; + if (left < marginleft) left = marginleft; + if (left > marginright + 1) left = marginright + 1; + if (bot < margintop) bot = margintop; + if (bot > marginbot) bot = marginbot; + if (right < marginleft) right = marginleft; + if (right > marginright) right = marginright; + + + debug(F111, "DECRQCRA", "top", top); + debug(F111, "DECRQCRA", "left", left); + debug(F111, "DECRQCRA", "bot", bot); + debug(F111, "DECRQCRA", "right", right); + + for ( y=top-1; ycells[x].c; + cellattr = line->cells[x].a; + a = line->vt_char_attrs[x]; + /* Get colour including bright flag - not sure if we actually + * need that for this calculation + * bgcolor = (cellattr&0xF0)>>4; + * fgcolor = (cellattr&0x0F);*/ + bgcoloridx = sgrindex[((cellattr&0x70)>>4)%8]; + fgcoloridx = sgrindex[(cellattr&0x07)%8]; + + debug(F111, "DECRQCRA iteration", "x", x); + debug(F111, "DECRQCRA iteration", "y", y); + debug(F111, "DECRQCRA iteration", "c", c); + debug(F111, "DECRQCRA iteration", "checksum", checksum); + + checksum += c; + + debug(F111, "DECRQCRA iteration", "checksum+c", checksum); + + if (a & VT_CHAR_ATTR_PROTECTED) checksum += 0x04; + if (a & VT_CHAR_ATTR_INVISIBLE) checksum += 0x08; + if (a & VT_CHAR_ATTR_UNDERLINE) checksum += 0x10; + if (a & VT_CHAR_ATTR_REVERSE) checksum += 0x20; + if (a & VT_CHAR_ATTR_BLINK) checksum += 0x40; + if (a & VT_CHAR_ATTR_BOLD) checksum += 0x80; + /*checksum += bgcoloridx; + checksum += fgcoloridx * 0x10;*/ + debug(F111, "DECRQCRA iteration", "checksum+attrs", checksum); + } + } + debug(F111, "DECRQCRA", "checksum", checksum); + sprintf(buf, "\033P%d!~%04X\033\\", pid, checksum); + + // TODO: Call sendesqseq instead (and check for any other places + // where we should be doing this but aren't) + sendchars(buf, strlen(buf)); + } + + break; + } } break; case '`': From a73662769b5e17b608b69e4155ef6f1da674402c Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 16 Feb 2024 22:52:32 +1300 Subject: [PATCH 14/14] commit sgrindex (required by DECRQCRA) --- kermit/k95/ckoco3.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index 39da1f72..92063a03 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -645,16 +645,36 @@ static int f_pushed = 0, c_pushed = 0, f_popped = 0; int sgrcolors = TRUE; /* Process SGR Color Commands */ +/* + * The numbers below are 3-bit colour codes for the OS/2 console + * +---+---+---+ + * | R | G | B | + * +---+---+---+ + * 1 0 0 = 4, Red + * See the comment in ckocon.h near swapcolors for a full description. + */ static unsigned char sgrcols[8] = { -/* Black */ 0, -/* Red */ 4, -/* Green */ 2, -/* Brown */ 6, -/* Blue */ 1, -/* Magenta */ 5, -/* Cyan */ 3, -/* White */ 7 +/* Black */ 0, /* 0 (index) */ +/* Red */ 4, /* 1 */ +/* Green */ 2, /* 2 */ +/* Brown */ 6, /* 3 */ +/* Blue */ 1, /* 4 */ +/* Magenta */ 5, /* 5 */ +/* Cyan */ 3, /* 6 */ +/* White */ 7 /* 7 */ +}; + +/* Map colour code (table above) back to SGR Index */ +static unsigned char sgrindex[8] = { + 0, + 4, + 2, + 6, + 1, + 5, + 3, + 7 }; #ifdef COMMENT