Class: Tmux::Window
- Inherits:
-
Object
- Object
- Tmux::Window
- Includes:
- Comparable
- Defined in:
- lib/tmux/window.rb,
lib/tmux/window/status.rb,
lib/tmux/window/status/state.rb
Overview
Defined Under Namespace
Classes: Status
Class Attribute Summary collapse
- .options(server) ⇒ OptionsList readonly
Instance Attribute Summary collapse
-
#aggressive_resize ⇒ Boolean
(also: #aggressive_resize?)
Aggressively resize the window.
-
#alternate_screen ⇒ Boolean
(also: #alternate_screen?)
This option configures whether programs running inside tmux may use the terminal alternate screen feature, which allows the smcup and rmcup terminfo(5) capabilities to be issued to preserve the existing window content on start and restore it on exit.
-
#automatic_rename ⇒ Boolean
(also: #automatic_rename?)
Control automatic window renaming.
-
#clock_mode_color ⇒ Symbol
(also: #clock_mode_colour)
Clock color.
-
#clock_mode_style ⇒ Symbol<:twelve, :twenty_four>
Clock hour format.
-
#current_pane(return_if = :always) ⇒ Pane?
readonly
The current pane.
- #height ⇒ Integer readonly
- #identifier ⇒ String readonly
- #layout ⇒ Symbol writeonly
-
#main_pane_height ⇒ Number
Set the height of the main (left or top) pane in the main-horizontal or main-vertical layouts.
-
#main_pane_width ⇒ Number
Set the width of the main (left or top) pane in the main-horizontal or main-vertical layouts.
-
#max_height ⇒ Number
(also: #force_height)
Prevent tmux from resizing the window to greater than
max_height
. -
#max_width ⇒ Number
(also: #force_width)
Prevent tmux from resizing the window to greater than
max_width
. - #mode_attr ⇒ Symbol
- #mode_bg ⇒ Symbol
- #mode_fg ⇒ Symbol
- #mode_keys ⇒ Symbol
-
#mode_mouse ⇒ Boolean
(also: #mode_mouse?)
Mouse state in modes.
-
#monitor_activity ⇒ Boolean
(also: #monitor_activity?)
Monitor for activity in the window.
-
#monitor_content ⇒ String
Monitor content in the window.
- #name ⇒ String
- #number ⇒ Number
- #options ⇒ OptionsList readonly
-
#panes ⇒ Array<Pane>
readonly
All panes.
-
#remain_on_exit ⇒ Boolean
(also: #remain_on_exit?)
A window with this flag set is not destroyed when the program running in it exits.
- #server ⇒ Server readonly
- #session ⇒ Session
- #status ⇒ Status readonly
- #synchronize_panes ⇒ Boolean (also: #synchronize_panes?)
-
#utf8 ⇒ Boolean
(also: #utf8?)
Instructs tmux to expect UTF-8 sequences to appear in this window.
- #width ⇒ Integer readonly
-
#word_separators ⇒ Array<String>
Sets the window's conception of what characters are considered word separators, for the purposes of the next and previous word commands in copy mode.
-
#xterm_keys ⇒ Boolean
(also: #xterm_keys?)
If this option is set to true, tmux will generate xterm(1)-style function key sequences.
Instance Method Summary collapse
- #<=>(other) ⇒ Undefined
- #==(other) ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #hash ⇒ Number
-
#initialize(session, number) ⇒ Window
constructor
A new instance of Window.
-
#kill
Kills the window.
-
#move(new_session, new_number)
Moves the window to either a different session, a different position or both.
-
#panes_information(search = {}) ⇒ Hash
A hash with information for all panes.
-
#paste(buffer, pop = false, translate = true, separator = nil)
Pastes a buffer into the window.
-
#respawn(command = nil, kill = false)
Reactivates a window in which the command has exited.
-
#rotate(direction = :upward)
Rotates the positions of the panes within a window.
-
#select
Select the window.
-
#select_last_pane(return_if = :always) ⇒ Pane?
Select the previously selected pane.
-
#swap_with(window)
Swap the window with another one.
Constructor Details
#initialize(session, number) ⇒ Window
Returns a new instance of Window.
52 53 54 55 56 |
# File 'lib/tmux/window.rb', line 52 def initialize(session, number) @session, @number = session, number @options = OptionsList.new(:window, self, false) @status = Status.new(self) end |
Class Attribute Details
.options(server) ⇒ OptionsList (readonly)
16 17 18 |
# File 'lib/tmux/window.rb', line 16 def @options end |
Instance Attribute Details
#aggressive_resize ⇒ Boolean Also known as: aggressive_resize?
Aggressively resize the window. This means that tmux will resize the window to the size of the smallest session for which it is the current window, rather than the smallest session to which it is attached. The window may resize when the current window is changed on another session; this option is good for full-screen programs which support SIGWINCH and poor for interactive programs such as shells.
178 179 180 |
# File 'lib/tmux/window.rb', line 178 def aggressive_resize @aggressive_resize end |
#alternate_screen ⇒ Boolean Also known as: alternate_screen?
This option configures whether programs running inside tmux may use the terminal alternate screen feature, which allows the smcup and rmcup terminfo(5) capabilities to be issued to preserve the existing window content on start and restore it on exit.
370 371 372 |
# File 'lib/tmux/window.rb', line 370 def alternate_screen @alternate_screen end |
#automatic_rename ⇒ Boolean Also known as: automatic_rename?
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=.
198 199 200 |
# File 'lib/tmux/window.rb', line 198 def automatic_rename @automatic_rename end |
#clock_mode_color ⇒ Symbol Also known as: clock_mode_colour
Clock color.
402 403 404 |
# File 'lib/tmux/window.rb', line 402 def clock_mode_color @clock_mode_color end |
#clock_mode_style ⇒ Symbol<:twelve, :twenty_four>
Clock hour format.
418 419 420 |
# File 'lib/tmux/window.rb', line 418 def clock_mode_style @clock_mode_style end |
#current_pane(return_if = :always) ⇒ Pane? (readonly)
Returns The current pane.
635 636 637 |
# File 'lib/tmux/window.rb', line 635 def current_pane @current_pane end |
#height ⇒ Integer (readonly)
154 155 156 |
# File 'lib/tmux/window.rb', line 154 def height @height end |
#identifier ⇒ String (readonly)
163 164 165 |
# File 'lib/tmux/window.rb', line 163 def identifier @identifier end |
#layout=(layout) ⇒ Symbol (writeonly)
attr_reader
539 540 541 |
# File 'lib/tmux/window.rb', line 539 def layout=(value) @layout = value end |
#main_pane_height ⇒ Number
Set the height of the main (left or top) pane in the main-horizontal or main-vertical layouts.
435 436 437 |
# File 'lib/tmux/window.rb', line 435 def main_pane_height @main_pane_height end |
#main_pane_width ⇒ Number
Set the width of the main (left or top) pane in the main-horizontal or main-vertical layouts.
451 452 453 |
# File 'lib/tmux/window.rb', line 451 def main_pane_width @main_pane_width end |
#max_height ⇒ Number Also known as: force_height
Prevent tmux from resizing the window to greater than
max_height
. A value of zero restores the default unlimited
setting.
315 316 317 |
# File 'lib/tmux/window.rb', line 315 def max_height @max_height end |
#max_width ⇒ Number Also known as: force_width
Prevent tmux from resizing the window to greater than
max_width
. A value of zero restores the default unlimited
setting.
297 298 299 |
# File 'lib/tmux/window.rb', line 297 def max_width @max_width end |
#mode_attr ⇒ Symbol
463 464 465 |
# File 'lib/tmux/window.rb', line 463 def mode_attr @mode_attr end |
#mode_bg ⇒ Symbol
475 476 477 |
# File 'lib/tmux/window.rb', line 475 def mode_bg @mode_bg end |
#mode_fg ⇒ Symbol
487 488 489 |
# File 'lib/tmux/window.rb', line 487 def mode_fg @mode_fg end |
#mode_keys ⇒ Symbol
499 500 501 |
# File 'lib/tmux/window.rb', line 499 def mode_keys @mode_keys end |
#mode_mouse ⇒ Boolean Also known as: mode_mouse?
Mouse state in modes. If true, the mouse may be used to copy a selection by dragging in copy mode, or to select an option in choice mode.
387 388 389 |
# File 'lib/tmux/window.rb', line 387 def mode_mouse @mode_mouse end |
#monitor_activity ⇒ Boolean Also known as: monitor_activity?
Monitor for activity in the window. Windows with activity are highlighted in the status line.
264 265 266 |
# File 'lib/tmux/window.rb', line 264 def monitor_activity @monitor_activity end |
#monitor_content ⇒ String
Monitor content in the window. When the fnmatch(3) pattern appears in the window, it is highlighted in the status line.
281 282 283 |
# File 'lib/tmux/window.rb', line 281 def monitor_content @monitor_content end |
#name ⇒ String
128 129 130 |
# File 'lib/tmux/window.rb', line 128 def name @name end |
#number ⇒ Number #number=(new_number) ⇒ Number
30 31 32 |
# File 'lib/tmux/window.rb', line 30 def number @number end |
#panes ⇒ Array<Pane> (readonly)
Returns All panes.
588 589 590 |
# File 'lib/tmux/window.rb', line 588 def panes @panes end |
#remain_on_exit ⇒ Boolean Also known as: remain_on_exit?
A window with this flag set is not destroyed when the program running in it exits. The window may be reactivated with #respawn.
232 233 234 |
# File 'lib/tmux/window.rb', line 232 def remain_on_exit @remain_on_exit end |
#server ⇒ Server (readonly)
119 120 121 |
# File 'lib/tmux/window.rb', line 119 def server @server end |
#session ⇒ Session #session=(new_session) ⇒ Session
46 47 48 |
# File 'lib/tmux/window.rb', line 46 def session @session end |
#synchronize_panes ⇒ Boolean Also known as: synchronize_panes?
215 216 217 |
# File 'lib/tmux/window.rb', line 215 def synchronize_panes @synchronize_panes end |
#utf8 ⇒ Boolean Also known as: utf8?
Instructs tmux to expect UTF-8 sequences to appear in this window.
248 249 250 |
# File 'lib/tmux/window.rb', line 248 def utf8 @utf8 end |
#width ⇒ Integer (readonly)
144 145 146 |
# File 'lib/tmux/window.rb', line 144 def width @width end |
#word_separators ⇒ Array<String>
Sets the window's conception of what characters are considered
word separators, for the purposes of the next and previous word
commands in copy mode. The default is [" ",
"-", "_", "@"]
.
352 353 354 |
# File 'lib/tmux/window.rb', line 352 def word_separators @word_separators end |
#xterm_keys ⇒ Boolean Also known as: xterm_keys?
If this option is set to true, tmux will generate xterm(1)-style function key sequences. These have a number included to indicate modifiers such as Shift, Alt or Ctrl. The default is false.
334 335 336 |
# File 'lib/tmux/window.rb', line 334 def xterm_keys @xterm_keys end |
Instance Method Details
#<=>(other) ⇒ Undefined
98 99 100 101 |
# File 'lib/tmux/window.rb', line 98 def <=>(other) return nil unless other.is_a?(Window) [@session, @number] <=> [other.session, other.number] end |
#==(other) ⇒ Boolean
104 105 106 |
# File 'lib/tmux/window.rb', line 104 def ==(other) self.class == other.class && @session == other.session && @number == other.number end |
#eql?(other) ⇒ Boolean
114 115 116 |
# File 'lib/tmux/window.rb', line 114 def eql?(other) self == other end |
#hash ⇒ Number
109 110 111 |
# File 'lib/tmux/window.rb', line 109 def hash [@session.hash, @number].hash end |
#kill
This method returns an undefined value.
Kills the window.
513 514 515 |
# File 'lib/tmux/window.rb', line 513 def kill server.invoke_command "kill-window -t #{identifier}" end |
#move(new_session, new_number)
This method returns an undefined value.
Moves the window to either a different session, a different position or both.
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/tmux/window.rb', line 86 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 |
#panes_information(search = {}) ⇒ Hash
Returns A hash with information for all panes.
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/tmux/window.rb', line 555 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)
This method returns an undefined value.
Pastes a buffer into the window.
608 609 610 |
# File 'lib/tmux/window.rb', line 608 def paste(buffer, pop = false, translate = true, separator = nil) buffer.paste(self, pop, translate, separator) end |
#respawn(command = nil, kill = false)
escape command
This method returns an undefined value.
Reactivates a window in which the command has exited.
688 689 690 691 692 693 694 695 |
# File 'lib/tmux/window.rb', line 688 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)
This method returns an undefined value.
Rotates the positions of the panes within a window.
521 522 523 524 525 526 527 528 529 530 531 |
# File 'lib/tmux/window.rb', line 521 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
This method returns an undefined value.
Select the window.
616 617 618 |
# File 'lib/tmux/window.rb', line 616 def select server.invoke_command "select-window -t #{identifier}" end |
#select_last_pane(return_if = :always) ⇒ Pane?
Select the previously selected pane.
673 674 675 676 |
# File 'lib/tmux/window.rb', line 673 def select_last_pane(return_if = :always) server.invoke_command("last-pane -t #{identifier}") current_pane(return_if) end |
#swap_with(window)
This method returns an undefined value.
Swap the window with another one.
625 626 627 |
# File 'lib/tmux/window.rb', line 625 def swap_with(window) server.invoke_command "swap-window -s #{identifier} -t #{window.identifier}" end |