Class: Mynu::Support::Terminal
- Inherits:
-
Object
- Object
- Mynu::Support::Terminal
- Defined in:
- lib/mynu/support/terminal.rb
Instance Attribute Summary collapse
-
#system ⇒ Object
Returns the value of attribute system.
-
#terminal ⇒ Object
Returns the value of attribute terminal.
Instance Method Summary collapse
-
#create_tab(command, options = {}) ⇒ Object
For terminal.app I use an SIMBL plugin called Visor, this intergates tab support for your primary (first) window If someone wants to write support for multiple windows, it would help the project a lot!.
-
#initialize ⇒ Terminal
constructor
A new instance of Terminal.
- #method_missing(method, *args) ⇒ Object
- #wait_for_terminal_tab(terminal_tab) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
14 15 16 |
# File 'lib/mynu/support/terminal.rb', line 14 def method_missing(method, *args) args.empty? ? @terminal.send(method) : @terminal.send(method, args) end |
Instance Attribute Details
#system ⇒ Object
Returns the value of attribute system.
6 7 8 |
# File 'lib/mynu/support/terminal.rb', line 6 def system @system end |
#terminal ⇒ Object
Returns the value of attribute terminal.
7 8 9 |
# File 'lib/mynu/support/terminal.rb', line 7 def terminal @terminal end |
Instance Method Details
#create_tab(command, options = {}) ⇒ Object
For terminal.app I use an SIMBL plugin called Visor, this intergates tab support for your primary (first) window If someone wants to write support for multiple windows, it would help the project a lot!
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mynu/support/terminal.rb', line 26 def create_tab(command, = {}) = { :exit => false, :focus => false }.merge() current_process = nil terminal_process = nil terminals = self.windows.first.tabs.map do |terminal_tab| terminal_tab end system.processes.each do |process| current_process = process if process.frontmost end system.processes.each do |process| terminal_process = process if process.shortName == "Terminal" end terminal_process.setFrontmost true system.keystroke "t", Mynu::Support::System::CommandDown system.keystroke "#{command}\r" if command.length > 0 current_terminals = self.windows.first.tabs.map do |terminal_tab| terminal_tab end new_terminal_tab = nil current_terminals.each do |terminal_tab| new_terminal_tab = terminal_tab unless terminals.include?(terminal_tab) end # exit the new tab if [:exit] # broken: # new_terminal_tab.send(:"closeSaving:savingIn:", TerminalSaveOptionsNo, nil) wait_for_terminal_tab(new_terminal_tab) system.keystroke("exit\r") wait_for_terminal_tab(new_terminal_tab) system.keystroke "w", Mynu::Support::System::CommandDown end current_process.setFrontmost true unless [:focus] new_terminal_tab end |
#wait_for_terminal_tab(terminal_tab) ⇒ Object
18 19 20 21 22 |
# File 'lib/mynu/support/terminal.rb', line 18 def wait_for_terminal_tab(terminal_tab) while(terminal_tab.busy) sleep 0.25 end end |