def _handle_input(self, expr, from_input_panel, handler="quicklojure_handlers.OutputToRepl", handler_args={}): repl_view = get_repl_view(self.window) expr = Template(expr).safe_substitute(from_input_panel=from_input_panel) port = int(repl_view.settings().get('nrepl_port')) client = nrepl.NreplClient('localhost', port) handler_class = resolve_attr(handler) handler_obj = handler_class(args=handler_args, window=self.window, repl_view=repl_view) thread.start_new_thread(client.eval, (expr, handler_obj))
def on_close(self, view): port = view.settings().get('nrepl_port') if port: # If there are any other views using that server, don't kill it. for w in sublime.windows(): for v in w.views(): if v.settings().get( 'nrepl_port') == port and v.id() != view.id(): return client = nrepl.NreplClient('localhost', port) thread.start_new_thread(client.kill_server, ())
def on_load(self, view): port = view.settings().get('nrepl_port') if port: # We're loading a REPL window that existed from a hot exit. Check # if nREPL is still running on that port. try: nrepl.NreplClient('localhost', port) print "nREPL on port %d is running" % port except: view.settings().set('nrepl_port', None) append_to_view(view, ("\n\n" + ";;;;;;;;;;;;;;;;\n" + "; DISCONNECTED ;\n" + ";;;;;;;;;;;;;;;;"))