Ejemplo n.º 1
0
 def activate(self, window):
     actions = [
       ('ZenCodingMenuAction',     None, '_Zen Coding',                  None,            "Zen Coding tools",                            None),
       ('ZenCodingExpandAction',   None, '_Expand abbreviation',         '<Shift><Alt>E',        "Expand abbreviation to raw HTML/CSS",         self.expand_abbreviation),
       ('ZenCodingExpandWAction',  None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E',   "Dynamically expand abbreviation as you type",           self.expand_with_abbreviation),
       ('ZenCodingWrapAction',     None, '_Wrap with abbreviation...',   '<Shift><Alt>W', "Wrap with code expanded from abbreviation",   self.wrap_with_abbreviation),
       ('ZenCodingInwardAction',   None, 'Balance tag _inward',          '<Ctrl><Alt>I',   "Select inner tag's content",                  self.match_pair_inward),
       ('ZenCodingOutwardAction',  None, 'Balance tag _outward',         '<Ctrl><Alt>O',   "Select outer tag's content",                  self.match_pair_outward),
       ('ZenCodingMergeAction',    None, '_Merge lines',                 '<Ctrl><Alt>M',   "Merge all lines of the current selection",    self.merge_lines),
       ('ZenCodingPrevAction',     None, '_Previous edit point',         '<Alt>Left',      "Place the cursor at the previous edit point", self.prev_edit_point),
       ('ZenCodingNextAction',     None, '_Next edit point',             '<Alt>Right',     "Place the cursor at the next edit point",     self.next_edit_point),
       ('ZenCodingRemoveAction',   None, '_Remove tag',                  '<Ctrl><Alt>R',   "Remove a tag",                                self.remove_tag),
       ('ZenCodingSplitAction',    None, 'Split or _join tag',           '<Ctrl><Alt>J',   "Toggle between single and double tag",        self.split_join_tag),
       ('ZenCodingCommentAction',  None, 'Toggle _comment',              '<Ctrl><Alt>C',   "Toggle an XML or HTML comment",               self.toggle_comment)
     ]
     windowdata = dict()
     window.set_data("ZenCodingPluginDataKey", windowdata)
     windowdata["action_group"] = gtk.ActionGroup("GeditZenCodingPluginActions")
     windowdata["action_group"].add_actions(actions, window)
     manager = window.get_ui_manager()
     manager.insert_action_group(windowdata["action_group"], -1)
     windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
     window.set_data("ZenCodingPluginInfo", windowdata)
     self.editor = ZenEditor()
     error = self.editor.get_user_settings_error()
     if error:
         md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
             gtk.BUTTONS_CLOSE, "There is an error in user settings:")
         message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
         md.set_title("Zen Coding error")
         md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset']))
         md.run()
         md.destroy()
def act(context):
	editor = ZenEditor(context)
	image = find_image(editor)
	
	if image:
		size = get_image_size(editor, image['tag'])
		if size:
			new_tag = replace_or_append(image['tag'], 'width', size['width'])
			new_tag = replace_or_append(new_tag, 'height', size['height'])
			
			editor.replace_content(new_tag, image['start'], image['end'])
			return True
		
	return False
Ejemplo n.º 3
0
 def __init_attributes(self, editor):
     self.__editor = editor
     from zen_editor import ZenEditor
     self.__zeditor = ZenEditor(self, editor)
     from os.path import join
     self.__gui = editor.get_gui_object(globals(), join("GUI", "GUI.glade"))
     return
