Class: Redwood::LogMode

Inherits:
TextMode show all
Defined in:
lib/sup/modes/log-mode.rb

Direct Known Subclasses

PollMode

Constant Summary

Constants inherited from ScrollMode

ScrollMode::COL_JUMP

Instance Attribute Summary

Attributes inherited from TextMode

#text

Attributes inherited from ScrollMode

#botline, #leftcol, #topline

Attributes inherited from Mode

#buffer

Instance Method Summary collapse

Methods inherited from TextMode

#[], #lines, #save_to_disk

Methods inherited from ScrollMode

#at_bottom?, #at_top?, #cancel_search!, #col_left, #col_right, #continue_search_in_buffer, #draw, #ensure_mode_validity, #in_search?, #jump_to_col, #jump_to_end, #jump_to_left, #jump_to_line, #jump_to_start, #line_down, #line_up, #page_down, #page_up, #resize, #rightcol, #search_goto_line, #search_in_buffer, #search_start_line

Methods inherited from Mode

#blur, #cancel_search!, #cleanup, #draw, #focus, #handle_input, #help_text, #in_search?, #killable?, load_all_modes, make_name, #name, register_keymap, #resize, #resolve_input, #save_to_file

Constructor Details

#initializeLogMode



8
9
10
11
# File 'lib/sup/modes/log-mode.rb', line 8

def initialize
  @follow = true
  super
end

Instance Method Details

#<<(line) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/sup/modes/log-mode.rb', line 31

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

#statusObject



39
40
41
# File 'lib/sup/modes/log-mode.rb', line 39

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

#text=(t) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/sup/modes/log-mode.rb', line 23

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

#toggle_followObject



13
14
15
16
17
18
19
20
21
# File 'lib/sup/modes/log-mode.rb', line 13

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