Sha256: 185d706a81319a27fd6a60a973c1fa6f810e213ce5d30133b30433b2438b1665

Contents?: true

Size: 792 Bytes

Versions: 12

Compression:

Stored size: 792 Bytes

Contents

module Redwood

class LogMode < TextMode
  register_keymap do |k|
    k.add :toggle_follow, "Toggle follow mode", 'f'
  end

  def initialize
    @follow = true
    super
  end

  def toggle_follow
    @follow = !@follow
    if buffer
      if @follow
        jump_to_line lines - buffer.content_height + 1 # leave an empty line at bottom
      end
      buffer.mark_dirty
    end
  end

  def text= t
    super
    if buffer && @follow
      follow_top = lines - buffer.content_height + 1
      jump_to_line follow_top if topline < follow_top
    end
  end

  def << line
    super
    if buffer && @follow
      follow_top = lines - buffer.content_height + 1
      jump_to_line follow_top if topline < follow_top
    end
  end

  def status
    super + " (follow: #@follow)"
  end
end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sup-0.8.1 lib/sup/modes/log-mode.rb
sup-0.0.3 lib/sup/modes/log-mode.rb
sup-0.0.2 lib/sup/modes/log-mode.rb
sup-0.0.4 lib/sup/modes/log-mode.rb
sup-0.0.5 lib/sup/modes/log-mode.rb
sup-0.0.6 lib/sup/modes/log-mode.rb
sup-0.6 lib/sup/modes/log-mode.rb
sup-0.5 lib/sup/modes/log-mode.rb
sup-0.4 lib/sup/modes/log-mode.rb
sup-0.7 lib/sup/modes/log-mode.rb
sup-0.3 lib/sup/modes/log-mode.rb
sup-0.8 lib/sup/modes/log-mode.rb