Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

vertical split on first level panes now works

  • Loading branch information...
commit 10b26088caa41ed147202c940503c5429a4ab37c 1 parent a018a4d
Michael Klein LevelbossMike authored
Showing with 32 additions and 7 deletions.
  1. +26 −2 lib/terminitor/cores/iterm_core.rb
  2. +6 −5 lib/terminitor/dsl.rb
28 lib/terminitor/cores/iterm_core.rb
View
@@ -49,7 +49,7 @@ def open_window(options = nil)
# We need this method to workaround appscript so that we can instantiate new tabs and windows.
# otherwise it would have looked something like window.make(:new => :tab) but that doesn't work.
def terminal_process
- Appscript.app("System Events").application_processes["iTerm.app"]
+ Appscript.app("System Events").processes["iTerm"]
end
# Returns the last instantiated tab from active window
@@ -67,6 +67,10 @@ def current_terminal
@terminal.current_terminal
end
+ def last_session
+ current_terminal.sessions.last
+ end
+
# Sets options of the given object
def set_options(object, options = {})
options.each_pair do |option, value|
@@ -141,13 +145,33 @@ def run_in_window(window_name, window_content, options = {})
# if tab_content hash has a key :panes we know this tab should be split
# we can execute tab commands as before if there is no key :panes
if tab_content.key?(:panes)
- #do some shit with the pane
+ handle_panes(tab_content)
else
tab_content[:commands].each { |cmd| execute_command(cmd, :in => tab) }
end
end
set_delayed_options
end
+
+ # handle panes
+ #
+ def handle_panes(tab_content)
+ panes = tab_content[:panes]
+ tab_commands = tab_content[:commands]
+ first_pane = true
+ panes.keys.sort.each do |pane_key|
+ # split and execute commands
+ split_v unless first_pane
+ first_pane = false if first_pane
+ pane_commands = panes[pane_key][:commands]
+ # tab commands in each pane
+ pane_commands = tab_commands + pane_commands
+ pane_commands.each {|cmd| execute_command cmd, :in => last_session}
+ #check if pane includes a pane
+ # puts "awesome there's a subpane I have to split_h here" if panes[pane_key].keys.include?(:panes)
+ end
+ end
+
# Methods for splitting panes
#
11 lib/terminitor/dsl.rb
View
@@ -97,10 +97,8 @@ def tab(*args, &block)
end
def pane(*args, &block)
- # @_context points to :commands-array in a tab when we're inside
- # a pane
- @_tab_context.merge!({:panes =>{}}) unless @_tab_context.key?(:panes)
- panes = @_tab_context[:panes]
+ current_tab[:panes] = {} unless current_tab.has_key? :panes
+ panes = current_tab[:panes]
pane_name = "#{panes.keys.size}"
if block_given?
pane_contents = panes[pane_name] = {:commands => []}
@@ -125,7 +123,10 @@ def in_context(context, &block)
instance_eval(&block)
@_context = @_old_context
end
-
+
+ def current_tab
+ @_tab_context
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.