Class: XTabbedWindow

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ XTabbedWindow

Returns a new instance of XTabbedWindow.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xtabbedwindow.rb', line 14

def initialize(name)

  a = WMCtrl.instance.windows
  @window = a.detect {|x| x.title =~ /#{name}/i}

  if @window
    sleep 0.3
    @window.activate
  end

  read_tabs()

end

Instance Attribute Details

#tabsObject (readonly)

Returns the value of attribute tabs.



12
13
14
# File 'lib/xtabbedwindow.rb', line 12

def tabs
  @tabs
end

#windowObject (readonly)

Returns the value of attribute window.



12
13
14
# File 'lib/xtabbedwindow.rb', line 12

def window
  @window
end

Instance Method Details

#goto_tab(pattern) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/xtabbedwindow.rb', line 28

def goto_tab(pattern)

  regex = pattern.is_a?(String) ? /^#{pattern}/i : pattern

  a = @tabs
  r = a.grep(regex)

  if r.empty? and pattern.is_a? String then
    regex = /#{pattern}/i
    r = a.grep(regex)
  end

  return if r.empty?

  i = a.index(r.first)

  @window.activate
  sleep 0.1

  XDo::Keyboard.char("Alt+1")
  sleep 0.1
  i.times { XDo::Keyboard.char("Ctrl+Tab") }

end

#next_tabObject



53
54
55
56
# File 'lib/xtabbedwindow.rb', line 53

def next_tab()
  sleep 0.05
  XDo::Keyboard.char("Ctrl+Tab")
end

#read_tabsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/xtabbedwindow.rb', line 58

def read_tabs()

  XDo::Keyboard.char("Alt+1")

  start_tab_title = title()
  @tabs = [start_tab_title]
  
  next_tab()
  window_title = title()

  while window_title != start_tab_title do

    @tabs << window_title
    next_tab()
    window_title = title()

  end

  @tabs

end

#titleObject



80
81
82
83
# File 'lib/xtabbedwindow.rb', line 80

def title()
  sleep 0.05
  XDo::XWindow.from_active.title
end