Skip to content

Commit

Permalink
splitting panes now works as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
LevelbossMike committed Apr 29, 2011
1 parent 3491eac commit 2308ca5
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/terminitor/dsl.rb
Expand Up @@ -104,11 +104,20 @@ def pane(*args, &block)
pane_name = "pane#{panes.keys.size}"
if block_given?
pane_contents = panes[pane_name] = {:commands => []}
in_context pane_contents, &block
if @_context.has_key? :is_pane
# after in_context we should be able to access
# @_old_context as before
context = @_context
old_context = @_old_context
in_context pane_contents[:commands], &block
clean_up_context(context, old_context)
else
pane_contents[:is_pane] = true
in_context pane_contents, &block
end
else
panes[pane_name] = { :commands => args }
end
puts @_context[:panes]
end

# Returns yaml file as Terminitor formmatted hash
Expand All @@ -127,9 +136,13 @@ def in_context(context, &block)
@_context = @_old_context
end

def clean_up_context
last_open_window_key = @windows.keys.last
@_context = @windows[last_open_window_key]
def clean_up_context(context = last_open_window, old_context = nil)
@_context = context
@_old_context = old_context
end

def last_open_window
@windows[@windows.keys.last]
end
end
end

0 comments on commit 2308ca5

Please sign in to comment.