Skip to content

Style IME pre-edit text with italics and a dashed underline - #10386

Merged
kovidgoyal merged 1 commit into
kovidgoyal:masterfrom
bjohas:ime-preedit-style
Aug 22, 2026
Merged

kovidgoyal merged 1 commit into
kovidgoyal:masterfrom
bjohas:ime-preedit-style

Conversation

@bjohas

@bjohas bjohas commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Per your instruction on #10382: pre-edit text is now italic with a dashed
underline in the highlight color, rather than reverse video.

One thing to check, since your wording could be read either way: I took "color
being the highlight color" to mean the underline's colour, so it sets
decoration_fg and the text keeps its normal foreground. That matches the
url_style/url_color pair, where url_color is the decoration colour, and it
avoids drawing the text itself in selection_background (#fffacd by default),
which would be close to invisible on a light theme. If you meant the text
colour, it is a one-line change to sgr.fg.

The highlight color resolves through colorprofile_to_color_with_fallback()
from highlight_bg, falling back to default_fg when selection colours are
unset or special.

The previous code toggled reverse with XOR, so it restored itself. The three
new attributes are saved and put back explicitly, next to the wrap,
cursor-visibility and insert-replace modes already saved there.

Test added, asserting the rendered cells are italic, not reversed, decoration 5,
and decoration_fg packed as RGB with the selection background; plus that the
styling does not leak into the screen's own cursor. Verified against the built
binary:

cell 0: italic=True reverse=False decoration=5 decoration_fg=0xfffacd02 (type=2, rgb=0xfffacd)

Full suite passes here apart from two failures unrelated to this change and
present on master: open_actions argument splitting, and glfw-wayland.so,
which this machine cannot build (its wayland-protocols predates
cursor-shape-v1).

Pre-edit text was drawn in reverse video, which is a solid inverted block
moving through the line as you compose. Draw it as italic with a dashed
underline in the highlight color instead.

Underline rather than reverse video is what other terminals do: VTE renders the
pre-edit run with the input method's own attributes and marks only the cursored
cell distinctly, and foot underlines the run explicitly, excluding the part
under the cursor. Dashed avoids the underline styles applications already use:
curly for spell checking and straight for hyperlinks, which is the collision
that made reverse video look like the safer choice.

The styling is applied to the overlay's own cursor and restored afterwards,
alongside the wrap, cursor-visibility and insert-replace modes already saved
there. The previous code toggled reverse with XOR, which restored itself; the
three new attributes are saved and put back explicitly.

Closes kovidgoyal#10382
@kovidgoyal
kovidgoyal merged commit df703db into kovidgoyal:master Aug 22, 2026
13 of 14 checks passed
@bjohas

bjohas commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Thank you!

(Apologies for the formatting miss, wrong clang-format version locally. Will use ./autoformat in future.)

@kovidgoyal

Copy link
Copy Markdown
Owner

No worries!

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