- 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>
25 lines
463 B
Ruby
25 lines
463 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'securerandom'
|
|
|
|
module BBS
|
|
class Session
|
|
include Telnet
|
|
|
|
attr_reader :session_id, :term_cols, :term_rows
|
|
|
|
def initialize(client)
|
|
@client = client
|
|
@session_id = SecureRandom.hex(8)
|
|
end
|
|
|
|
def run
|
|
negotiate
|
|
flow = BBS.config.flow or raise "BBS.config.flow is not set"
|
|
FlowRunner.new(self, @session_id, flow).run
|
|
ensure
|
|
@client.close rescue nil
|
|
end
|
|
end
|
|
end
|