commit b119447d2198667e25bad72566581f1f70021417
parent 8039b8594c5246338406b284ab9b2c4974b77937
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Wed, 9 Sep 2009 10:05:11 -0400
don't require log-mode to auto-respawn
Don't require log-mode (and more importantly, subclasses thereof) to respawn.
If a buffer name is provided during initialization, respawning will be on;
otherwise, it will be off. Now e.g. console mode can use log-mode without
requiring a buffer name, or incurring potentially weird auto-respawn behavior.
Diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/lib/sup/modes/log-mode.rb b/lib/sup/modes/log-mode.rb
@@ -9,9 +9,12 @@ class LogMode < TextMode
k.add :toggle_follow, "Toggle follow mode", 'f'
end
- def initialize buffer_name
+ ## if buffer_name is supplied, this mode will spawn a buffer
+ ## upon receiving the << message. otherwise, it will act like
+ ## a regular buffer.
+ def initialize autospawn_buffer_name=nil
@follow = true
- @buffer_name = buffer_name
+ @autospawn_buffer_name = autospawn_buffer_name
@on_kill = []
super()
end
@@ -28,8 +31,8 @@ class LogMode < TextMode
end
def << s
- unless buffer
- BufferManager.spawn @buffer_name, self, :hidden => true, :system => true
+ if buffer.nil? && @autospawn_buffer_name
+ BufferManager.spawn @autospawn_buffer_name, self, :hidden => true, :system => true
end
s.split("\n").each { |l| super(l + "\n") } # insane. different << semantics.