Class: Pppt::Presentation

Inherits:
Object
  • Object
show all
Defined in:
lib/pppt/presentation.rb

Instance Method Summary collapse

Constructor Details

#initialize(pages) ⇒ Presentation

Returns a new instance of Presentation.



9
10
11
12
13
14
15
16
# File 'lib/pppt/presentation.rb', line 9

def initialize(pages)
  @window = Pppt::PresentationWindow.new(pages)
  @prev_ch = nil
  Curses.stdscr.keypad(true)
  Curses.noecho
  Curses.curs_set(0)
  Curses.timeout = 1000
end

Instance Method Details

#getchObject



42
43
44
# File 'lib/pppt/presentation.rb', line 42

def getch
  @prev_ch = Curses.stdscr.getch
end

#inputObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pppt/presentation.rb', line 46

def input
  Curses.timeout = -1
  setpos(Curses.stdscr.maxy - 1, 0)
  Curses.stdscr.deleteln
  Curses.stdscr.addstr(':')
  Curses.echo
  Curses.curs_set(2)
  buf = Curses.stdscr.getstr
  Curses.curs_set(0)
  Curses.noecho
  Curses.timeout = 1000
  @prev_input = buf.chomp
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pppt/presentation.rb', line 18

def run
  loop do
    @window.show
    c = getch
    case c
    when 'l'
      @window.index
    when ':'
      cmd = input
      case cmd
      when 'list', 'l'
        @window.index
      when 'q', 'exit'
        exit
      end
      next
    when 'k', Curses::KEY_UP, Curses::KEY_LEFT, 8
      @window.prev
    when ' ', 'j', Curses::KEY_RIGHT, Curses::KEY_DOWN, 10
      @window.next
    end
  end
end