feat: add Set Lines and Set Columns for character-based terminal sizing#731
Open
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
Open
feat: add Set Lines and Set Columns for character-based terminal sizing#731mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
Conversation
Add Lines/Rows and Columns/Cols settings that compute pixel dimensions from font metrics, allowing users to specify terminal size in characters instead of pixels. Relates to charmbracelet#578
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.
Summary
Add
Set LinesandSet Columnssettings that let users specify terminal dimensions in characters instead of pixels. Also addsSet RowsandSet Colsas aliases.Why this matters
VHS currently requires pixel-based sizing (
Set Width 1200/Set Height 600). Users who want a specific terminal geometry (e.g., 80x24) have to guess at pixel values, render, check, and adjust repeatedly.colsandrowsnatively in their configVideo Demo
Changes
token/token.go: AddedLINES,COLUMNS,ROWS,COLStoken types, keyword mappings, andIsSetting()registrationcommand.go: AddedExecuteSetLinesandExecuteSetColumnsfunctions that compute pixel dimensions from font metrics (font size * line height for rows, font size * 0.6 char width ratio for columns), accounting for padding, margin, and window barexamples/fixtures/all.tape: Added fixture entries for parser/lexer test coveragelexer/lexer_test.go: Added expected tokens for new settingsparser/parser_test.go: Added expected parsed commands for new settingsREADME.md: Documented new settings in the Settings tableexamples/settings/lines-columns.tape: Added example tapeUsage
When both pixel and character dimensions are specified, the last one wins (consistent with existing Set behavior).
Testing
All existing tests pass. New parser and lexer tests cover
Lines,Columns,Rows, andColskeywords. Built from source and verified the feature renders correctly.Relates to #578
This contribution was developed with AI assistance (Claude Code).