コード例 #1
0
ファイル: create_layout.py プロジェクト: 7sun/ERBAutocomplete
 def run(self, edit):
     core = Core()
     path = self.view.file_name();
     self.project_dir = core.get_project_path(path)
     if self.project_dir is not None:
         self.view.window().show_input_panel('Enter layout filename.', '_custom_layout.html.erb', self.on_done, None, None)
     else:
         sublime.active_window().new_file()
コード例 #2
0
    def run(self, edit):
        # new core
        core = Core()
        
        # find target
        lines = core.get_lines_text(self.view)

        if self.isMark(lines):
            self.unmark(edit, lines)
        else:
            self.mark(edit, lines)
コード例 #3
0
 def on_load(self, view):
     filename = view.file_name()
     if not filename:
         return
     core = Core()
     name = os.path.basename(filename.lower())
     if name[-8:] == "html.erb" or name[-3:] == "erb":
         try:
             view.settings().set("syntax", core.get_grammar_path())
             print("Switched syntax to: ERB")
         except:
             pass
コード例 #4
0
 def run(self, edit):
     core = Core()
     project_dir = self.view.file_name()
     partial_dir = core.get_partial_path(project_dir)
     self.partial_asset = os.path.relpath(partial_dir, os.path.dirname(project_dir))
     self.partial_list = []
     for name in os.listdir(partial_dir):
         if core.is_erb_layout_file(name) is False:
             continue
         if os.path.isfile(os.path.join(partial_dir, name)):
             self.partial_list.append([name, os.path.join(partial_dir, name)])
     sublime.active_window().show_quick_panel(self.partial_list, self.on_mapping)
コード例 #5
0
ファイル: unmapping.py プロジェクト: 7sun/ERBAutocomplete
    def run(self, *args, **kwargs):
        core = Core()
        path = self.window.active_view().file_name();

        if core.is_erb_file(path) is False:
            sublime.error_message('File is not ERB file.')
            return

        mapping_layout_file = path[:-3] + 'layout'
        if os.path.isfile(mapping_layout_file):
            os.remove(mapping_layout_file)
        else:
            sublime.error_message('We don\'t found your layout mapping file.')
コード例 #6
0
 def run(self, *args, **kwargs):
     core = Core()
     self.layout_list = []
     path = self.window.active_view().file_name()
     if core.is_erb_file(path) is False:
         sublime.error_message("File is not ERB file.")
         return
     self.project_dir = core.get_project_path(path)
     self.view_dir = os.path.dirname(path)
     if self.project_dir is not None:
         for name in os.listdir(self.project_dir):
             if core.is_erb_layout_file(name) is False:
                 continue
             if os.path.isfile(os.path.join(self.project_dir, name)):
                 self.layout_list.append([name, os.path.join(self.project_dir, name)])
         sublime.active_window().show_quick_panel(self.layout_list, self.on_mapping)
     else:
         sublime.error_message("We don't find your project folder. Please check your '.base' file.")
コード例 #7
0
ファイル: unmark.py プロジェクト: 7sun/ERBAutocomplete
    def run(self, edit):
        # new core
        core = Core()
        target = '<%#'
        lines = core.get_lines_text(self.view)
        reg = re.search('<%#', lines)
        if(reg == None): return
        idx = reg.start()

        # get current select line
        sel = self.view.sel()
        region = sel[0]
        sel_line = self.view.line(region)
        start = sel_line.a + idx
        end = start + len(target)

        replace_region = sublime.Region(start, end)
        self.view.replace(edit, replace_region, '<%')
コード例 #8
0
    def on_query_completions(self, view, prefix, locations):
        core = Core()
        self.completions = []
        specialkey = False
        scope = core.words.get("scope")
        temp = core.get_line_text(view)
        lineText = temp[-1]

        specialkey = True if lineText.find("<") >= 0 else False

        if scope and view.match_selector(locations[0], scope):
            self.completions += core.words.get("completions")
            self.completions += core.get_custom_tag()
        if not self.completions:
            return []

        completions = list(self.completions)
        if specialkey:
            for idx, item in enumerate(self.completions):
                self.completions[idx][1] = item[1][1:]

        completions = [tuple(attr) for attr in self.completions]
        return completions