diff --git a/.rubocop.yml b/.rubocop.yml index 79e5ca5..5a31f0b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,3 +16,6 @@ Style/TrailingCommaInArguments: Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma + +Style/VariableInterpolation: + Enabled: false diff --git a/lib/main.rb b/lib/main.rb index cc522b6..8109536 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -64,7 +64,9 @@ private end 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(' ') end @@ -86,14 +88,18 @@ private def render 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 Curses.attron Curses.color_pair 2 else Curses.attron Curses.color_pair 1 end - Curses.setpos index, 0 + Curses.setpos 1 + index, 0 Curses.addstr "#{index}: #{item}".ljust Curses.stdscr.maxx end