def run(self, edit): view = self.view point = view.sel()[0].b # Current lines, used to detemine whether is input, include, cite, or includegraphics line = view.substr(get_Region(view.line(point).a, point))[::-1] # if \cite or \ref if (OLD_STYLE_CITE_REGEX.match(line) or NEW_STYLE_CITE_REGEX.match(line) or OLD_STYLE_REF_REGEX.match(line) or NEW_STYLE_REF_REGEX.match(line)): view.run_command('latex_ref_cite') # if \input, \include or \includegraphics if TEX_INPUT_FILE_REGEX.match(line): prefix, suffix, nc_current_word = get_current_word(view, point) current_word = prefix + suffix if current_word != '': startpoint = point - len(prefix) endpoint = point + len(suffix) view.run_command('latex_tools_replace', { 'a': startpoint, 'b': endpoint, 'replacement': '' }) view.run_command('latex_fill_input') else: view.run_command("latex_fill_input") if BEGIN_END_BEFORE_REGEX.match(line): view.run_command("latex_fill_env")
def run(self, edit): view = self.view point = view.sel()[0].b # Current lines, used to detemine whether is input, include, cite, or includegraphics line = view.substr(get_Region(view.line(point).a, point))[::-1] # if \cite or \ref if (OLD_STYLE_CITE_REGEX.match(line) or NEW_STYLE_CITE_REGEX.match(line) or OLD_STYLE_REF_REGEX.match(line) or NEW_STYLE_REF_REGEX.match(line)): view.run_command('latex_ref_cite') # if \begin or \end elif BEGIN_END_BEFORE_REGEX.match(line): view.run_command("latex_fill_env") # input completions else: _, dyn_regex = _get_dyn_entries() if ( TEX_INPUT_FILE_REGEX.match(line) or (dyn_regex and dyn_regex.match(line)) ): prefix, suffix, nc_current_word = get_current_word(view, point) current_word = prefix + suffix if current_word != '': startpoint = point - len(prefix) endpoint = point + len(suffix) view.run_command( 'latex_tools_replace', {'a': startpoint, 'b': endpoint, 'replacement': ''} ) view.run_command('latex_fill_input') else: view.run_command("latex_fill_input")
def run(self, edit): view = self.view point = view.sel()[0].b # Current lines, used to detemine whether is input, include, cite, or includegraphics line = view.substr(get_Region(view.line(point).a, point))[::-1] # if \cite or \ref if ( OLD_STYLE_CITE_REGEX.match(line) or NEW_STYLE_CITE_REGEX.match(line) or OLD_STYLE_REF_REGEX.match(line) or NEW_STYLE_REF_REGEX.match(line) ): view.run_command("latex_ref_cite") # if \input, \include or \includegraphics if TEX_INPUT_FILE_REGEX.match(line): prefix, suffix, nc_current_word = get_current_word(view, point) current_word = prefix + suffix if current_word != "": startpoint = point - len(prefix) endpoint = point + len(suffix) view.run_command("latex_tools_replace", {"a": startpoint, "b": endpoint, "replacement": ""}) view.run_command("latex_fill_input") else: view.run_command("latex_fill_input") if BEGIN_END_BEFORE_REGEX.match(line): view.run_command("latex_fill_env")
def matches_line(self, line): return bool( BEGIN_END_BEFORE_REGEX.match(line) )