Skip to content

feat: add Set Lines and Set Columns for character-based terminal sizing#731

Open
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
mvanhorn:osc/578-set-lines-columns
Open

feat: add Set Lines and Set Columns for character-based terminal sizing#731
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
mvanhorn:osc/578-set-lines-columns

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

Add Set Lines and Set Columns settings that let users specify terminal dimensions in characters instead of pixels. Also adds Set Rows and Set Cols as 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.

  • #578 - "Allow size control by line count (height) and character count (width)" (3 reactions)
  • Discussion Q&A - "How can I set the terminal size in units of characters?" (2 upvotes)
  • Competitors like terminalizer support cols and rows natively in their config

Video Demo

Demo

Changes

  • token/token.go: Added LINES, COLUMNS, ROWS, COLS token types, keyword mappings, and IsSetting() registration
  • command.go: Added ExecuteSetLines and ExecuteSetColumns functions 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 bar
  • examples/fixtures/all.tape: Added fixture entries for parser/lexer test coverage
  • lexer/lexer_test.go: Added expected tokens for new settings
  • parser/parser_test.go: Added expected parsed commands for new settings
  • README.md: Documented new settings in the Settings table
  • examples/settings/lines-columns.tape: Added example tape

Usage

# Before: pixel guesswork
Set Width 1200
Set Height 600

# After: specify exactly 80 columns by 24 lines
Set Columns 80
Set Lines 24

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, and Cols keywords. Built from source and verified the feature renders correctly.

Relates to #578

This contribution was developed with AI assistance (Claude Code).

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
@mvanhorn mvanhorn requested a review from a team as a code owner March 26, 2026 22:56
@mvanhorn mvanhorn requested review from andreynering and aymanbagabas and removed request for a team March 26, 2026 22:56
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.

1 participant