]> git.cworth.org Git - sup/blob - lib/sup/modes/log-mode.rb
moved evertying to devel
[sup] / lib / sup / modes / log-mode.rb
1 module Redwood
2
3 class LogMode < TextMode
4   register_keymap do |k|
5     k.add :toggle_follow, "Toggle follow mode", 'f'
6   end
7
8   def initialize
9     @follow = true
10     super ""
11   end
12
13   def toggle_follow
14     @follow = !@follow
15     if buffer
16       if @follow
17         jump_to_line lines - buffer.content_height + 1 # leave an empty line at bottom
18       end
19       buffer.mark_dirty
20     end
21   end
22
23   def text= t
24     super
25     if buffer && @follow
26       follow_top = lines - buffer.content_height + 1
27       jump_to_line follow_top if topline < follow_top
28     end
29   end
30
31   def << line
32     super
33     if buffer && @follow
34       follow_top = lines - buffer.content_height + 1
35       jump_to_line follow_top if topline < follow_top
36     end
37   end
38
39   def status
40     super + " (follow: #@follow)"
41   end
42 end
43
44 end