Sha256: c72468c14cd9bc3a5a0f062d4aef1a81d3c16342529fcaf972ac766d6dab340b
Contents?: true
Size: 973 Bytes
Versions: 3
Compression:
Stored size: 973 Bytes
Contents
module Redwood class LogMode < TextMode register_keymap do |k| k.add :toggle_follow, "Toggle follow mode", 'f' k.add :save_to_disk, "Save log to disk", 's' 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 save_to_disk fn = BufferManager.ask :filename, "Save log to file: " save_to_file(fn) { |f| f.puts text } if fn end def status super + " (follow: #@follow)" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sup-0.0.8 | lib/sup/modes/log-mode.rb |
sup-0.0.7 | lib/sup/modes/log-mode.rb |
sup-0.1 | lib/sup/modes/log-mode.rb |