Sha256: 4fd9517bb9cc95e64d2131f5868157937ad0155a8ea024d918abb865cea4c64e
Contents?: true
Size: 1.41 KB
Versions: 6
Compression:
Stored size: 1.41 KB
Contents
require "drb" module Textbringer module Commands define_command(:server_start, doc: "Start Textbringer server.") do uri = CONFIG[:server_uri] || "drbunix:" + File.expand_path("server.sock", "~/.textbringer") options = CONFIG[:server_options] || { UNIXFileMode: 0600 } DRb.start_service(uri, Server.new, options) end define_command(:server_kill, doc: "Kill Textbringer server.") do DRb.stop_service end define_command(:server_edit_done, doc: "Finish server edit.") do queue = Buffer.current[:client_wait_queue] if queue.nil? raise EditorError, "No waiting clients" end if Buffer.current.modified? && y_or_n?("Save file #{Buffer.current.file_name}?") save_buffer end kill_buffer(Buffer.current, force: true) queue.push(:done) end end class Server def eval(s) with_redisplay do Controller.current.instance_eval(s).inspect end end def visit_file(filename, wait: true) queue = Queue.new if wait with_redisplay do find_file(filename) Buffer.current[:client_wait_queue] = queue if wait end queue.deq if wait end private def with_redisplay foreground! do begin yield ensure Window.redisplay end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems