From mboxrd@z Thu Jan 1 00:00:00 1970 From: dunghopper@gmail.com (Daniel Hilton) Date: Wed, 20 Feb 2008 21:43:55 -0700 Subject: [sup-talk] nonblocking_getch Message-ID: <3902af2f0802202043r3c8a98ablabf458d0a99937b3@mail.gmail.com> First of all, kudos to all who have contributed to sup (especially William!). Its the bees knees. One issue: At least on my slow computer, the time it takes to dispatch even a simple action (like cursor_down) is a bit longer than my keyboard's repeat interval. So, when I hold down 'j' to scroll through several messages, it continues to scroll for a few seconds after I release the key, causing me to overshoot my target every time. 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 This effectively discards the extra keystrokes that accumulate while the action is taking place, and makes the UI seem more responsive (even though it isn't actually any faster). 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. There may also be side-effects that I haven't noticed from using nodelay, but everything seems to work as it should. Dan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/sup-talk/attachments/20080220/0c1c9318/attachment.html