tty_slides 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -5
- data/lib/slide_list.rb +1 -1
- data/lib/tty_slides/version.rb +1 -1
- data/lib/tty_slides.rb +47 -48
- metadata +1 -1
data/README.md
CHANGED
@@ -9,20 +9,28 @@ gem install tty_slides
|
|
9
9
|
```
|
10
10
|
|
11
11
|
## Usage
|
12
|
+
Create a startup file (e.g. `start.rb`)
|
12
13
|
```ruby
|
14
|
+
#! /usr/bin/env ruby
|
15
|
+
|
16
|
+
require "tty_slides"
|
17
|
+
|
13
18
|
# define the BASE_PATH and SLIDES
|
14
|
-
class SlideList
|
15
|
-
BASE_PATH = Pathname.new(
|
19
|
+
class TtySlides::SlideList
|
20
|
+
BASE_PATH = Pathname.new(__FILE__) + ".." + "slides"
|
16
21
|
|
17
22
|
SLIDES = [
|
18
|
-
"introduction"
|
19
|
-
"covermymeds",
|
23
|
+
"introduction"
|
20
24
|
]
|
21
25
|
end
|
26
|
+
|
27
|
+
# call `.start`
|
28
|
+
TtySlides.start
|
22
29
|
```
|
23
30
|
|
31
|
+
Start the presentation:
|
24
32
|
``bash
|
25
|
-
|
33
|
+
bundle exec ruby start.rb
|
26
34
|
```
|
27
35
|
|
28
36
|
## Adding Slides
|
data/lib/slide_list.rb
CHANGED
data/lib/tty_slides/version.rb
CHANGED
data/lib/tty_slides.rb
CHANGED
@@ -1,51 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Curses.
|
22
|
-
Curses.
|
23
|
-
Curses.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
q_a_client = QandAClient.new(q_and_a, options.host, options.port)
|
32
|
-
if !q_a_client.connected?
|
33
|
-
main_window.resize height, width
|
34
|
-
Curses.refresh
|
35
|
-
end
|
36
|
-
|
37
|
-
CML.new(main_window, File.read(slides.next)).render
|
38
|
-
|
39
|
-
at_exit { puts "Last Slide: #{slides.current}" if $!.kind_of?(StandardError) }
|
40
|
-
at_exit { Curses.close_screen }
|
1
|
+
module TtySlides
|
2
|
+
require 'curses'
|
3
|
+
require 'io/console'
|
4
|
+
|
5
|
+
require 'tty_slides/version'
|
6
|
+
require 'helpers/helper'
|
7
|
+
require 'cml/cml'
|
8
|
+
require 'main_window'
|
9
|
+
require 'q_and_a_window'
|
10
|
+
require 'q_and_a_client'
|
11
|
+
require 'slide_list'
|
12
|
+
require 'options'
|
13
|
+
|
14
|
+
@options = Options.parse!
|
15
|
+
|
16
|
+
Curses.init_screen
|
17
|
+
Curses.noecho
|
18
|
+
Curses.curs_set(0) # no cursor please
|
19
|
+
|
20
|
+
@height = Curses.lines
|
21
|
+
@width = Curses.cols
|
22
|
+
@main_window = MainWindow.new(Curses::Window.new @height - 5, @width, 0, 0)
|
23
|
+
@q_and_a = QandAWindow.new(Curses::Window.new 5, @width, @main_window.maxy, 0)
|
24
|
+
@slides = SlideList.new(@options.start_at)
|
25
|
+
|
26
|
+
@q_a_client = QandAClient.new(@q_and_a, @options.host, @options.port)
|
27
|
+
if !@q_a_client.connected?
|
28
|
+
@main_window.resize @height, @width
|
29
|
+
Curses.refresh
|
30
|
+
end
|
41
31
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
32
|
+
at_exit { puts "Last Slide: #{@slides.current}" if $!.kind_of?(StandardError) }
|
33
|
+
at_exit { Curses.close_screen }
|
34
|
+
|
35
|
+
def self.start
|
36
|
+
CML.new(@main_window, File.read(@slides.next)).render
|
37
|
+
|
38
|
+
loop do
|
39
|
+
case STDIN.getch
|
40
|
+
when /b/i
|
41
|
+
CML.new(@main_window, File.read(@slides.previous)).render
|
42
|
+
when /q/i
|
43
|
+
exit
|
44
|
+
else
|
45
|
+
CML.new(@main_window, File.read(@slides.next)).render
|
46
|
+
end
|
47
|
+
end
|
50
48
|
end
|
49
|
+
|
51
50
|
end
|