class Tmux::Window

A {Window window} occupies the entire screen and may be split into rectangular {Pane panes}, each of which is a separate pseudo terminal (the pty(4) manual page documents the technical details of pseudo terminals).

@todo Figure out better names for some attributes, e.g. mode_mouse

Attributes

options[R]

@return [OptionsList]

aggressive_resize[RW]

Aggressively resize the window. This means that tmux will resize the window to the size of the smallest {Session session} for which it is the current window, rather than the smallest {Session session} to which it is attached. The window may resize when the current window is changed on another {Session session}; this option is good for full-screen programs which support SIGWINCH and poor for interactive programs such as shells.

@return [Boolean]

aggressive_resize?[RW]

Aggressively resize the window. This means that tmux will resize the window to the size of the smallest {Session session} for which it is the current window, rather than the smallest {Session session} to which it is attached. The window may resize when the current window is changed on another {Session session}; this option is good for full-screen programs which support SIGWINCH and poor for interactive programs such as shells.

@return [Boolean]

alternate_screen[RW]

This option configures whether programs running inside tmux may use the terminal alternate screen feature, which allows the smcup and rmcup {linux.die.net/man/5/terminfo terminfo(5)} capabilities to be issued to preserve the existing window content on start and restore it on exit.

@return [Boolean]

alternate_screen?[RW]

This option configures whether programs running inside tmux may use the terminal alternate screen feature, which allows the smcup and rmcup {linux.die.net/man/5/terminfo terminfo(5)} capabilities to be issued to preserve the existing window content on start and restore it on exit.

@return [Boolean]

automatic_rename[RW]

