Sha256: ca3a7421f7a62fc21d8f770c9e0e85c6ffa298ff4bf7ef506794061dd9addda1
Contents?: true
Size: 986 Bytes
Versions: 1
Compression:
Stored size: 986 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_for_filename :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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sup-0.2 | lib/sup/modes/log-mode.rb |