Add NAWS terminal size negotiation and dynamic dimensions
- Negotiate NAWS (option 31) on connect to receive terminal cols/rows - Expose term_cols/term_rows on Session (default 80×24) - Add term_cols/term_rows helpers to TUIRunner::Context - Make bar() default width dynamic via term_cols Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,13 +56,17 @@ module BBS
|
||||
@buf << "\e[#{row};#{col}H"
|
||||
end
|
||||
|
||||
def term_cols = @session.term_cols || 80
|
||||
def term_rows = @session.term_rows || 24
|
||||
|
||||
def text(content, x: nil, y: nil, style: nil)
|
||||
at(x, y) if x && y
|
||||
color = STYLES[style]
|
||||
@buf << (color ? "#{color}#{content}\e[0m" : content.to_s)
|
||||
end
|
||||
|
||||
def bar(y:, content:, width: 80, style: :muted)
|
||||
def bar(y:, content:, width: nil, style: :muted)
|
||||
width ||= term_cols
|
||||
text content.to_s.ljust(width), x: 1, y: y, style: style
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user