Class: Editserver::Vim
Instance Method Summary
collapse
Methods inherited from Editor
define_editor, terminal, #terminal, terminal=
Instance Method Details
#edit(file) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/editserver/terminal/vim.rb', line 16
def edit file
if terminal.nil?
File.open(file, 'w') { |f| f.write 'No terminal defined!' }
else
start_server unless server_available?
sleep 0.1 until server_available?
super
end
end
|
#server_available? ⇒ Boolean
7
8
9
|
# File 'lib/editserver/terminal/vim.rb', line 7
def server_available?
%x(vim --serverlist).split("\n").map { |l| l.strip.upcase }.include? 'EDITSERVER'
end
|
#start_server ⇒ Object
11
12
13
14
|
# File 'lib/editserver/terminal/vim.rb', line 11
def start_server
pid = fork { exec *(terminal + %w[-e vim --servername EDITSERVER]) }
Process.detach pid
end
|