def launch(self, text_before, visual_content, parent, start, end = None): indent = self._INDENT.match(text_before).group(0) lines = (self._v + "\n").splitlines() ind_util = IndentUtil() # Replace leading tabs in the snippet definition via proper indenting v = [] for line_num, line in enumerate(lines): if "t" in self._opts: tabs = 0 else: tabs = len(self._TABS.match(line).group(0)) line_ind = ind_util.ntabs_to_proper_indent(tabs) if line_num != 0: line_ind = indent + line_ind v.append(line_ind + line[tabs:]) v = os.linesep.join(v) if parent is None: return SnippetInstance(StartMarker(start), indent, v, None, None, visual_content = visual_content, last_re = self._last_re, globals = self._globals) else: return SnippetInstance(parent, indent, v, start, end, visual_content, last_re = self._last_re, globals = self._globals)
def __init__(self, trigger, value, descr, options, globals): self._t = as_unicode(trigger) self._v = as_unicode(value) self._d = as_unicode(descr) self._opts = options self._matched = "" self._last_re = None self._globals = globals self._util = IndentUtil()
def __init__(self, initial_indent, cur=""): self._ind = IndentUtil() self._initial_indent = self._ind.indent_to_spaces(initial_indent) self._reset(cur)