Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: sup-talk <sup-talk@rubyforge.org>
Subject: [sup-talk] [PATCH 1/4] Add method to shell out asynchronously
Date: Sat, 10 Apr 2010 16:07:21 +0530	[thread overview]
Message-ID: <1270895815-sup-99@kytes> (raw)

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

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 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
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


             reply	other threads:[~2010-04-10 10:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-10 10:37 Ramkumar Ramachandra [this message]
2010-04-10 19:40 ` Anirudh Sanjeev
2010-04-10 20:12   ` Ramkumar Ramachandra
2010-04-10 20:21     ` Anirudh Sanjeev
2010-04-11  2:50       ` Ramkumar Ramachandra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270895815-sup-99@kytes \
    --to=artagnon@gmail.com \
    --cc=sup-talk@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox