2024-08-07 00:17:31 +02:00
|
|
|
# pyright: reportIncompatibleMethodOverride=false
|
2023-08-17 18:39:47 +02:00
|
|
|
import sublime
|
|
|
|
import sublime_plugin
|
2024-08-09 19:20:58 +02:00
|
|
|
import logging
|
2023-08-17 18:39:47 +02:00
|
|
|
|
2024-09-07 14:24:51 +02:00
|
|
|
from .src.utils import safe_listener_detach
|
2024-09-17 16:23:19 +02:00
|
|
|
from listeners import TEXT_LISTENER
|
|
|
|
|
|
|
|
from client_commands import CodempConnectCommand
|
|
|
|
from client_commands import CodempDisconnectCommand
|
|
|
|
from client_commands import CodempCreateWorkspaceCommand
|
|
|
|
from client_commands import CodempDeleteWorkspaceCommand
|
|
|
|
from client_commands import CodempJoinWorkspaceCommand
|
|
|
|
from client_commands import CodempLeaveWorkspaceCommand
|
|
|
|
from client_commands import CodempInviteToWorkspaceCommand
|
|
|
|
|
|
|
|
from workspace_commands import CodempCreateBufferCommand
|
|
|
|
from workspace_commands import CodempDeleteBufferCommand
|
|
|
|
from workspace_commands import CodempJoinBufferCommand
|
|
|
|
from workspace_commands import CodempLeaveBufferCommand
|
2024-08-09 09:17:38 +02:00
|
|
|
|
2024-08-09 19:20:58 +02:00
|
|
|
LOG_LEVEL = logging.DEBUG
|
|
|
|
handler = logging.StreamHandler()
|
|
|
|
handler.setFormatter(
|
|
|
|
logging.Formatter(
|
2024-09-02 11:39:01 +02:00
|
|
|
fmt="<{thread}/{threadName}> {levelname} [{name} :: {funcName}] {message}",
|
2024-08-09 19:20:58 +02:00
|
|
|
style="{",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
package_logger = logging.getLogger(__package__)
|
|
|
|
package_logger.addHandler(handler)
|
|
|
|
package_logger.setLevel(LOG_LEVEL)
|
|
|
|
package_logger.propagate = False
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2024-02-21 23:59:49 +01:00
|
|
|
# Initialisation and Deinitialisation
|
2023-11-23 14:36:33 +01:00
|
|
|
##############################################################################
|
|
|
|
def plugin_loaded():
|
2024-08-09 19:20:58 +02:00
|
|
|
logger.debug("plugin loaded")
|
2024-02-21 23:59:49 +01:00
|
|
|
|
|
|
|
|
2024-08-21 21:35:57 +02:00
|
|
|
def plugin_unloaded():
|
|
|
|
logger.debug("unloading")
|
2024-09-17 16:23:19 +02:00
|
|
|
safe_listener_detach(TEXT_LISTENER)
|
2024-08-09 19:20:58 +02:00
|
|
|
package_logger.removeHandler(handler)
|
2024-08-23 20:59:06 +02:00
|
|
|
# client.disconnect()
|
2024-08-25 20:27:29 +02:00
|
|
|
|
|
|
|
|
2024-02-24 16:56:22 +01:00
|
|
|
# Text Change Command
|
|
|
|
#############################################################################
|
|
|
|
class CodempReplaceTextCommand(sublime_plugin.TextCommand):
|
|
|
|
def run(self, edit, start, end, content, change_id):
|
|
|
|
# we modify the region to account for any change that happened in the mean time
|
|
|
|
region = self.view.transform_region_from(sublime.Region(start, end), change_id)
|
|
|
|
self.view.replace(edit, region, content)
|
|
|
|
|
|
|
|
|
|
|
|
# Proxy Commands ( NOT USED, left just in case we need it again. )
|
2023-09-05 16:07:22 +02:00
|
|
|
#############################################################################
|
|
|
|
# class ProxyCodempShareCommand(sublime_plugin.WindowCommand):
|
2024-02-21 23:59:49 +01:00
|
|
|
# # on_window_command, does not trigger when called from the command palette
|
|
|
|
# # See: https://github.com/sublimehq/sublime_text/issues/2234
|
|
|
|
# def run(self, **kwargs):
|
|
|
|
# self.window.run_command("codemp_share", kwargs)
|
2023-09-05 16:07:22 +02:00
|
|
|
#
|
2024-02-21 23:59:49 +01:00
|
|
|
# def input(self, args):
|
|
|
|
# if 'sublime_buffer' not in args:
|
|
|
|
# return SublimeBufferPathInputHandler()
|
2023-09-05 16:07:22 +02:00
|
|
|
#
|
2024-02-21 23:59:49 +01:00
|
|
|
# def input_description(self):
|
|
|
|
# return 'Share Buffer:'
|