Dynamic Shortcut Helper Height Auto-Adaptation - #131
Merged
Conversation
- Calculate required height on-the-fly using a custom word-wrap algorithm. - Support terminal resizing via a custom draw function that recalculates the height when the width changes. - Avoid line splits inside individual shortcut entries by formatting space with non-breaking spaces (\u00a0) and separator vertical bar (|) with non-breaking dental clicks (\u01c0). - Avoid first-frame flicker by querying terminal size using golang.org/x/term on startup.
- Achieves 89% statement coverage for ShortcutMapComponent. - Verifies NewShortcutMap initialization, SetEntries formatting, Clear behavior, and custom CalculateHeightForWidth wrapping computations.
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.
This PR introduces dynamic height auto-adaptation for the TUI shortcut helper panel at the bottom of the interface. It ensures that all defined shortcuts are visible at all times, handling line wraps and terminal window resizing cleanly in a one-shot computation without clipping, entry splitting, or startup flickering.
Features & Implementation Details
1. Custom Word-Wrapping Height Math
CalculateHeightForWidth) insideShortcutMapComponent(shortcut_map_component.go) that operates on a slice of runes.2. Unbreakable Shortcut Entries (NBSP & Dental Click separators)
\u00a0).⭾|shift+⭾) are joined using the Unicode Latin Letter Dental Click (\u01c0/ǀ), which renders identically to a vertical bar but is treated as an alphabetic character by the Unicode wrapping algorithm (UAX Bump github.com/spf13/viper from 1.17.0 to 1.18.0 #14).3. Flicker-Free Initial Sizing
golang.org/x/term(term.GetSize(int(os.Stdout.Fd()))) as a fallback if the layout hasn't been drawn yet.Flexprior to the first draw loop, rendering the first frame perfectly with zero layout flickering.4. Smooth Terminal Resize Support
SetDrawFuncon the underlying text view to monitor real-time dimension shifts during terminal window resizes.Flexlayout (mainPageLayoutin main_page.go) is updated asynchronously usingapplication.QueueUpdateDrawfrom a background goroutine, avoiding deadlocks or recursion during the draw loop.Validation
go test ./...) compile and pass successfully.