Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCHv2] idle and unidle updates
@ 2010-01-14 15:45 Eric Sherman
  2010-01-22 20:13 ` Eric Sherman
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sherman @ 2010-01-14 15:45 UTC (permalink / raw)
  To: sup-devel

---
 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.
-- 
1.6.6

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-22 20:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-14 15:45 [sup-devel] [PATCHv2] idle and unidle updates Eric Sherman
2010-01-22 20:13 ` Eric Sherman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox