Top Level Namespace
Defined Under Namespace
Modules: Intent
Instance Method Summary collapse
- #draw_card(top, item, focus) ⇒ Object
-
#draw_list(items, focus) ⇒ Object
print $cursor.hide.
- #truncate(str, width) ⇒ Object
Instance Method Details
#draw_card(top, item, focus) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/intent/ui/projects_active.rb', line 33 def draw_card(top, item, focus) style = unless top == focus { fg: :white, border: { fg: :white } } else { fg: :bright_white, border: { fg: :bright_magenta, bg: :black } } end title = if top == focus {bottom_right: "[x: close][enter: launch]"} else {} end #pastel = Pastel.new width = 90 TTY::Box.frame(width: width, height: 4, left: 4, title: title, border: :thick, style: style) do "\s#{truncate(item[:title], 88)}" end end |
#draw_list(items, focus) ⇒ Object
print $cursor.hide
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/intent/ui/projects_active.rb', line 70 def draw_list(items, focus) buffer = [] items.each_with_index do |item, i| buffer << draw_card(i, item, focus) end result = buffer.join("") print $cursor.clear_screen + $cursor.move_to(0,0) print result end |
#truncate(str, width) ⇒ Object
27 28 29 30 31 |
# File 'lib/intent/ui/projects_active.rb', line 27 def truncate(str, width) return str unless str.length >= width "#{str.slice(0, width-3)}..." end |