Repository navigation
Measure the new session label in cells, not characters - #4
Merged
Merged
Conversation
The framed button pads its label to the sidebar's width with `String.length`, which counts a full-width character as one. A label with CJK characters therefore came up short by one cell per character and pushed the right border past the frame; the ellipsis cut long labels at the wrong place for the same reason. Measure in cells instead: two for an East Asian Wide or Fullwidth character, one for the rest, and cut to a cell budget rather than to a character count. English labels render exactly as before. This is the label half of the CJK rendering problem. The glyphs themselves were also being drawn a cell wide, which is ascii.rest's mount(): see bas3line/ascii#79.
Contributor
Author
|
mainly fixed by AI, and im very appreciate to your theme, it is so nice for a retro style enthusiast like me |
fit() can return room-1 cells when a wide character does not fit, so always pad after fitting. The glint, arrow shaft and border checks now walk cell columns instead of string indices, so wide labels animate correctly.
3 tasks
Owner
|
Thanks, merged! I also opened #5 so I don't forget to bump the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
The framed New Session button pads its label to the sidebar's width using
String.length, which counts a full-width character as one cell. With a CJK label the row comes up short by one cell per character, so the right border sits past the frame and the label looks squeezed next to the arrow:After this change every row of the frame is 40 cells wide for
new session,新会话,新しいセッションand새 세션alike.What changed
src/pieces/new-session.js— measure the label in cells (two for an East Asian Wide or Fullwidth character, one otherwise) and pad toroomcells instead ofroomcharacters. The ellipsis that trims an over-long label now cuts at a cell budget too, so it no longer splits a wide character.lib/client.js— rebuilt withnpm run build.English labels are byte-for-byte unchanged: with no wide characters, cells and characters are the same number.
There is a second half to this
Padding correctly is only part of it. The glyphs were also being drawn one cell wide, because
mount()in ascii.rest advances one cell per character. That is not this repository's bug, and I have opened bas3line/ascii#79 for it. With this patch alone the label is positioned correctly but the glyphs still overlap; with that one merged, the button renders properly.If you would rather wait, this PR is still correct on its own — it fixes the frame width and the trim, both of which stay wrong regardless of how glyphs are rasterised.
Verification
npm run build— clean