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