Class: Themigrator::UI::LogArea::LogWindow
- Inherits:
-
Window
- Object
- Window
- Themigrator::UI::LogArea::LogWindow
- Defined in:
- lib/themigrator/ui/log_area.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
- #append(msg) ⇒ Object
-
#initialize(height, width, top, left) ⇒ LogWindow
constructor
A new instance of LogWindow.
- #log(msg) ⇒ Object
- #name ⇒ Object
- #nextpage ⇒ Object
- #prevpage ⇒ Object
- #redraw ⇒ Object
- #render(force = false) ⇒ Object
Constructor Details
#initialize(height, width, top, left) ⇒ LogWindow
Returns a new instance of LogWindow.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/themigrator/ui/log_area.rb', line 11 def initialize(height, width, top, left) @height = height @width = width @top = top @left = left @inner_win = ::Curses::Window.new(height - 2, width - 2, top + 1, left + 1) @inner_win.scrollok(true) @buffer = '' @scroll = -1 super idlok(true) end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
10 11 12 |
# File 'lib/themigrator/ui/log_area.rb', line 10 def action @action end |
#role ⇒ Object
Returns the value of attribute role.
10 11 12 |
# File 'lib/themigrator/ui/log_area.rb', line 10 def role @role end |
Instance Method Details
#append(msg) ⇒ Object
55 56 57 |
# File 'lib/themigrator/ui/log_area.rb', line 55 def append(msg) @buffer << msg end |
#log(msg) ⇒ Object
64 65 66 |
# File 'lib/themigrator/ui/log_area.rb', line 64 def log(msg) ui_log("#{name}##{msg}") end |
#name ⇒ Object
51 52 53 |
# File 'lib/themigrator/ui/log_area.rb', line 51 def name '%-13s/%-10s' % [action, role] end |
#nextpage ⇒ Object
35 36 37 38 39 |
# File 'lib/themigrator/ui/log_area.rb', line 35 def nextpage @scroll += 5 @scroll = -1 if @scroll > -1 log("@scroll = #{@scroll}") end |
#prevpage ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/themigrator/ui/log_area.rb', line 41 def prevpage @scroll -= 5 buffer_lines = @buffer.split("\n").size offset_lines = buffer_lines - @height + (2 + 5) log("@scroll = #{@scroll} and offset_lines - #{offset_lines} | buffer_lines #{buffer_lines} | @height = #{@height}") @height @scroll = -offset_lines if @scroll < -offset_lines end |
#redraw ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/themigrator/ui/log_area.rb', line 24 def redraw clear @inner_win.clear setpos(0, 0) box('|', '-') addstr(name) log('redraw') refresh render(true) end |
#render(force = false) ⇒ Object
59 60 61 62 |
# File 'lib/themigrator/ui/log_area.rb', line 59 def render(force = false) # refresh render_inner_win(force) end |