Ejemplo n.º 4
0
 def activate(self, window):
     actions = [
       ('ZenCodingMenuAction',     None, '_Zen Coding',                  None,            "Zen Coding tools",                            None),
       ('ZenCodingExpandAction',   None, '_Expand abbreviation',         '<Ctrl>E',        "Expand abbreviation to raw HTML/CSS",         self.expand_abbreviation),
       ('ZenCodingExpandWAction',  None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E',   "Dynamically expand abbreviation as you type",           self.expand_with_abbreviation),
       ('ZenCodingWrapAction',     None, '_Wrap with abbreviation...',   '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation",   self.wrap_with_abbreviation),
       ('ZenCodingInwardAction',   None, 'Balance tag _inward',          '<Ctrl><Alt>I',   "Select inner tag's content",                  self.match_pair_inward),
       ('ZenCodingOutwardAction',  None, 'Balance tag _outward',         '<Ctrl><Alt>O',   "Select outer tag's content",                  self.match_pair_outward),
       ('ZenCodingMergeAction',    None, '_Merge lines',                 '<Ctrl><Alt>M',   "Merge all lines of the current selection",    self.merge_lines),
       ('ZenCodingPrevAction',     None, '_Previous edit point',         '<Alt>Left',      "Place the cursor at the previous edit point", self.prev_edit_point),
       ('ZenCodingNextAction',     None, '_Next edit point',             '<Alt>Right',     "Place the cursor at the next edit point",     self.next_edit_point),
       ('ZenCodingRemoveAction',   None, '_Remove tag',                  '<Ctrl><Alt>R',   "Remove a tag",                                self.remove_tag),
       ('ZenCodingSplitAction',    None, 'Split or _join tag',           '<Ctrl><Alt>J',   "Toggle between single and double tag",        self.split_join_tag),
       ('ZenCodingCommentAction',  None, 'Toggle _comment',              '<Ctrl><Alt>C',   "Toggle an XML or HTML comment",               self.toggle_comment)
     ]
     windowdata = dict()
     window.set_data("ZenCodingPluginDataKey", windowdata)
     windowdata["action_group"] = gtk.ActionGroup("GeditZenCodingPluginActions")
     windowdata["action_group"].add_actions(actions, window)
     manager = window.get_ui_manager()
     manager.insert_action_group(windowdata["action_group"], -1)
     windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
     window.set_data("ZenCodingPluginInfo", windowdata)
     self.editor = ZenEditor()
     error = self.editor.get_user_settings_error()
     if error:
         md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
             gtk.BUTTONS_CLOSE, "There is an error in user settings:")
         message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
         md.set_title("Zen Coding error")
         md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset']))
         md.run()
         md.destroy()
Ejemplo n.º 5
0
 def wrap(self, context, abbr):
     # Set up the config variables
     if abbr:
         editor = ZenEditor(context)
         return zencoding.run_action('wrap_with_abbreviation', editor, abbr)
     else:
         return False
Ejemplo n.º 6
0
def act(controller, bundle, options):
    context = tea.get_context(controller)
    action_name = tea.get_option(options, 'action', '')
    editor = ZenEditor(context, bundle)

    try:
        return zencoding.run_action(action_name, editor)
    except zencoding.utils.ZenError:
        tea.say(context, 'Error while performing Zen Coding action',
                sys.exc_info()[1].value)
    except:
        msg_writer = SimpleWriter()
        msg = traceback.print_exc(file=msg_writer)
        tea.say(context, 'Runtime error', msg_writer.get())
Ejemplo n.º 7
0
	def __init__(self, window):

		# window
		self.window = window

		# menu items
		actions = [
			('ZenCodingMenuAction',		None, '_Zen Coding',					None,				"Zen Coding tools",								None),
			('ZenCodingExpandAction',	None, '_Expand abbreviation',			'<Ctrl>E',			"Expand abbreviation to raw HTML/CSS",			self.expand_abbreviation),
			('ZenCodingExpandWAction',	None, 'E_xpand with abbreviation...',	'<Ctrl><Alt>E',		"Type in an abbreviation to expand",			self.expand_with_abbreviation),
			('ZenCodingWrapAction',		None, '_Wrap with abbreviation...',		'<Ctrl><Shift>E',	"Wrap with code expanded from abbreviation",	self.wrap_with_abbreviation),
			('ZenCodingZenifyAction',	None, '_Zenify',						None,				"Reduce to abbreviation",						None),
			('ZenCodingZenify0Action',	None, '_Tag names',						'<Ctrl><Alt>Z',		"Reduce to tag names only",						self.zenify0),
			('ZenCodingZenify1Action',	None, '  + _Ids and classes',			None,				"Reduce with ids and classes",					self.zenify1),
			('ZenCodingZenify2Action',	None, '    + All other _attributes',	None,				"Reduce with all attributes",					self.zenify2),
			('ZenCodingZenify3Action',	None, '      + _Values',				None,				"Reduce with all attributes and values",		self.zenify3),
			('LoremIpsumAction',		None, '_Lorem ipsum...',				'<Ctrl><Alt>X',		"Insert a lorem ipsum string",					self.lorem_ipsum),
			('ZenCodingInwardAction',	None, 'Select _inward',					'<Ctrl><Alt>I',		"Select inner tag's content",					self.match_pair_inward),
			('ZenCodingOutwardAction',	None, 'Select _outward',				'<Ctrl><Alt>O',		"Select outer tag's content",					self.match_pair_outward),
			('ZenCodingPTagAction',		None, 'Previous tag',					'<Ctrl><Alt>Up',	"Select the previous tag in HTML code",			self.prev_tag),
			('ZenCodingNTagAction',		None, 'Next tag',						'<Ctrl><Alt>Down',	"Select the next tag in HTML code",				self.next_tag),
			('ZenCodingPNodeAction',	None, 'Previous node',					'<Ctrl><Alt>Left',	"Select the previous HTML node",				self.prev_node),
			('ZenCodingNNodeAction',	None, 'Next node',						'<Ctrl><Alt>Right',	"Select the next HTML node",					self.next_node),
			('ZenCodingPrevAction',		None, '_Previous edit point',			'<Alt>Left',		"Place the cursor at the previous edit point",	self.prev_edit_point),
			('ZenCodingNextAction',		None, '_Next edit point',				'<Alt>Right',		"Place the cursor at the next edit point",		self.next_edit_point),
			('ZenCodingSizeAction',		None, 'Update image _size',				'<Ctrl><Alt>S',		"Update image size tag from file",				self.update_image_size),
			('ZenCodingDataAction',		None, 'Toggle image url/da_ta',			'<Ctrl><Alt>A',		"Toggle between image url and data",			self.encode_decode_base64),
			('ZenCodingMergeAction',	None, '_Merge lines',					'<Ctrl><Alt>M',		"Merge all lines of the current selection",		self.merge_lines),
			('ZenCodingRemoveAction',	None, '_Remove tag',					'<Ctrl><Alt>R',		"Remove a tag",									self.remove_tag),
			('ZenCodingSplitAction',	None, 'Split or _join tag',				'<Ctrl><Alt>J',		"Toggle between single and double tag",			self.split_join_tag),
			('ZenCodingCommentAction',	None, 'Toggle _comment',				'<Ctrl><Alt>C',		"Toggle an XML or HTML comment",				self.toggle_comment),
			('ZenCodingSettingsAction',	None, 'E_dit settings...',				None,				"Customize snippets and abbreviations",			self.edit_settings)
		]
		windowdata = dict()
		self.window.set_data("ZenCodingPluginDataKey", windowdata)
		windowdata["action_group"] = gtk.ActionGroup("GeditZenCodingPluginActions")
		windowdata["action_group"].add_actions(actions)
		manager = self.window.get_ui_manager()
		manager.insert_action_group(windowdata["action_group"], -1)
		windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
		self.window.set_data("ZenCodingPluginInfo", windowdata)

		# zen coding
		self.modified = None
		self.editor = ZenEditor(self.window)
Ejemplo n.º 8
0
def act(context, actionObject, action_name, undo_name=None):
    zen_editor = ZenEditor(context, actionObject)

    try:
        if action_name == 'wrap_with_abbreviation':
            abbr = actionObject.userInput().stringValue()
            if abbr:
                return zencoding.run_action(action_name, zen_editor, abbr)
        else:
            return zencoding.run_action(action_name, zen_editor)
    except zencoding.utils.ZenError:
        tea.say(context, 'Error while performing Zen Coding action',
                sys.exc_info()[1].value)
    except:
        msg_writer = SimpleWriter()
        msg = traceback.print_exc(file=msg_writer, limit=5)
        tea.say(context, 'Runtime error', msg_writer.get())

    return False
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import re
import zencoding
import zencoding.utils
from zen_editor import ZenEditor

editor = ZenEditor()
"""
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(
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import re
from zencoding import zen_core
from zen_editor import ZenEditor

editor = ZenEditor()
"""
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
"""

abbr = os.getenv('TM_SELECTED_TEXT', '')
if abbr:
    result = zen_core.expand_abbreviation(abbr, editor.get_syntax(),
                                          editor.get_profile_name())
    if result:
        sys.stdout.write(editor.add_placeholders(result))
else:
    cur_line = os.getenv('TM_CURRENT_LINE', '')
    cur_index = int(os.getenv('TM_LINE_INDEX', 0))
    line = cur_line[0:cur_index]
    abbr = zen_core.extract_abbreviation(line)

    if abbr:
        result = line[0:-len(abbr)] + zen_core.expand_abbreviation(
            abbr, editor.get_syntax(), editor.get_profile_name())
Ejemplo n.º 11
0
 def activate(self, window):
     actions = [
         ("ZenCodingMenuAction", None, "_Zen Coding", None, "Zen Coding tools", None),
         (
             "ZenCodingExpandAction",
             None,
             "_Expand abbreviation",
             "<Ctrl>E",
             "Expand abbreviation to raw HTML/CSS",
             self.expand_abbreviation,
         ),
         (
             "ZenCodingExpandWAction",
             None,
             "E_xpand with abbreviation...",
             "<Ctrl><Alt>E",
             "Type in an abbreviation to expand",
             self.expand_with_abbreviation,
         ),
         (
             "ZenCodingWrapAction",
             None,
             "_Wrap with abbreviation...",
             "<Ctrl><Shift>E",
             "Wrap with code expanded from abbreviation",
             self.wrap_with_abbreviation,
         ),
         (
             "ZenCodingInwardAction",
             None,
             "Balance tag _inward",
             "<Ctrl><Alt>I",
             "Select inner tag's content",
             self.match_pair_inward,
         ),
         (
             "ZenCodingOutwardAction",
             None,
             "Balance tag _outward",
             "<Ctrl><Alt>O",
             "Select outer tag's content",
             self.match_pair_outward,
         ),
         (
             "ZenCodingMergeAction",
             None,
             "_Merge lines",
             "<Ctrl><Alt>M",
             "Merge all lines of the current selection",
             self.merge_lines,
         ),
         (
             "ZenCodingPrevAction",
             None,
             "_Previous edit point",
             "<Alt>Left",
             "Place the cursor at the previous edit point",
             self.prev_edit_point,
         ),
         (
             "ZenCodingNextAction",
             None,
             "_Next edit point",
             "<Alt>Right",
             "Place the cursor at the next edit point",
             self.next_edit_point,
         ),
         (
             "ZenCodingSizeAction",
             None,
             "Update image _size",
             "<Ctrl><Alt>S",
             "Update image size tag from file",
             self.update_image_size,
         ),
         ("ZenCodingRemoveAction", None, "_Remove tag", "<Ctrl><Alt>R", "Remove a tag", self.remove_tag),
         (
             "ZenCodingSplitAction",
             None,
             "Split or _join tag",
             "<Ctrl><Alt>J",
             "Toggle between single and double tag",
             self.split_join_tag,
         ),
         (
             "ZenCodingCommentAction",
             None,
             "Toggle _comment",
             "<Ctrl><Alt>C",
             "Toggle an XML or HTML comment",
             self.toggle_comment,
         ),
         (
             "ZenCodingSettingsAction",
             None,
             "E_dit settings...",
             None,
             "Customize snippets and abbreviations",
             self.edit_settings,
         ),
     ]
     windowdata = dict()
     window.set_data("ZenCodingPluginDataKey", windowdata)
     windowdata["action_group"] = gtk.ActionGroup("GeditZenCodingPluginActions")
     windowdata["action_group"].add_actions(actions, window)
     manager = window.get_ui_manager()
     manager.insert_action_group(windowdata["action_group"], -1)
     windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
     window.set_data("ZenCodingPluginInfo", windowdata)
     self.editor = ZenEditor()
     error = self.editor.get_user_settings_error()
     if error:
         md = gtk.MessageDialog(
             window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "There is an error in user settings:"
         )
         message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
         md.set_title("Zen Coding error")
         md.format_secondary_text(message.format(error["msg"], error["lineno"], error["offset"]))
         md.run()
         md.destroy()
Ejemplo n.º 12
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import re
import zencoding
import zencoding.utils
from zen_editor import ZenEditor

editor = ZenEditor()

"""
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:
Ejemplo n.º 13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from zencoding import zen_core as zen_coding
from zen_editor import ZenEditor

editor = ZenEditor()
zen_coding.run_action('next_edit_point', editor)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from zencoding import zen_core as zen_coding
from zen_editor import ZenEditor

editor = ZenEditor()
abbr = editor.prompt('Enter abbreviation')
if abbr is not None:
	zen_coding.run_action('wrap_with_abbreviation', editor, abbr)
def get_absolute_uri(img_path):
	file_uri = os.getenv('TM_FILEPATH', None)
	if not file_uri: return None
	
	if img_path[0] == '/':
		img_path = img_path[1:]
	
	while True:
		head, tail = os.path.split(file_uri)
		if not head or head == '/': break # reached the top
			
		abs_image_path = os.path.join(head, img_path)
		abs_image_path = os.path.normpath(abs_image_path)
		if os.path.exists(abs_image_path):
			return os.path.join(abs_image_path)
		
		if head == file_uri: break # infinite loop protection
		file_uri = head
		
	return None

editor = ZenEditor()
image = find_image(editor)
if image:
	size = get_image_size(image['tag'])
	if size:
		new_tag = replace_or_append(image['tag'], 'width', size['width'])
		new_tag = replace_or_append(new_tag, 'height', size['height'])
		
		editor.replace_content(new_tag, image['start'], image['end'])
Ejemplo n.º 16
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from zen_editor import ZenEditor

editor = ZenEditor()
editor.run_applescript() 
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import re
from zencoding import zen_core
from zen_editor import ZenEditor

editor = ZenEditor()

"""
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
"""

abbr = os.getenv('TM_SELECTED_TEXT', '')
if abbr:
	result = zen_core.expand_abbreviation(abbr, editor.get_syntax(), editor.get_profile_name())
	if result:
		sys.stdout.write(editor.add_placeholders(result))
else:
	cur_line = os.getenv('TM_CURRENT_LINE', '')
	cur_index = int(os.getenv('TM_LINE_INDEX', 0))
	line = cur_line[0:cur_index]
	abbr = zen_core.extract_abbreviation(line)

	if abbr:
		result = line[0:-len(abbr)] + zen_core.expand_abbreviation(abbr, editor.get_syntax(), editor.get_profile_name())
		cur_line_pad = re.match(r'^(\s+)', cur_line)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import re
from zencoding import zen_core
from zen_editor import ZenEditor

editor = ZenEditor()

"""
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
"""

abbr = os.getenv('TM_SELECTED_TEXT', '')
if abbr:
	result = zen_core.expand_abbreviation(abbr, editor.get_syntax(), editor.get_profile_name())
	if result:
		sys.stdout.write(result)
else:
	cur_line = os.getenv('TM_CURRENT_LINE', '')
	cur_index = int(os.getenv('TM_LINE_INDEX', 0))
	abbr, start_index = zen_core.find_abbr_in_line(cur_line, cur_index)

	if abbr:
		result = cur_line[0:start_index] + zen_core.expand_abbreviation(abbr, editor.get_syntax(), editor.get_profile_name())
		cur_line_pad = re.match(r'^(\s+)', cur_line)
		if cur_line_pad:
Ejemplo n.º 19
0
    def __init__(self, window):

        # window
        self.window = window

        # menu items
        actions = [
            ('ZenCodingMenuAction', None, '_Zen Coding', None,
             "Zen Coding tools", None),
            ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E',
             "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation),
            ('ZenCodingExpandWAction', None, 'E_xpand with abbreviation...',
             '<Ctrl><Alt>E', "Type in an abbreviation to expand",
             self.expand_with_abbreviation),
            ('ZenCodingWrapAction', None, '_Wrap with abbreviation...',
             '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation",
             self.wrap_with_abbreviation),
            ('ZenCodingZenifyAction', None, '_Zenify', None,
             "Reduce to abbreviation", None),
            ('ZenCodingZenify0Action', None, '_Tag names', '<Ctrl><Alt>Z',
             "Reduce to tag names only", self.zenify0),
            ('ZenCodingZenify1Action', None, '  + _Ids and classes', None,
             "Reduce with ids and classes", self.zenify1),
            ('ZenCodingZenify2Action', None, '    + All other _attributes',
             None, "Reduce with all attributes", self.zenify2),
            ('ZenCodingZenify3Action', None, '      + _Values', None,
             "Reduce with all attributes and values", self.zenify3),
            ('LoremIpsumAction', None, '_Lorem ipsum...', '<Ctrl><Alt>X',
             "Insert a lorem ipsum string", self.lorem_ipsum),
            ('ZenCodingInwardAction', None, 'Select _inward', '<Ctrl><Alt>I',
             "Select inner tag's content", self.match_pair_inward),
            ('ZenCodingOutwardAction', None, 'Select _outward', '<Ctrl><Alt>O',
             "Select outer tag's content", self.match_pair_outward),
            ('ZenCodingPTagAction', None, 'Previous tag', '<Ctrl><Alt>Up',
             "Select the previous tag in HTML code", self.prev_tag),
            ('ZenCodingNTagAction', None, 'Next tag', '<Ctrl><Alt>Down',
             "Select the next tag in HTML code", self.next_tag),
            ('ZenCodingPNodeAction', None, 'Previous node', '<Ctrl><Alt>Left',
             "Select the previous HTML node", self.prev_node),
            ('ZenCodingNNodeAction', None, 'Next node', '<Ctrl><Alt>Right',
             "Select the next HTML node", self.next_node),
            ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left',
             "Place the cursor at the previous edit point",
             self.prev_edit_point),
            ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right',
             "Place the cursor at the next edit point", self.next_edit_point),
            ('ZenCodingSizeAction', None, 'Update image _size', '<Ctrl><Alt>S',
             "Update image size tag from file", self.update_image_size),
            ('ZenCodingDataAction', None, 'Toggle image url/da_ta',
             '<Ctrl><Alt>A', "Toggle between image url and data",
             self.encode_decode_base64),
            ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M',
             "Merge all lines of the current selection", self.merge_lines),
            ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R',
             "Remove a tag", self.remove_tag),
            ('ZenCodingSplitAction', None, 'Split or _join tag',
             '<Ctrl><Alt>J', "Toggle between single and double tag",
             self.split_join_tag),
            ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C',
             "Toggle an XML or HTML comment", self.toggle_comment),
            ('ZenCodingSettingsAction', None, 'E_dit settings...', None,
             "Customize snippets and abbreviations", self.edit_settings)
        ]
        windowdata = dict()
        self.window.set_data("ZenCodingPluginDataKey", windowdata)
        windowdata["action_group"] = gtk.ActionGroup(
            "GeditZenCodingPluginActions")
        windowdata["action_group"].add_actions(actions)
        manager = self.window.get_ui_manager()
        manager.insert_action_group(windowdata["action_group"], -1)
        windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
        self.window.set_data("ZenCodingPluginInfo", windowdata)

        # zen coding
        self.modified = None
        self.editor = ZenEditor(self.window)
