Class: WindowBlessing::WindowedScreen

Inherits:
XtermScreen show all
Defined in:
lib/window_blessing/windowed_screen.rb

Instance Attribute Summary collapse

Attributes inherited from XtermScreen

#event_manager, #event_queue, #input, #output, #state

Instance Method Summary collapse

Methods inherited from XtermScreen

#event_loop, #in_xterm_state, #initialize_screen, #inspect, #process_events, #process_queued_events, #queue_event, #queue_pending_xterm_events, #queued_events?, #quit, #running?, #start, #wait_for_events

Constructor Details

#initializeWindowedScreen

Returns a new instance of WindowedScreen.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/window_blessing/windowed_screen.rb', line 17

def initialize
  super
  @root_window = Window.new
  @root_window.buffer.dirty
  @root_window.name = "root_window"

  event_manager.on :tick do
    if root_window.redraw_requested?
      root_window.draw
      buffer = root_window.buffer
      output.draw_buffer buffer.dirty_area.loc, buffer.dirty_subbuffer if buffer.dirty_area
      buffer.clean
    end
  end

  event_manager.on :key_press do |event|
    root_window.route_keyboard_event event
  end

  event_manager.on :string_input do |event|
    root_window.route_keyboard_event event
  end

  event_manager.on :resize do |event|
    root_window.size = event[:size]
    root_window.request_redraw_internal
  end

  event_manager.on :pointer do |event|
    root_window.route_pointer_event event.clone
  end
end

Instance Attribute Details

#root_windowObject

Returns the value of attribute root_window.



4
5
6
# File 'lib/window_blessing/windowed_screen.rb', line 4

def root_window
  @root_window
end

Instance Method Details

#time(category, info) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/window_blessing/windowed_screen.rb', line 6

def time(category,info)
  start = Time.now
  yield
  stop = Time.now
  @total_time ||= 0
  @draw_count ||= 0
  @draw_count += 1
  @total_time += stop - start
  XtermLog.log "#{category} time = #{((@total_time/@draw_count)*1000).to_i}ms #{info}"
end