diff --git a/ide_plugins/sublime_text/CoatiCommunicator/CoatiCommunicator.py b/ide_plugins/sublime_text/CoatiCommunicator/CoatiCommunicator.py index 6484c8a3..c0481b78 100644 --- a/ide_plugins/sublime_text/CoatiCommunicator/CoatiCommunicator.py +++ b/ide_plugins/sublime_text/CoatiCommunicator/CoatiCommunicator.py @@ -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("") + data = self.request.recv(1024).strip() + text = data.decode('utf-8') + eom_index = text.find("") 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) + "" - print(message) settings = sublime.load_settings('CoatiCommunicator.sublime-settings') host_ip = settings.get('host_ip') diff --git a/ide_plugins/sublime_text/readme.txt b/ide_plugins/sublime_text/readme.txt index 0ec794ed..3a4ad976 100644 --- a/ide_plugins/sublime_text/readme.txt +++ b/ide_plugins/sublime_text/readme.txt @@ -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... \ No newline at end of file +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.