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

Inherits:
View
  • Object
show all
Defined in:
lib/osctl/cli/top/tui.rb,
lib/osctl/cli/top/tui/screen.rb

Defined Under Namespace

Classes: Help, Main, Screen

Constant Summary collapse

SELECTED =
1
HIGHLIGHTED =
2
SELECTED_HIGHLIGHTED =
3

Instance Attribute Summary

Attributes inherited from View

#model, #rate

Instance Method Summary collapse

Methods inherited from View

#initialize

Constructor Details

This class inherits a constructor from OsCtl::Cli::Top::View

Instance Method Details

#startObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/osctl/cli/top/tui.rb', line 10

def start
  Curses.init_screen
  Curses.start_color
  Curses.crmode
  Curses.stdscr.keypad = true
  Curses.curs_set(0)  # hide cursor
  Curses.use_default_colors
  Curses.init_pair(SELECTED, Curses::COLOR_BLACK, Curses::COLOR_WHITE)
  Curses.init_pair(HIGHLIGHTED, Curses::COLOR_YELLOW, Curses::COLOR_BLACK)
  Curses.init_pair(SELECTED_HIGHLIGHTED, Curses::COLOR_RED, Curses::COLOR_WHITE)

  screen = Top::Tui::Main.new(model, rate)

  loop do
    screen = screen.open
    break unless screen

    Curses.clear
  end

rescue Interrupt
ensure
  Curses.close_screen
end