Skip to content

input: UTF-8 encode the button in 1005 mouse reports - #14532

Merged
mitchellh merged 1 commit into
ghostty-org:mainfrom
fornwall:dec-1005-fix
Oct 5, 2026
Merged

mitchellh merged 1 commit into
ghostty-org:mainfrom
fornwall:dec-1005-fix

Conversation

@fornwall

@fornwall fornwall commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Fix UTF-8 mouse reporting (DECSET 1005) to UTF-8 encode the button value, as required by xterm’s specification.

Previously, buttons 8 and 9 (back/forward) produced a raw byte of 0xA0 or 0xA1, making the report invalid UTF-8. For example, pressing button 8 at column 1, row 1 produced:

  • Before: b'\x1b[M\xa0!!'
  • After: b'\x1b[M\xc2\xa0!!'

AI disclosure: Initially created with claude code using opus 5.5. Iterated on, reviewed and tested manually by me.

In UTF-8 mouse mode (DECSET 1005) the button value was written as a
single raw byte. xterm encodes it as UTF-8 like the coordinates, so
values from 128 (buttons 8 and 9) take two bytes. The raw byte made
the report invalid UTF-8.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@ghostty-bot ghostty-bot Bot added the input Keyboard or mouse input label Oct 4, 2026
@mitchellh
mitchellh enabled auto-merge October 5, 2026 03:45
@mitchellh
mitchellh merged commit b094a6b into ghostty-org:main Oct 5, 2026
@github-actions github-actions Bot added this to the 1.4.0 milestone Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

input Keyboard or mouse input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants