I am learning the Curses class and am having trouble controlling the ENTER key. This is my code:
require 'curses' win = Curses::Window.new(0, 0, 0, 0) Curses.init_screen Curses.cbreak Curses.nonl Curses.stdscr.keypad(true) loop do case Curses.getch when 13
The problem is that when I press the ENTER key, "abc" is written on the screen (as expected); however, when I press ENTER again, "abc" just overwrites the same position on the screen. It seems that pressing the ENTER key first sets the cursor position to (0,0) and then adds the line. How can I stop setting the cursor position to (0,0)?
In addition, for some reason, the constants do not match my keys, so the ENTER key is 13, but the Ruby constant for the ENTER key is 400ish. I do not use a fancy keyboard or anything else; standard american.
source share