liango2 / conque

Automatically exported from code.google.com/p/conque
0 stars 0 forks source link

suggestion: close buffer when the program exits #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

your conque plugin is amazing! Thanks for making it available. If I was to 
suggest one useful feature, it would be to let buffers automatically close when 
the associated process terminates. That would make it super-fast to open up a 
shell in a split window, type a few commands, and then have it close after 
pressing Ctrl+D.

Thanks,
Wenzel

Original issue reported on code.google.com by waz...@gmail.com on 5 Oct 2010 at 3:32

GoogleCodeExporter commented 8 years ago
whoops, sorry -- it looks like this was marked as a defect, which it really 
isn't :)

Original comment by waz...@gmail.com on 5 Oct 2010 at 3:33

GoogleCodeExporter commented 8 years ago
Adding this as a configuration option sounds like a good idea, though it 
probably won't be the default mode.

Original comment by nicora...@gmail.com on 5 Oct 2010 at 5:11

GoogleCodeExporter commented 8 years ago
After fooling a bit with the source, I managed to add this feature as follows 
(arguably not the most elegant solution)

--- conque_1.1/autoload/conque_term.vim 2010-05-28 07:43:25.000000000 +0200
+++ conque_term.vim 2010-10-05 20:46:23.199629687 +0200
@@ -575,8 +575,11 @@

     # wrap CUF/CUB around line breaks
     wrap_cursor = False

+    # Set when the process is terminated
+    leave = False
+
     # }}}

     # constructor
     def __init__(self): # {{{
@@ -605,10 +608,8 @@
         # }}}

     # write to pty
     def write(self, input): # {{{
-
-
         # check if window size has changed
         self.update_window_size()

         # write and read
@@ -617,8 +618,13 @@
         # }}}

     # read from pty, and update buffer
     def read(self, timeout = 1): # {{{
+        if not self.proc.get_status():
+            self.leave = True
+            if vim.current.buffer.number == self.screen.buffer.number:
+                vim.command('bwipeout! ' + str(self.screen.buffer.number))
+                return
         # read from subprocess
         output = self.proc.read(timeout)
         # and strip null chars
         output = output.replace(chr(0), '')
@@ -715,8 +721,10 @@

     # for polling
     def auto_read(self): # {{{
         self.read(1)
+        if self.leave:
+            return
         if self.c == 1:
             vim.command('call feedkeys("\<F23>", "t")')
         else:
             vim.command('call feedkeys("\<F22>", "t")')

Original comment by waz...@gmail.com on 5 Oct 2010 at 6:47

GoogleCodeExporter commented 8 years ago
I added a slightly modified version of your code to the new 1.2 release.

Set...

let g:ConqueTerm_CloseOnEnd = 1

...in your .vimrc

Thanks.

Original comment by nicora...@gmail.com on 12 Oct 2010 at 1:27