Skip to content

Let the user set their own text size - #14

Open
r3quie wants to merge 2 commits into
omacom-io:masterfrom
r3quie:text-size
Open

Let the user set their own text size#14
r3quie wants to merge 2 commits into
omacom-io:masterfrom
r3quie:text-size

Conversation

@r3quie

@r3quie r3quie commented Aug 16, 2026

Copy link
Copy Markdown

I was missing a feature to change text size on the fly.

Summary:

  • Adds bindingsCtrl+=, Ctrl+-, Ctrl+0, and Ctrl+wheel to control text size
  • Uses Chromium's zoom ladder, 67% to 200%
  • The footer reports each change
  • The size persists to the next window

Tested: bin/test passes (14, two of them new), and stepping the built app from 75%
to 150% scales the editor text, footer, and column width together.

The desktop's text scale was the only knob on typography, so a document
that read too small could only be fixed by changing the size of every
other application too. Multiply a text size of the user's own onto that
scale: the desktop still sets the baseline, and Ctrl+= / Ctrl+- /
Ctrl+0 and Ctrl+wheel move from there. Because everything already sizes
itself off textScale, the editor font, the 65-character column, the
footer, and the wheel physics all follow with no further plumbing.

The steps are Chromium's zoom ladder trimmed to 67%-200%, the range the
whole window still reads well at, so Ctrl+wheel here lands where the
same gesture lands in a browser. The ends of the ladder hold instead of
running away, and every change reports the new size in the footer,
including a keypress the ladder has no room for. A wheel notch is a
whole step, but a touchpad trickles in pixels, so bank the fractions
and step once a whole notch has been scrolled.

The size persists, so the next window opens where the last one left off.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Liam-Griffiths

Copy link
Copy Markdown

I'd also like this feature.

Ctrl++ is a distinct shortcut to Qt rather than a shifted Ctrl+=: pressing Shift and = resolves through QXkbCommon::possibleKeys to Ctrl+Plus, which Ctrl+= does not match, and a layout that puts + on its own key — German, Czech, the Nordic ones — never produces Ctrl+= at all, so its users had no way to make the text bigger. Ctrl+- needs nothing: minus is unshifted on those layouts, and the keypad modifier is stripped before shortcuts are matched, so the numpad keys fall out of this too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed this and drove the real Main.qml rather than reading behaviour off the diff. One fix pushed to your branch, two things still open.

Pushed (ee6e551): Ctrl++ and numpad + did not zoom in. "Ctrl+=" registers Qt::Key_Equal, and pressing Shift and = resolves through QXkbCommon::possibleKeys to Ctrl+Plus — a different combination, which Ctrl+= does not match. On a layout that puts + on its own key (German, Czech, the Nordic ones) nothing produces Ctrl+= at all, so those users had no way to make the text bigger at all. sequences: ["Ctrl+=", "Ctrl++"] covers both, and the numpad keys fall out of it because Qt strips KeypadModifier before matching shortcuts. There is a test that fails without the change. Ctrl+- needed nothing — minus is unshifted on those layouts.

Open: a text size change scrolls the view back to the caret. onCursorRectangleChanged: editorFlick.ensureCursorVisible() (Main.qml:612) fires when the font size changes the cursor rectangle, not only when the caret moves. With a 400-line document, the caret left at the top and the view parked at contentY 5000, one Ctrl+= leaves contentY at 0 — and so does one Ctrl+wheel notch. Zooming in only grows contentHeight, so nothing is clamping this; it is the jump to the caret. Reading in the middle of a long file and nudging the size throws you back to the top, on every step. Left for you because what zoom should do to the reading position is a call about the app, not a bug with one obvious fix.

Open, minor: the ladder drops Chromium's 80% rung. Chromium's is 0.25, 1/3, 0.5, 2/3, 0.75, 0.8, 0.9, 1.0, 1.1, ..., so 90% → 75% here is a coarser step than "Chromium's zoom ladder, trimmed to the range the whole window still reads well at" promises — trimming the range takes the ends off, not a rung out of the middle.

The rest held up under test. The 67%–200% clamp is enforced in the backend, so Ctrl+wheel past an end banks nothing and does not lurch when you reverse. A corrupt, empty, negative, zero, NaN or non-numeric text/zoom falls back to 100%, and an absurd one clamps to 200%. The while loops are bounded and cheap: a 100,000px pixelDelta, orders of magnitude past anything a compositor sends, ran in 8ms and settled at 200% with the bank drained to zero. Your own size composes with the desktop textScale rather than replacing it, at startup and on a live desktop change. bin/test is green at 15.

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.

3 participants