Skip to content

Configurable word separators for selection, and the OSC terminator on OscReceived - #188

Merged
tomlm merged 1 commit into
tomlm:mainfrom
confetty-sh:stack/control-public-hovered-claude
Nov 9, 2026
Merged

tomlm merged 1 commit into
tomlm:mainfrom
confetty-sh:stack/control-public-hovered-claude

Conversation

@JohnCampionJr

@JohnCampionJr JohnCampionJr commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Why

A terminal host built on XTerm.NET (Confetty, a Ghostty-style terminal) needs two things the emulator doesn't expose yet:

  • Where a double-click word ends. SelectionManager.IsWordChar is private and fixed to letters, digits and _, so ~/src/foo-bar.txt selects as foo. Ghostty's selection-word-chars lets the user choose, and a host's own keyboard word motion should agree with the mouse, which it can't do while the rule is private.
  • Which terminator an OSC used. A host answering an OSC it handles through OscReceived should reply in the terminator the program used (BEL or ST), as the terminal's own replies already do. The parser knows; the event doesn't say.

API

Member Default What it does
TerminalOptions.WordSeparators (string?) null The characters that end a word. null keeps today's rule exactly. Given a string, every character not in it is part of a word (Ghostty's meaning), so ., - and / join a path unless listed. Each code point counts on its own, including ones outside the BMP. Copied by the options' copy constructor and Clone. Read on every expansion, so a change applies to the next double-click.
SelectionManager.IsWordChar(string?) Now public: the rule double-click expansion uses, for a host's word motion to share. Null or empty content is never a word character.
OscReceivedEventArgs.EndedWithBel false Whether the sequence ended with BEL rather than ST. A new constructor overload carries it; the existing constructor is kept and reports false.

One thing a host should know: blank cells hold a space rather than nothing, so a separator list without the space joins words across a gap of blank cells. Ghostty's default list (\t '"│`|:;,()[]{}<>$) includes the space.

Backward compatible

Purely additive. With WordSeparators unset the word rule is the one IsWordChar applied before, and OscReceivedEventArgs' existing constructor and members are unchanged. Neither touches the print path. The separator set is parsed only when the option changes and consulted only by word expansion; EndedWithBel reads a flag the parser already keeps, once per OSC.

Tests

  • WordSeparatorsTests (8): the default rule; a listed separator ending a word while unlisted punctuation joins it; Ghostty's default list on a path:line; a separator outside the BMP; blank cells as spaces; a change applying to the next double-click, including from one list to another; the public rule; Clone.
  • OscTerminatorTests (4): BEL, ST, each sequence reporting its own, and the old constructor.

Mutation passes caught all 10 mutants:

  • 7 for WordSeparators: the null fallback, the separator check, code-point decoding of the cell and of the list, the cache rebuild, the empty-cell rule, and the copy constructor. The first pass had one survivor (a separator set that never rebuilt); the test now switches between two lists and kills it.
  • 3 for EndedWithBel: the terminator not passed, always BEL, and the argument not stored.

tomlm/Iciclecreek.Avalonia.Terminal#212 builds on this: the control's keyboard word selection calls the now-public IsWordChar, so it needs a release with this change.

🤖 Generated with Claude Code

@JohnCampionJr JohnCampionJr changed the title Hovered link, paste hook and selection options (control) + WordSeparators and OSC terminator (XTerm.NET) Configurable word separators for selection, and the OSC terminator on OscReceived Nov 6, 2026

@JohnCampionJr JohnCampionJr left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-merge review (Codex), for the PR author

One should-fix finding: configured word expansion still stops at a wide character's continuation cell, so it does not honor the separator list and disagrees with keyboard word selection in the dependent control PR.

Checked option defaults/copying, separator caching and code-point decoding, OSC terminator propagation and constructor compatibility, and interaction with the checksum option. The combined core PRs passed 212 filtered tests. A focused reproduction failed for both CJK and an unlisted emoji. No finding in the OSC terminator addition.

@JohnCampionJr
JohnCampionJr force-pushed the stack/control-public-hovered-claude branch from 912005e to e7363f4 Compare November 6, 2026 01:35

@JohnCampionJr JohnCampionJr left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-merge review follow-up (Codex), for the PR author

Rechecked the post-review delta at e7363f4. Resolved: the retained CJK/emoji reproductions now select the whole word from either side. The added separator/continuation tests pass, including the default-rule CJK case. No new findings in this delta. The combined filtered core run passed 231 tests.

@tomlm
tomlm merged commit f830a0e into tomlm:main Nov 9, 2026
9 checks passed
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.

2 participants