-
Notifications
You must be signed in to change notification settings - Fork 23
Colorcoder now allows saving to custom directory locations #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
80fd218
5e8dab0
8762c7a
5d7b454
0887030
de66178
5e8dd43
c03e3ab
d60759c
bc1ab30
b8d0558
70c1cd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,13 +64,13 @@ def on_load(self,view): | |
| view.settings().set('colorcode',False) | ||
| return | ||
|
|
||
| if view.size() > set.get('max_size',10000) and not view.settings().get('forcecolorcode',False): | ||
| if view.size() > set.get('max_size',colorshemeemodifier.get_max_size()) and not view.settings().get('forcecolorcode',False): | ||
| sublime.status_message("File is too big, disabling colorcoding as it might hurt perfromance") | ||
| view.settings().set('colorcode',False) | ||
| return | ||
|
|
||
| vcc = view.settings().get('color_scheme') | ||
| if vcc and "Widget" in vcc: | ||
| if vcc and "Widget" in vcc: | ||
| view.settings().set('colorcode',False) | ||
| return | ||
|
|
||
|
|
@@ -126,15 +126,15 @@ def run(self): | |
| for i in map(hex,range(256)): | ||
| view.erase_regions('cc'+i) | ||
| else: | ||
| if view.size() > sublime.load_settings("colorcoder.sublime-settings").get('max_size',10000): | ||
| if view.size() > sublime.load_settings("colorcoder.sublime-settings").get('max_size',colorshemeemodifier.get_max_size()): | ||
| view.settings().set('forcecolorcode',True) | ||
| view.run_command("colorcoder") | ||
|
|
||
| def is_checked(self): | ||
| return sublime.active_window().active_view().settings().get('colorcode',False) | ||
|
|
||
| def description(self): | ||
| if sublime.active_window().active_view().size() > sublime.load_settings("colorcoder.sublime-settings").get('max_size',10000): | ||
| if sublime.active_window().active_view().size() > sublime.load_settings("colorcoder.sublime-settings").get('max_size',colorshemeemodifier.get_max_size()): | ||
| return "Colorcoding may hurt performance, File is large" | ||
| else: | ||
| return "Colorcode this view" | ||
|
|
@@ -152,6 +152,36 @@ def panel_callback(self, text): | |
| sublime.save_settings("colorcoder.sublime-settings") | ||
| colorshemeemodifier.modify_color_scheme(l,s,True) | ||
|
|
||
| @staticmethod | ||
| def get_max_size(): | ||
| return sublime.load_settings("colorcoder.sublime-settings").get('max_size') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as noted above this is not needed |
||
|
|
||
| @staticmethod | ||
| def get_save_dir(): | ||
| colorcoder_settings = sublime.load_settings("colorcoder.sublime-settings") | ||
| save_dir = colorcoder_settings.get('colorcoder_schemas_dir') | ||
| if save_dir: | ||
| if save_dir[0] != '/': | ||
| save_dir = '/' + save_dir | ||
| if save_dir[-1] != '/': | ||
| save_dir = save_dir + '/' | ||
| else: | ||
| save_dir = '' | ||
|
|
||
| colorcoder_settings.set('colorcoder_schemas_dir', save_dir) | ||
| sublime.save_settings("colorcoder.sublime-settings") | ||
|
|
||
| pp = sublime.packages_path() | ||
| save_dir = pp + save_dir | ||
| if not os.path.exists(save_dir): | ||
| os.makedirs(save_dir) | ||
| firstrunfile = save_dir + '/firstrun' | ||
| if not os.path.exists(firstrunfile): | ||
| colorshemeemodifier.maybefixscheme() | ||
| open(firstrunfile, 'a').close() | ||
|
|
||
| return save_dir | ||
|
|
||
| @staticmethod | ||
| def maybefixscheme(): | ||
| set = sublime.load_settings("colorcoder.sublime-settings") | ||
|
|
@@ -204,9 +234,9 @@ def modify_color_scheme(l,s,read_original = False): | |
| ) | ||
| )) | ||
|
|
||
| newname = "/Colorcoder/%s (Colorcoded).tmTheme" % re.search("/([^/]+).tmTheme$", name).group(1) | ||
| newname = "/%s (Colorcoded).tmTheme" % re.search("/([^/]+).tmTheme$", name).group(1) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the way you populate i guess it would be simpler just to do
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed it. It has a relative and full path now. Phew! You were completely right. I was missing something huge! |
||
|
|
||
| plistlib.writePlist(cs,"%s%s" % (sublime.packages_path(),newname)) | ||
| plistlib.writePlist(cs,"%s%s" % (colorshemeemodifier.get_save_dir(),newname)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is needed so colorcoder modifies the currently used theme when being installed revert this change please
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. So if I add
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, it needs to create the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole addition should be fixed now if you wanna give it another shot. |
||
|
|
||
| sublime.load_settings("Preferences.sublime-settings").set("original_color_scheme", name) | ||
| sublime.load_settings("Preferences.sublime-settings").set("color_scheme","Packages%s" % newname) | ||
|
|
@@ -227,16 +257,12 @@ def run(self): | |
|
|
||
| def plugin_loaded(): | ||
| sublime.load_settings("Preferences.sublime-settings").add_on_change('color_scheme',colorshemeemodifier.maybefixscheme) | ||
| sublime.load_settings("colorcoder.sublime-settings").add_on_change('scopes',colorcoder.update_scopes) | ||
| colorcoder_settings = sublime.load_settings("colorcoder.sublime-settings") | ||
| colorcoder_settings.add_on_change('scopes',colorcoder.update_scopes) | ||
| colorcoder_settings.add_on_change('colorcoder_schemas_dir',colorshemeemodifier.get_save_dir) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesnt make sense to call this line is useless and should be removed |
||
| colorcoder_settings.add_on_change('max_size',colorshemeemodifier.get_max_size) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as line above, also ,as noted above, |
||
|
|
||
| colorcoder.update_scopes() | ||
| pp = sublime.packages_path() | ||
| if not os.path.exists(pp+"/Colorcoder"): | ||
| os.makedirs(pp+"/Colorcoder") | ||
|
|
||
| firstrunfile = pp+"/Colorcoder/firstrun" | ||
| if not os.path.exists(firstrunfile): | ||
| colorshemeemodifier.maybefixscheme() | ||
| open(firstrunfile, 'a').close() | ||
|
|
||
| for wnd in sublime.windows(): | ||
| for view in wnd.views(): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sublime API states:
what you are doing here is essentially
which is redundant
please revert this and following changes of same manner