Class: XtopLoop

Inherits:
Object
  • Object
show all
Extended by:
Curses
Defined in:
lib/xtop/xtop_loop.rb

Overview

XtopLoop: Fetch input from user and respond.

Class Method Summary collapse

Class Method Details

.exit_xtopObject



7
8
9
10
# File 'lib/xtop/xtop_loop.rb', line 7

def self.exit_xtop
  close_screen
  exit(0)
end

.start(view) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xtop/xtop_loop.rb', line 12

def self.start(view)
  begin
    Signal.trap("SIGINT") do
      exit(0)
    end

    cbreak

    while true
      view.redraw
      yield(getch)
    end
  ensure
    close_screen
  end
end