From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.213.7.146 with SMTP id d18cs94786ebd; Wed, 13 Jan 2010 05:57:05 -0800 (PST) Received: by 10.224.86.207 with SMTP id t15mr296112qal.67.1263391024258; Wed, 13 Jan 2010 05:57:04 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 6si1380120qwd.56.2010.01.13.05.57.03; Wed, 13 Jan 2010 05:57:04 -0800 (PST) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 9275915B802B; Wed, 13 Jan 2010 08:57:03 -0500 (EST) Received: from mail-yx0-f187.google.com (mail-yx0-f187.google.com [209.85.210.187]) by rubyforge.org (Postfix) with ESMTP id A868A1858289 for ; Wed, 13 Jan 2010 08:56:48 -0500 (EST) Received: by yxe17 with SMTP id 17so22546302yxe.33 for ; Wed, 13 Jan 2010 05:56:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:subject:from:to :date:message-id:user-agent:content-transfer-encoding; bh=nuFaV268wwyzcBugeW/m+pg3jGfApjvUci5eO5V0Nuo=; b=LRYt74Ypcr+6avRrGwHR3RAOalHbNcTWy2CqrlrB6+vqDebmonNO66zBn28tKC3d/E XC+BnGHCHy3R+p2juDb3I/5IIG2MB5lqsccNn+Z54ojK1oVShI48KC3DSgDUw25DZe8C vesSsI82gGmnrPHsWYDmg/7SPMmrjZlMiT3ds= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:subject:from:to:date:message-id:user-agent :content-transfer-encoding; b=aFGKKVOCkm5zp2uVoUG4OrHYnjMPDNezlC28TEB/zWaociq6IvPw8sbhACWQJeOwil X2XTl6yScDZ2x0d3jRZG3UpS48iMDpVIF8KZwYSgvcV6UqA2kGJRUUm91PDt9dR0ZZu1 7nvpsr14SGyzVY9veB+Ll0uB2zgvbTpYVjRlg= Received: by 10.150.243.5 with SMTP id q5mr967550ybh.13.1263391007879; Wed, 13 Jan 2010 05:56:47 -0800 (PST) Received: from localhost (c-76-98-110-216.hsd1.nj.comcast.net [76.98.110.216]) by mx.google.com with ESMTPS id 21sm11529035yxe.1.2010.01.13.05.56.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 13 Jan 2010 05:56:47 -0800 (PST) From: Eric Sherman To: sup-devel Date: Wed, 13 Jan 2010 08:56:44 -0500 Message-Id: <1263390213-sup-2608@changeling.local> User-Agent: Sup/git Subject: [sup-devel] [PATCH] idle and unidle updates X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org After talking it over with Rich Lane who suggested I check for idleness near the unblocking_getch loop, it made sense to separate it out into its own patch. The :idle and :unidle updates are relayed only once, when transitioning from one state to the other. * Is setting 'main' as the relay sender a problem? * Is there anything more meaningful to send as the payload than the time of the last keystroke? --- bin/sup | 16 ++++++++++++++++ lib/sup.rb | 3 ++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/bin/sup b/bin/sup index 19b2a87..f4261f4 100755 --- a/bin/sup +++ b/bin/sup @@ -260,6 +260,9 @@ begin SearchResultsMode.spawn_from_query $opts[:search] end + no_keystrokes_since = Time.now + idle = false + until Redwood::exceptions.nonempty? || $die c = begin Ncurses.nonblocking_getch @@ -274,9 +277,22 @@ begin debug "redrawing screen on sigwinch" BufferManager.completely_redraw_screen end + + if !idle and Time.now.to_i - no_keystrokes_since.to_i >= ($config[:idle_threshold] || 60) + 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. diff --git a/lib/sup.rb b/lib/sup.rb index b83bbe7..e228772 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -230,7 +230,8 @@ else :discard_snippets_from_encrypted_messages => false, :default_attachment_save_dir => "", :sent_source => "sup://sent", - :poll_interval => 300 + :poll_interval => 300, + :idle_threshold => 60 } begin FileUtils.mkdir_p Redwood::BASE_DIR -- 1.6.6 _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel