Author: bdonlan
Date: 2005-07-19 21:59:48 -0400 (Tue, 19 Jul 2005)
New Revision: 885
Modified:
trunk/
trunk/clients/ravish/eventmanager.rb
trunk/clients/ravish/ravish2.rb
Log:
[EMAIL PROTECTED]: bdonlan | 2005-07-19 21:44:52 -0400
* modelines (not sure if they work, though...)
* EventManager: add an idle hook
* ravish2.rb: call @term.resize on idle
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/havercurs-objc:43089
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:1301
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
+ 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/havercurs-objc:43089
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:11166
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk-merge-10131:11178
1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/winch/trunk:43192
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
e9404bb1-7af0-0310-a7ff-e22194cd388b:/haver/local:1297
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
Modified: trunk/clients/ravish/eventmanager.rb
===================================================================
--- trunk/clients/ravish/eventmanager.rb 2005-07-20 01:55:37 UTC (rev
884)
+++ trunk/clients/ravish/eventmanager.rb 2005-07-20 01:59:48 UTC (rev
885)
@@ -1,3 +1,4 @@
+# vim: set noet :
# EventManager - ruby event loop
# Copyright (c) 2005 Bryan J. Donlan and Jeremy C. Apthorp
# This program is FREE SOFTWARE.
@@ -23,6 +24,9 @@
# token is the next handle returned by the watch functions
@token = 0
@pipe = IO.pipe
+
+ @idlers = {}
+ @idle_idx = 0
end
def jolt
@@ -51,8 +55,24 @@
ret[2].each { |fd| @fderror[fd].values.each { |c| c.call fd } }
self.checktimers
+
+ @idlers.each_value { |l|
+ l.call
+ }
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
+ @[EMAIL PROTECTED] = l
+ return @idle_idx
+ end
+
+ # Cancel an idle event
+ def del_idle idx
+ @idlers.delete idx
+ end
+
# Check for any timers which should have gone off by now.
# Dispatch the ones that have, then return the time remaining
# until the next timer, or nil if no timers remain
Modified: trunk/clients/ravish/ravish2.rb
===================================================================
--- trunk/clients/ravish/ravish2.rb 2005-07-20 01:55:37 UTC (rev 884)
+++ trunk/clients/ravish/ravish2.rb 2005-07-20 01:59:48 UTC (rev 885)
@@ -4,6 +4,7 @@
# put term/visual in the search path
$:.unshift "lib"
+require 'eventmanager'
require 'term/visual'
require 'yaml'
require 'haver'
@@ -48,7 +49,7 @@
Bindings = {
((0..9).to_a + ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
'O']).collect {
- |k| "A-#{k}" } => :switch_window
+ |k| "A-#{k}" } => :switch_window,
}
ConfDefaults = {
@@ -90,9 +91,21 @@
@haver.add_observer self
@haver.start
- @chancontents = {}
+ @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
+ @term.resize
+ end
+
def global_prefix
Time.now.strftime "%H:%M:%S "
end
@@ -321,17 +334,17 @@
srvmsg "Stray JOIN: #{uid} has joined #{cid}"
end
- clist = @chancontents[cid]
- if clist.nil?
- @chancontents[cid] = clist = Hash.new
- end
- clist[uid] = 1
+ clist = @chancontents[cid]
+ if clist.nil?
+ @chancontents[cid] = clist = Hash.new
+ end
+ clist[uid] = 1
end
def ev_PART cid, uid
win = find_window :channel, cid
if @nick and uid == @nick
- @chancontents.delete cid
+ @chancontents.delete cid
if win
@windows.delete win
@term.delete_window win.window
@@ -344,21 +357,21 @@
else
srvmsg "Stray PART: #{uid} parts #{cid}"
end
- clist = @chancontents[cid]
- if !clist.nil?
- clist.delete uid
- end
+ clist = @chancontents[cid]
+ if !clist.nil?
+ clist.delete uid
+ end
end
def ev_QUIT uid, type, detail=""
srvmsg "Quits: #{uid} (#{type}#{detail ? ": " + detail : ''})"
- @chancontents.each_key { |cid|
- if @chancontents[cid][uid]
- win = find_window :channel, cid
- win.window.print "#{uid} has quit: (#{type}#{detail ? ": " +
detail : ''})"
- @chancontents[cid].delete uid
- end
- }
+ @chancontents.each_key { |cid|
+ if @chancontents[cid][uid]
+ win = find_window :channel, cid
+ win.window.print "#{uid} has quit:
(#{type}#{detail ? ": " + detail : ''})"
+ @chancontents[cid].delete uid
+ end
+ }
end
def ev_LIST cid, ns, *users
@@ -377,12 +390,12 @@
win.columnize users, {'before_each' =>
'%(listdecs)[%(listitem)',
'after_each' =>
'%(listdecs)]%(default)'}
- if win != @servwin && ns == 'user'
- clist = @chancontents[cid] = Hash.new
- users.each { |uid|
- clist[uid] = 1
- }
- end
+ if win != @servwin && ns == 'user'
+ clist = @chancontents[cid] = Hash.new
+ users.each { |uid|
+ clist[uid] = 1
+ }
+ end
end
def ev_IN cid, uid, type, *msg