Extract pages into lib/page/ modules; thin down bbs.rb
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>
This commit is contained in:
20
lib/page/page_view_page.rb
Normal file
20
lib/page/page_view_page.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageViewPage
|
||||
def self.configure(tui)
|
||||
tui.page :page_view do
|
||||
render do
|
||||
text @page_meta[0, cont_w], x: CONT_X, y: CONT_Y, style: THEME[:normal]
|
||||
(@detail[@scroll, cont_h - 2] || []).each_with_index do |l, i|
|
||||
text l[0, cont_w], x: CONT_X, y: CONT_Y + 2 + i, style: THEME[:normal]
|
||||
end
|
||||
text "#{@scroll + 1}/#{@detail.size} ↑↓ scroll q back",
|
||||
x: CONT_X, y: CONT_Y + cont_h, style: THEME[:normal]
|
||||
end
|
||||
|
||||
nav :scroll, content: -> { @detail }, window: -> { cont_h - 2 }
|
||||
key('q') { @scroll = 0; go(@prev_page || :idle) }
|
||||
key(:escape) { @scroll = 0; go(@prev_page || :idle) }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user