mirror of
https://github.com/hexedtech/codemp-sublime.git
synced 2024-10-23 02:19:18 +02:00
705c5e014e
the client doesn't hold the task manager anymore, instead it is now a singleton that all objects dump their tasks into to be managed. This allows to better separate the responsibilities of the various virtual-objects. The client now is also a module-singleton which allows us to remove that ugly global variable. fixup: uses relative imports instead that absolute ones with Codemp in front. rename of codemp_client.py into just client.py Former-commit-id: 4a0cc20e82f9631931ba2f61379a61c461b1f291
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
import sublime
|
|
import sublime_plugin
|
|
|
|
|
|
def status_log(msg, popup=False):
|
|
sublime.status_message("[codemp] {}".format(msg))
|
|
print("[codemp] {}".format(msg))
|
|
if popup:
|
|
sublime.error_message(msg)
|
|
|
|
|
|
def rowcol_to_region(view, start, end):
|
|
a = view.text_point(start[0], start[1])
|
|
b = view.text_point(end[0], end[1])
|
|
return sublime.Region(a, b)
|
|
|
|
|
|
def safe_listener_detach(txt_listener: sublime_plugin.TextChangeListener):
|
|
if txt_listener is not None and txt_listener.is_attached():
|
|
txt_listener.detach()
|
|
|
|
|
|
def safe_listener_attach(txt_listener: sublime_plugin.TextChangeListener, buffer):
|
|
if txt_listener is not None and not txt_listener.is_attached():
|
|
txt_listener.attach(buffer)
|
|
|
|
|
|
def get_contents(view):
|
|
r = sublime.Region(0, view.size())
|
|
return view.substr(r)
|
|
|
|
|
|
def populate_view(view, content):
|
|
view.run_command(
|
|
"codemp_replace_text",
|
|
{
|
|
"start": 0,
|
|
"end": view.size(),
|
|
"content": content,
|
|
"change_id": view.change_id(),
|
|
},
|
|
)
|
|
|
|
|
|
def get_view_from_local_path(path):
|
|
for window in sublime.windows():
|
|
for view in window.views():
|
|
if view.file_name() == path:
|
|
return view
|