Ejemplo n.º 20
0
class ZenCodingWindowHelper():
    def __init__(self, window):

        # window
        self.window = window

        # menu items
        actions = [
            ('ZenCodingMenuAction', None, '_Zen Coding', None,
             "Zen Coding tools", None),
            ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E',
             "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation),
            ('ZenCodingExpandWAction', None, 'E_xpand with abbreviation...',
             '<Ctrl><Alt>E', "Type in an abbreviation to expand",
             self.expand_with_abbreviation),
            ('ZenCodingWrapAction', None, '_Wrap with abbreviation...',
             '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation",
             self.wrap_with_abbreviation),
            ('ZenCodingZenifyAction', None, '_Zenify', None,
             "Reduce to abbreviation", None),
            ('ZenCodingZenify0Action', None, '_Tag names', '<Ctrl><Alt>Z',
             "Reduce to tag names only", self.zenify0),
            ('ZenCodingZenify1Action', None, '  + _Ids and classes', None,
             "Reduce with ids and classes", self.zenify1),
            ('ZenCodingZenify2Action', None, '    + All other _attributes',
             None, "Reduce with all attributes", self.zenify2),
            ('ZenCodingZenify3Action', None, '      + _Values', None,
             "Reduce with all attributes and values", self.zenify3),
            ('LoremIpsumAction', None, '_Lorem ipsum...', '<Ctrl><Alt>X',
             "Insert a lorem ipsum string", self.lorem_ipsum),
            ('ZenCodingInwardAction', None, 'Select _inward', '<Ctrl><Alt>I',
             "Select inner tag's content", self.match_pair_inward),
            ('ZenCodingOutwardAction', None, 'Select _outward', '<Ctrl><Alt>O',
             "Select outer tag's content", self.match_pair_outward),
            ('ZenCodingPTagAction', None, 'Previous tag', '<Ctrl><Alt>Up',
             "Select the previous tag in HTML code", self.prev_tag),
            ('ZenCodingNTagAction', None, 'Next tag', '<Ctrl><Alt>Down',
             "Select the next tag in HTML code", self.next_tag),
            ('ZenCodingPNodeAction', None, 'Previous node', '<Ctrl><Alt>Left',
             "Select the previous HTML node", self.prev_node),
            ('ZenCodingNNodeAction', None, 'Next node', '<Ctrl><Alt>Right',
             "Select the next HTML node", self.next_node),
            ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left',
             "Place the cursor at the previous edit point",
             self.prev_edit_point),
            ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right',
             "Place the cursor at the next edit point", self.next_edit_point),
            ('ZenCodingSizeAction', None, 'Update image _size', '<Ctrl><Alt>S',
             "Update image size tag from file", self.update_image_size),
            ('ZenCodingDataAction', None, 'Toggle image url/da_ta',
             '<Ctrl><Alt>A', "Toggle between image url and data",
             self.encode_decode_base64),
            ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M',
             "Merge all lines of the current selection", self.merge_lines),
            ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R',
             "Remove a tag", self.remove_tag),
            ('ZenCodingSplitAction', None, 'Split or _join tag',
             '<Ctrl><Alt>J', "Toggle between single and double tag",
             self.split_join_tag),
            ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C',
             "Toggle an XML or HTML comment", self.toggle_comment),
            ('ZenCodingSettingsAction', None, 'E_dit settings...', None,
             "Customize snippets and abbreviations", self.edit_settings)
        ]
        windowdata = dict()
        self.window.set_data("ZenCodingPluginDataKey", windowdata)
        windowdata["action_group"] = gtk.ActionGroup(
            "GeditZenCodingPluginActions")
        windowdata["action_group"].add_actions(actions)
        manager = self.window.get_ui_manager()
        manager.insert_action_group(windowdata["action_group"], -1)
        windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
        self.window.set_data("ZenCodingPluginInfo", windowdata)

        # zen coding
        self.modified = None
        self.editor = ZenEditor(self.window)

    def deactivate(self):

        # zen coding
        self.editor = None

        # menu items
        windowdata = self.window.get_data("ZenCodingPluginDataKey")
        manager = self.window.get_ui_manager()
        manager.remove_ui(windowdata["ui_id"])
        manager.remove_action_group(windowdata["action_group"])

        # window
        self.window = None

    def update_ui(self):

        # disabled if not editable
        view = self.window.get_active_view()
        windowdata = self.window.get_data("ZenCodingPluginDataKey")
        windowdata["action_group"].set_sensitive(
            bool(view and view.get_editable()))

        # user settings
        modified = os.path.getmtime(
            os.path.join(os.path.dirname(__file__), 'my_zen_settings.py'))
        if modified != self.modified:
            try:
                import my_zen_settings
                reload(my_zen_settings)
            except Exception as error:
                md = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL,
                                       gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
                                       "An error occured in user settings:")
                message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
                md.set_title("Zen Coding error")
                md.format_secondary_text(
                    message.format(error.msg, error.lineno, error.offset))
                md.run()
                md.destroy()
            else:
                globals()['zen_core'].zen_settings = globals(
                )['stparser'].get_settings(my_zen_settings.my_zen_settings)
            self.modified = modified

        # the content changed
        self.editor.set_context(view)

    # Menu handlers

    def expand_abbreviation(self, action):
        self.editor.expand_abbreviation()

    def expand_with_abbreviation(self, action):
        self.editor.expand_with_abbreviation()

    def wrap_with_abbreviation(self, action):
        self.editor.wrap_with_abbreviation()

    def zenify0(self, action):
        self.editor.zenify(0)

    def zenify1(self, action):
        self.editor.zenify(1)

    def zenify2(self, action):
        self.editor.zenify(2)

    def zenify3(self, action):
        self.editor.zenify(3)

    def lorem_ipsum(self, action):
        self.editor.lorem_ipsum()

    def match_pair_inward(self, action):
        self.editor.match_pair_inward()

    def match_pair_outward(self, action):
        self.editor.match_pair_outward()

    def prev_tag(self, action):
        self.editor.prev_tag()

    def next_tag(self, action):
        self.editor.next_tag()

    def prev_node(self, action):
        self.editor.prev_node()

    def next_node(self, action):
        self.editor.next_node()

    def prev_edit_point(self, action):
        self.editor.prev_edit_point()

    def next_edit_point(self, action):
        self.editor.next_edit_point()

    def update_image_size(self, action):
        self.editor.update_image_size()

    def encode_decode_base64(self, action):
        self.editor.encode_decode_base64()

    def merge_lines(self, action):
        self.editor.merge_lines()

    def remove_tag(self, action):
        self.editor.remove_tag()

    def split_join_tag(self, action):
        self.editor.split_join_tag()

    def toggle_comment(self, action):
        self.editor.toggle_comment()

    def edit_settings(self, action):
        name = 'file://' + os.path.join(os.path.dirname(__file__),
                                        'my_zen_settings.py')
        self.window.create_tab_from_uri(name, None, 0, True, True)
