wok annotate tpp/stuff/ruby19.patch @ rev 23993

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