Archived
1
0
Fork 0

Display status

This commit is contained in:
Braiden Vasco 2017-07-21 12:18:29 +00:00
parent 5fbd8b1657
commit 563cb4c99a
2 changed files with 12 additions and 3 deletions

View file

@ -16,3 +16,6 @@ Style/TrailingCommaInArguments:
Style/TrailingCommaInLiteral: Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma EnforcedStyleForMultiline: comma
Style/VariableInterpolation:
Enabled: false

View file

@ -64,7 +64,9 @@ private
end end
def initials def initials
@items = 1.upto(Curses.stdscr.maxy + 10).map do @height = Curses.stdscr.maxy - 1
@items = 1.upto(@height + 10).map do
['Qwe'].*(3 * (1 + rand(10))).join(' ') ['Qwe'].*(3 * (1 + rand(10))).join(' ')
end end
@ -86,14 +88,18 @@ private
def render def render
Curses.clear Curses.clear
@items.each_with_index.to_a[@top...(@top + Curses.stdscr.maxy)].each do |item, index| Curses.attron Curses.color_pair 1
Curses.setpos 0, 0
Curses.addstr "items: #{@items.count}, height: #@height, active: #@active, top: #@top"
@items.each_with_index.to_a[@top...(@top + @height)].each do |item, index|
if index == @active if index == @active
Curses.attron Curses.color_pair 2 Curses.attron Curses.color_pair 2
else else
Curses.attron Curses.color_pair 1 Curses.attron Curses.color_pair 1
end end
Curses.setpos index, 0 Curses.setpos 1 + index, 0
Curses.addstr "#{index}: #{item}".ljust Curses.stdscr.maxx Curses.addstr "#{index}: #{item}".ljust Curses.stdscr.maxx
end end