Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Eric Sherman <hyperbolist@gmail.com>
To: sup-devel <sup-devel@rubyforge.org>
Subject: Re: [sup-devel] [PATCHv2] idle and unidle updates
Date: Fri, 22 Jan 2010 15:13:01 -0500	[thread overview]
Message-ID: <1264190784-sup-222@changeling.local> (raw)
In-Reply-To: <1263483819-sup-9886@changeling.local>

This is a problematic place for this logic to go, since it appears as if 
the idle update does not fire when shelled to the editor, and instead fires 
immediately upon returning.  Which ironically is exactly when you're 
becoming unidle.

I'm thinking of an IdleManager with a single public method #ping that can 
be called here where no_keystrokes_since is being updated.  It has a thread 
that does the threshold checking and relays the updates.  This way it's not 
in the main thread and doesn't block when shelled.

Thoughts?

Excerpts from Eric Sherman's message of Thu Jan 14 10:45:54 -0500 2010:
> ---
>  bin/sup |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/bin/sup b/bin/sup
> index 19b2a87..0d90d00 100755
> --- a/bin/sup
> +++ b/bin/sup
> @@ -260,6 +260,10 @@ begin
>      SearchResultsMode.spawn_from_query $opts[:search]
>    end
>  
> +  IDLE_THRESHOLD = 60
> +  no_keystrokes_since = Time.now
> +  idle = false
> +
>    until Redwood::exceptions.nonempty? || $die
>      c = begin
>        Ncurses.nonblocking_getch
> @@ -274,9 +278,22 @@ begin
>          debug "redrawing screen on sigwinch"
>          BufferManager.completely_redraw_screen
>        end
> +
> +      if !idle and Time.now.to_i - no_keystrokes_since.to_i >= IDLE_THRESHOLD
> +        UpdateManager.relay self, :idle, Time.at(no_keystrokes_since)
> +        idle = true
> +      end
> +
>        next
>      end
>  
> +    if idle
> +      UpdateManager.relay self, :unidle, Time.at(no_keystrokes_since)
> +      idle = false
> +    end
> +
> +    no_keystrokes_since = Time.now
> +
>      if c == 410
>        ## this is ncurses's way of telling us it's detected a refresh.
>        ## since we have our own sigwinch handler, we don't do anything.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


      reply	other threads:[~2010-01-22 20:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 15:45 Eric Sherman
2010-01-22 20:13 ` Eric Sherman [this message]

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=1264190784-sup-222@changeling.local \
    --to=hyperbolist@gmail.com \
    --cc=sup-devel@rubyforge.org \
    /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