Class: Termup::Terminal

Inherits:
Base
  • Object
show all
Defined in:
lib/termup/terminal.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Termup::Base

Instance Method Details

#layout(command) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/termup/terminal.rb', line 21

def layout(command)
  case command.to_sym
  when :new_tab             then hit 't', :command_down
  when :close_tab           then hit 'w', :command_down
  when :goto_previous_tab   then hit '[', :command_down, :shift_down
  when :goto_next_tab       then hit ']', :command_down, :shift_down
  else
    abort "Unknown Terminal.app command: #{command}"
  end
end

#startObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/termup/terminal.rb', line 3

def start
  # Setting up tabs / panes
  @tabs.each.with_index do |(tabname, values), index|
    values.each do |command|
      @lines << "app.doScript('#{command}', { in: app.windows[0].tabs.last() })"
    end

    if index < @tabs.size - 1
      layout :new_tab
      sleep 0.01 # Allow some time to complete opening a new tab
    else
      layout :goto_next_tab # Back home
    end
  end

  super
end