Ejemplo n.º 21
0
class ZenCodingWindowHelper():

	def __init__(self, window):

		# window
		self.window = window

		# menu items
		actions = [
			('ZenCodingMenuAction',		None, '_Zen Coding',					None,				"Zen Coding tools",								None),
			('ZenCodingExpandAction',	None, '_Expand abbreviation',			'<Ctrl>E',			"Expand abbreviation to raw HTML/CSS",			self.expand_abbreviation),
			('ZenCodingExpandWAction',	None, 'E_xpand with abbreviation...',	'<Ctrl><Alt>E',		"Type in an abbreviation to expand",			self.expand_with_abbreviation),
			('ZenCodingWrapAction',		None, '_Wrap with abbreviation...',		'<Ctrl><Shift>E',	"Wrap with code expanded from abbreviation",	self.wrap_with_abbreviation),
			('ZenCodingZenifyAction',	None, '_Zenify',						None,				"Reduce to abbreviation",						None),
			('ZenCodingZenify0Action',	None, '_Tag names',						'<Ctrl><Alt>Z',		"Reduce to tag names only",						self.zenify0),
			('ZenCodingZenify1Action',	None, '  + _Ids and classes',			None,				"Reduce with ids and classes",					self.zenify1),
			('ZenCodingZenify2Action',	None, '    + All other _attributes',	None,				"Reduce with all attributes",					self.zenify2),
			('ZenCodingZenify3Action',	None, '      + _Values',				None,				"Reduce with all attributes and values",		self.zenify3),
			('LoremIpsumAction',		None, '_Lorem ipsum...',				'<Ctrl><Alt>X',		"Insert a lorem ipsum string",					self.lorem_ipsum),
			('ZenCodingInwardAction',	None, 'Select _inward',					'<Ctrl><Alt>I',		"Select inner tag's content",					self.match_pair_inward),
			('ZenCodingOutwardAction',	None, 'Select _outward',				'<Ctrl><Alt>O',		"Select outer tag's content",					self.match_pair_outward),
			('ZenCodingPTagAction',		None, 'Previous tag',					'<Ctrl><Alt>Up',	"Select the previous tag in HTML code",			self.prev_tag),
			('ZenCodingNTagAction',		None, 'Next tag',						'<Ctrl><Alt>Down',	"Select the next tag in HTML code",				self.next_tag),
			('ZenCodingPNodeAction',	None, 'Previous node',					'<Ctrl><Alt>Left',	"Select the previous HTML node",				self.prev_node),
			('ZenCodingNNodeAction',	None, 'Next node',						'<Ctrl><Alt>Right',	"Select the next HTML node",					self.next_node),
			('ZenCodingPrevAction',		None, '_Previous edit point',			'<Alt>Left',		"Place the cursor at the previous edit point",	self.prev_edit_point),
			('ZenCodingNextAction',		None, '_Next edit point',				'<Alt>Right',		"Place the cursor at the next edit point",		self.next_edit_point),
			('ZenCodingSizeAction',		None, 'Update image _size',				'<Ctrl><Alt>S',		"Update image size tag from file",				self.update_image_size),
			('ZenCodingDataAction',		None, 'Toggle image url/da_ta',			'<Ctrl><Alt>A',		"Toggle between image url and data",			self.encode_decode_base64),
			('ZenCodingMergeAction',	None, '_Merge lines',					'<Ctrl><Alt>M',		"Merge all lines of the current selection",		self.merge_lines),
			('ZenCodingRemoveAction',	None, '_Remove tag',					'<Ctrl><Alt>R',		"Remove a tag",									self.remove_tag),
			('ZenCodingSplitAction',	None, 'Split or _join tag',				'<Ctrl><Alt>J',		"Toggle between single and double tag",			self.split_join_tag),
			('ZenCodingCommentAction',	None, 'Toggle _comment',				'<Ctrl><Alt>C',		"Toggle an XML or HTML comment",				self.toggle_comment),
			('ZenCodingSettingsAction',	None, 'E_dit settings...',				None,				"Customize snippets and abbreviations",			self.edit_settings)
		]
		windowdata = dict()
		self.window.set_data("ZenCodingPluginDataKey", windowdata)
		windowdata["action_group"] = gtk.ActionGroup("GeditZenCodingPluginActions")
		windowdata["action_group"].add_actions(actions)
		manager = self.window.get_ui_manager()
		manager.insert_action_group(windowdata["action_group"], -1)
		windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
		self.window.set_data("ZenCodingPluginInfo", windowdata)

		# zen coding
		self.modified = None
		self.editor = ZenEditor(self.window)

	def deactivate(self):

		# zen coding
		self.editor = None

		# menu items
		windowdata = self.window.get_data("ZenCodingPluginDataKey")
		manager = self.window.get_ui_manager()
		manager.remove_ui(windowdata["ui_id"])
		manager.remove_action_group(windowdata["action_group"])

		# window
		self.window = None

	def update_ui(self):
	
		# disabled if not editable
		view = self.window.get_active_view()
		windowdata = self.window.get_data("ZenCodingPluginDataKey")
		windowdata["action_group"].set_sensitive(bool(view and view.get_editable()))
		
		# user settings
		modified = os.path.getmtime(os.path.join(os.path.dirname(__file__), 'my_zen_settings.py'))
		if modified != self.modified:
			try:
				import my_zen_settings
				reload(my_zen_settings)
			except Exception as error:
				md = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
					gtk.BUTTONS_CLOSE, "An error occured in user settings:")
				message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
				md.set_title("Zen Coding error")
				md.format_secondary_text(message.format(error.msg, error.lineno, error.offset))
				md.run()
				md.destroy()
			else:
				globals()['zen_core'].zen_settings = globals()['stparser'].get_settings(my_zen_settings.my_zen_settings)
			self.modified = modified

		# the content changed
		self.editor.set_context(view)
		
	# Menu handlers

	def expand_abbreviation(self, action):
		self.editor.expand_abbreviation()

	def expand_with_abbreviation(self, action):
		self.editor.expand_with_abbreviation()

	def wrap_with_abbreviation(self, action):
		self.editor.wrap_with_abbreviation()

	def zenify0(self, action):
		self.editor.zenify(0)

	def zenify1(self, action):
		self.editor.zenify(1)

	def zenify2(self, action):
		self.editor.zenify(2)

	def zenify3(self, action):
		self.editor.zenify(3)

	def lorem_ipsum(self, action):
		self.editor.lorem_ipsum()

	def match_pair_inward(self, action):
		self.editor.match_pair_inward()

	def match_pair_outward(self, action):
		self.editor.match_pair_outward()

	def prev_tag(self, action):
		self.editor.prev_tag()

	def next_tag(self, action):
		self.editor.next_tag()

	def prev_node(self, action):
		self.editor.prev_node()

	def next_node(self, action):
		self.editor.next_node()

	def prev_edit_point(self, action):
		self.editor.prev_edit_point()

	def next_edit_point(self, action):
		self.editor.next_edit_point()

	def update_image_size(self, action):
		self.editor.update_image_size()

	def encode_decode_base64(self, action):
		self.editor.encode_decode_base64()

	def merge_lines(self, action):
		self.editor.merge_lines()

	def remove_tag(self, action):
		self.editor.remove_tag()

	def split_join_tag(self, action):
		self.editor.split_join_tag()

	def toggle_comment(self, action):
		self.editor.toggle_comment()

	def edit_settings(self, action):
		name = 'file://' + os.path.join(os.path.dirname(__file__), 'my_zen_settings.py')
		self.window.create_tab_from_uri(name, None, 0, True, True)
