Module: Rum::WindowInfo

Defined in:
lib/rum/help.rb

Constant Summary collapse

StopKey =
'escape'

Class Method Summary collapse

Class Method Details

.register_stop_keyObject



114
115
116
117
118
# File 'lib/rum/help.rb', line 114

def register_stop_key
  @old_action = StopKey.unregister
  StopKey.do { WindowInfo.stop }
  Gui.message "Press '#{StopKey}' to stop WindowInfo."
end

.startObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/rum/help.rb', line 90

def start
  return if @thread
  register_stop_key
  @stop = false
  @thread = Thread.new do
    new = old = nil
    loop do
      break if @stop
      new = active_window
      if new != old
        window_report = new.report
        Gui.message(window_report) { System::Clipboard.set window_report }
        old = new
      end
      sleep 0.1
    end
    Clipboard.set new.report
    Gui.message 'Window Info stopped.'
    @thread = nil
  end
end

.stopObject



120
121
122
123
124
125
126
127
128
# File 'lib/rum/help.rb', line 120

def stop
  return unless @thread
  @stop = true
  if @old_action
    @old_action.register
  else
    StopKey.unregister
  end
end