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.
-
#progress_monitor ⇒ Object
Returns the value of attribute progress_monitor.
-
#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
- #render_title(force = false) ⇒ Object
- #status ⇒ 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 |
#progress_monitor ⇒ Object
Returns the value of attribute progress_monitor.
10 11 12 |
# File 'lib/themigrator/ui/log_area.rb', line 10 def progress_monitor @progress_monitor 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
69 70 71 |
# File 'lib/themigrator/ui/log_area.rb', line 69 def append(msg) @buffer << msg end |
#log(msg) ⇒ Object
79 80 81 |
# File 'lib/themigrator/ui/log_area.rb', line 79 def log(msg) ui_log("#{name}##{msg}") end |
#name ⇒ Object
59 60 61 |
# File 'lib/themigrator/ui/log_area.rb', line 59 def name "#{role} (#{status})" end |
#nextpage ⇒ Object
43 44 45 46 47 |
# File 'lib/themigrator/ui/log_area.rb', line 43 def nextpage @scroll += 5 @scroll = -1 if @scroll > -1 log("@scroll = #{@scroll}") end |
#prevpage ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/themigrator/ui/log_area.rb', line 49 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 |
# File 'lib/themigrator/ui/log_area.rb', line 24 def redraw clear @inner_win.clear render(true) end |
#render(force = false) ⇒ Object
73 74 75 76 77 |
# File 'lib/themigrator/ui/log_area.rb', line 73 def render(force = false) # refresh render_title(force) render_inner_win(force) end |
#render_title(force = false) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/themigrator/ui/log_area.rb', line 30 def render_title(force = false) n = name return if !force && @previous_title == n @previous_title = n start = (@width - n.size ) / 2 start = 1 if start < 1 setpos(0,start) box(?|, ?-) addstr(n) log('redraw') refresh end |
#status ⇒ Object
63 64 65 66 67 |
# File 'lib/themigrator/ui/log_area.rb', line 63 def status info = self.progress_monitor.actions[action][:roles][role][:status] rescue => e e.inspect end |