From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Mon, 25 Feb 2008 09:38:28 -0800 Subject: [sup-talk] nonblocking_getch In-Reply-To: <3902af2f0802202043r3c8a98ablabf458d0a99937b3@mail.gmail.com> References: <3902af2f0802202043r3c8a98ablabf458d0a99937b3@mail.gmail.com> Message-ID: <1203959878-sup-6905@south> Reformatted excerpts from Daniel Hilton's message of 2008-02-20: > I've got a solution that works on my system, adding > 'Ncurses.stdscr.nodelay1' to start_cursing, and modifying > nonblocking_getch as follows: > > def nonblocking_getch > if IO.select([$stdin], nil, nil, 1) > repeat = c = Ncurses.getch > repeat = Ncurses.getch until repeat != c > c > else > nil > end > end Thanks, I'm going to play around with this. If you feel like learning git-format-patch (the wiki has some instructions), you can get your name in the commit log (ooohhh!). > As a side note: having added nodelay, there doesn't seem to be any > real reason we would need to keep the IO.select... but in my brief > experimentation I found various unpleasant side-effects when I tried > to remove it. I guess it doesn't hurt anything to leave it in. Yeah, the entire ncurses setup is completely cargo-cult programming. I have no idea why it works, and changing any bit of it breaks everything in weird ways. -- William