forked from randy3k/Terminus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
148 lines (130 loc) · 4.09 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import sublime
import sys
import logging
# from PackageDev
# https://github.com/SublimeText/PackageDev/blob/35a68969f94459d38341ea373ab2e583e60d8cda/main.py
try:
from package_control import events
except ImportError:
pass
else:
if events.post_upgrade(__package__):
# clean up sys.modules to ensure all submodules are reloaded
prefix = __package__ + "." # don't clear the base package
modules_to_clear = {
module_name
for module_name in sys.modules
if module_name.startswith(prefix) and module_name != __name__
}
print("[{}] Cleaning up {} cached modules after update…"
.format(__package__, len(modules_to_clear)))
for module_name in modules_to_clear:
del sys.modules[module_name]
from .terminus.clipboard import TerminusClipboardHistoryUpdater
from .terminus.commands import (
TerminusActivateCommand,
TerminusCancelBuildCommand,
TerminusClearUndoStackCommand,
TerminusCloseAllCommand,
TerminusCloseCommand,
TerminusCopyCommand,
TerminusDeleteWordCommand,
TerminusExecCommand,
TerminusInitializeViewCommand,
TerminusKeypressCommand,
TerminusMaximizeCommand,
TerminusMinimizeCommand,
TerminusOpenCommand,
TerminusPasteCommand,
TerminusPasteFromHistoryCommand,
TerminusPasteTextCommand,
TerminusRenameTitleCommand,
TerminusResetCommand,
TerminusSendStringCommand,
ToggleTerminusPanelCommand
)
from .terminus.event_listeners import (
TerminusCoreEventListener
)
from .terminus.mouse import (
TerminusClickCommand,
TerminusMouseEventListener,
TerminusOpenContextUrlCommand,
TerminusOpenImageCommand
)
from .terminus.query import TerminusQueryContextListener
from .terminus.render import (
TerminusCleanupCommand,
TerminusRenderCommand,
TerminusShowCursorCommand
)
from .terminus.theme import (
TerminusGenerateThemeCommand,
TerminusSelectThemeCommand,
plugin_loaded as theme_plugin_loaded,
plugin_unloaded as theme_plugin_unloaded
)
from .terminus.utils import settings_on_change
from .terminus.view import (
TerminusInsertCommand,
TerminusNukeCommand,
TerminusTrimTrailingLinesCommand
)
__all__ = [
"TerminusActivateCommand",
"TerminusCancelBuildCommand",
"TerminusCleanupCommand",
"TerminusClearUndoStackCommand",
"TerminusClickCommand",
"TerminusClipboardHistoryUpdater",
"TerminusCloseAllCommand",
"TerminusCloseCommand",
"TerminusCopyCommand",
"TerminusCoreEventListener",
"TerminusDeleteWordCommand",
"TerminusExecCommand",
"TerminusGenerateThemeCommand",
"TerminusInitializeViewCommand",
"TerminusInsertCommand",
"TerminusKeypressCommand",
"TerminusMaximizeCommand",
"TerminusMinimizeCommand",
"TerminusMouseEventListener",
"TerminusNukeCommand",
"TerminusOpenCommand",
"TerminusOpenContextUrlCommand",
"TerminusOpenImageCommand",
"TerminusPasteCommand",
"TerminusPasteFromHistoryCommand",
"TerminusPasteTextCommand",
"TerminusQueryContextListener",
"TerminusRenameTitleCommand",
"TerminusRenderCommand",
"TerminusResetCommand",
"TerminusSelectThemeCommand",
"TerminusSendStringCommand",
"TerminusShowCursorCommand",
"TerminusTrimTrailingLinesCommand",
"ToggleTerminusPanelCommand"
]
logger = logging.getLogger('Terminus')
def plugin_loaded():
theme_plugin_loaded()
if not logger.hasHandlers():
ch = logging.StreamHandler(sys.stdout)
logger.addHandler(ch)
settings = sublime.load_settings("Terminus.sublime-settings")
def on_change(debug):
if debug:
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.WARNING)
on_change(settings.get("debug", False))
settings_on_change(settings, "debug")(on_change)
def plugin_unloaded():
# close all terminals
for w in sublime.windows():
w.run_command("terminus_close_all")
theme_plugin_unloaded()
settings = sublime.load_settings("Terminus.sublime-settings")
settings_on_change(settings, "debug", clear=True)