summarylogtreecommitdiffstats
path: root/fix-for-ruby1.9.patch
blob: 5f52a3f694ea1c849f2cb51aef0276284ff596b7 (plain)
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
--- ../tpp-old/tpp-1.3.1/tpp.rb	2007-04-23 02:12:21.000000000 -0700
+++ tpp.rb	2014-12-10 23:23:37.572444501 -0800
@@ -568,13 +568,17 @@
       window.move(@termheight/4,1+prompt.length+cursor_pos) # move cursor to the end of code
       ch = window.getch
       case ch
-        when Ncurses::KEY_ENTER, ?\n, ?\r
+        when Ncurses::KEY_ENTER, "\n"[0].ord, "\r"[0].ord
           Ncurses.curs_set(0)
           Ncurses.noecho
+          window.move(@termheight/4 + 1,1) # move cursor to the next line
+          window.refresh
           rc = Kernel.system(string)
           if not rc then
             @screen.mvaddstr(@termheight/4+1,1,"Error: exec \"#{string}\" failed with error code #{$?}")
             @screen.mvaddstr(@termheight-2,@termwidth/2-message.length/2,message)
+            ch = Ncurses.getch()
+            @screen.refresh
           end
           if rc then
             @screen.mvaddstr(@termheight-2,@termwidth/2-message.length/2,message)
@@ -582,15 +586,15 @@
             @screen.refresh
           end
           return
-		when Ncurses::KEY_LEFT
+        when Ncurses::KEY_LEFT
           cursor_pos = [0, cursor_pos-1].max # jump one character to the left
         when Ncurses::KEY_RIGHT
           cursor_pos = [0, cursor_pos+1].max # jump one character to the right
-        when Ncurses::KEY_BACKSPACE
+        when Ncurses::KEY_BACKSPACE, "\b"[0].ord, 127
           string = string[0...([0, cursor_pos-1].max)] + string[cursor_pos..-1]
           cursor_pos = [0, cursor_pos-1].max
-          window.mvaddstr(@termheight/4, 1+prompt.length+string.length, " ")
-        when " "[0]..255
+          window.mvaddstr(@termheight/4, 1+prompt.length+string.length, "   ")
+        when " "[0].ord..255
           if (cursor_pos < max_len)
             string[cursor_pos,0] = ch.chr
             cursor_pos += 1
@@ -1396,17 +1400,17 @@
       loop do
         ch = @vis.get_key
         case ch
-          when 'q'[0], 'Q'[0] # 'Q'uit
+          when 'q'[0].ord, 'Q'[0].ord # 'Q'uit
             return
-          when 'r'[0], 'R'[0] # 'R'edraw slide
+          when 'r'[0].ord, 'R'[0].ord # 'R'edraw slide
             changed_page = true # @todo: actually implement redraw
-          when 'e'[0], 'E'[0]
+          when 'e'[0].ord, 'E'[0].ord
             @cur_page = @pages.size - 1
             break
-          when 's'[0], 'S'[0]
+          when 's'[0].ord, 'S'[0].ord
             @cur_page = 0
             break
-          when 'j'[0], 'J'[0] # 'J'ump to slide
+          when 'j'[0].ord, 'J'[0].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 +1421,28 @@
               @vis.restore_screen(screen)
             end
             break
-          when 'l'[0], 'L'[0] # re'l'oad current file
+          when 'l'[0].ord, 'L'[0].ord # re'l'oad current file
             @reload_file = true
             return
-          when 'c'[0], 'C'[0] # command prompt
+          when 'c'[0].ord, 'C'[0].ord # command prompt
             screen = @vis.store_screen
             @vis.do_command_prompt
             @vis.clear
             @vis.restore_screen(screen)
-          when '?'[0], 'h'[0]
+          when '?'[0].ord, 'h'[0].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, ' '[0].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'[0].ord, 'B'[0].ord, :keyleft, :keyup
             if @cur_page > 0 then
               @cur_page -= 1
               @pages[@cur_page].reset_eop