-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtoggle.py
106 lines (75 loc) · 2.98 KB
/
toggle.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
import sublime
import sublime_plugin
HAVE_GET_LOG_STATE = int(sublime.version()) >= 4099
class ToggleLogBuiltSystemsCommand(sublime_plugin.ApplicationCommand):
def __init__(self):
self.flag = False
def run(self):
if HAVE_GET_LOG_STATE:
self.flag = not sublime.get_log_build_systems()
else:
self.flag = not self.flag
sublime.log_build_systems(self.flag)
sublime.status_message('log_build_systems -> %s' % str(self.flag))
class ToggleLogCommandsCommand(sublime_plugin.ApplicationCommand):
def __init__(self):
self.flag = False
def run(self):
if HAVE_GET_LOG_STATE:
self.flag = not sublime.get_log_commands()
else:
self.flag = not self.flag
sublime.log_commands(self.flag)
sublime.status_message('log_commands -> %s' % str(self.flag))
class ToggleLogControlTreeCommand(sublime_plugin.ApplicationCommand):
def __init__(self):
self.flag = False
def is_enabled(self):
return hasattr(sublime, 'log_control_tree')
def run(self):
if HAVE_GET_LOG_STATE:
self.flag = not sublime.get_log_control_tree()
else:
self.flag = not self.flag
sublime.log_control_tree(self.flag)
sublime.status_message('log_control_tree -> %s' % str(self.flag))
class ToggleLogInputCommand(sublime_plugin.ApplicationCommand):
def __init__(self):
self.flag = False
def run(self):
if HAVE_GET_LOG_STATE:
self.flag = not sublime.get_log_input()
else:
self.flag = not self.flag
sublime.log_input(self.flag)
sublime.status_message('log_input -> %s' % str(self.flag))
class ToggleLogIndexingCommand(sublime_plugin.ApplicationCommand):
def __init__(self):
self.flag = False
def run(self):
if HAVE_GET_LOG_STATE:
self.flag = not sublime.get_log_indexing()
else:
self.flag = not self.flag
sublime.log_indexing(self.flag)
sublime.status_message('log_indexing -> %s' % str(self.flag))
class ToggleLogResultRegexCommand(sublime_plugin.ApplicationCommand):
def __init__(self):
self.flag = False
def run(self):
if HAVE_GET_LOG_STATE:
self.flag = not sublime.get_log_result_regex()
else:
self.flag = not self.flag
sublime.log_result_regex(self.flag)
sublime.status_message('log_result_regex -> %s' % str(self.flag))
class TogglePreferenceCommand(sublime_plugin.ApplicationCommand):
def run(self, setting, persist=True):
pref = sublime.load_settings("Preferences.sublime-settings")
pref.set(setting, not pref.get(setting, False))
if persist:
sublime.save_settings("Preferences.sublime-settings")
class ToggleDrawDebug(sublime_plugin.TextCommand):
def run(self, edit):
settings = self.view.settings()
settings.set("draw_debug", not settings.get("draw_debug", False))