list_view

This commit is contained in:
2026-05-12 21:27:00 +02:00
parent 0db3951999
commit d92768dd23
2 changed files with 8 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
GIT GIT
remote: https://git.teletype.hu/tools/rubbs.git remote: https://git.teletype.hu/tools/rubbs.git
revision: da5acfd55e5e9dcb9959437bba84db21e5540aa8 revision: be21826eccc8eb2930b7a83a97b8ed9672219a9c
specs: specs:
bbs (0.3.0) bbs (0.3.0)
artii (~> 2.1) artii (~> 2.1)

View File

@@ -55,22 +55,13 @@ module TUIHelpers
end end
def render_wiki_list def render_wiki_list
list_height = content_height - 3 list_view @items,
visible = @items[@scroll, list_height] || [] x: CONTENT_X, y: CONTENT_Y,
if visible.empty? height: content_height - 3, scroll: @scroll, selected: @item_selection,
text 'No items found.', x: CONTENT_X, y: CONTENT_Y, style: THEME[:normal] label: ->(p) { p.title[0, content_width - 2] },
else hint: ->(p) { p.description.to_s[0, content_width] },
list visible.map { |wiki_page| wiki_page.title[0, content_width - 2] }, hint_y: CONTENT_Y + content_height - 2,
x: CONTENT_X, style: THEME[:normal], highlight: THEME[:selected]
y: CONTENT_Y,
selected: @item_selection - @scroll,
style: THEME[:normal],
highlight: THEME[:selected]
if (wiki_page = @items[@item_selection])
hint = wiki_page.description.to_s.strip[0, content_width]
text hint, x: CONTENT_X, y: CONTENT_Y + content_height - 2, style: THEME[:normal] unless hint.empty?
end
end
text '↑↓ navigate Enter read r refresh q back', text '↑↓ navigate Enter read r refresh q back',
x: CONTENT_X, y: CONTENT_Y + content_height, style: THEME[:label] x: CONTENT_X, y: CONTENT_Y + content_height, style: THEME[:label]
end end