src: Sublime Text 3 compatibility.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import sublime
|
||||
import sublime_plugin
|
||||
import SocketServer
|
||||
import threading
|
||||
import socket
|
||||
import os.path
|
||||
|
||||
try: # use this for Sublime Text 2
|
||||
import SocketServer
|
||||
except ImportError: # use this for Sublime Text 3
|
||||
import socketserver as SocketServer
|
||||
|
||||
MESSAGE_SPLIT_STRING = ">>"
|
||||
|
||||
|
||||
@@ -15,14 +19,15 @@ def setCursorPosition(filePath, row, col):
|
||||
sublime.active_window().open_file(filePath + ":" + str(row) + ":" + str(col), sublime.ENCODED_POSITION)
|
||||
else:
|
||||
sublime.error_message("Coati is trying to jump to a file that does not exist: " + filePath)
|
||||
|
||||
|
||||
|
||||
class ConnectionHandler(SocketServer.BaseRequestHandler): # This class is instantiated once per connection to the server
|
||||
def handle(self):
|
||||
self.data = self.request.recv(1024).strip()
|
||||
eom_index = self.data.find("<EOM>")
|
||||
data = self.request.recv(1024).strip()
|
||||
text = data.decode('utf-8')
|
||||
eom_index = text.find("<EOM>")
|
||||
if (not eom_index == 0):
|
||||
message_string = self.data[0:eom_index]
|
||||
message_string = text[0:eom_index]
|
||||
message_fields = message_string.split(MESSAGE_SPLIT_STRING)
|
||||
if (message_fields[0] == "moveCursor"):
|
||||
sublime.set_timeout(lambda: setCursorPosition(message_fields[1], int(message_fields[2]), int(message_fields[3]) + 1), 0)
|
||||
@@ -67,7 +72,6 @@ class SetActiveTokenCommand(sublime_plugin.TextCommand):
|
||||
row += 1 # rows returned by rowcol() are 0-based.
|
||||
|
||||
message = "setActiveToken" + MESSAGE_SPLIT_STRING + filePath + MESSAGE_SPLIT_STRING + str(row) + MESSAGE_SPLIT_STRING + str(col) + "<EOM>"
|
||||
print(message)
|
||||
|
||||
settings = sublime.load_settings('CoatiCommunicator.sublime-settings')
|
||||
host_ip = settings.get('host_ip')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
how to install:
|
||||
How to Install:
|
||||
|
||||
Just copy and past this "CoatiCommunicator" folder into your Packages folder of Sublime Text.
|
||||
You can find that folder from within Sublime via the menu: Preferences -> Browse Packages...
|
||||
Just copy and past this "CoatiCommunicator" folder into your Packages folder of Sublime Text. (You can find
|
||||
that folder from within Sublime via the menu: Preferences -> Browse Packages...). Restart Sublime before
|
||||
starting to use the plugin.
|
||||
|
||||
Reference in New Issue
Block a user