pppt 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/pppt +1 -1
- data/lib/pppt/helpers.rb +8 -2
- data/lib/pppt/presentation.rb +2 -2
- data/lib/pppt/presentation_pages.rb +1 -1
- data/lib/pppt/presentation_window.rb +10 -17
- data/lib/pppt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f90ebf9bce01e79f124e7a2c2d58561bf22fbaab
|
4
|
+
data.tar.gz: baa9af08d7443cb4444a5777024533a3c8d6a56a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 621a0b993e1716cdd36e639652bb8940da46a10c2ad73d12612ddabdc0e8770634e374c2206e06146be2d9d1164d19fa481e1f8c1e48b133eb9d42a42701e9c0
|
7
|
+
data.tar.gz: a5cfc7ec844c9a36c536bf979c2b9fb9712ecce83a2f8d5d4a00a0d131c19c68cc73da16691e722e62752a0242b47ad0d90bf919a8bcf38cdb7e0ab22bebfdb2
|
data/exe/pppt
CHANGED
data/lib/pppt/helpers.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Helpers
|
1
|
+
class Pppt::Helpers
|
2
2
|
def self.truncate_screen_width(str, width, suffix = '...')
|
3
3
|
i = 0
|
4
4
|
str.each_char.inject(0) do |c, x|
|
@@ -12,7 +12,7 @@ class Helpers
|
|
12
12
|
|
13
13
|
def self.split_screen_width(str, width = 40)
|
14
14
|
s = i = r = 0
|
15
|
-
str.each_char.
|
15
|
+
str.each_char.each_with_object([]) do |c, res|
|
16
16
|
i += c.ascii_only? ? 1 : 2
|
17
17
|
r += 1
|
18
18
|
next res if i < width
|
@@ -27,4 +27,10 @@ class Helpers
|
|
27
27
|
hankaku_len = str.each_char.count(&:ascii_only?)
|
28
28
|
hankaku_len + (str.size - hankaku_len) * 2
|
29
29
|
end
|
30
|
+
|
31
|
+
def self.format_page_number(page)
|
32
|
+
index = page['page'] || '-'
|
33
|
+
title = page['action'] || (page['title'] && " - #{page['title']}") || page['h1'] || page['h2'] || page['h3'] || (page['body'] && " #{Helpers.truncate_screen_width(page['body'].join(''), 15)}")
|
34
|
+
format('%02s %s', index, title)
|
35
|
+
end
|
30
36
|
end
|
data/lib/pppt/presentation.rb
CHANGED
@@ -5,9 +5,9 @@ require 'pppt/presentation_pages'
|
|
5
5
|
require 'pppt/presentation_window'
|
6
6
|
include Curses
|
7
7
|
|
8
|
-
class Presentation
|
8
|
+
class Pppt::Presentation
|
9
9
|
def initialize(pages)
|
10
|
-
@window = PresentationWindow.new(pages)
|
10
|
+
@window = Pppt::PresentationWindow.new(pages)
|
11
11
|
@prev_ch = nil
|
12
12
|
Curses.stdscr.keypad(true)
|
13
13
|
Curses.noecho
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class PresentationWindow
|
1
|
+
class Pppt::PresentationWindow
|
2
2
|
def initialize(data)
|
3
|
-
@pages = PresentationPages.new(data)
|
3
|
+
@pages = Pppt::PresentationPages.new(data)
|
4
4
|
@current = 0
|
5
5
|
@max = @pages.size
|
6
6
|
init_screen
|
@@ -40,8 +40,8 @@ class PresentationWindow
|
|
40
40
|
w.addstr(' ' * w.maxx)
|
41
41
|
w.setpos(vindex, 3)
|
42
42
|
w.standout if i == current
|
43
|
-
|
44
|
-
w.addstr(
|
43
|
+
page_number_string = Pppt::Helpers.format_page_number(page)
|
44
|
+
w.addstr(page_number_string + (' ' * (w.maxx - Pppt::Helpers.screen_width(page_number_string) - 4)))
|
45
45
|
vindex += 1
|
46
46
|
w.standend if i == current
|
47
47
|
break if i >= start_point + height
|
@@ -85,17 +85,10 @@ class PresentationWindow
|
|
85
85
|
w.addstr(Time.now.strftime('%H:%M:%S'))
|
86
86
|
end
|
87
87
|
|
88
|
-
# 目次ページでのページ番号の整形
|
89
|
-
def page_to_string(page)
|
90
|
-
index = page['page'] || '-'
|
91
|
-
title = page['action'] || (page['title'] && " - #{page['title']}") || page['h1'] || page['h2'] || page['h3'] || (page['body'] && " #{Helpers.truncate_screen_width(page['body'].join(''), 15)}")
|
92
|
-
format('%02s %s', index, title)
|
93
|
-
end
|
94
|
-
|
95
88
|
# ページコンテンツを表示する
|
96
89
|
def write_element(w, k, v)
|
97
90
|
len = 1
|
98
|
-
len = Helpers.screen_width(v) if v.is_a? String
|
91
|
+
len = Pppt::Helpers.screen_width(v) if v.is_a? String
|
99
92
|
width = w.maxx - 1
|
100
93
|
pad = ' ' * ((width - len) / 2)
|
101
94
|
case k
|
@@ -134,7 +127,7 @@ class PresentationWindow
|
|
134
127
|
v.split("\n").each do |x|
|
135
128
|
x.chomp!
|
136
129
|
w.setpos((w.maxy / 2) - 2 + vindex, 0)
|
137
|
-
len = Helpers.screen_width(x)
|
130
|
+
len = Pppt::Helpers.screen_width(x)
|
138
131
|
pad = ' ' * ((width - len) / 2)
|
139
132
|
w.addstr("#{pad}#{x}#{pad}")
|
140
133
|
vindex += 1
|
@@ -152,7 +145,7 @@ class PresentationWindow
|
|
152
145
|
vindex = 5
|
153
146
|
w.setpos(vindex, 2)
|
154
147
|
v.each do |line|
|
155
|
-
vindex =
|
148
|
+
vindex = render_body_text(w, line, vindex)
|
156
149
|
end
|
157
150
|
when 'page'
|
158
151
|
w.setpos(w.maxy - 2, 0)
|
@@ -160,18 +153,18 @@ class PresentationWindow
|
|
160
153
|
end
|
161
154
|
end
|
162
155
|
|
163
|
-
def
|
156
|
+
def render_body_text(w, lines, vindex, level = 1)
|
164
157
|
width = w.maxx - 4
|
165
158
|
vi = vindex + 1
|
166
159
|
if lines.is_a? Array
|
167
160
|
lines.each do |sub_line|
|
168
|
-
vi =
|
161
|
+
vi = render_body_text(w, sub_line, vi, level + 1)
|
169
162
|
end
|
170
163
|
else
|
171
164
|
sp = ['*', '-', '>'][level - 1]
|
172
165
|
indent = ' ' * (level * 2)
|
173
166
|
lines.split("\n").each do |x|
|
174
|
-
Helpers.split_screen_width(x, width - (4 + 4 * level)).each do |xl|
|
167
|
+
Pppt::Helpers.split_screen_width(x, width - (4 + 4 * level)).each do |xl|
|
175
168
|
w.setpos(vi, 2)
|
176
169
|
w.addstr("#{indent}#{sp} #{xl}")
|
177
170
|
sp = ' '
|
data/lib/pppt/version.rb
CHANGED