From 38c7f568d897916cef60065060d79a75a0802cfa Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Mon, 2 Nov 2026 19:24:07 +1300 Subject: [PATCH 1/2] Fix DECCARA-0 clearing the protected attribute. STD-070 and the programmer reference manuals say nothing about the protected attribute being affected by DECCARA-0, and DECCARA doesn't support setting the protected attribute so there is no reason to expect DECCARA-0 to clear this attribute. The VT420 works as implied by the documentation, while the VT520 does not. This is expected to be a bug, so by default K95 does not replicate this behaviour. Fixes #581 --- doc/changes.md | 3 +++ kermit/k95/ckoco3.c | 34 ++++++++++++++++++++++++++++++++-- kermit/k95/ckuusr.h | 6 ++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/doc/changes.md b/doc/changes.md index 796513da6..a02ecef86 100644 --- a/doc/changes.md +++ b/doc/changes.md @@ -579,6 +579,9 @@ as part of K95 at this time, the default terminal remains VT220 for now. - Fixed APC causing all subsequent OSC, DCS and other string-type escape sequences to be processed as APC (and so likely producing errors on the command screen if APC is enabled) until terminal reset (K95 bug 845). + - Fixed DECCARA-0 clearing the protected attribute. While the VT520 does this + too, it's likely a bug as the VT420 doesn't do this and the manuals and + STD-070 say nothing about the protected attribute being affected. ## Kermit 95 v3.0 beta 7 - 27 January 2025 diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index ea7781f13..f5c2a0608 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -8987,7 +8987,37 @@ static vt_char_attr_t deccara_attribute(vt_char_attr_t a, int pn) { switch ( pn ) { case 0: - a = VT_CHAR_ATTR_NORMAL; + vt_char_attr_t new_attr = VT_CHAR_ATTR_NORMAL; + + if (a & VT_CHAR_ATTR_PROTECTED + && !(ISVT520_FOR_REAL(tt_type) && tt_strict)) { + /* DECCARA-0 should not clear the protected attribute according + * to STD-070 and the terminal documentation, so if its + * currently set then preserve that bit. + * + * VT520-BUG + * The VT520 (v2.1) (and I assume VT525) resets the protected + * attribute for DECCARA-0. The VT420 does not, and STD-070 and + * the programmer manual say nothing about the protected + * attribute being reset. We only behave as the VT520 does here + * if strict emulation has been requested. Otherwise we'll fix + * DECs mistake in K95s VT520 emulation. */ + new_attr |= VT_CHAR_ATTR_PROTECTED; + } + + /* Also don't clear hyperlinks */ + if (a & VT_CHAR_ATTR_HYPERLINK) new_attr |= VT_CHAR_ATTR_HYPERLINK; + + /* Also don't clear the graphic attribute. I'm not entirely sure + * what it is/was intended for, but its not settable via DECCARA + * so shouldn't be cleared by it either. */ + if (a & VT_CHAR_ATTR_GRAPHIC) new_attr |= VT_CHAR_ATTR_GRAPHIC; + + /* This WYSE attribute probably shouldn't ever be set in any + * emulation that supports DECCARA, but just in case... */ + if (a & WY_CHAR_ATTR) new_attr |= WY_CHAR_ATTR; + + a = new_attr; break; case 1: a |= VT_CHAR_ATTR_BOLD; @@ -10431,7 +10461,7 @@ udkreset( void ) * key has not had something assigned to it via DECUDK. So for now we * pre-initialise these with DECFNK. * */ - if (ISK95(tt_type) /* || ISVT520(tt_type) */) { + if (ISK95(tt_type) || ISVT520_FOR_REAL(tt_type) ) { udkfkeys[0] = strdup("\033[1;2P"); /* F1 */ udkfkeys[1] = strdup("\033[1;2Q"); udkfkeys[2] = strdup("\033[1;2R"); diff --git a/kermit/k95/ckuusr.h b/kermit/k95/ckuusr.h index 5d4525545..26981df03 100644 --- a/kermit/k95/ckuusr.h +++ b/kermit/k95/ckuusr.h @@ -1125,6 +1125,12 @@ struct stringint { /* String and (wide) integer */ #define ISVT520(x) (ISVT320(x)) #define ISVT420(x) (ISVT320(x)) #define ISVT330(x) (FALSE) + +/* All of these should be replaced with ISVT520(x) when that is no longer a + * synonym for ISVT320(x). This is temporarily used for behaviours we do *not* + * want to temporarily extend to VT320 emulation */ +#define ISVT520_FOR_REAL(x) (FALSE) + #endif /* COMMENT */ #define ISVT320(x) (x >= TT_VT320 && x <= TT_K95) #define ISVT220(x) (x >= TT_VT220 && x <= TT_K95 || \ From 22caae9ed2e3dc0ab0826c668e5f1327c5b68012 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Mon, 2 Nov 2026 19:35:21 +1300 Subject: [PATCH 2/2] Fix ANSI-C issue. This one always seems to catch me out. --- 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 f5c2a0608..a4369fee8 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -8986,7 +8986,7 @@ static rect_t get_rect_area(int vmode, int page, int top, int left, int bottom, static vt_char_attr_t deccara_attribute(vt_char_attr_t a, int pn) { switch ( pn ) { - case 0: + case 0: { vt_char_attr_t new_attr = VT_CHAR_ATTR_NORMAL; if (a & VT_CHAR_ATTR_PROTECTED @@ -9019,6 +9019,7 @@ deccara_attribute(vt_char_attr_t a, int pn) { a = new_attr; break; + } case 1: a |= VT_CHAR_ATTR_BOLD; break;