Repository navigation
Fold text for clients without Unicode (AsciiFold) - #59
Merged
Merged
Conversation
AsciiFold replaces each character an ASCII-only or Latin-1 client cannot show with the nearest one it can, keeping markup and, for the built-in stand-ins, each character's width. A game's own stand-ins come first. LayoutContext.Fold folds the text inside every block before it is measured, through Block.MapText, so layouts stay aligned. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wkz2sT8dyvFw7JXXNXvjYN
|
Warning Review paused — included plan limit reachedKeep your review moving with free on-demand reviews.
On-demand reviews are free for one more day.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Promotion and pricing detailsOn-demand reviews are free for one more day. After that, they cost $0.25 per reviewed file. Review limit detailsOr wait 27 minutes for your next included review. Limit details: You’ve used the included review currently available. Your 84 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (19)
Comment |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wkz2sT8dyvFw7JXXNXvjYN
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.
Requested by Grave · project thread
Before: with
AsciiOnly, borders were drawn in ASCII but the text inside a block was left alone. A·in a title, a—or acaféreached an ASCII client unchanged, and the caller's encoder turned it into?or mojibake.After:
AsciiFoldreplaces each character the client cannot show with the nearest one it can.·and•become*, dashes-, curly quotes straight ones,éane, a fullwidth letter the letter plus a space. Anything else becomes?, once for each cell it took.new AsciiFold(latin1: true)keeps what Latin-1 has. A game's own stand-ins (new AsciiFold(translations)) come first and may be any width.Every built-in stand-in is as wide as the character it replaces, so softcode-padded columns stay aligned. Set as
LayoutContext.Fold, the fold runs on the text inside every block before the block is measured, so layouts stay aligned even with wider stand-ins.How:
AsciiFold.Fold(string | MarkupText)works on grapheme clusters, keeps each replaced character's markup and leaves point carriers alone. Accents and fullwidth forms come from built-in tables rather thanstring.Normalize, becauseNormalizedoes nothing under invariant globalization (checked withDOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1). New virtualBlock.MapTextis overridden by every built-in block and maps content and titles, not decoration.BlockLayout.Build/Lines/RelayoutapplyLayoutContext.Fold; the tree aLayoutMarkupcarries stays unfolded. Docs indocs/layout.md, changelog under Unreleased.This should ship after 2.16.0 (#58); it adds API, so it is a minor bump. The SharpMUSH side (charset plumbing,
ascii_translationsconfig) follows once it is released.Tests:
AsciiFoldTests(23) pass with and without invariant globalization; the full suite (1145) passes; whitespace format is clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Wkz2sT8dyvFw7JXXNXvjYN
Generated by Claude Code