Class: WindowBlessing::XtermState

Inherits:
Object
  • Object
show all
Defined in:
lib/window_blessing/xterm_state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_manager) ⇒ XtermState

Returns a new instance of XtermState.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/window_blessing/xterm_state.rb', line 5

def initialize(event_manager)
  @state = {:size => point(-1,-1)}

  event_manager.on :xterm_state do |event|
    state_type = event[:state_type]
    old_state = state[state_type]
    new_state = event[:state]
    state[state_type] = new_state
    if old_state!=new_state
      case state_type
      when :size
        event_manager.handle_event :type => :resize, :old_size => old_state, :size => new_state, :raw => event[:raw]
      else
        event_manager.handle_event :type => :state_change, :state_type => state_type, :old_state => old_state, :state => new_state, :raw => event[:raw]
      end

    end
  end
end

Instance Attribute Details

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/window_blessing/xterm_state.rb', line 3

def state
  @state
end

Instance Method Details

#sizeObject



25
# File 'lib/window_blessing/xterm_state.rb', line 25

def size; state[:size] end