editbox: draw the text by SetJustifyH (#2999)

An edit box always drew its text left-aligned: `SetJustifyH("RIGHT")` or `("CENTER")` moved only the `OnCursorChanged` x.

In 1.12.1 the box's `SetJustifyH` writes the box's own font (`0x797a17`, `+0x324`) through the shared setter `0x79fc20`, which pushes the change to the label linked to that font (`0x779c27`). `SetMultiLine` cuts off only the label's vertical bits (`0x77a509`, `0x77a599`), so the horizontal justify draws.

The box's font now exists with its label, justified `LEFT` as the constructor leaves it (`0x779bd2`). The four justify methods act on that font, the label no longer pins H, and the caret reads the label's justify. The separate justify word on the box is gone.

Test: `the_text_draws_by_the_boxs_justify_h_and_its_own_justify_v` checks the drawn H follows `SetJustifyH` while V stays the box's own. Without the fix, RIGHT draws LEFT.

Fixes #2977

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sam Sung
2026-11-06 22:09:19 +07:00
committed by GitHub
parent f9889a3c9d
commit e748780b9e
7 changed files with 119 additions and 55 deletions
+6 -6
View File
@@ -851,12 +851,12 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### widget
- The history browses as a shell's does because it is a small everyday gain: the first UP stashes the line being typed and DOWN past the newest line brings it back, UP holds at the oldest, DOWN does nothing when not browsing, typing or a focus gain ends the browse, and an empty line is not kept. The reference's history is a ring of `historyLines` slots that keeps any line (`0x77cf40`); UP scans back for the previous filled slot, wrapping (`0x77d030`), DOWN forward with `idiv` (`0x77cfd0`), each a `SetText` (`0x77be00`), with no draft and no stop at either end. ([`src/widget/kinds/editbox.rs:247`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L247))
- A plain Left or Right (or Ctrl+B or F) with a selection collapses it to that edge, because every OS's own text fields do; the reference clears the selection and steps once from the caret (`0x77c6b0` from `0x77c70b`). ([`src/widget/kinds/editbox.rs:818`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L818))
- Left reads the whole character before the caret, not the lone byte `caret - 1` the client reads (`0x77c8da`), because that takes a multi-byte space for a non-space. ([`src/widget/kinds/editbox.rs:837`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L837))
- On the last row a walk may end at the text's end, because the end starts no row; the reference steps back from it as from a row's start (its line table ends with the text's length, `0x77d6ef`), so DOWN onto a short last line stops before its last letter. ([`src/widget/kinds/editbox.rs:888`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L888))
- The drag selects from its anchor, because every OS's own text fields do, where the reference's applies `0x77cd10` to each mouse move's whole delta (`0x77a8a1`). The two part in two cases. One move that carries the caret across the anchor keeps the far end selected too in the reference. And a drag that starts with the caret inside a selection, as after a focus that selects all, gives `(0, t)` here dragging right to `t`, where the reference gives `(t, len)`. ([`src/widget/kinds/editbox.rs:1001`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L1001))
- A code point past U+FFFF is no space, because the client tests its low 16 bits, so U+10020 counts as a space there. ([`src/widget/kinds/editbox.rs:1131`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L1131))
- The history browses as a shell's does because it is a small everyday gain: the first UP stashes the line being typed and DOWN past the newest line brings it back, UP holds at the oldest, DOWN does nothing when not browsing, typing or a focus gain ends the browse, and an empty line is not kept. The reference's history is a ring of `historyLines` slots that keeps any line (`0x77cf40`); UP scans back for the previous filled slot, wrapping (`0x77d030`), DOWN forward with `idiv` (`0x77cfd0`), each a `SetText` (`0x77be00`), with no draft and no stop at either end. ([`src/widget/kinds/editbox.rs:218`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L218))
- A plain Left or Right (or Ctrl+B or F) with a selection collapses it to that edge, because every OS's own text fields do; the reference clears the selection and steps once from the caret (`0x77c6b0` from `0x77c70b`). ([`src/widget/kinds/editbox.rs:789`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L789))
- Left reads the whole character before the caret, not the lone byte `caret - 1` the client reads (`0x77c8da`), because that takes a multi-byte space for a non-space. ([`src/widget/kinds/editbox.rs:808`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L808))
- On the last row a walk may end at the text's end, because the end starts no row; the reference steps back from it as from a row's start (its line table ends with the text's length, `0x77d6ef`), so DOWN onto a short last line stops before its last letter. ([`src/widget/kinds/editbox.rs:859`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L859))
- The drag selects from its anchor, because every OS's own text fields do, where the reference's applies `0x77cd10` to each mouse move's whole delta (`0x77a8a1`). The two part in two cases. One move that carries the caret across the anchor keeps the far end selected too in the reference. And a drag that starts with the caret inside a selection, as after a focus that selects all, gives `(0, t)` here dragging right to `t`, where the reference gives `(t, len)`. ([`src/widget/kinds/editbox.rs:972`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L972))
- A code point past U+FFFF is no space, because the client tests its low 16 bits, so U+10020 counts as a space there. ([`src/widget/kinds/editbox.rs:1102`](../crates/benilla-ui/src/widget/kinds/editbox.rs#L1102))
- The cut backs up to a character start, where the reference cuts at the byte, because a Rust string holds whole characters. ([`src/widget/kinds/messageframe.rs:120`](../crates/benilla-ui/src/widget/kinds/messageframe.rs#L120))
- N of -2 or less is an empty line too, because the reference asks `SMemAlloc` for about 4 GB and fails. ([`src/widget/kinds/messageframe.rs:122`](../crates/benilla-ui/src/widget/kinds/messageframe.rs#L122))
- An index past 5 reads the last entry, because 1.12.1 reads past both six-entry tables (`0x6da9d5`, `0x6da9c4`), a client fault a hand-edited CVar reaches. ([`src/widget/kinds/mod.rs:973`](../crates/benilla-ui/src/widget/kinds/mod.rs#L973))