def add_comments(node, i): """ Add comments to tag @type node: ZenNode @type i: int """ id_attr = node.get_attribute('id') class_attr = node.get_attribute('class') nl = utils.get_newline() if id_attr or class_attr: comment_str = '' padding = node.parent and node.parent.padding or '' if id_attr: comment_str += '#' + id_attr if class_attr: comment_str += '.' + class_attr node.start = node.start.replace( '<', '<!-- ' + comment_str + ' -->' + nl + padding + '<', 1) node.end = node.end.replace( '>', '>' + nl + padding + '<!-- /' + comment_str + ' -->', 1) # replace counters counter = zencoding.utils.get_counter_for_node(node) node.start = utils.replace_counter(node.start, counter) node.end = utils.replace_counter(node.end, counter)
def add_comments(node, i): """ Add comments to tag @type node: ZenNode @type i: int """ id_attr = node.get_attribute('id') class_attr = node.get_attribute('class') nl = utils.get_newline() if id_attr or class_attr: comment_str = '' padding = node.parent and node.parent.padding or '' if id_attr: comment_str += '#' + id_attr if class_attr: comment_str += '.' + class_attr #node.start = node.start.replace('<', '<!-- ' + comment_str + ' -->' + nl + padding + '<', 1) #node.end = node.end.replace('>', '>' + nl + padding + '<!-- /' + comment_str + ' -->', 1) node.end = node.end.replace('>', '><!-- ' + comment_str + ' -->', 1) # replace counters counter = zencoding.utils.get_counter_for_node(node) #node.start = utils.replace_counter(node.start, counter) node.end = utils.replace_counter(node.end, counter)
def __init__(self, context=None): self._content = '' "Editor's content" self.apple_script = os.path.join(os.getenv('TM_BUNDLE_SUPPORT'), 'pasteboard.scpt') zen.set_newline(os.getenv('TM_LINE_ENDING', zen.get_newline())) self.set_context(context)
def set_caret_pos(self, pos): """ Set new caret position @type pos: int """ # figure out line and column vars head = zen.split_by_lines(self.get_content()[0:pos]) line = max(len(head), 1) column = pos - len(zen.get_newline().join(head[0:-1])) subprocess.Popen( ['open', 'txmt://open/?line=%d&column=%d' % (line, column)]).communicate()