-
Notifications
You must be signed in to change notification settings - Fork 366
/
reveal_folders.py
100 lines (83 loc) · 3.02 KB
/
reveal_folders.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
import os
import sublime
import sublime_plugin
from .latextools_utils.settings import get_setting
from .latextools_utils.tex_directives import get_tex_root
from .latextools_utils.output_directory import (
get_output_directory, get_aux_directory
)
class LatextoolsRevealAuxDirectoryCommand(sublime_plugin.WindowCommand):
"""
Reveal the aux directory of the current document in the default
file browser.
"""
def is_visible(self, *args):
view = self.window.active_view()
if not view.score_selector(0, "text.tex.latex"):
return False
return bool(get_setting("aux_directory"))
def run(self):
window = self.window
view = window.active_view()
folder_path = get_aux_directory(view)
if not folder_path:
message = "'aux directory' not found"
print(message)
sublime.error_message(message)
return
if not os.path.exists(folder_path):
message = (
"'aux directory' does not exist: '{}'"
.format(folder_path)
)
print(message)
sublime.error_message(message)
return
print("open folder '{}'".format(folder_path))
window.run_command("open_dir", {"dir": folder_path})
class LatextoolsRevealOutputDirectoryCommand(sublime_plugin.WindowCommand):
"""
Reveal the output directory of the current document in the default
file browser.
"""
def is_visible(self, *args):
view = self.window.active_view()
if not view.score_selector(0, "text.tex.latex"):
return False
return bool(get_setting("output_directory"))
def run(self):
window = self.window
view = window.active_view()
folder_path = get_output_directory(view)
if not folder_path:
message = "'output directory' not found"
print(message)
sublime.error_message(message)
return
if not os.path.exists(folder_path):
message = (
"'output directory' does not exist: '{}'"
.format(folder_path)
)
print(message)
sublime.error_message(message)
return
print("open folder '{}'".format(folder_path))
window.run_command("open_dir", {"dir": folder_path})
class LatextoolsRevealTexRootDirectoryCommand(sublime_plugin.WindowCommand):
"""
Reveal the tex root directory of the current document in the default
file browser.
"""
def is_visible(self, *args):
view = self.window.active_view()
return bool(view.score_selector(0, "text.tex.latex"))
def run(self):
window = self.window
view = window.active_view()
tex_root = get_tex_root(view)
if not tex_root:
return
folder_path, file_path = os.path.split(tex_root)
print("open folder '{}', file: {}".format(folder_path, file_path))
window.run_command("open_dir", {"dir": folder_path, "file": file_path})