mirror of
https://github.com/hexedtech/codemp-sublime.git
synced 2025-03-26 03:31:32 +01:00
feat: adds small utility to check if a view is a codemp buffer
This commit is contained in:
parent
7cd471eb4f
commit
40073be509
3 changed files with 17 additions and 11 deletions
|
@ -13,12 +13,12 @@
|
|||
"default": "[\n\t$0\n]\n"
|
||||
}
|
||||
},
|
||||
{ "caption": "Codemp: Open Readme",
|
||||
"command": "open_file",
|
||||
"args": {
|
||||
"file": "${packages}/CodempClient/README.md"
|
||||
}
|
||||
},
|
||||
// { "caption": "Codemp: Open Readme",
|
||||
// "command": "open_file",
|
||||
// "args": {
|
||||
// "file": "${packages}/CodempClient/README.md"
|
||||
// }
|
||||
// },
|
||||
{
|
||||
"caption": "Codemp: Browse Server",
|
||||
"command": "codemp_browse_server",
|
||||
|
@ -27,9 +27,7 @@
|
|||
{
|
||||
"caption": "Codemp: Browse Workspace",
|
||||
"command": "codemp_browse_workspace",
|
||||
"args": {
|
||||
|
||||
}
|
||||
"args": {}
|
||||
},
|
||||
{
|
||||
// # on_window_command, does not trigger when called from the command palette
|
||||
|
|
7
main.py
7
main.py
|
@ -51,7 +51,7 @@ def kill_all():
|
|||
session.stop()
|
||||
|
||||
def vbuff_form_view(view):
|
||||
if not view.settings().get(g.CODEMP_VIEW_TAG, False):
|
||||
if not is_codemp_buffer(view):
|
||||
raise ValueError("The view is not a Codemp Buffer.")
|
||||
|
||||
buffid = str(view.settings().get(g.CODEMP_BUFFER_ID))
|
||||
|
@ -103,8 +103,11 @@ class CodempReplaceTextCommand(sublime_plugin.TextCommand):
|
|||
|
||||
|
||||
class CodempSyncBuffer(sublime_plugin.TextCommand):
|
||||
def is_enabled(self) -> bool:
|
||||
return is_codemp_buffer(self.view)
|
||||
|
||||
def run(self, edit):
|
||||
buff = buffers.lookupId(str(self.view.settings().get(g.CODEMP_BUFFER_ID)))
|
||||
buff = vbuff_form_view(self.view)
|
||||
buff.sync(TEXT_LISTENER)
|
||||
|
||||
|
||||
|
|
|
@ -99,6 +99,11 @@ def view_from_local_path(path):
|
|||
if view.file_name() == path:
|
||||
return view
|
||||
|
||||
def is_codemp_buffer(view):
|
||||
if view.settings().get(g.CODEMP_VIEW_TAG, False):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def draw_cursor_region(view, start, end, user):
|
||||
reg = rowcol_to_region(view, start, end)
|
||||
|
|
Loading…
Add table
Reference in a new issue