From a3c52e081791ac168cf051c051b82f26214b7632 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Thu, 26 Feb 2026 00:06:39 -0600 Subject: [PATCH] Add terminal query responses for BBS ANSI detection Handle ENQ (0x05), ESC[c (Device Attributes), ESC[5n (Device Status Report), and ESC[6n (Cursor Position Report). Responses are sent back through OnKeyData so BBSes can detect ANSI terminal capability. Co-Authored-By: Claude Opus 4.6 --- delphi/KPANSI.PAS | 27 +++++++++++++++++++++++++++ delphi/README.md | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/delphi/KPANSI.PAS b/delphi/KPANSI.PAS index d6eae58..42fbd0b 100644 --- a/delphi/KPANSI.PAS +++ b/delphi/KPANSI.PAS @@ -639,6 +639,28 @@ begin FSaveCurRow := FCursorRow; FSaveCurCol := FCursorCol; end; + 'c': { DA - Device Attributes } + begin + { Respond as VT100 with no options } + if Assigned(FOnKeyData) then + FOnKeyData(Self, #27'[?1;0c'); + end; + 'n': { DSR - Device Status Report } + begin + if P1 = 5 then + begin + { Terminal status: report OK } + if Assigned(FOnKeyData) then + FOnKeyData(Self, #27'[0n'); + end + else if P1 = 6 then + begin + { Cursor Position Report: respond with ESC[row;colR (1-based) } + if Assigned(FOnKeyData) then + FOnKeyData(Self, #27'[' + IntToStr(FCursorRow + 1) + ';' + + IntToStr(FCursorCol + 1) + 'R'); + end; + end; 'u': { RCP - Restore Cursor Position } begin FCursorRow := FSaveCurRow; @@ -1201,6 +1223,11 @@ begin TabCol := FCols - 1; FCursorCol := TabCol; end; + #5: { ENQ - Answerback } + begin + if Assigned(FOnKeyData) then + FOnKeyData(Self, #27'[?1;0c'); + end; #7: { BEL } MessageBeep(0); else diff --git a/delphi/README.md b/delphi/README.md index 70f58d2..4579b31 100644 --- a/delphi/README.md +++ b/delphi/README.md @@ -116,6 +116,9 @@ CSI (ESC\[) sequences: | ESC\[*params*m | SGR | Set graphic rendition (see below) | | ESC\[s | SCP | Save cursor position | | ESC\[u | RCP | Restore cursor position | +| ESC\[c | DA | Device Attributes — responds ESC\[?1;0c (VT100) | +| ESC\[5n | DSR | Device Status Report — responds ESC\[0n (OK) | +| ESC\[6n | CPR | Cursor Position Report — responds ESC\[*row*;*col*R | SGR codes: @@ -148,6 +151,7 @@ Control characters: | LF (#10) | Line feed (scrolls at bottom) | | BS (#8) | Backspace (no erase) | | TAB (#9) | Tab to next 8-column stop | +| ENQ (#5) | Answerback — responds ESC\[?1;0c (VT100) | | BEL (#7) | System beep | **ANSI Music:**