24
25
26
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
61
62
63
64
65
|
# File 'lib/pppt/presentation_window.rb', line 24
def index
w = Curses.stdscr
current = @current
start_point = current - w.maxy / 2
loop do
height = w.maxy - 5
w.clear
w.setpos(1, 0)
w.addstr(' -- index --'.center(w.maxx - 1))
vindex = 3
start_point = current if start_point > current
start_point = current - height if current - start_point >= height
start_point = 0 if start_point < 0
@pages.data.each_with_index do |page, i|
next if i < start_point
w.setpos(vindex, 0)
w.addstr(' ' * w.maxx)
w.setpos(vindex, 3)
w.standout if i == current
page_number_string = Pppt::Helpers.format_page_number(page)
w.addstr(page_number_string + (' ' * (w.maxx - Pppt::Helpers.screen_width(page_number_string) - 4)))
vindex += 1
w.standend if i == current
break if i >= start_point + height
end
w.refresh
Curses.timeout = -1
c = w.getch
Curses.timeout = 1000
case c
when 27, 8
return current
when Curses::KEY_UP, 'k'
current -= 1 if current > 0
when Curses::KEY_DOWN, 'j'
current += 1 if current < @pages.data.length - 1
when 10, ' '
@current = current
return current
end
end
end
|