Skip to content

native: fix 16-color drawing and lost mouse clicks in ConEmu - #2200

Merged
simonklee merged 2 commits into
mainfrom
harden/conemu-alt-screen
Nov 23, 2026
Merged

simonklee merged 2 commits into
mainfrom
harden/conemu-alt-screen

Conversation

@simonklee

Copy link
Copy Markdown
Member

Since 0.9.0, apps in ConEmu draw with its 16-color palette, and mouse clicks do nothing while the wheel works.

Colors: when a write ends with the ST of an APC or DCS, ConEmu holds it back, then drops it and two more bytes of the next write. Since #2056 the startup queries end with the Kitty graphics APC, and the next write is ESC[s ESC[?1049h. ConEmu loses the ESC [ and never enters its alternate buffer, the only one where it draws 24-bit color. The batch now ends with its hide-cursor CSI.

Clicks: ConEmu sends every SGR release as button 3. The native parser dropped those; the TypeScript parser removed in #1981 did not. Such a release now releases the held button.

Checked on Windows 11 in ConEmu 230724, conhost and Windows Terminal, with a Core app and OpenCode 2.4.0. Lost clicks in conhost on older Windows 10 builds are a separate case that this does not fix.

Refs anomalyco/opencode#65832, anomalyco/opencode#65894

ConEmu sends every mouse release in SGR form with X10's button code 3:
ESC[<0;37;8M, then ESC[<3;37;8m. The parser read code 3 as no button
and dropped the release, so a press never ended. Clicks on tabs and
palette entries did nothing, while the wheel worked. The legacy
TypeScript parser, the default until #1981, reported these as releases.

Such a release now releases the lowest button held, which for a left
click is the left button, as the TypeScript parser reported. With no
button held it is still not an event. The added line is the comment
that names ConEmu.

Refs anomalyco/opencode#65894
ConEmu reads an OSC through its ST in one go, but an APC or DCS is not a
sequence it knows: when a write ends with the APC's or DCS's ST, ConEmu
holds those last two bytes back and parses them again in front of the
next write. That second parse loses two more bytes of the next write,
after its first sequence.

Since #2056 the startup query batch ends with the Kitty graphics query,
an APC, and the next write is setup's ESC[s ESC[?1049h. ConEmu runs
ESC[s, loses the ESC [, and prints ?1049h as text. It never enters its
alternate buffer, the only place it draws 24-bit color, so apps in
ConEmu draw with its 16-color palette.

The batch now ends with its hide-cursor sequence, which gets no reply
and which ConEmu parses whole. Two lines are added: the write on a line
of its own, and the comment that says why it is last.

Refs anomalyco/opencode#65832
@simonklee
simonklee requested a review from kommander as a code owner November 23, 2026 22:10
@simonklee
simonklee merged commit 234ae0c into main Nov 23, 2026
24 checks passed
@simonklee
simonklee deleted the harden/conemu-alt-screen branch November 23, 2026 22:25
Dicklesworthstone pushed a commit to Dicklesworthstone/opentui that referenced this pull request Nov 23, 2026
…co#2200)

Since 0.9.0, apps in ConEmu draw with its 16-color palette, and mouse
clicks do nothing while the wheel works.

Colors: when a write ends with the ST of an APC or DCS, ConEmu holds it
back, then drops it and two more bytes of the next write. Since anomalyco#2056
the startup queries end with the Kitty graphics APC, and the next write
is `ESC[s ESC[?1049h`. ConEmu loses the `ESC [` and never enters its
alternate buffer, the only one where it draws 24-bit color. The batch
now ends with its hide-cursor CSI.

Clicks: ConEmu sends every SGR release as button 3. The native parser
dropped those; the TypeScript parser removed in anomalyco#1981 did not. Such a
release now releases the held button.

Checked on Windows 11 in ConEmu 230724, conhost and Windows Terminal,
with a Core app and OpenCode 2.4.0. Lost clicks in conhost on older
Windows 10 builds are a separate case that this does not fix.

Refs anomalyco/opencode#65832, anomalyco/opencode#65894

(cherry picked from commit 234ae0c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant