vim-pad

minimal etherpad alternative - vim plugin
git clone https://git.ce9e.org/vim-pad.git

commit
47b60d28bbb90aebebe7f97bf6ced773b81fe090
parent
38f9b1e2fbc37773343b7e2c6fa692445887c74b
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-05-29 14:21
stop job on close

Diffstat

M python/pad/__init__.py 13 ++++++++-----

1 files changed, 8 insertions, 5 deletions


diff --git a/python/pad/__init__.py b/python/pad/__init__.py

@@ -27,11 +27,12 @@ class Pad:
   27    27 	def get_text(self):
   28    28 		return '\n'.join(self.buffer[:])
   29    29 
   30    -1 	def start_listen(self):  # TODO
   31    -1 		vim.command(f'call job_start(["curl", "-N", "{self.url}"], {{"out_cb": "pad#on_channel"}})')
   -1    30 	def start_listen(self):
   -1    31 		# FIXME jobs for different pads collide
   -1    32 		vim.command(f'let g:pad_curl = job_start(["curl", "-N", "{self.url}"], {{"out_cb": "pad#on_channel"}})')
   32    33 
   33    34 	def stop_listen(self):
   34    -1 		pass  # TODO
   -1    35 		vim.command('call job_stop(g:pad_curl)')
   35    36 
   36    37 	def on_input(self):
   37    38 		text = self.get_text()
@@ -110,8 +111,10 @@ def on_write():
  110   111 
  111   112 
  112   113 def on_close():
  113    -1 	pad = pads[vim.current.buffer]
  114    -1 	pad.stop_listen.stop_listen()
   -1   114 	i = int(vim.eval('expand("<abuf>")'), 10)
   -1   115 	buffer = vim.buffers[i]
   -1   116 	pad = pads.pop(buffer)
   -1   117 	pad.stop_listen()
  115   118 
  116   119 
  117   120 def on_channel(msg):