예제 #1
0
    def expand_abbr(self, abbr, syntax=None, selection=True):

        syntax = syntax or self.get_syntax()
        profile_name = self.get_profile_name()
        content = expand_abbreviation(abbr, syntax, profile_name)

        return self.add_placeholders(content, selection=selection).decode("utf8", "ignore")
예제 #2
0
    def expand_abbr(self, abbr, syntax = None, selection=True,
                                               super_profile=None):

        syntax       = syntax or self.get_syntax()
        profile_name = self.get_profile_name()

        if super_profile: profile_name += '.%s' % super_profile
        content      = expand_abbreviation(abbr, syntax, profile_name)

        return ( self.add_placeholders(content, selection=selection) )
예제 #3
0
    def expand_abbr(self, abbr, syntax = None, selection=True, 
                                               super_profile=None):

        syntax       = syntax or self.get_syntax()
        profile_name = self.get_profile_name()

        if super_profile: profile_name += '.%s' % super_profile
        
        content      = expand_abbreviation(abbr, syntax, profile_name)

        return ( self.add_placeholders(content, selection=selection)
                     .decode('utf8', 'ignore') )
In order to make "Expand Abbreviation" more natural to
TextMate's bundle system we have to forget about predefined Zen Coding actions
and write our own
"""

cur_line = os.getenv('TM_CURRENT_LINE', '')
cur_index = int(os.getenv('TM_LINE_INDEX', 0))
line = cur_line[0:cur_index]

abbr = os.getenv('TM_SELECTED_TEXT', '')
if not abbr:
    abbr = zencoding.utils.extract_abbreviation(line)

output = zencoding.utils.escape_text(
    line) + '$0' + zencoding.utils.escape_text(cur_line[cur_index:])

if abbr:
    try:
        result = line[0:-len(abbr)] + zencoding.expand_abbreviation(
            abbr, editor.get_syntax(), editor.get_profile_name())
        cur_line_pad = re.match(r'^(\s+)', cur_line)
        if cur_line_pad:
            result = zencoding.utils.pad_string(result, cur_line_pad.group(1))

        output = editor.add_placeholders(result) + zencoding.utils.escape_text(
            cur_line[cur_index:])
    except:
        pass

sys.stdout.write(output)
"""
In order to make "Expand Abbreviation" more natural to
TextMate's bundle system we have to forget about predefined Zen Coding actions
and write our own
"""

cur_line = os.getenv('TM_CURRENT_LINE', '')
cur_index = int(os.getenv('TM_LINE_INDEX', 0))
line = cur_line[0:cur_index]

abbr = os.getenv('TM_SELECTED_TEXT', '')
if not abbr:
	abbr = zencoding.utils.extract_abbreviation(line)


output = zencoding.utils.escape_text(line) + '$0' + zencoding.utils.escape_text(cur_line[cur_index:])

if abbr:
	try:
		result = line[0:-len(abbr)] + zencoding.expand_abbreviation(abbr, editor.get_syntax(), editor.get_profile_name())
		cur_line_pad = re.match(r'^(\s+)', cur_line)
		if cur_line_pad:
			result = zencoding.utils.pad_string(result, cur_line_pad.group(1))
		
		output = editor.add_placeholders(result) + zencoding.utils.escape_text(cur_line[cur_index:])
	except:
		pass
	
sys.stdout.write(output)