class TheFox::TermKit::UIApp
Attributes
active_controller[RW]
app_controller[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
TheFox::TermKit::App::new
# File lib/termkit/app/app_ui.rb, line 10 def initialize super() #puts 'UIApp initialize' @render_count = 0 @app_controller = nil @active_controller = nil ui_init end
Public Instance Methods
draw_line(point, row)
click to toggle source
# File lib/termkit/app/app_ui.rb, line 81 def draw_line(point, row) x_pos = point.x y_pos = point.y row.length.times do |n| draw_point(Point.new(x_pos, y_pos), ViewContent.new(row[n])) x_pos += 1 end end
draw_point(point, content)
click to toggle source
render()
click to toggle source
Handles the actual rendering and drawing of the UI layer. Calls `draw_point()` for all points of `@active_controller`.
# File lib/termkit/app/app_ui.rb, line 55 def render #sleep 1 # @TODO: remove this line area = nil # @TODO: use current terminal size as area @render_count += 1 # @logger.debug("--- RENDER: #{@render_count} ---") if !@active_controller.nil? # @logger.debug("RENDER active_controller OK: #{@active_controller.inspect}") # @logger.debug("RENDER active_controller view grid_cache: #{@active_controller.view.grid_cache.inspect}") @active_controller.render(area).each do |y_pos, row| row.each do |x_pos, content| #sleep 0.1 # @TODO: remove this line # @logger.debug("RENDER #{x_pos}:#{y_pos} '#{content}'") draw_point(Point.new(x_pos, y_pos), content) #ui_refresh # @TODO: remove this line end end end ui_refresh end
run_cycle()
click to toggle source
See App
`run_cycle()` method.
Calls superclass method
TheFox::TermKit::App#run_cycle
# File lib/termkit/app/app_ui.rb, line 24 def run_cycle super() #puts 'UIApp->run_cycle' render end
set_active_controller(active_controller)
click to toggle source
# File lib/termkit/app/app_ui.rb, line 40 def set_active_controller(active_controller) if !active_controller.is_a?(ViewController) raise ArgumentError, "Argument is not a ViewController -- #{active_controller.class} given" end if !@active_controller.nil? @active_controller.inactive end @active_controller = active_controller @active_controller.active end
set_app_controller(app_controller)
click to toggle source
# File lib/termkit/app/app_ui.rb, line 32 def set_app_controller(app_controller) if !app_controller.is_a?(AppController) raise ArgumentError, "Argument is not a AppController -- #{app_controller.class} given" end @app_controller = app_controller end
ui_max_x()
click to toggle source
# File lib/termkit/app/app_ui.rb, line 103 def ui_max_x -1 end
ui_max_y()
click to toggle source
# File lib/termkit/app/app_ui.rb, line 107 def ui_max_y -1 end
ui_refresh()
click to toggle source
# File lib/termkit/app/app_ui.rb, line 99 def ui_refresh raise NotImplementedError end
Protected Instance Methods
app_will_terminate()
click to toggle source
# File lib/termkit/app/app_ui.rb, line 113 def app_will_terminate #puts 'UIApp app_will_terminate' ui_close end
key_down(key)
click to toggle source
# File lib/termkit/app/app_ui.rb, line 127 def key_down(key) if !key.nil? && !@active_controller.nil? event = KeyEvent.new event.key = key begin @active_controller.handle_event(event) rescue Exception::UnhandledKeyEventException => e @logger.warn("#{self.class} UnhandledKeyEventException: #{e}") if @app_controller.nil? @logger.warn("#{self.class} UnhandledKeyEventException: no app controller set, raise") raise e end @app_controller.handle_event(e.event) rescue Exception::UnhandledEventException => e @logger.warn("#{self.class} UnhandledEventException: #{e}") end end end
ui_close()
click to toggle source
# File lib/termkit/app/app_ui.rb, line 123 def ui_close # raise NotImplementedError end
ui_init()
click to toggle source
# File lib/termkit/app/app_ui.rb, line 119 def ui_init # raise NotImplementedError end