Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: dunghopper@gmail.com (Daniel Hilton)
Subject: [sup-talk] nonblocking_getch
Date: Wed, 20 Feb 2008 21:43:55 -0700	[thread overview]
Message-ID: <3902af2f0802202043r3c8a98ablabf458d0a99937b3@mail.gmail.com> (raw)

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 


             reply	other threads:[~2008-02-21  4:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-21  4:43 Daniel Hilton [this message]
2008-02-25 17:38 ` William Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3902af2f0802202043r3c8a98ablabf458d0a99937b3@mail.gmail.com \
    --to=dunghopper@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox