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
@return [OptionsList]
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]
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]
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]
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]
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]
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 color.
@return [Symbol]
Clock color.
@return [Symbol]
Clock hour format.
@return [Symbol<:twelve, :twenty_four>]
@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
Prevent tmux from resizing the window to greater than `max_height`. A value of zero restores the default unlimited setting.
@return [Number]
Prevent tmux from resizing the window to greater than `max_width`. A value of zero restores the default unlimited setting.
@return [Number]
@return [Integer] @tmuxver >=1.1
@return [String]
@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 >=1.3 for :tiled layout @tmuxver >=1.0 for all other layouts
Set the height of the main (left or top) pane in the main-horizontal or main-vertical {#layout= layouts}.
@return [Number] @see layout=
Set the width of the main (left or top) pane in the main-horizontal or main-vertical {#layout= layouts}.
@return [Number] @see layout=
Prevent tmux from resizing the window to greater than `max_height`. A value of zero restores the default unlimited setting.
@return [Number]
Prevent tmux from resizing the window to greater than `max_width`. A value of zero restores the default unlimited setting.
@return [Number]
@return [Symbol]
@return [Symbol]
@return [Symbol]
@return [Symbol]
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]
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 for activity in the window. Windows with activity are highlighted in the {StatusBar status line}.
@return [Boolean]
Monitor for activity in the window. Windows with activity are highlighted in the {StatusBar status line}.
@return [Boolean]
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]
@return [String] @tmuxver >=1.1 @tmux rename-window
@overload number
@return [Number]
@overload number=(new_number)
@return [Number] @raise [Exception::IndexInUse] @see #move
@return [Number]
@return [OptionsList]
@return [Array<Pane>] All {Pane panes} @tmuxver >=1.1
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]
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]
@return [Server]
@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]
@return [Status]
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]
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]
Instructs tmux to expect UTF-8 sequences to appear in this window.
@return [Boolean]
Instructs tmux to expect UTF-8 sequences to appear in this window.
@return [Boolean]
@return [Integer] @tmuxver >=1.1
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>]
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]
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
# 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
# File lib/tmux/window.rb, line 97 def <=>(other) return nil unless other.is_a?(Window) [@session, @number] <=> [other.session, other.number] end
@return [Boolean]
# File lib/tmux/window.rb, line 103 def ==(other) self.class == other.class && @session == other.session && @number == other.number end
# File lib/tmux/window.rb, line 185 def aggressive_resize=(bool) @options.aggressive_resize = bool end
# File lib/tmux/window.rb, line 377 def alternate_screen=(bool) @options.alternate_screen = bool end
# File lib/tmux/window.rb, line 205 def automatic_rename=(bool) @options.automatic_rename = bool end
# File lib/tmux/window.rb, line 409 def clock_mode_color=(color) @options.clock_mode_colour = color end
# File lib/tmux/window.rb, line 425 def clock_mode_style=(style) @options.clock_mode_style = style end
@return [Boolean]
# File lib/tmux/window.rb, line 113 def eql?(other) self == other end
@return [Number]
# File lib/tmux/window.rb, line 108 def hash [@session.hash, @number].hash end
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
# File lib/tmux/window.rb, line 441 def main_pane_height=(height) @options.main_pane_height = height end
# File lib/tmux/window.rb, line 457 def main_pane_width=(width) @options.main_pane_width = width end
# File lib/tmux/window.rb, line 321 def max_height=(value) @options.force_height = value end
# File lib/tmux/window.rb, line 303 def max_width=(value) @options.force_width = value end
# File lib/tmux/window.rb, line 469 def mode_attr=(attr) @options.mode_attr = attr end
# File lib/tmux/window.rb, line 481 def mode_bg=(bg) @options.mode_bg = bg end
# File lib/tmux/window.rb, line 493 def mode_fg=(fg) @options.mode_fg = fg end
# File lib/tmux/window.rb, line 505 def mode_keys=(keymap) @options.mode_keys = keymap end
# File lib/tmux/window.rb, line 394 def mode_mouse=(bool) @options.mode_mouse = bool end
# File lib/tmux/window.rb, line 271 def monitor_activity=(bool) @options.monitor_activity = bool end
# File lib/tmux/window.rb, line 287 def monitor_content=(pattern) @options.monitor_content = pattern end
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
# File lib/tmux/window.rb, line 136 def name=(value) # TODO escape name? server.invoke_command "rename-window -t #{identifier} '#{value}'" end
# File lib/tmux/window.rb, line 69 def number=(new_number) move(@session, new_number) end
@param [Hash] search Filters the resulting hash using {FilterableHash#filter} @return [Hash] A hash with information for all panes @tmux list-panes @tmuxver >=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
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
# File lib/tmux/window.rb, line 239 def remain_on_exit=(bool) @options.remain_on_exit = bool end
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
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 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 the previously selected pane.
@param return_if (see Window#current_pane
) @return (see Window#current_pane
) @tmux last-pane @tmuxver >=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
# 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 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
# File lib/tmux/window.rb, line 222 def synchronize_panes=(bool) @options.synchronize_panes = bool end
# File lib/tmux/window.rb, line 255 def utf8=(bool) @options.utf8 = bool end
# File lib/tmux/window.rb, line 358 def word_separators=(value) @options.word_separators = value end
# File lib/tmux/window.rb, line 341 def xterm_keys=(bool) @options.xterm_keys = bool end