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
 
