Module: Tornado::Applications::Terminal

Defined in:
lib/applications/terminal.rb

Defined Under Namespace

Classes: Tab

Instance Method Summary collapse

Instance Method Details

#absolutize_size(size, width_or_height) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/applications/terminal.rb', line 31

def absolutize_size(size, width_or_height)
  if size.to_s[-1].chr == "%"
    OSX.send("desktop_#{width_or_height}") * (size.to_f / 100)
  else
    size + height
  end
end

#open_new_tab(path = nil, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/applications/terminal.rb', line 3

def open_new_tab(path=nil, &block)
  Terminal.ensure_launched
  Terminal.keystroke("t", :using => :command_down)
  tab = Tab.new(app.windows.first.tabs.last)
  if path
    tab.cd(path) 
    tab.clear
  end
  if block_given?
    tab.instance_eval(&block)
  end
  tab
end

#position_top_left_corner_at(x, y, animate = false) ⇒ Object

For some reason (a bug), we have to add the window’s height to both y-values in the coordinates



18
19
20
21
# File 'lib/applications/terminal.rb', line 18

def position_top_left_corner_at(x,y, animate=false)
  b = current_bounds
  app.windows[0].bounds.set([x, y + height, x + width, y + height + height])
end

#resize(w, h, animate = false) ⇒ Object

same bug is addressed here



24
25
26
27
28
29
# File 'lib/applications/terminal.rb', line 24

def resize(w, h, animate=false)
  b = current_bounds
  w = absolutize_size(w, :width)
  h = absolutize_size(h, :height)
  app.windows[0].bounds.set([ b[0], b[1] + height, b[0] + w, b[1] + h + height ])
end