Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows focus #53

Merged
merged 2 commits into from
Jan 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/teamocil/layout/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def generate_commands
commands = []
commands << "tmux rename-session \"#{@name}\"" unless @name.nil?
commands << @windows.map(&:generate_commands)
@windows.each { |w| commands << "tmux select-window -t:#{w.name}" && break if w.focus }
commands
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/teamocil/layout/window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Teamocil
class Layout
# This class represents a window within tmux
class Window
attr_reader :filters, :root, :panes, :options, :index, :name, :clear, :layout, :with_env_var, :cmd_separator
attr_reader :filters, :focus, :root, :panes, :options, :index, :name, :clear, :layout, :with_env_var, :cmd_separator

# Initialize a new tmux window
#
Expand All @@ -17,6 +17,7 @@ def initialize(session, index, attrs={})
@clear = attrs["clear"] == true ? "clear" : nil
@options = attrs["options"] || {}
@layout = attrs["layout"]
@focus = attrs["focus"]

@panes = attrs["panes"] || attrs["splits"] || []
raise Teamocil::Error::LayoutError.new("You must specify a `panes` (or legacy `splits`) key for every window.") if @panes.empty?
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/layouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ two-windows:
- name: "foo"
clear: true
root: "/foo"
focus: true
layout: "tiled"
panes:
- cmd: "echo 'foo'"
Expand Down
5 changes: 5 additions & 0 deletions spec/layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
session.windows[0].layout.should == "tiled"
session.windows[1].layout.should be_nil
end

it "handles focused windows" do
session = @layout.compile!
session.windows.first.focus.should be_true
end
end

describe "panes" do
Expand Down