Author: bdonlan
Date: 2005-07-24 18:01:32 -0400 (Sun, 24 Jul 2005)
New Revision: 892
Modified:
trunk/clients/ravish/eventmanager.rb
trunk/clients/ravish/ravish2.rb
Log:
Hooks for proper resize handling at the tv-layer.
Modified: trunk/clients/ravish/eventmanager.rb
===================================================================
--- trunk/clients/ravish/eventmanager.rb 2005-07-24 18:51:59 UTC (rev
891)
+++ trunk/clients/ravish/eventmanager.rb 2005-07-24 22:01:32 UTC (rev
892)
@@ -5,6 +5,7 @@
# You may edit and redistribute it under the same terms as ruby.
require 'singleton'
+require 'io/nonblock'
class EventManager
include Singleton
@@ -27,17 +28,31 @@
@idlers = {}
@idle_idx = 0
+
+ @pending = []
+
+ @pipe.each { |io| io.nonblock = true }
+ watchread @pipe[0], lambda {
+ begin
+ @pipe[0].read 1
+ rescue
+ end
+ }
end
def jolt
@pipe[1].write 'a'
end
+ def interrupt
+ jolt
+ end
+
# Check and block for events, once
def runonce
nexttimer = self.checktimers
- readhand = @fdread.keys + [EMAIL PROTECTED]
+ readhand = @fdread.keys
writehand = @fdwrite.keys
errorhand = @fderror.keys
@@ -46,10 +61,6 @@
#print "ret=" + ret.to_s + "\n"
if !ret then ret = [[],[],[]] end
- if ret[0].delete @pipe[0]
- @pipe[0].read 1
- end
-
ret[0].each { |fd| @fdread[fd].values.each { |c| c.call fd } }
ret[1].each { |fd| @fdwrite[fd].values.each { |c| c.call fd } }
ret[2].each { |fd| @fderror[fd].values.each { |c| c.call fd } }
@@ -59,8 +70,18 @@
@idlers.each_value { |l|
l.call
}
+
+ until @pending.empty?
+ @pending.pop.call
+ end
end
+ # Run f later.
+ def yield f
+ @pending.push f
+ interrupt
+ end
+
# Add a function to be called each time through the event loop
# Returns an opaque value which may be passed to del_idle
def add_idle l
Modified: trunk/clients/ravish/ravish2.rb
===================================================================
--- trunk/clients/ravish/ravish2.rb 2005-07-24 18:51:59 UTC (rev 891)
+++ trunk/clients/ravish/ravish2.rb 2005-07-24 22:01:32 UTC (rev 892)
@@ -97,15 +97,6 @@
@haver.start
@chancontents = {}
-
- EventManager.instance.add_idle lambda {
- # compatibility with non-patched tv
- # remove this when the resize-patch is merged
- if @term.respond_to? :resize
- @term.resize
- end
- }
-
end
def do_resize