Sha256: 92aeccd6dd25c57efac9a9492374d13a92c77b883ccaccd78231c73cba44c643
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
module Teamocil class Layout # This class represents a window within tmux class Window attr_reader :filters, :root, :splits, :options, :index, :name, :clear # Initialize a new tmux window # # @param session [Session] the session where the window is initialized # @param index [Fixnnum] the window index # @param attrs [Hash] the window data from the layout file def initialize(session, index, attrs={}) # {{{ @name = attrs["name"] || "teamocil-window-#{index+1}" @root = attrs["root"] || "." @clear = attrs["clear"] == true ? "clear" : nil @options = attrs["options"] || {} @splits = attrs["splits"] || [] raise Teamocil::Error::LayoutError.new("You must specify a `splits` key for every window.") if @splits.empty? @splits = @splits.each_with_index.map { |split, split_index| Split.new(self, split_index, split) } @filters = attrs["filters"] || {} @filters["before"] ||= [] @filters["after"] ||= [] @index = index @session = session end # }}} # Generate commands to send to tmux # # @return [Array] def generate_commands # {{{ commands = [] if @session.options.include?(:here) and @index == 0 commands << "tmux rename-window \"#{@name}\"" else commands << "tmux new-window -n \"#{@name}\"" end commands << @splits.map(&:generate_commands) @options.each_pair do |option, value| value = "on" if value === true value = "off" if value === false commands << "tmux set-window-option #{option} #{value}" end commands << "tmux select-pane -t #{@splits.map(&:focus).index(true) || 0}" commands end # }}} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
teamocil-0.3.8 | lib/teamocil/layout/window.rb |