def add_placeholders(self, text): _ix = [1000] def get_ix(m): _ix[0] += 1 return '${%s}' % _ix[0] return re.sub(zen.get_caret_placeholder(), get_ix, text)
def add_placeholders(self, text, selection=True, explicit_zero=False): _ix = [-1 if explicit_zero else 1000] def get_ix(m): _ix[0] += 1 return '${%s}' % _ix[0] # text = re.sub(r'\$', '\\$', text) text = re.sub(utils.get_caret_placeholder(), get_ix, text) if selection: text = re.sub(r'\$\{(%s)\}' % _ix[0], r'${\1:$SELECTION}', text) return text
def add_placeholders(self, text, selection=True, explicit_zero=False): _ix = [-1 if explicit_zero else 1000] def get_ix(m): _ix[0] += 1 return '$%s' % _ix[0] # text = re.sub(r'\$', '\\$', text) text = re.sub(utils.get_caret_placeholder(), get_ix, text) if selection: # The last placeholder will contain the selected text, if any text = re.sub('\$(%s)' % _ix[0], r'${\1:$SELECTION}', text) return text
def add_placeholders(self, text, selection=True, explicit_zero=False): _ix = [-1 if explicit_zero else 1000] def get_ix(m): _ix[0] += 1 return "$%s" % _ix[0] # text = re.sub(r'\$', '\\$', text) text = re.sub(utils.get_caret_placeholder(), get_ix, text) if selection: # The last placeholder will contain the selected text, if any text = re.sub("\$(%s)" % _ix[0], r"${\1:$SELECTION}", text) return text