From: William Morgan Date: Sat, 22 Dec 2007 18:10:03 +0000 (-0800) Subject: add #pipe-to-process to text-mode X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=d9aad433dff55af342d17e70d26c7eb54169643b;p=sup add #pipe-to-process to text-mode --- 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