Ejemplo n.º 22
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from zencoding import zen_core as zen_coding
from zen_editor import ZenEditor

editor = ZenEditor()
abbr = editor.prompt('Enter abbreviation')
if abbr is not None:
    zen_coding.run_action('wrap_with_abbreviation', editor, abbr)
Ejemplo n.º 23
0
class ZenCodingPlugin(GObject.Object, Gedit.WindowActivatable):
    """A Gedit plugin to implement Zen Coding's HTML and CSS shorthand expander."""

    window = GObject.property(type=Gedit.Window)

    def do_activate(self):
        actions = [
            ('ZenCodingMenuAction', None, '_Zen Coding', None,
             "Zen Coding tools", None),
            ('ZenCodingExpandAction', None, '_Expand abbreviation', '<Ctrl>E',
             "Expand abbreviation to raw HTML/CSS", self.expand_abbreviation),
            ('ZenCodingExpandWAction', None, '_Expand dynamic abbreviation...',
             '<Ctrl><Alt>E', "Dynamically expand abbreviation as you type",
             self.expand_with_abbreviation),
            ('ZenCodingWrapAction', None, '_Wrap with abbreviation...',
             '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation",
             self.wrap_with_abbreviation),
            ('ZenCodingInwardAction', None, 'Balance tag _inward',
             '<Ctrl><Alt>I', "Select inner tag's content",
             self.match_pair_inward),
            ('ZenCodingOutwardAction', None, 'Balance tag _outward',
             '<Ctrl><Alt><Shift>O', "Select outer tag's content",
             self.match_pair_outward),
            ('ZenCodingMergeAction', None, '_Merge lines', '<Ctrl><Alt>M',
             "Merge all lines of the current selection", self.merge_lines),
            ('ZenCodingPrevAction', None, '_Previous edit point', '<Alt>Left',
             "Place the cursor at the previous edit point",
             self.prev_edit_point),
            ('ZenCodingNextAction', None, '_Next edit point', '<Alt>Right',
             "Place the cursor at the next edit point", self.next_edit_point),
            ('ZenCodingRemoveAction', None, '_Remove tag', '<Ctrl><Alt>R',
             "Remove a tag", self.remove_tag),
            ('ZenCodingSplitAction', None, 'Split or _join tag',
             '<Ctrl><Alt>J', "Toggle between single and double tag",
             self.split_join_tag),
            ('ZenCodingCommentAction', None, 'Toggle _comment', '<Ctrl><Alt>C',
             "Toggle an XML or HTML comment", self.toggle_comment)
        ]
        windowdata = dict()
        self.window.ZenCodingPluginDataKey = windowdata
        windowdata["action_group"] = Gtk.ActionGroup(
            "GeditZenCodingPluginActions")
        windowdata["action_group"].add_actions(actions)
        manager = self.window.get_ui_manager()
        manager.insert_action_group(windowdata["action_group"], -1)
        windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
        self.window.ZenCodingPluginInfo = windowdata
        self.editor = ZenEditor()
        error = self.editor.get_user_settings_error()
        if error:
            md = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL,
                                   Gtk.MessageType.ERROR,
                                   Gtk.ButtonsType.CLOSE,
                                   "There is an error in user settings:")
            message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
            md.set_title("Zen Coding error")
            md.format_secondary_text(
                message.format(error['msg'], error['lineno'], error['offset']))
            md.run()
            md.destroy()

    def do_deactivate(self):
        windowdata = self.window.ZenCodingPluginDataKey
        manager = self.window.get_ui_manager()
        manager.remove_ui(windowdata["ui_id"])
        manager.remove_action_group(windowdata["action_group"])

    def do_update_state(self):
        view = self.window.get_active_view()
        windowdata = self.window.ZenCodingPluginDataKey
        windowdata["action_group"].set_sensitive(
            bool(view and view.get_editable()))

    def expand_abbreviation(self, action):
        self.editor.expand_abbreviation(self.window)

    def expand_with_abbreviation(self, action):
        self.editor.expand_with_abbreviation(self.window)

    def wrap_with_abbreviation(self, action):
        self.editor.wrap_with_abbreviation(self.window)

    def match_pair_inward(self, action):
        self.editor.match_pair_inward(self.window)

    def match_pair_outward(self, action):
        self.editor.match_pair_outward(self.window)

    def merge_lines(self, action):
        self.editor.merge_lines(self.window)

    def prev_edit_point(self, action):
        self.editor.prev_edit_point(self.window)

    def next_edit_point(self, action):
        self.editor.next_edit_point(self.window)

    def remove_tag(self, action):
        self.editor.remove_tag(self.window)

    def split_join_tag(self, action):
        self.editor.split_join_tag(self.window)

    def toggle_comment(self, action):
        self.editor.toggle_comment(self.window)
