wok view tpp/stuff/ruby19.patch @ rev 21840

updated remind (03.01.15 -> 03.01.16)
author Hans-G?nter Theisgen
date Sat Sep 14 16:43:37 2019 +0100 (2019-09-14)
parents
children
line source
1 Description: make key events work on ruby 1.9
2 Author: Chad Fowler <chad@chadfowler.com>
3 Debian-Bug: 671530
5 Index: tpp/tpp.rb
6 ===================================================================
7 --- tpp.orig/tpp.rb 2013-06-12 18:13:40.000000000 +0200
8 +++ tpp/tpp.rb 2013-06-12 21:05:55.000000000 +0200
9 @@ -44,7 +44,7 @@
10 "blue" => 5,
11 "cyan" => 6,
12 "magenta" => 7,
13 - "black" => 8,
14 + "black" => 8,
15 "default" =>-1}
16 colors[color]
17 end
18 @@ -95,7 +95,7 @@
19 end # class FileParser
22 -# Represents a page (aka `slide') in TPP. A page consists of a title and one or
23 +# Represents a page (aka `slide') in TPP. A page consists of a title and one or
24 # more lines.
25 class Page
27 @@ -145,8 +145,8 @@
31 -# Implements a generic visualizer from which all other visualizers need to be
32 -# derived. If Ruby supported abstract methods, all the do_* methods would be
33 +# Implements a generic visualizer from which all other visualizers need to be
34 +# derived. If Ruby supported abstract methods, all the do_* methods would be
35 # abstract.
36 class TppVisualizer
38 @@ -154,8 +154,8 @@
39 # nothing
40 end
42 - # Splits a line into several lines, where each of the result lines is at most
43 - # _width_ characters long, caring about word boundaries, and returns an array
44 + # Splits a line into several lines, where each of the result lines is at most
45 + # _width_ characters long, caring about word boundaries, and returns an array
46 # of strings.
47 def split_lines(text,width)
48 lines = []
49 @@ -190,13 +190,13 @@
50 $stderr.puts "Error: TppVisualizer#do_footer has been called directly."
51 Kernel.exit(1)
52 end
53 -
54 +
55 def do_header(header_text)
56 $stderr.puts "Error: TppVisualizer#do_header has been called directly."
57 Kernel.exit(1)
58 end
60 -
61 +
62 def do_refresh
63 $stderr.puts "Error: TppVisualizer#do_refresh has been called directly."
64 Kernel.exit(1)
65 @@ -316,7 +316,7 @@
66 $stderr.puts "Error: TppVisualizer#do_command_prompt has been called directly."
67 Kernel.exit(1)
68 end
69 -
70 +
71 def do_beginslideright
72 $stderr.puts "Error: TppVisualizer#do_beginslideright has been called directly."
73 Kernel.exit(1)
74 @@ -377,7 +377,7 @@
75 Kernel.exit(1)
76 end
78 - # Receives a _line_, parses it if necessary, and dispatches it
79 + # Receives a _line_, parses it if necessary, and dispatches it
80 # to the correct method which then does the correct processing.
81 # It returns whether the controller shall wait for input.
82 def visualize(line,eop)
83 @@ -446,10 +446,10 @@
84 do_huge(figlet_text)
85 when /^--footer /
86 @footer_txt = line.sub(/^--footer /,"")
87 - do_footer(@footer_txt)
88 + do_footer(@footer_txt)
89 when /^--header /
90 @header_txt = line.sub(/^--header /,"")
91 - do_header(@header_txt)
92 + do_header(@header_txt)
93 when /^--title /
94 title = line.sub(/^--title /,"")
95 do_title(title)
96 @@ -547,7 +547,7 @@
97 @withborder = true
98 draw_border
99 end
100 -
101 +
102 def do_command_prompt()
103 message = "Press any key to continue :)"
104 cursor_pos = 0
105 @@ -614,11 +614,11 @@
106 (@termwidth-2).times { @screen.addstr("-") }; @screen.addstr("'")
107 1.upto(@termheight-3) do |y|
108 @screen.move(y,0)
109 - @screen.addstr("|")
110 + @screen.addstr("|")
111 end
112 1.upto(@termheight-3) do |y|
113 @screen.move(y,@termwidth-1)
114 - @screen.addstr("|")
115 + @screen.addstr("|")
116 end
117 end
119 @@ -700,7 +700,7 @@
120 end
122 def show_help_page
123 - help_text = [ "tpp help",
124 + help_text = [ "tpp help",
125 "",
126 "space bar ............................... display next entry within page",
127 "space bar, cursor-down, cursor-right .... display next page",
128 @@ -775,7 +775,7 @@
129 @screen.move(@termheight - 3, (@termwidth - footer_txt.length)/2)
130 @screen.addstr(footer_txt)
131 end
132 -
133 +
134 def do_header(header_txt)
135 @screen.move(@termheight - @termheight+1, (@termwidth - header_txt.length)/2)
136 @screen.addstr(header_txt)
137 @@ -918,7 +918,7 @@
138 time_to_sleep = 1.to_f / 20
139 Kernel.sleep(time_to_sleep)
140 xcount -= 1
141 - end
142 + end
143 when "right"
144 (@termwidth - @indent).times do |pos|
145 @screen.move(@cur_line,@termwidth - pos - 1)
146 @@ -991,7 +991,7 @@
147 @screen.move(line,col*15 + 2)
148 if current_page == i then
149 @screen.printw("%2d %s <=",i+1,pages[i].title[0..80])
150 - else
151 + else
152 @screen.printw("%2d %s",i+1,pages[i].title[0..80])
153 end
154 line += 1
155 @@ -1092,7 +1092,7 @@
157 def do_footer(footer_text)
158 end
159 -
160 +
161 def do_header(header_text)
162 end
164 @@ -1166,7 +1166,7 @@
166 def do_revon
167 end
168 -
169 +
170 def do_command_prompt
171 end
172 def do_revoff
173 @@ -1183,7 +1183,7 @@
175 def do_endslide
176 end
177 -
178 +
179 def do_beginslideright
180 end
182 @@ -1349,7 +1349,7 @@
184 end
186 -# Implements an interactive controller which feeds the visualizer until it is
187 +# Implements an interactive controller which feeds the visualizer until it is
188 # told to stop, and then reads a key press and executes the appropiate action.
189 class InteractiveController < TppController
191 @@ -1396,17 +1396,17 @@
192 loop do
193 ch = @vis.get_key
194 case ch
195 - when 'q'[0], 'Q'[0] # 'Q'uit
196 + when ?q.ord, ?Q.ord # 'Q'uit
197 return
198 - when 'r'[0], 'R'[0] # 'R'edraw slide
199 + when ?r.ord, ?R.ord # 'R'edraw slide
200 changed_page = true # @todo: actually implement redraw
201 - when 'e'[0], 'E'[0]
202 + when ?e.ord, ?E.ord
203 @cur_page = @pages.size - 1
204 break
205 - when 's'[0], 'S'[0]
206 + when ?s.ord, ?S.ord
207 @cur_page = 0
208 break
209 - when 'j'[0], 'J'[0] # 'J'ump to slide
210 + when ?j.ord, ?J.ord # 'J'ump to slide
211 screen = @vis.store_screen
212 p = @vis.read_newpage(@pages,@cur_page)
213 if p >= 0 and p < @pages.size
214 @@ -1417,28 +1417,28 @@
215 @vis.restore_screen(screen)
216 end
217 break
218 - when 'l'[0], 'L'[0] # re'l'oad current file
219 + when ?l.ord, ?L.ord # re'l'oad current file
220 @reload_file = true
221 return
222 - when 'c'[0], 'C'[0] # command prompt
223 + when ?c.ord, ?C.ord # command prompt
224 screen = @vis.store_screen
225 @vis.do_command_prompt
226 @vis.clear
227 @vis.restore_screen(screen)
228 - when '?'[0], 'h'[0]
229 + when ??.ord, ?h.ord
230 screen = @vis.store_screen
231 @vis.show_help_page
232 ch = @vis.get_key
233 @vis.clear
234 @vis.restore_screen(screen)
235 - when :keyright, :keydown, ' '[0]
236 + when :keyright, :keydown, ' '.ord
237 if @cur_page + 1 < @pages.size and eop then
238 @cur_page += 1
239 @pages[@cur_page].reset_eop
240 @vis.new_page
241 end
242 break
243 - when 'b'[0], 'B'[0], :keyleft, :keyup
244 + when ?b.ord, ?B.ord, :keyleft, :keyup
245 if @cur_page > 0 then
246 @cur_page -= 1
247 @pages[@cur_page].reset_eop
248 @@ -1455,7 +1455,7 @@
249 end
252 -# Implements a visualizer which converts TPP source to a nicely formatted text
253 +# Implements a visualizer which converts TPP source to a nicely formatted text
254 # file which can e.g. be used as handout.
255 class TextVisualizer < TppVisualizer
257 @@ -1475,7 +1475,7 @@
259 def do_footer(footer_text)
260 end
261 -
262 +
263 def do_header(header_text)
264 end
266 @@ -1539,7 +1539,7 @@
268 def do_revon
269 end
270 -
271 +
272 def do_command_prompt
273 end
274 def do_revoff
275 @@ -1556,7 +1556,7 @@
277 def do_endslide
278 end
279 -
280 +
281 def do_beginslideright
282 end
284 @@ -1650,8 +1650,8 @@
286 end
288 -# Implements a non-interactive controller to control non-interactive
289 -# visualizers (i.e. those that are used for converting TPP source code into
290 +# Implements a non-interactive controller to control non-interactive
291 +# visualizers (i.e. those that are used for converting TPP source code into
292 # another format)
293 class ConversionController < TppController