Module: Themigrator::UI::LogArea

Includes:
Curses
Included in:
Themigrator::UI
Defined in:
lib/themigrator/ui/log_area.rb

Defined Under Namespace

Classes: LogWindow

Instance Method Summary collapse

Instance Method Details

#initialize_log_area(roles) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/themigrator/ui/log_area.rb', line 98

def initialize_log_area(roles)
  @la_roles = roles
  @la_scripts = Themigrator::Migration::SCRIPTS
  @la_actions = Themigrator::Migration::ACTIONS
  @la_current_action = nil
  @la_lines = lines
  @la_cols = cols
  @la_mutex = Mutex.new
  # @windows = Hash.new {|h,a| h[a] = {} }
  # @windows[action][role]
  @la_windows
  @la_windows = Hash.new do |h, action|
    role_windows = {}
    @la_roles.each_with_index do |role, n|
      column_height = @la_lines - 4
      column_width = @la_cols / @la_roles.size
      top = 2
      left = column_width * n
      w = LogWindow.new(column_height, column_width - 1, top, left)
      w.role = role
      w.action = action
      role_windows[role] = w
    end
    h[action] = role_windows
  end
end

#la_append(action, role, msg) ⇒ Object



145
146
147
148
149
# File 'lib/themigrator/ui/log_area.rb', line 145

def la_append(action, role, msg)
  @la_mutex.synchronize do
    la_get_window(action, role).append(msg)
  end
end

#la_initialize?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/themigrator/ui/log_area.rb', line 125

def la_initialize?
  defined?(@la_roles)
end

#la_npageObject



129
130
131
# File 'lib/themigrator/ui/log_area.rb', line 129

def la_npage
  la_each_window { |w,_role| w.nextpage }
end

#la_ppageObject



133
134
135
# File 'lib/themigrator/ui/log_area.rb', line 133

def la_ppage
  la_each_window { |w,_role| w.prevpage }
end

#la_renderObject



151
152
153
154
155
# File 'lib/themigrator/ui/log_area.rb', line 151

def la_render
  la_each_window do |w, _role|
    w.render
  end
end

#la_switch_action(action) ⇒ Object



137
138
139
140
141
142
143
# File 'lib/themigrator/ui/log_area.rb', line 137

def la_switch_action(action)
  return if @la_current_action == action || @la_roles.empty?
  @la_current_action = action.to_s
  @la_roles.each do |role|
    la_get_window(action, role).redraw
  end
end