tty_slides 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/main_window.rb +5 -4
- data/lib/options.rb +1 -1
- data/lib/q_and_a_client.rb +1 -1
- data/lib/q_and_a_window.rb +1 -1
- data/lib/tty_slides.rb +35 -17
- data/lib/tty_slides/version.rb +2 -2
- metadata +1 -1
data/lib/main_window.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'delegate'
|
2
2
|
|
3
|
-
class MainWindow < SimpleDelegator
|
4
|
-
def initialize window
|
5
|
-
|
3
|
+
class TtySlides::MainWindow < SimpleDelegator
|
4
|
+
def initialize window, title=''
|
5
|
+
@title = title
|
6
|
+
super window
|
6
7
|
refresh
|
7
8
|
end
|
8
9
|
|
@@ -13,7 +14,7 @@ class MainWindow < SimpleDelegator
|
|
13
14
|
def refresh
|
14
15
|
box("|", "-")
|
15
16
|
setpos(0, 0)
|
16
|
-
addstr(
|
17
|
+
addstr(@title)
|
17
18
|
super
|
18
19
|
end
|
19
20
|
end
|
data/lib/options.rb
CHANGED
data/lib/q_and_a_client.rb
CHANGED
data/lib/q_and_a_window.rb
CHANGED
data/lib/tty_slides.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
class TtySlides
|
2
2
|
require 'curses'
|
3
3
|
require 'io/console'
|
4
4
|
|
@@ -11,28 +11,22 @@ module TtySlides
|
|
11
11
|
require 'slide_list'
|
12
12
|
require 'options'
|
13
13
|
|
14
|
-
@options = Options.parse!
|
15
|
-
|
16
14
|
Curses.init_screen
|
17
15
|
Curses.noecho
|
18
16
|
Curses.curs_set(0) # no cursor please
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Curses.refresh
|
18
|
+
def initialize title=''
|
19
|
+
@title = title
|
20
|
+
@options = Options.parse!
|
21
|
+
@height = Curses.lines
|
22
|
+
@width = Curses.cols
|
23
|
+
@slides = SlideList.new(@options.start_at)
|
24
|
+
setup_windows
|
25
|
+
exit_handlers
|
26
|
+
setup_q_and_a
|
30
27
|
end
|
31
28
|
|
32
|
-
|
33
|
-
at_exit { Curses.close_screen }
|
34
|
-
|
35
|
-
def self.start
|
29
|
+
def start
|
36
30
|
CML.new(@main_window, File.read(@slides.next)).render
|
37
31
|
|
38
32
|
loop do
|
@@ -47,4 +41,28 @@ module TtySlides
|
|
47
41
|
end
|
48
42
|
end
|
49
43
|
|
44
|
+
private
|
45
|
+
|
46
|
+
def setup_windows
|
47
|
+
main_win = Curses::Window.new(@height - 5, @width, 0, 0)
|
48
|
+
@main_window = MainWindow.new(main_win, @title)
|
49
|
+
q_and_a_win = Curses::Window.new(5, @width, @main_window.maxy, 0)
|
50
|
+
@q_and_a = QandAWindow.new(q_and_a_win)
|
51
|
+
end
|
52
|
+
|
53
|
+
def setup_q_and_a
|
54
|
+
@q_a_client = QandAClient.new(@q_and_a, @options.host, @options.port)
|
55
|
+
if !@q_a_client.connected?
|
56
|
+
@main_window.resize @height, @width
|
57
|
+
Curses.refresh
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def exit_handlers
|
62
|
+
at_exit do
|
63
|
+
puts "Last Slide: #{@slides.current}" if $!.kind_of?(StandardError)
|
64
|
+
end
|
65
|
+
at_exit { Curses.close_screen }
|
66
|
+
end
|
67
|
+
|
50
68
|
end
|
data/lib/tty_slides/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0.
|
1
|
+
class TtySlides
|
2
|
+
VERSION = "0.0.3"
|
3
3
|
end
|