コード例 #1
0
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)
コード例 #2
0
ファイル: comment.py プロジェクト: Rob-McCormack/Sublime-1
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)
コード例 #3
0
    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)
コード例 #4
0
    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()