Skip to content

fixes word wrap when text length is <2 Fixes #1360 - #1362

Open
hoseyjoe wants to merge 28 commits into
HeapsIO:masterfrom
hoseyjoe:master
Open

hoseyjoe wants to merge 28 commits into
HeapsIO:masterfrom
hoseyjoe:master

Conversation

@hoseyjoe

Copy link
Copy Markdown

Fixes highlighting and word wrap

Joe Williamson and others added 28 commits August 5, 2026 09:01
cursorIndex and selectionRange count the EXPANDED text - the text with the
line breaks word wrapping inserted, as getTextPos's documentation says - and
every operation on the text itself converts through getTextPos first.
Ctrl+C and Ctrl+X did not: they took `text.substr(selectionRange.start,
selectionRange.length)` straight from the text, so on any wrapped line the
clipboard was given a copy shifted by one character per wrap above the
selection, while cutSelection removed the correct characters. Cutting a word
and pasting it back therefore lost a letter. getSelectedText already does the
conversion, so both now use it.

getWordEnd had the mirror of the same confusion: `ret` is a position in the
text, but it was bounded by getTextLength(), which is the expanded length and
so longer than the text by one per inserted break. A double-click on a word at
the end of a wrapped text selected one character past the end of it.
When a break char already overflows maxWidth, lastBreak is set to i - 1,
which can point before the start of the current line (lastPos - 1). The
rewind branch then flushes an empty line without advancing i or lastPos,
and the loop repeats forever. This happens e.g. with maxWidth = 0 (layouts
that measure at zero width first) and CJK text, or TextInput with
trimTrailingSpaces = false.

Only rewind to a break point inside the current line, so every rewind
consumes at least one character. lastPos is never negative, so this still
implies the old lastBreak >= 0 check.

Fixes HeapsIO#1347

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re's origin

Object.drawFilters pushes the filter texture with the (xMin, yMin) of its
bounds as the target's start, but setRZ mapped a zone through the filter
matrix (relative to the filtered object's origin, already in texture
pixels) and then through the scene viewport. The zone was therefore
offset by (xMin, yMin) - e.g. 2px up and left under a Blur/Glow with
radius 1 - and scaled a second time when the viewport is scaled.

Visible as a single-line TextInput, drawn inside any filtered parent,
having the descenders of its text clipped off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
convertAndCache saves cache.dat from haxe.Timer.delay, or at once only when
CACHE_SAVE_MAX_PENDING changes are waiting. A macro has no event loop to run
the delayed save, so a project that embeds its resources at compile time
(hxd.Res.initEmbed) with fewer converted files than that never wrote the
cache, and converted every resource again on every compilation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ack registry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…input, candidate area

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…field leaves the scene

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pair; wrapping keeps pairs whole

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…keyboard; UTF-16 offsets on macOS; startTextInput docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…glyph

A surrogate pair is one character (one getChar, one glyph, one break
unit); joiners, variation selectors and tag characters draw nothing and
take no space. TextInput's caret, clicks, vertical moves and deletes step
over an emoji with its selectors as one character. Helpers in hxd.Charset
(codeAt, charLength, isZeroWidth). tests/text/EmojiTextTest runs headless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uster + ClusterFallback; FontChar.isColor

hxd.Charset.clusterEnd groups a code point with its selectors, skin tone,
keycap mark, tags and ZWJ-joined code points, and pairs regional
indicators (flags). Text, HtmlText and TextInput lay out, wrap and move
the caret by cluster. Font.getCluster asks a fallback implementing the
new ClusterFallback for one glyph per emoji sequence (cached, cloned,
resized and offset with the font); a miss draws the parts as one
unbreakable unit with one caret stop. Text without these characters
lays out as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p shadow

Glyphs marked FontChar.isColor go to a colour TileGroup drawn after the
text without its shaders (no SDF, no tint): white with the text's alpha.
Its drop shadow is the glyphs' shapes in the shadow colour (FixedColor,
USE_ALPHA off), not a colour copy. HtmlText shares one colour layer for
all its fonts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ZWJ took whatever code point followed it into the cluster, so "👨‍a"
or Sinhala "ශ්‍රී" merged letters into one caret stop. Now the ZWJ stays
on its own cluster and joins the next code point only when it is a
pictographic symbol (UAX HeapsIO#29 GB11).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lyph

Font.glyphs also caches fallback glyphs, which are colour for a lone emoji,
so "☺︎" came out in colour once a bare "☺" had been drawn. The cached glyph
is used only when it is not colour; otherwise the fallback's plain one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Text fields and the apps check Ctrl for copy, paste, cut, select all and undo;
on a Mac, and with a hardware keyboard on iOS, those shortcuts are on Command,
which was mapped to the unused window key. On Mac, iOS and tvOS the Command
keys now give LCTRL / RCTRL. Other systems are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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