Each page is now a self-contained module with a configure(tui) class method. Shared helpers live in TUIHelpers. bbs.rb is reduced to constants, chrome, and wiring. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
934 B
Ruby
32 lines
934 B
Ruby
# frozen_string_literal: true
|
|
|
|
module NewMsgPage
|
|
def self.configure(tui)
|
|
tui.page :new_msg do
|
|
enter { @page_title = 'POST MESSAGE'; @input = +''; @status = +'' }
|
|
|
|
render do
|
|
text 'Type your message and press Enter. Esc cancels.',
|
|
x: CONT_X, y: CONT_Y, style: THEME[:normal]
|
|
text "#{tc(:bright, @username)}: #{tc(:input, @input)}_",
|
|
x: CONT_X, y: CONT_Y + 2
|
|
unless @status.empty?
|
|
text @status, x: CONT_X, y: CONT_Y + 4, style: THEME[:error]
|
|
end
|
|
end
|
|
|
|
key(:enter) do
|
|
if @input.strip.empty?
|
|
@status = 'Message cannot be empty.'
|
|
else
|
|
MESSAGES.append(@username, @input.strip[0...200])
|
|
go :idle
|
|
end
|
|
end
|
|
key(:backspace) { @input.chop! unless @input.empty? }
|
|
key(:escape) { go :idle }
|
|
printable { |ch| @input << ch if @input.length < 200 }
|
|
end
|
|
end
|
|
end
|