mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-24 20:45:56 +03:00
[PR #791] fix(buffer): preserve wide characters under translucent overlays #1566
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#1566
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/791
Author: @aarcamp
Created: 3/8/2026
Status: 🔄 Open
Base:
main← Head:fix-wide-char-alpha-blending📝 Commits (1)
c84ec57fix(buffer): preserve wide characters under translucent overlays📊 Changes
4 files changed (+1064 additions, -36 deletions)
View changed files
➕
packages/core/docs/wide-grapheme-alpha-blending-tests.svg(+309 -0)📝
packages/core/src/zig/buffer.zig(+156 -34)📝
packages/core/src/zig/lib.zig(+1 -1)📝
packages/core/src/zig/tests/buffer_test.zig(+598 -1)📄 Description
blendCells() refused to preserve characters with display width > 1, so any semi-transparent overlay (e.g. a tinted box) replaced grapheme start cells with spaces, making CJK/emoji invisible underneath. Now we preserve underlying wide graphemes when translucent space overlays land on them instead of replacing continuation cells with spaces or tinting only the touched cell.
Make setCellWithAlphaBlending() the source of truth for preserved wide-grapheme alpha blending: resolve the full grapheme span from any touched cell, blend once from the canonical start cell, and apply the resulting style uniformly across the span. Return the rightmost written x-coordinate so sequential writers can coordinate around preserved spans.
Introduce a per-pass BlendCursor for left-to-right alpha-writing loops so repeated space writes inside the same preserved span are skipped without leaking state across separate draw calls. Use it in fillRect(), drawText(), drawFrameBuffer(), drawTextBufferInternal(), and the image/grayscale compositors.
Respect scissor clipping during span style propagation and add native regression coverage for preservation, partial overlap, mixed space/character overwrites, multi-space passes, multiple graphemes, repeated overlays, and clipped-then-unclipped writes.
Discovered this while adding a feature that detects uid == 0 use and applies a tinted red overlay to the terminal.
Sample text file with wide chars:
With overlay applied, before the fix (wide chars disappear):
With overlay applied, after the fix (wide chars remain visible as expected):
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.