From: William Morgan Date: Wed, 9 Sep 2009 14:05:11 +0000 (-0400) Subject: don't require log-mode to auto-respawn X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=b119447d2198667e25bad72566581f1f70021417;p=sup 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. --- diff --git a/lib/sup/modes/log-mode.rb b/lib/sup/modes/log-mode.rb index 07fa9dd..de320ce 100644 --- 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.