diff --git a/doc/changes.md b/doc/changes.md index 796513da..a02ecef8 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 ea7781f1..a4369fee 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -8986,9 +8986,40 @@ 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: - a = VT_CHAR_ATTR_NORMAL; + case 0: { + 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; break; @@ -10431,7 +10462,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 5d452554..26981df0 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 || \