sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit d9aad433dff55af342d17e70d26c7eb54169643b
parent e5fed61def6b358044cf1b64382361568c684bf6
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Sat, 22 Dec 2007 10:10:03 -0800

add #pipe-to-process to text-mode

Diffstat:
M lib/sup/modes/text-mode.rb | 16 ++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git 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