-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
50 lines (37 loc) · 1.46 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# --- Clear module cache ---
# Clear module cache to force reloading all modules of this package.
# See https://github.com/emmetio/sublime-text-plugin/issues/35
import sys
prefix = __package__ + "." # don't clear the base package
for module_name in [
module_name
for module_name in sys.modules
if (module_name.startswith(prefix) and module_name != __name__)
or module_name == "projectionist"
]:
del sys.modules[module_name]
# --- Clear module cache ---
import sublime_plugin # noqa: E402
from .plugin import Plugin, api # noqa: E402
# Expose public API
sys.modules["projectionist"] = api
class ProjectionistOpenAlternateCommand(sublime_plugin.TextCommand):
def run(self, _, mode=None, reveal=None):
Plugin(self.view.window()).open_alternate(
self.view.file_name(),
mode=mode,
focus=(Plugin.FOCUS_SIDEBAR if reveal else None),
)
class ProjectionistOutputProjectionsCommand(sublime_plugin.TextCommand):
def run(self, _):
Plugin(self.view.window()).output_projections()
class ProjectionistClearCacheCommand(sublime_plugin.ApplicationCommand):
def run(self):
Plugin.clear_cache()
class ProjectionistSidebarOpenAlternateCommand(sublime_plugin.WindowCommand):
def run(self, files=[], reveal=False):
if not files:
return
Plugin(self.window).open_alternate(
files[0], focus=(Plugin.FOCUS_SIDEBAR if reveal else Plugin.FOCUS_VIEW)
)