Control automatic window renaming. When this setting is enabled, tmux will attempt – on supported platforms – to rename the window to reflect the command currently running in it. This flag is automatically disabled for an individual window when a name is specified at creation with {Session#create_window} or {Server#create_session}, or later with {#name=}.

@return [Boolean]

automatic_rename?[RW]

Control automatic window renaming. When this setting is enabled, tmux will attempt – on supported platforms – to rename the window to reflect the command currently running in it. This flag is automatically disabled for an individual window when a name is specified at creation with {Session#create_window} or {Server#create_session}, or later with {#name=}.

@return [Boolean]

clock_mode_color[RW]

Clock color.

@return [Symbol]

clock_mode_colour[RW]

Clock color.

@return [Symbol]

clock_mode_style[RW]

Clock hour format.

@return [Symbol<:twelve, :twenty_four>]

current_pane[R]

@param [Symbol<:never, :if_same_window, :always>] return_if When

to return the current pane.

Note: In tmux versions prior to 1.4, :always can lead to flickering
Note: Since tmux version 1.4, :always is forced

@return [Pane, nil] The current pane

force_height[RW]

Prevent tmux from resizing the window to greater than `max_height`. A value of zero restores the default unlimited setting.

@return [Number]

force_width[RW]

Prevent tmux from resizing the window to greater than `max_width`. A value of zero restores the default unlimited setting.

@return [Number]

height[R]

@return [Integer] @tmuxver &gt;=1.1

identifier[R]

@return [String]

layout[W]

@todo attr_reader @param [Symbol<:even_horizontal, :even_vertical, :main_horizontal, :main_vertical] The layout to apply to the window @return [Symbol] @tmux select-layout @tmuxver &gt;=1.3 for :tiled layout @tmuxver &gt;=1.0 for all other layouts

main_pane_height[RW]

Set the height of the main (left or top) pane in the main-horizontal or main-vertical {#layout= layouts}.

@return [Number] @see layout=

main_pane_width[RW]

Set the width of the main (left or top) pane in the main-horizontal or main-vertical {#layout= layouts}.

@return [Number] @see layout=

max_height[RW]

Prevent tmux from resizing the window to greater than `max_height`. A value of zero restores the default unlimited setting.

@return [Number]

max_width[RW]

Prevent tmux from resizing the window to greater than `max_width`. A value of zero restores the default unlimited setting.

@return [Number]

mode_attr[RW]

@return [Symbol]

mode_bg[RW]

@return [Symbol]

mode_fg[RW]

@return [Symbol]

mode_keys[RW]

@return [Symbol]

mode_mouse[RW]

Mouse state in modes. If true, the mouse may be used to copy a selection by dragging in {Pane#copy_mode copy mode}, or to select an option in choice mode.

@return [Boolean]

mode_mouse?[RW]

Mouse state in modes. If true, the mouse may be used to copy a selection by dragging in {Pane#copy_mode copy mode}, or to select an option in choice mode.

@return [Boolean]

monitor_activity[RW]

Monitor for activity in the window. Windows with activity are highlighted in the {StatusBar status line}.

@return [Boolean]

monitor_activity?[RW]

Monitor for activity in the window. Windows with activity are highlighted in the {StatusBar status line}.

@return [Boolean]

monitor_content[RW]

Monitor content in the window. When the {linux.die.net/man/3/fnmatch fnmatch(3)} pattern appears in the window, it is highlighted in the {StatusBar status line}.

@return [String]

name[RW]

@return [String] @tmuxver &gt;=1.1 @tmux rename-window

number[RW]

@overload number

@return [Number]

@overload number=(new_number)

@return [Number]
@raise [Exception::IndexInUse]
@see #move

@return [Number]

options[R]

@return [OptionsList]

panes[R]

@return [Array<Pane>] All {Pane panes} @tmuxver &gt;=1.1

remain_on_exit[RW]

A window with this flag set is not destroyed when the program running in it exits. The window may be reactivated with {#respawn}.

@return [Boolean]

remain_on_exit?[RW]

A window with this flag set is not destroyed when the program running in it exits. The window may be reactivated with {#respawn}.

@return [Boolean]

server[R]

@return [Server]

session[RW]

@overload session

@return [Session]

@overload session=(new_session)

Moves the window to another {Session session}. First it tries
to reuse the current number of the window. If that number is
already used in the new {Session session}, the first free
number will be used instead.

@return [Session]
@raise [Exception::IndexInUse]
@see #move
@todo use base-index

@return [Session]

status[R]

@return [Status]

synchronize_panes[RW]

Duplicate input to any {Pane pane} to all other {Pane panes} in the same window (only for {Pane panes} that are not in any special mode)

@return [Boolean]

synchronize_panes?[RW]

Duplicate input to any {Pane pane} to all other {Pane panes} in the same window (only for {Pane panes} that are not in any special mode)

@return [Boolean]

utf8[RW]

Instructs tmux to expect UTF-8 sequences to appear in this window.

@return [Boolean]

utf8?[RW]

Instructs tmux to expect UTF-8 sequences to appear in this window.

@return [Boolean]

width[R]

@return [Integer] @tmuxver &gt;=1.1

word_separators[RW]

Sets the window's conception of what characters are considered word separators, for the purposes of the next and previous word commands in {Pane#copy_mode copy mode}. The default is `[“ ”, “-”, “_”, “@”]`.

@return [Array<String>]

xterm_keys[RW]

If this option is set to true, tmux will generate {linux.die.net/man/1/xterm xterm(1)}-style function key sequences. These have a number included to indicate modifiers such as Shift, Alt or Ctrl. The default is false.

@return [Boolean]

xterm_keys?[RW]

If this option is set to true, tmux will generate {linux.die.net/man/1/xterm xterm(1)}-style function key sequences. These have a number included to indicate modifiers such as Shift, Alt or Ctrl. The default is false.

@return [Boolean]

Public Class Methods

new(session, number) click to toggle source
# File lib/tmux/window.rb, line 51
def initialize(session, number)
  @session, @number = session, number
  @options = OptionsList.new(:window, self, false)
  @status = Status.new(self)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/tmux/window.rb, line 97
def <=>(other)
  return nil unless other.is_a?(Window)
  [@session, @number] <=> [other.session, other.number]
end
==(other) click to toggle source

@return [Boolean]

# File lib/tmux/window.rb, line 103
def ==(other)
  self.class == other.class && @session == other.session && @number == other.number
end
aggressive_resize=(bool) click to toggle source
# File lib/tmux/window.rb, line 185
def aggressive_resize=(bool)
  @options.aggressive_resize = bool
end
alternate_screen=(bool) click to toggle source
# File lib/tmux/window.rb, line 377
def alternate_screen=(bool)
  @options.alternate_screen = bool
end
automatic_rename=(bool) click to toggle source
# File lib/tmux/window.rb, line 205
def automatic_rename=(bool)
  @options.automatic_rename = bool
end
clock_mode_color=(color) click to toggle source
# File lib/tmux/window.rb, line 409
def clock_mode_color=(color)
  @options.clock_mode_colour = color
end
Also aliased as: clock_mode_colour=
clock_mode_colour=(color)
Alias for: clock_mode_color=
clock_mode_style=(style) click to toggle source
# File lib/tmux/window.rb, line 425
def clock_mode_style=(style)
  @options.clock_mode_style = style
end
eql?(other) click to toggle source

@return [Boolean]

# File lib/tmux/window.rb, line 113
def eql?(other)
  self == other
end
force_height=(value)
Alias for: max_height=
force_width=(value)
Alias for: max_width=
hash() click to toggle source

@return [Number]

# File lib/tmux/window.rb, line 108
def hash
  [@session.hash, @number].hash
end
kill() click to toggle source

Kills the window. @tmux kill-window @return [void]

# File lib/tmux/window.rb, line 512
def kill
  server.invoke_command "kill-window -t #{identifier}"
end
main_pane_height=(height) click to toggle source
# File lib/tmux/window.rb, line 441
def main_pane_height=(height)
  @options.main_pane_height = height
end
main_pane_width=(width) click to toggle source
# File lib/tmux/window.rb, line 457
def main_pane_width=(width)
  @options.main_pane_width = width
end
max_height=(value) click to toggle source
# File lib/tmux/window.rb, line 321
def max_height=(value)
  @options.force_height = value
end
Also aliased as: force_height=
max_width=(value) click to toggle source
# File lib/tmux/window.rb, line 303
def max_width=(value)
  @options.force_width = value
end
Also aliased as: force_width=
mode_attr=(attr) click to toggle source
# File lib/tmux/window.rb, line 469
def mode_attr=(attr)
  @options.mode_attr = attr
end
mode_bg=(bg) click to toggle source
# File lib/tmux/window.rb, line 481
def mode_bg=(bg)
  @options.mode_bg = bg
end
mode_fg=(fg) click to toggle source
# File lib/tmux/window.rb, line 493
def mode_fg=(fg)
  @options.mode_fg = fg
end
mode_keys=(keymap) click to toggle source
# File lib/tmux/window.rb, line 505
def mode_keys=(keymap)
  @options.mode_keys = keymap
end
mode_mouse=(bool) click to toggle source
# File lib/tmux/window.rb, line 394
def mode_mouse=(bool)
  @options.mode_mouse = bool
end
monitor_activity=(bool) click to toggle source
# File lib/tmux/window.rb, line 271
def monitor_activity=(bool)
  @options.monitor_activity = bool
end
monitor_content=(pattern) click to toggle source
# File lib/tmux/window.rb, line 287
def monitor_content=(pattern)
  @options.monitor_content = pattern
end
move(new_session, new_number) click to toggle source

Moves the window to either a different session, a different position or both.

@param [Session] new_session @param [Number] new_number

@return [void] @raise [Exception::IndexInUse] @see number= @see session=

@tmux move-window

# File lib/tmux/window.rb, line 85
def move(new_session, new_number)
  return if @session == new_session && @number == new_number
  target = "%s:%s" % [new_session.identifier, new_number]

  res = server.invoke_command("move-window -s #{identifier} -t #{target}")
  if res =~ /^can't move window: index in use: \d+/
    raise IndexInUse, [new_session, new_number]
  end
  @session = new_session
  @number  = new_number
end
name=(value) click to toggle source
# File lib/tmux/window.rb, line 136
def name=(value)
  # TODO escape name?
  server.invoke_command "rename-window -t #{identifier} '#{value}'"
end
number=(new_number) click to toggle source
# File lib/tmux/window.rb, line 69
def number=(new_number)
  move(@session, new_number)
end
panes_information(search={}) click to toggle source

@param [Hash] search Filters the resulting hash using {FilterableHash#filter} @return [Hash] A hash with information for all panes @tmux list-panes @tmuxver &gt;=1.1

# File lib/tmux/window.rb, line 554
def panes_information(search={})
  server.check_for_version!("1.1")

  hash = {}
  output = server.invoke_command "list-panes -t #{identifier}"
  output.each_line do |pane|
    params = pane.match(/^(?<num>\d+): \[(?<width>\d+)x(?<height>\d+)\] \[history (?<cur_history>\d+)\/(?<max_history>\d+), (?<memory>\d+) bytes\](?<active> \(active\))?$/)
    num = params[:num].to_i
    width = params[:width].to_i
    height = params[:height].to_i
    cur_history = params[:cur_history].to_i
    max_history = params[:max_history].to_i
    memory = Filesize.new(params[:memory].to_i)

    # this flag requires tmux >=1.4
    active = !params[:active].nil?

    hash[num] = {
      :num => num,
      :width => width,
      :height => height,
      :cur_history => cur_history,
      :max_history => max_history,
      :memory => memory,
      :active => active,
    }
  end
  hash.extend FilterableHash
  hash.filter(search)
end
paste(buffer, pop = false, translate = true, separator = nil) click to toggle source

Pastes a {Buffer buffer} into the window.

@param [Buffer] buffer The {Buffer buffer} to paste @param pop (see Buffer#paste) @param translate (see Buffer#paste) @param separator (see Buffer#paste) @return [void] @tmux paste-buffer @see Buffer#paste @see Pane#paste

# File lib/tmux/window.rb, line 607
def paste(buffer, pop = false, translate = true, separator = nil)
  buffer.paste(self, pop, translate, separator)
end
remain_on_exit=(bool) click to toggle source
# File lib/tmux/window.rb, line 239
def remain_on_exit=(bool)
  @options.remain_on_exit = bool
end
respawn(command = nil, kill = false) click to toggle source

Reactivates a window in which the command has exited.

@param [String, nil] command The command to use to respawn the

window. If nil, the command used when the window was created is
executed.

@param [Boolean] kill Unless `kill` is true, only inactive windows can be respawned @return [void] @tmux respawn-window @see remain_on_exit @todo escape command

# File lib/tmux/window.rb, line 687
def respawn(command = nil, kill = false)
  flags = []
  flags << "-k" if kill
  flags << "-t #{identifier}"
  flags << "\"#{command}\"" if command

  server.invoke_command "respawn-window #{flags.join(" ")}"
end
rotate(direction = :upward) click to toggle source

Rotates the positions of the {Pane panes} within a window.

@tmux rotate-window @return [void]

# File lib/tmux/window.rb, line 520
def rotate(direction = :upward)
  flag = case direction
         when :upward
           "U"
         when :downward
           "D"
         else
           raise ArgumentError
         end
  server.invoke_command "rotate-window -#{flag} -t #{identifier}"
end
select() click to toggle source

Select the window.

@return [void] @tmux select-window

# File lib/tmux/window.rb, line 615
def select
  server.invoke_command "select-window -t #{identifier}"
end
select_last_pane(return_if = :always) click to toggle source

Select the previously selected pane.

@param return_if (see Window#current_pane) @return (see Window#current_pane) @tmux last-pane @tmuxver &gt;=1.4

# File lib/tmux/window.rb, line 672
def select_last_pane(return_if = :always)
  server.invoke_command("last-pane -t #{identifier}")
  current_pane(return_if)
end
session=(new_session) click to toggle source
# File lib/tmux/window.rb, line 57
def session=(new_session)
  i = -1
  first_try = true
  begin
    num = (first_try ? @number : (i += 1))
    move(new_session, num)
  rescue IndexInUse
    first_try = false
    retry
  end
end
swap_with(window) click to toggle source

Swap the window with another one.

@param [Window] window The window to swap with @return [void] @tmux swap-window

# File lib/tmux/window.rb, line 624
def swap_with(window)
  server.invoke_command "swap-window -s #{identifier} -t #{window.identifier}"
end
synchronize_panes=(bool) click to toggle source
# File lib/tmux/window.rb, line 222
def synchronize_panes=(bool)
  @options.synchronize_panes = bool
end
utf8=(bool) click to toggle source
# File lib/tmux/window.rb, line 255
def utf8=(bool)
  @options.utf8 = bool
end
word_separators=(value) click to toggle source
# File lib/tmux/window.rb, line 358
def word_separators=(value)
  @options.word_separators = value
end
xterm_keys=(bool) click to toggle source
# File lib/tmux/window.rb, line 341
def xterm_keys=(bool)
  @options.xterm_keys = bool
end