Skip to content

Right to left round 2: editing, keys, window frame, copies, fallbacks and edit cost - #812

Merged
Hona merged 1 commit into
devfrom
bidi-round2
Nov 12, 2026
Merged

Hona merged 1 commit into
devfrom
bidi-round2

Conversation

@Hona

@Hona Hona commented Nov 12, 2026

Copy link
Copy Markdown
Member

Round 2 of right-to-left support: editing, keys, the window frame, copies, fallbacks and the cost of a keystroke in a long draft.

Before and after (Arabic interface, 1.5x)

Before After
Caption buttons and tab strip
Tooltip with keycaps
Untranslated sentence

Editing

  • Words by UAX Linux: FreeSerif symbol fallback, session-theme icons, single-instance, GNOME toplevel fallback (fixes #2, #20, #21, #22) #29 (edit/caret_motion.rs): src/util/format.ts steps src, util, format.ts; Ctrl+Backspace after مرحبا(اختبار) keeps (; می‌شود is one word.
  • Word forward in right-to-left text (edit/input.rs, space_ahead): Ctrl+Left from an Arabic line's start lands past the space, as Chrome 152 on Windows does (offset 6 in مرحبا مرحبا).
  • Ctrl+Left Shift / Ctrl+Right Shift (edit/direction_keys.rs): sets a field's direction, as Notepad and Word do. The runtime steps the chord on every physical key; any logical key disarms it, so Ctrl+Shift+P never sets it.
stateDiagram-v2
  Idle --> Ctrl: Ctrl down
  Ctrl --> Armed: one Shift down
  Armed --> Idle: release (sets Ltr or Rtl)
  Armed --> Idle: any other key
Loading

Keys, frame and overlays

  • Left and Right swap in right-to-left focus groups, sliders and Kit trees (Tree::right_to_left).
  • Caption::mirrored follows labels::set_direction: the buttons sit at the top-left with Close first, hit-testing and ChromeInsets::leading with them.
  • Tooltips lay right-to-left words inside the box and put keycaps after the words (runtime/input/help.rs).
  • El::inline_icon in right-to-left text takes the far side of its room, so the gap stays between icon and word (text/pill_chips.rs).

Copies and fallbacks

  • serialize_html adds dir per block when the copy holds right-to-left text; a left-to-right copy is byte-identical.
<p dir="rtl">مرحبا بالعالم</p><p dir="rtl">123</p><pre dir="ltr"><code>let x = 1</code></pre>
  • rune-i18n codegen: a right-to-left locale's missing message is LRI + source + PDI; plural categories keep their own fallback.

Cost of a keystroke in a 2,000-line draft

TextSystem::lay_out_paragraphs now keys only the paragraphs between the old and new text's common start and end (reuse_keys, compared 16 bytes at a time) and keeps kept paragraphs' measures (Paragraph::widths). spell::by_words hashes each line once.

Profile, 260 keystrokes, release + debuginfo Before After
layout_text per keystroke 550 µs 277 µs
of it, the old-vs-new scan 180 µs 60 µs

Tooling

  • --tree lists a focused field's selection (UTF-8 anchor and focus).
  • Scripts press one modifier key: {"modifier": "ShiftRight", "down": true, "mods": "ctrl+shift"}.

… and edit cost

- Fields step words by UAX #29 (paths, brackets, Persian ZWNJ words), and a word forward stops at the next word's start in right-to-left text too.
- Ctrl+Left Shift and Ctrl+Right Shift set a field's direction on Windows and Linux; a shortcut with them never does.
- Left and Right swap in right-to-left focus groups, sliders and Kit trees; right-to-left table rows copy as tab-separated cells.
- Tab titles fade at their own end; Luau UI text reads the way its words do.
- In a right-to-left app the Windows caption buttons sit at the top-left, tooltips read from the right, and inline icons keep their gap beside their word.
- Rich HTML copies say each block's direction; a right-to-left locale's missing message is the English one, isolated.
- A keystroke in a long plain draft keys only the paragraphs it touched; spell checking hashes each line once.
- Tooling: --tree lists a focused field's selection; scripts press single modifier keys.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 18:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Hona
Hona merged commit 5cca610 into dev Nov 12, 2026
1 check passed
kitlangton added a commit that referenced this pull request Nov 12, 2026
…pped over (r378)

#812 broke the pill stop: its pill-end clause skipped the end the scan reached,
so the caret jumped over @noah instead of stopping after it. Its UAX #29 split of
an emoji from the word before it is deliberate, so that expectation moved to "hé".
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