diff --git a/doc/changes.md b/doc/changes.md
index 578adc3d9..796513da6 100644
--- a/doc/changes.md
+++ b/doc/changes.md
@@ -564,6 +564,21 @@ as part of K95 at this time, the default terminal remains VT220 for now.
discarded and the remainder written to the terminal. While this behaviour was
intentional, it was incorrect and doesn't match any real terminal.
- Fixed rendering on large window sizes (this time for good I hope!)
+ - Fixed DEC UDKs being reset on soft terminal reset
+ - Fixed a potential buffer overflow in DECUDK processing
+ - Fixed DECUDK dumping the remainder of the DECUDK sequence to the terminal
+ when an odd number of hex digits was encountered. This behaviour was
+ inconsistent with the VT220, VT420 and VT520.
+ - Fixed null key definitions causing the remainder of a DECUDK sequence to be
+ dumped to the terminal. This behaviour was inconsistent with the VT220,
+ VT420, and VT520. Null key definitions are now ignored as per DEC STD 070.
+ - Fixed DECUDK not correctly ignoring certain bytes in the command string.
+ - Fixed DECUDK not correctly handling an empty key definition resulting in the
+ key being defined to garbage
+ - Fixed C1 control code SCI being interpreted as DECID
+ - 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).
## Kermit 95 v3.0 beta 7 - 27 January 2025
diff --git a/doc/ctlseqs.xml b/doc/ctlseqs.xml
index e9fec3e86..70a74b7d8 100644
--- a/doc/ctlseqs.xml
+++ b/doc/ctlseqs.xml
@@ -3990,27 +3990,523 @@ DECTSR 462
The first parameter can be either 0 (clear all UDK definitions before - starting, default), or 1 (erase below).
-The second parameter can be either 0 (lock the keys, default), or 1 (do not - lock the keys)
- - ++ Programs the response to pressing one or more of the user-defined + function keys (Shift+F1 through F20). If key definitions are + locked (SET TERM LOCK-KEY-DEFINITIONS ON, the default) + then DECUDK is ignored. You can view the current state of the + user-defined keys with SHOW UDK, and query for it with + DSR-25. +
- The third parameter is a ;-seperated list of key definitions. A key - definition consists of the key code for one of the function keys, a / character - and then the string to send in response to that function key being pressed. + While DECs hardware terminals offered a fixed amount of space + available to store all key definitions (256 bytes on the VT220, + 768 bytes on the VT420 and VT520), Kermit 95 instead currently + enforces a per-key limit of 256 bytes.
+Specifies which existing key definitions should be erased. + Valid values are: +
++ Using Pe=1, you can modify only some key definitions without + having to reload all definitions. +
++ Specifies if key definitions should be locked upon completion + of DECDLD to prevent subsequent modification, or if they + should be left unlocked. Valid values are: +
++ If key definitions are locked (Pl=0), only the user can + unlock them again using the + SET TERM LOCK-KEY-DEFINITIONS OFF command. +
++ In the interests of security, host applications should not + leave key definitions unlocked. +
++ The command string portion of the DCS sequence contains zero + or more key definition strings separated by the + semicolon character (';'). Each key definition + string is of the form Kyn/Kstn where Kyn is the key + number, and Kstn is the new definition for that key. +
+ +Note that key numbers 16, 22, 27 and 30 are skipped. Valid + key numbers are: +
+| Key number (Kyn) | +Key | +Notes | +
|---|---|---|
| 11 | +F1 | +VT420 or higher | +
| 12 | +F2 | +VT420 or higher | +
| 13 | +F3 | +VT420 or higher | +
| 14 | +F4 | +VT420 or higher | +
| 15 | +F5 | +VT420 or higher | +
| 17 | +F6 | ++ |
| 18 | +F7 | ++ |
| 19 | +F8 | ++ |
| 20 | +F9 | ++ |
| 21 | +F10 | ++ |
| 23 | +F11 | +Shift+Alt+F1 on keyboards with 12 function keys. | +
| 24 | +F12 | +Shift+Alt+F2 on keyboards with 12 function keys. | +
| 25 | +F13 | +Shift+Alt+F3 on keyboards with 12 function keys. | +
| 26 | +F14 | +Shift+Alt+F4 on keyboards with 12 function keys. | +
| 28 | +F15 | +The HELP key on an LK450 keyboard. Shift+Alt+F5 on keyboards with 12 function keys. | +
| 29 | +F16 | +The DO key on an LK450 keyboard. Shift+Alt+F6 on keyboards with 12 function keys. | +
| 31 | +F17 | +Shift+Alt+F7 on keyboards with 12 function keys. | +
| 32 | +F18 | +Shift+Alt+F8 on keyboards with 12 function keys. | +
| 33 | +F19 | +Shift+Alt+F9 on keyboards with 12 function keys. | +
| 34 | +F20 | +Shift+Alt+F10 on keyboards with 12 function keys. | +
+ The key definition (Kstn) is written as a sequence of hex + digit pairs, which are the charactes in the following + ranges: +
+
+ Each pair of hex digits represents a single 8-bit byte.
+ For example the hex digits 4B represent the letter
+ K. The digits 4B65726D697420393521 represent the
+ string Kermit 95!. This string could be bound to
+ Shift+F6 with the DCS sequence
+
+ If a key definition contains an uneven number of hex digits + this is an error, and Kermit 95 will ignore the final hex + digit in keeping with the DEC terminals it emulates. +
++ The characters HT (TAB), LF, VT, FF and CR can be included + in the key definition string for formatting purposes (they + are ignored when DECUDK is processed). +
++ Kermits 95s \fhexify function may be useful for + converting strings to hex format. For example, typing + echo \fhexify(Hello!) at the K95 prompt will output + 48656C6C6F21 which you can then use with DECUDK. + The reverse of this function, \funhexify, is also + available if you wish to decode key definitions. +
+
+ As a final example, you could bind the string "Hello, " to
+ Shift+F6 and "Kermit 95!" to Shift=F7 with the following
+ DCS sequence:
+
+ The DECUDK specification leaves some behaviour undefined. + Where possible, Kermit 95 attempts to match the behaviour of + the DEC products it emulates regardless, though at the time + this was feature was last updated only a VT220, VT420 and + VT520 were available for testing. Kermit 95s other terminal + emulations may not exactly match their respective terminals. +
++ The following bytes have behaviours undefined by the DECUDK + specification, and so kermit 95 assigns them meaning as + described: +
+K95 does not currently - support specifying the shift-state of function keys, or the direction the - response to pressing the key is to be sent in.
++ While Kermit 95 supports some features of DECUDK as it + exists on the VT420 and VT500 such as being able to program + F1 through F5, it does not currently support specifying + the modifier keys or direction the keys response should be + sent in. These features will arrive in some future release + that includes VT420 emulation. +
+ When K95 receives an APC escape sequence it fails to clear the APC flag + whether or not the APC sequence is processed. This causes subsequent OSC, + DCS and other string-type control sequences to be interprted as APC instead + of their correct type until the terminal is reset. If APC is enabled, using + an OSC (like setting the title) or DCS (like setting user-defined keys) may + cause errors to appear on the command screen. +
++ This affects all releases of Kermit 95 since at least 1.1.11 (February + 1997). Older releases were not available for testing, but its possible the + bug may have been introduced as early as 1.1.7 (July 1996). It is fixed in + K95 3.0.0 beta 8. +
+