class Tmux::Buffer
Attributes
@param [Boolean] force_reload Ignore frozen state if true @return [String]
@return [Number]
@return [Server]
@return [Session]
@param [Boolean] force_reload Ignore frozen state if true @return [Filesize]
Public Class Methods
@return [Filesize]
# File lib/tmux/buffer.rb, line 11 def initialize(number, session) @number, @session, @size = number, session unless server.version >= "1.3" # we do not need a temporary file for tmux versions that can # directly load/save from/to stdin/stdout @file = Tempfile.new("buffer") end end
Public Instance Methods
# File lib/tmux/buffer.rb, line 51 def data=(new_data) # FIXME maybe some more escaping? server.invoke_command "set-buffer -b #@number -t #{@session.identifier} \"#{new_data}\"" @data = data(true) if @frozen @size = size(true) end
Deletes a buffer.
@tmux delete-buffer @return [void]
# File lib/tmux/buffer.rb, line 91 def delete freeze! # so we can still access its old value server.invoke_command "delete-buffer -b #@number -t #{@session.identifier}" end
By default, Buffer
will not cache its data but instead query it each time. By calling this method, the data will be cached and not updated anymore.
@return [void]
# File lib/tmux/buffer.rb, line 74 def freeze! @frozen = true @data = data @size = size end
Pastes the content of a buffer into a {Window window} or {Pane pane}.
@param [Window] target The {Pane pane} or {Window window} to
paste the buffer into. Note: {Pane Panes} as as target are only supported since tmux version 1.3.
@param [Boolean] pop If true, delete the buffer from the stack @param [Boolean] translate If true, any linefeed (LF) characters
in the paste buffer are replaced with carriage returns (CR)
@param [String] separator Replace any linefeed (LF) in the
buffer with this separator. +translate+ must be false.
@tmux paste-buffer @tmuxver >=1.3 for pasting to {Pane panes} @return [void] @see Window#paste
@see Pane#paste
# File lib/tmux/buffer.rb, line 117 def paste(target = nil, pop = false, translate = true, separator = nil) if server.version < "1.3" if separator || target.is_a?(Pane) raise Exception::UnsupportedVersion, "1.3" end end flag_pop = pop ? "-d" : "" flag_translate = translate ? "" : "-r" flag_separator = separator ? "" : "-s \"#{separator}\"" # FIXME escape window_param = target ? "-t #{target.identifier}" : "" server.invoke_command "paste-buffer #{flag_pop} #{flag_translate} #{flag_separator} #{window_param}" end
Saves the contents of a buffer.
@param [String] file The file to write to @param [Boolean] append Append to instead of overwriting the file @tmux save-buffer @return [void]
# File lib/tmux/buffer.rb, line 64 def save(file, append = false) flag = append ? "-a" : "" server.invoke_command "save-buffer #{flag} -b #@number -t #{@session.identifier} #{file}" end
@return [String] The content of a buffer
# File lib/tmux/buffer.rb, line 97 def to_s text end