Advertisement
Guest User

Untitled

a guest
Dec 11th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. --- ../tpp-old/tpp-1.3.1/tpp.rb 2007-04-23 02:12:21.000000000 -0700
  2. +++ tpp.rb 2014-12-10 23:23:37.572444501 -0800
  3. @@ -568,13 +568,17 @@
  4. window.move(@termheight/4,1+prompt.length+cursor_pos) # move cursor to the end of code
  5. ch = window.getch
  6. case ch
  7. - when Ncurses::KEY_ENTER, ?\n, ?\r
  8. + when Ncurses::KEY_ENTER, "\n"[0].ord, "\r"[0].ord
  9. Ncurses.curs_set(0)
  10. Ncurses.noecho
  11. + window.move(@termheight/4 + 1,1) # move cursor to the next line
  12. + window.refresh
  13. rc = Kernel.system(string)
  14. if not rc then
  15. @screen.mvaddstr(@termheight/4+1,1,"Error: exec \"#{string}\" failed with error code #{$?}")
  16. @screen.mvaddstr(@termheight-2,@termwidth/2-message.length/2,message)
  17. + ch = Ncurses.getch()
  18. + @screen.refresh
  19. end
  20. if rc then
  21. @screen.mvaddstr(@termheight-2,@termwidth/2-message.length/2,message)
  22. @@ -582,15 +586,15 @@
  23. @screen.refresh
  24. end
  25. return
  26. - when Ncurses::KEY_LEFT
  27. + when Ncurses::KEY_LEFT
  28. cursor_pos = [0, cursor_pos-1].max # jump one character to the left
  29. when Ncurses::KEY_RIGHT
  30. cursor_pos = [0, cursor_pos+1].max # jump one character to the right
  31. - when Ncurses::KEY_BACKSPACE
  32. + when Ncurses::KEY_BACKSPACE, "\b"[0].ord, 127
  33. string = string[0...([0, cursor_pos-1].max)] + string[cursor_pos..-1]
  34. cursor_pos = [0, cursor_pos-1].max
  35. - window.mvaddstr(@termheight/4, 1+prompt.length+string.length, " ")
  36. - when " "[0]..255
  37. + window.mvaddstr(@termheight/4, 1+prompt.length+string.length, " ")
  38. + when " "[0].ord..255
  39. if (cursor_pos < max_len)
  40. string[cursor_pos,0] = ch.chr
  41. cursor_pos += 1
  42. @@ -1396,17 +1400,17 @@
  43. loop do
  44. ch = @vis.get_key
  45. case ch
  46. - when 'q'[0], 'Q'[0] # 'Q'uit
  47. + when 'q'[0].ord, 'Q'[0].ord # 'Q'uit
  48. return
  49. - when 'r'[0], 'R'[0] # 'R'edraw slide
  50. + when 'r'[0].ord, 'R'[0].ord # 'R'edraw slide
  51. changed_page = true # @todo: actually implement redraw
  52. - when 'e'[0], 'E'[0]
  53. + when 'e'[0].ord, 'E'[0].ord
  54. @cur_page = @pages.size - 1
  55. break
  56. - when 's'[0], 'S'[0]
  57. + when 's'[0].ord, 'S'[0].ord
  58. @cur_page = 0
  59. break
  60. - when 'j'[0], 'J'[0] # 'J'ump to slide
  61. + when 'j'[0].ord, 'J'[0].ord # 'J'ump to slide
  62. screen = @vis.store_screen
  63. p = @vis.read_newpage(@pages,@cur_page)
  64. if p >= 0 and p < @pages.size
  65. @@ -1417,28 +1421,28 @@
  66. @vis.restore_screen(screen)
  67. end
  68. break
  69. - when 'l'[0], 'L'[0] # re'l'oad current file
  70. + when 'l'[0].ord, 'L'[0].ord # re'l'oad current file
  71. @reload_file = true
  72. return
  73. - when 'c'[0], 'C'[0] # command prompt
  74. + when 'c'[0].ord, 'C'[0].ord # command prompt
  75. screen = @vis.store_screen
  76. @vis.do_command_prompt
  77. @vis.clear
  78. @vis.restore_screen(screen)
  79. - when '?'[0], 'h'[0]
  80. + when '?'[0].ord, 'h'[0].ord
  81. screen = @vis.store_screen
  82. @vis.show_help_page
  83. ch = @vis.get_key
  84. @vis.clear
  85. @vis.restore_screen(screen)
  86. - when :keyright, :keydown, ' '[0]
  87. + when :keyright, :keydown, ' '[0].ord
  88. if @cur_page + 1 < @pages.size and eop then
  89. @cur_page += 1
  90. @pages[@cur_page].reset_eop
  91. @vis.new_page
  92. end
  93. break
  94. - when 'b'[0], 'B'[0], :keyleft, :keyup
  95. + when 'b'[0].ord, 'B'[0].ord, :keyleft, :keyup
  96. if @cur_page > 0 then
  97. @cur_page -= 1
  98. @pages[@cur_page].reset_eop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement