Class: OsCtl::Cli::Top::Tui::Help

Inherits:
Screen
  • Object
show all
Defined in:
lib/osctl/cli/top/tui/help.rb

Instance Method Summary collapse

Constructor Details

#initialize(main_screen) ⇒ Help

Returns a new instance of Help.



6
7
8
9
# File 'lib/osctl/cli/top/tui/help.rb', line 6

def initialize(main_screen)
  super()
  @main_screen = main_screen
end

Instance Method Details

#openObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/osctl/cli/top/tui/help.rb', line 11

def open
  loop do
    render

    case Curses.getch
    when 'q', '?', Tui::Key::ESCAPE
      return @main_screen

    when Curses::Key::RESIZE
      Curses.clear
    end
  end
end

#renderObject (protected)



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/osctl/cli/top/tui/help.rb', line 27

def render
  Curses.setpos(0, 0)
  Curses.addstr('Key bindings:')

  pos = 0

  [
    ['q', 'Quit'],
    ['<, >, left, right', 'Change sort column'],
    ['r, R', 'Reverse sort order'],
    ['up, down', 'Select containers'],
    ['space', 'Highlight selected container'],
    ['enter, t', 'Open top and filter container processes'],
    ['h', 'Open htop and filter container processes'],
    ['PageDown', 'Scroll down'],
    ['PageUp', 'Scroll up'],
    ['Home', 'Scroll to the top'],
    ['End', 'Scroll to the bottom'],
    ['m', 'Toggle between realtime and cumulative mode'],
    ['p', 'Pause/unpause resource tracking'],
    ['/', 'Filter containers by ID. Confirm by enter, cancel by esc'],
    ['?', 'Show/hide this help message']
  ].each_with_index do |arr, i|
    key, desc = arr

    Curses.setpos(i + 2, 4)
    Curses.addstr(format('%20s - %s', key, desc))

    pos = i + 2
  end

  Curses.setpos(pos + 2, 0)
  Curses.addstr("Press 'q', '?' or <Esc> to continue")
end