forked from SublimeLinter/SublimeLinter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_view.py
46 lines (33 loc) · 1.35 KB
/
message_view.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
import sublime
import sublime_plugin
PANEL_NAME = "SublimeLinter Messages"
OUTPUT_PANEL = "output." + PANEL_NAME
def plugin_unloaded():
for window in sublime.windows():
window.destroy_output_panel(PANEL_NAME)
class SublimeLinterDisplayPanelCommand(sublime_plugin.WindowCommand):
def run(self, msg=""):
window = self.window
if is_panel_active(window):
panel = window.find_output_panel(PANEL_NAME)
assert panel
else:
panel = window.create_output_panel(PANEL_NAME)
syntax_path = "Packages/SublimeLinter/panel/message_view.sublime-syntax"
try: # Try the resource first, in case we're in the middle of an upgrade
sublime.load_resource(syntax_path)
except Exception:
return
panel.assign_syntax(syntax_path)
scroll_to = panel.size()
msg = msg.rstrip() + '\n\n\n'
panel.set_read_only(False)
panel.run_command('append', {'characters': msg})
panel.set_read_only(True)
panel.show(scroll_to)
window.run_command("show_panel", {"panel": OUTPUT_PANEL})
class SublimeLinterRemovePanelCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.destroy_output_panel(PANEL_NAME)
def is_panel_active(window):
return window.active_panel() == OUTPUT_PANEL