Class: Ace::Tmux::Models::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/tmux/models/window.rb

Overview

Represents a tmux window configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, layout: nil, root: nil, panes: [], pre_window: nil, focus: false, options: {}, layout_tree: nil) ⇒ Window

Returns a new instance of Window.

Parameters:

  • name (String, nil) (defaults to: nil)

    Window name

  • layout (String, nil) (defaults to: nil)

    tmux layout (e.g., “main-vertical”, “tiled”)

  • root (String, nil) (defaults to: nil)

    Working directory for the window

  • panes (Array<Pane>) (defaults to: [])

    Pane configurations

  • pre_window (String, nil) (defaults to: nil)

    Command to run before each pane

  • focus (Boolean) (defaults to: false)

    Whether this window should be focused

  • options (Hash) (defaults to: {})

    Raw tmux window options (passed to set-window-option)

  • layout_tree (Models::LayoutNode, nil) (defaults to: nil)

    Nested layout tree (nil for flat layouts)



18
19
20
21
22
23
24
25
26
27
# File 'lib/ace/tmux/models/window.rb', line 18

def initialize(name: nil, layout: nil, root: nil, panes: [], pre_window: nil, focus: false, options: {}, layout_tree: nil)
  @name = name
  @layout = layout
  @root = root
  @panes = panes
  @pre_window = pre_window
  @focus = focus
  @options = options || {}
  @layout_tree = layout_tree
end

Instance Attribute Details

#focusObject (readonly)

Returns the value of attribute focus.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def focus
  @focus
end

#layoutObject (readonly)

Returns the value of attribute layout.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def layout
  @layout
end

#layout_treeObject (readonly)

Returns the value of attribute layout_tree.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def layout_tree
  @layout_tree
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def options
  @options
end

#panesObject (readonly)

Returns the value of attribute panes.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def panes
  @panes
end

#pre_windowObject (readonly)

Returns the value of attribute pre_window.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def pre_window
  @pre_window
end

#rootObject (readonly)

Returns the value of attribute root.



8
9
10
# File 'lib/ace/tmux/models/window.rb', line 8

def root
  @root
end

Instance Method Details

#focus?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/ace/tmux/models/window.rb', line 34

def focus?
  @focus == true
end

#nested_layout?Boolean

Returns true if this window uses a nested layout tree.

Returns:

  • (Boolean)

    true if this window uses a nested layout tree



30
31
32
# File 'lib/ace/tmux/models/window.rb', line 30

def nested_layout?
  !@layout_tree.nil?
end

#to_hObject



38
39
40
41
42
43
44
45
46
# File 'lib/ace/tmux/models/window.rb', line 38

def to_h
  hash = {"name" => @name, "panes" => @panes.map(&:to_h)}
  hash["layout"] = @layout if @layout
  hash["root"] = @root if @root
  hash["pre_window"] = @pre_window if @pre_window
  hash["focus"] = @focus if @focus
  hash["options"] = @options unless @options.empty?
  hash
end