@@ -42,34 +42,24 @@ def crc(self, msg):
42
42
runningCRC = self .crcTable [runningCRC ^ c ]
43
43
return runningCRC
44
44
45
+ def plugin_loaded ():
46
+ sublime .load_settings ("Preferences.sublime-settings" ).add_on_change ('color_scheme' ,maybefixscheme )
47
+ pp = sublime .packages_path ()
48
+ if not os .path .exists (pp + "/Colorcoder" ):
49
+ os .makedirs (pp + "/Colorcoder" )
50
+
51
+ firstrunfile = pp + "/Colorcoder/firstrun"
52
+ if not os .path .exists (firstrunfile ):
53
+ maybefixscheme ()
54
+ open (firstrunfile , 'a' ).close ()
55
+
45
56
class colorcoder (sublime_plugin .EventListener ):
46
57
47
58
hasher = crc8 ();
48
59
49
60
def __init__ (self ):
50
- sublime .set_timeout (self .read_settings ,500 )
51
-
52
- def read_settings (self ):
53
- sublime .load_settings ("Preferences.sublime-settings" ).add_on_change ('color_scheme' ,self .maybefixscheme )
54
- pp = sublime .packages_path ()
55
- if not os .path .exists (pp + "/Colorcoder" ):
56
- os .makedirs (pp + "/Colorcoder" )
57
-
58
- firstrunfile = pp + "/Colorcoder/firstrun"
59
- if not os .path .exists (firstrunfile ):
60
- self .maybefixscheme ()
61
- open (firstrunfile , 'a' ).close ()
62
-
63
- self .on_modified (sublime .active_window ().active_view ())
64
-
65
- def maybefixscheme (self ):
66
- set = sublime .load_settings ("colorcoder.sublime-settings" )
67
- if set .get ('auto_apply_on_scheme_change' ):
68
- if sublime .load_settings ("Preferences.sublime-settings" ).get ('color_scheme' ).find ('/Colorcoder/' ) == - 1 :
69
- modify_color_scheme (set .get ('lightness' ),set .get ('saturation' ))
70
-
71
- def on_modified (self , view ):
72
- sublime .set_timeout (lambda : self .on_modified_async (view ), 0 )
61
+ sublime .set_timeout (plugin_loaded ,500 )
62
+ sublime .set_timeout (lambda : self .on_modified (sublime .active_window ().active_view ()),500 )
73
63
74
64
def on_load (self ,view ):
75
65
if view .file_name ():
@@ -90,6 +80,8 @@ def on_load(self,view):
90
80
91
81
self .on_modified (view )
92
82
83
+ def on_modified (self , view ):
84
+ sublime .set_timeout (lambda : self .on_modified_async (view ), 0 )
93
85
94
86
def on_modified_async (self , view ):
95
87
if not view .settings ().get ('colorcode' ,True ):
@@ -111,6 +103,10 @@ def on_text_command(self, win, cmd, args):
111
103
if cmd == "set_file_type" :
112
104
self .on_modified_async (sublime .active_window ().active_view ())
113
105
106
+ class colorcoderdisabler (sublime_plugin .ApplicationCommand ):
107
+ def run (self ):
108
+ sublime .active_window ().active_view ().settings ().set ('colorcode' ,False )
109
+
114
110
class colorshemeemodifier (sublime_plugin .ApplicationCommand ):
115
111
def run (self ):
116
112
sublime .active_
8000
window ().show_input_panel ("Lightness and Saturation" ,"%s %s" % (sublime .load_settings ("colorcoder.sublime-settings" ).get ('lightness' ),sublime .load_settings ("colorcoder.sublime-settings" ).get ('saturation' )),self .panel_callback ,None ,None )
@@ -123,16 +119,18 @@ def panel_callback(self, text):
123
119
sublime .save_settings ("colorcoder.sublime-settings" )
124
120
sublime .set_timeout (lambda : modify_color_scheme (l ,s ,True ), 0 )
125
121
126
-
127
-
128
122
class colorcoderInspectScope (sublime_plugin .ApplicationCommand ):
129
123
def run (self ):
130
124
view = sublime .active_window ().active_view ();
131
125
sel = view .sel ()[0 ]
132
126
print (view .scope_name (sel .a ))
133
127
sublime .active_window ().run_command ("show_panel" , {"panel" : "console" , "toggle" : True })
134
128
135
- modification_running = False
129
+ def maybefixscheme ():
130
+ set = sublime .load_settings ("colorcoder.sublime-settings" )
131
+ if set .get ('auto_apply_on_scheme_change' ):
132
+ if sublime .load_settings ("Preferences.sublime-settings" ).get ('color_scheme' ).find ('/Colorcoder/' ) == - 1 :
133
+ modify_color_scheme (set .get ('lightness' ),set .get ('saturation' ))
136
134
137
135
def modify_color_scheme (l ,s ,read_original = False ):
138
136
global modification_running
@@ -187,3 +185,5 @@ def modify_color_scheme(l,s,read_original = False):
187
185
sublime .save_settings ("Preferences.sublime-settings" )
188
186
189
187
modification_running = False
188
+
189
+ modification_running = False
0 commit comments