Subject: [sup-talk] [PATCH 1/4] Add method to shell out asynchronously

From: Ramkumar Ramachandra <[email-masked]>
Date: Sat, 10 Apr 2010 16:07:21 +0530

Add shell_out_async method to fork and detach the editor, and register
the monitoring thread in PollManager.

Signed-off-by: Ramkumar Ramachandra <[email-masked]>
---
 lib/sup/buffer.rb |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index 5772bb0..25a2025 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -768,6 +768,26 @@ EOS
     @shelled = false
   end
 
+  def shell_out_async editor, file
+    @shelled = true
+    command = "#{editor} #{file.path}"
+    mtime = File.mtime file.path
+
+    Ncurses.sync do
+      pid = Process.fork
+      if pid.nil?
+        exec(command)
+      else
+        pthread = Process.detach(pid)
+        PollManager.editor_loop_init pthread, file, mtime
+      end
+      Ncurses.stdscr.keypad 1
+      Ncurses.refresh
+      Ncurses.curs_set 0
+    end
+    @shelled = false
+  end
+
 private
 
   def default_status_bar buf
-- 
1.7.0.4
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Anirudh Sanjeev <[email-masked]>
Date: Sun, 11 Apr 2010 01:10:08 +0530

Some people (me for instance) use an editor in-shell. Even the default
command that sup sets is "vim". Trying to launch an editor asynchronously
in this manner might not work.

Perhaps adding a custom option in config.yaml to launch editor
asynchronously might be a better option, and also suggest sensible
defaults.

Thanks,
Anirudh
-- 
Senior Undergraduate Student, Indian Institute of Technology, Kharagpur
http://anirudhsanjeev.org

The Unix philosophy - Do one thing. Do it well.
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Ramkumar Ramachandra <[email-masked]>
Date: Sun, 11 Apr 2010 01:42:59 +0530

> asynchronously might be a better option, and also suggest sensible

Did you even read the patch? That's what I've done. From PATCH 4/4:
+    editor_daemon = $config[:editor_daemon]

-- Ram

---

From: Anirudh Sanjeev <[email-masked]>
Date: Sun, 11 Apr 2010 01:51:10 +0530

> +    editor_daemon = $config[:editor_daemon]

Oh, I guess it does. I should've gone through it in better detail. My bad.

Btw, I applied the patch and it seems to work great!
-- 
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Ramkumar Ramachandra <[email-masked]>
Date: Sun, 11 Apr 2010 08:20:14 +0530

> Btw, I applied the patch and it seems to work great!

Thanks. Rendering is horribly broken though, and I have no experience
whatsoever with Ncurses- can someone help me out there?

-- Ram