diff --git a/autofilename.py b/autofilename.py index 8e284aa..952687f 100644 --- a/autofilename.py +++ b/autofilename.py @@ -5,7 +5,7 @@ from .getimageinfo import getImageInfo class AfnShowFilenames(sublime_plugin.TextCommand): def run(self, edit): - FileNameComplete.is_active = True + FileNameComplete.is_active = True self.view.run_command('auto_complete', {'disable_auto_insert': True, 'next_completion_if_showing': False}) @@ -51,6 +51,7 @@ class InsertDimensionsCommand(sublime_plugin.TextCommand): def insert_dimension(self,edit,dim,name,tag_scope): view = self.view sel = view.sel()[0].a + if name in view.substr(tag_scope): reg = view.find('(?<='+name+'\=)\s*\"\d{1,5}', tag_scope.a) view.replace(edit, reg, '"'+str(dim)) @@ -64,13 +65,37 @@ class InsertDimensionsCommand(sublime_plugin.TextCommand): else: return sublime.load_settings('autofilename.sublime-settings').get(string) + + def insert_dimensions(self, edit, scope, w, h): + view = self.view + + if self.get_setting('afn_insert_width_first',view): + self.insert_dimension(edit,h,'height', scope) + self.insert_dimension(edit,w,'width', scope) + else: + self.insert_dimension(edit,w,'width', scope) + self.insert_dimension(edit,h,'height', scope) + + + # determines if there is a template tag in a given region. supports HTML and template languages. + def img_tag_in_region(self, region): + view = self.view + + # handle template languages but template languages like slim may also contain HTML so + # we do a check for that as well + return view.substr(region).strip().startswith('img') | ('