examples/read_line.rb in ncursesw-1.4.3 vs examples/read_line.rb in ncursesw-1.4.4

- old
+ new

@@ -1,8 +1,8 @@ #!/usr/bin/env ruby # Emacs: This is -*- ruby -*- code! -# +# # Unfinished read_line function # # Written 2003, 2004 by Tobias Peters # No warranties # Share and enjoy! @@ -31,37 +31,37 @@ when Ncurses::KEY_BACKSPACE string = string[0...([0, cursor_pos-1].max)] + string[cursor_pos..-1] cursor_pos = [0, cursor_pos-1].max window.mvaddstr(y, x+string.length, " ") # when etc... - when " "[0]..255 # remaining printables + when " ".ord..255 # remaining printables if (cursor_pos < max_len) string[cursor_pos,0] = ch.chr cursor_pos += 1 else Ncurses.beep end else Ncurses.beep end - end -end + end +end if (__FILE__ == $0) then begin # demo mode Ncurses.initscr Ncurses.cbreak Ncurses.noecho # recognize KEY_ENTER, KEY_BACKSPACE etc Ncurses.keypad(Ncurses.stdscr, true) - + y = 10 x = 2 prompt = "Hallo > " Ncurses.mvaddstr(y,x, prompt) s = read_line(y, x + prompt.length) - + ensure Ncurses.endwin end end p s