From d9aad433dff55af342d17e70d26c7eb54169643b Mon Sep 17 00:00:00 2001 From: William Morgan Date: Sat, 22 Dec 2007 10:10:03 -0800 Subject: [PATCH] add #pipe-to-process to text-mode --- lib/sup/modes/text-mode.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/sup/modes/text-mode.rb b/lib/sup/modes/text-mode.rb index aa53a84..22214d9 100644 --- a/lib/sup/modes/text-mode.rb +++ b/lib/sup/modes/text-mode.rb @@ -4,6 +4,7 @@ class TextMode < ScrollMode 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="" @@ -18,6 +19,21 @@ class TextMode < ScrollMode 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 -- 2.45.2