Ejemplo n.º 24
0
class ZenCodingPlugin(GObject.Object, Gedit.WindowActivatable):
    """A Gedit plugin to implement Zen Coding's HTML and CSS shorthand expander."""

    window = GObject.property(type=Gedit.Window)
    
    def do_activate(self):
        actions = [
          ('ZenCodingMenuAction',     None, '_Zen Coding',                  None,            "Zen Coding tools",                            None),
          ('ZenCodingExpandAction',   None, '_Expand abbreviation',         '<Ctrl>E',        "Expand abbreviation to raw HTML/CSS",         self.expand_abbreviation),
          ('ZenCodingExpandWAction',  None, 'E_xpand dynamic abbreviation...', '<Ctrl><Alt>E',   "Dynamically expand abbreviation as you type",           self.expand_with_abbreviation),
          ('ZenCodingWrapAction',     None, '_Wrap with abbreviation...',   '<Ctrl><Shift>E', "Wrap with code expanded from abbreviation",   self.wrap_with_abbreviation),
          ('ZenCodingInwardAction',   None, 'Balance tag _inward',          '<Ctrl><Alt>I',   "Select inner tag's content",                  self.match_pair_inward),
          ('ZenCodingOutwardAction',  None, 'Balance tag _outward',         '<Ctrl><Alt>O',   "Select outer tag's content",                  self.match_pair_outward),
          ('ZenCodingMergeAction',    None, '_Merge lines',                 '<Ctrl><Alt>M',   "Merge all lines of the current selection",    self.merge_lines),
          ('ZenCodingPrevAction',     None, '_Previous edit point',         '<Alt>Left',      "Place the cursor at the previous edit point", self.prev_edit_point),
          ('ZenCodingNextAction',     None, '_Next edit point',             '<Alt>Right',     "Place the cursor at the next edit point",     self.next_edit_point),
          ('ZenCodingRemoveAction',   None, '_Remove tag',                  '<Ctrl><Alt>R',   "Remove a tag",                                self.remove_tag),
          ('ZenCodingSplitAction',    None, 'Split or _join tag',           '<Ctrl><Alt>J',   "Toggle between single and double tag",        self.split_join_tag),
          ('ZenCodingCommentAction',  None, 'Toggle _comment',              '<Ctrl><Alt>C',   "Toggle an XML or HTML comment",               self.toggle_comment)
        ]
        windowdata = dict()
        self.window.ZenCodingPluginDataKey = windowdata
        windowdata["action_group"] = Gtk.ActionGroup("GeditZenCodingPluginActions")
        windowdata["action_group"].add_actions(actions)
        manager = self.window.get_ui_manager()
        manager.insert_action_group(windowdata["action_group"], -1)
        windowdata["ui_id"] = manager.add_ui_from_string(zencoding_ui_str)
        self.window.ZenCodingPluginInfo = windowdata
        self.editor = ZenEditor()
        error = self.editor.get_user_settings_error()
        if error:
            md = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
                Gtk.ButtonsType.CLOSE, "There is an error in user settings:")
            message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
            md.set_title("Zen Coding error")
            md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset']))
            md.run()
            md.destroy()


    def do_deactivate(self):
        windowdata = self.window.ZenCodingPluginDataKey
        manager = self.window.get_ui_manager()
        manager.remove_ui(windowdata["ui_id"])
        manager.remove_action_group(windowdata["action_group"])

    def do_update_state(self):
        view = self.window.get_active_view()
        windowdata = self.window.ZenCodingPluginDataKey
        windowdata["action_group"].set_sensitive(bool(view and view.get_editable()))

    def expand_abbreviation(self, action):
        self.editor.expand_abbreviation(self.window)
        
    def expand_with_abbreviation(self, action):
        self.editor.expand_with_abbreviation(self.window)

    def wrap_with_abbreviation(self, action):
        self.editor.wrap_with_abbreviation(self.window)

    def match_pair_inward(self, action):
        self.editor.match_pair_inward(self.window)

    def match_pair_outward(self, action):
        self.editor.match_pair_outward(self.window)

    def merge_lines(self, action):
        self.editor.merge_lines(self.window)

    def prev_edit_point(self, action):
        self.editor.prev_edit_point(self.window)

    def next_edit_point(self, action):
        self.editor.next_edit_point(self.window)

    def remove_tag(self, action):
        self.editor.remove_tag(self.window)

    def split_join_tag(self, action):
        self.editor.split_join_tag(self.window)

    def toggle_comment(self, action):
        self.editor.toggle_comment(self.window)