From 52de091eab0437ea4e8d1d1296c8c0b70499c5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dejan=20Leki=C4=87?= Date: Thu, 12 Feb 2026 17:06:18 +0000 Subject: [PATCH 1/2] Fix: Bounds checking for repeat count in `handleWinKey` --- source/dcell/parser.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dcell/parser.d b/source/dcell/parser.d index e9e3097..9e3794e 100644 --- a/source/dcell/parser.d +++ b/source/dcell/parser.d @@ -12,7 +12,7 @@ module dcell.parser; import core.time; -import std.algorithm : max; +import std.algorithm : max, min; import std.ascii; import std.base64; import std.conv : to; @@ -1046,7 +1046,7 @@ private: auto key = Key.graph; auto chr = p2; auto mod = Modifiers.none; - auto rpt = max(1, p5); + auto rpt = min(max(1, p5), 1024); if (p0 in winKeys) { From 1fb7fbce3ce91a26359bc810bddba29281d9d461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dejan=20Leki=C4=87?= Date: Thu, 12 Feb 2026 17:13:37 +0000 Subject: [PATCH 2/2] Added DDoc style comment to the handleWinKey() --- source/dcell/parser.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/dcell/parser.d b/source/dcell/parser.d index 9e3794e..e55259a 100644 --- a/source/dcell/parser.d +++ b/source/dcell/parser.d @@ -1001,6 +1001,21 @@ private: evs ~= newMouseEvent(x, y, button, mod); } + /*** + * Handles Win32 input mode key sequences (CSI ... _). + * + * Parses a Win32 console input key event encoded as a CSI sequence with + * six semicolon-separated parameters, and translates it into one or more + * key events appended to `evs`. + * + * Params: + * p0 = wVirtualKeyCode (default 0) + * p1 = wVirtualScanCode (default 0) + * p2 = UnicodeChar as a decimal value (default 0) + * p3 = bKeyDown — 1 for key-down, 0 for key-up (default 0) + * p4 = dwControlKeyState — modifier flags (default 0) + * p5 = wRepeatCount — clamped to [1, 1024] to prevent CPU hang (default 1) + */ void handleWinKey(int p0, int p1, int p2, int p3, int p4, int p5) @safe { // win32-input-mode