6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/wingtips/presentation.rb', line 6
def self.start(config)
slides = config.slide_classes
puts "Presenting #{slides.size} slides"
Shoes.app(config.app_options) do
@slides = slides
@wingtips_options = config.wingtips_options
@code_highlighting = Shoes::Highlighter::Markup::COLORS
if @wingtips_options[:code_highlighting]
@code_highlighting = @code_highlighting.merge @wingtips_options[:code_highlighting]
end
def start
setup_controls
go_to_slide(0)
end
def code_highlighting
@code_highlighting
end
def on_slide_change(&block)
@on_slide_change_block = block
end
def slide_changing
@on_slide_change_block.call if @on_slide_change_block
end
def go_to_slide(number)
clear
@current_slide.slide_changing if @current_slide
@current_slide_number = number.to_i
slide_class = @slides[@current_slide_number]
@current_slide = slide_class.new(app, @wingtips_options)
@current_slide.show
end
def next_slide
if @current_slide_number <= @slides.size - 2
go_to_slide @current_slide_number + 1
else
exit
end
end
def previous_slide
if @current_slide_number > 0
go_to_slide @current_slide_number - 1
end
end
def setup_controls
keypress do |key|
slide_controls key
fullscreen_controls key
end
end
def slide_controls(key)
if NEXT_KEYS.include? key
if @current_slide.effects_left?
@current_slide.trigger_effect
else
next_slide
end
end
previous_slide if PREVIOUS_KEYS.include? key
end
def fullscreen_controls(key)
toggle_fullscreen if key == :f11 || key == "f"
end
def toggle_fullscreen
self.fullscreen = !fullscreen
end
start
end
end
|