Class: Tmux::Buffer
- Inherits:
-
Object
- Object
- Tmux::Buffer
- Defined in:
- lib/tmux/buffer.rb
Instance Attribute Summary collapse
- #data(force_reload = false) ⇒ String
- #number ⇒ Number readonly
- #server ⇒ Server readonly
- #session ⇒ Session readonly
- #size(force_reload = false) ⇒ Filesize readonly
Instance Method Summary collapse
-
#delete
Deletes a buffer.
-
#freeze!
By default, Buffer will not cache its data but instead query it each time.
- #initialize(number, session) ⇒ Filesize constructor
- #paste(target = nil, pop = false, translate = true, separator = nil)
-
#save(file, append = false)
(also: #write)
Saves the contents of a buffer.
-
#to_s ⇒ String
The content of a buffer.
Constructor Details
#initialize(number, session) ⇒ Filesize
11 12 13 14 15 16 17 18 |
# 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 |
Instance Attribute Details
#data(force_reload = false) ⇒ String
34 35 36 |
# File 'lib/tmux/buffer.rb', line 34 def data @data end |
#number ⇒ Number (readonly)
7 8 9 |
# File 'lib/tmux/buffer.rb', line 7 def number @number end |
#size(force_reload = false) ⇒ Filesize (readonly)
22 23 24 |
# File 'lib/tmux/buffer.rb', line 22 def size @size end |
Instance Method Details
#delete
This method returns an undefined value.
Deletes a buffer.
91 92 93 94 |
# 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 |
#freeze!
This method returns an undefined value.
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.
74 75 76 77 78 |
# File 'lib/tmux/buffer.rb', line 74 def freeze! @frozen = true @data = data @size = size end |
#paste(target = nil, pop = false, translate = true, separator = nil)
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# 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 |
#save(file, append = false) Also known as: write
This method returns an undefined value.
Saves the contents of a buffer.
64 65 66 67 |
# 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 |
#to_s ⇒ String
Returns The content of a buffer.
97 98 99 |
# File 'lib/tmux/buffer.rb', line 97 def to_s text end |