* [sup-talk] [PATCH 1/4] Add method to shell out asynchronously
@ 2010-04-10 10:37 Ramkumar Ramachandra
2010-04-10 19:40 ` Anirudh Sanjeev
0 siblings, 1 reply; 5+ messages in thread
From: Ramkumar Ramachandra @ 2010-04-10 10:37 UTC (permalink / raw)
To: sup-talk
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH 1/4] Add method to shell out asynchronously
2010-04-10 10:37 [sup-talk] [PATCH 1/4] Add method to shell out asynchronously Ramkumar Ramachandra
@ 2010-04-10 19:40 ` Anirudh Sanjeev
2010-04-10 20:12 ` Ramkumar Ramachandra
0 siblings, 1 reply; 5+ messages in thread
From: Anirudh Sanjeev @ 2010-04-10 19:40 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: sup-talk
[-- Attachment #1.1: Type: text/plain, Size: 485 bytes --]
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.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 140 bytes --]
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH 1/4] Add method to shell out asynchronously
2010-04-10 19:40 ` Anirudh Sanjeev
@ 2010-04-10 20:12 ` Ramkumar Ramachandra
2010-04-10 20:21 ` Anirudh Sanjeev
0 siblings, 1 reply; 5+ messages in thread
From: Ramkumar Ramachandra @ 2010-04-10 20:12 UTC (permalink / raw)
To: Anirudh Sanjeev; +Cc: sup-talk
On Sun, Apr 11, 2010 at 1:10 AM, Anirudh Sanjeev
<anirudh@anirudhsanjeev.org> wrote:
> Perhaps adding a custom option in config.yaml to launch editor
> asynchronously might be a better option, and also suggest sensible
> defaults.
Did you even read the patch? That's what I've done. From PATCH 4/4:
+ editor_daemon = $config[:editor_daemon]
-- Ram
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH 1/4] Add method to shell out asynchronously
2010-04-10 20:12 ` Ramkumar Ramachandra
@ 2010-04-10 20:21 ` Anirudh Sanjeev
2010-04-11 2:50 ` Ramkumar Ramachandra
0 siblings, 1 reply; 5+ messages in thread
From: Anirudh Sanjeev @ 2010-04-10 20:21 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: sup-talk
Excerpts from Ramkumar Ramachandra's message of Sun Apr 11 01:42:59 +0530 2010:
> Did you even read the patch? That's what I've done. From PATCH 4/4:
> + 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
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH 1/4] Add method to shell out asynchronously
2010-04-10 20:21 ` Anirudh Sanjeev
@ 2010-04-11 2:50 ` Ramkumar Ramachandra
0 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2010-04-11 2:50 UTC (permalink / raw)
To: Anirudh Sanjeev; +Cc: sup-talk
> 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
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-04-11 2:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-10 10:37 [sup-talk] [PATCH 1/4] Add method to shell out asynchronously Ramkumar Ramachandra
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox