Sha256: 94a1dd8ed21e4a8080157034fe59b2f5c381e67c6715f012e00d623adc0a593d

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 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

1 entries across 1 versions & 1 rubygems

Version Path
sup-0.0.1 lib/sup/modes/log-mode.rb