attr_reader :text
register_keymap do |k|
k.add :save_to_disk, "Save to disk", 's'
+ k.add :pipe, "Pipe to process", '|'
end
def initialize text=""
save_to_file(fn) { |f| f.puts text } if fn
end
+ def pipe
+ command = BufferManager.ask(:shell, "pipe command: ")
+ return if command.nil? || command.empty?
+
+ output = pipe_to_process(command) do |stream|
+ @text.each { |l| stream.puts l }
+ end
+
+ if output
+ BufferManager.spawn "Output of '#{command}'", TextMode.new(output)
+ else
+ BufferManager.flash "'#{command}' done!"
+ end
+ end
+
def text= t
@text = t
update_lines