Permalink
Browse files

merge with fmarcia's updates

  • Loading branch information...
2 parents e18faff + c711d0b commit dcbefb47248c1d9d6935822af4b6f4d2ea2484dc @mikecrittenden committed May 9, 2010
Showing with 292 additions and 105 deletions.
  1. +21 −22 README.md
  2. +11 −0 install.sh
  3. +5 −5 zencoding.gedit-plugin
  4. BIN zencoding.png
  5. +46 −25 zencoding/plugin.py
  6. +5 −3 zencoding/zen_core.py
  7. +93 −0 zencoding/zen_dialog.py
  8. +99 −38 zencoding/zen_editor.py
  9. +12 −12 zencoding/zen_settings.py
View
43 README.md
@@ -1,6 +1,6 @@
Zen Coding for Gedit
====================
-A new way of writing HTML and CSS code for Gedit.
+A new way of writing HTML and CSS code for Gedit
Information
-----------
@@ -13,43 +13,42 @@ expand expressions—similar to CSS selectors—into HTML code.
- [Demo video](http://vimeo.com/7405114)
- [Examples and usage](http://www.smashingmagazine.com/2009/11/21/zen-coding-a-new-way-to-write-html-code/)
-This is a Gedit plugin that partially integrates Zen Coding into Gedit.
+This plugin fully integrates Zen Coding into Gedit.
Features
--------
-Zen Coding isn't only a decent abbreviations expander, but also a set of handy tools for common XHTML tasks.
-Read [this page](http://code.google.com/p/zen-coding/wiki/Actions) carefully to boost your productivity even
-more. Note that almost every action highly depends on current caret position inside text editor.
+Zen Coding isn't only a decent abbreviations expander but also a set of handy tools for common XHTML tasks.
+Read [this page](http://code.google.com/p/zen-coding/wiki/Actions) thoroughly for details.
+Note that almost every action highly depends on current caret position inside text editor.
+
+With this plugin, you can:
- Expand abbreviation with `Ctrl+E`
-- Wrap with abbreviation with `Ctrl+Shift+E` (needs gcocoadialog, see Installation and Credits)
+- Expand with abbreviation with `Ctrl+Alt+E`
+- Wrap with abbreviation with `Ctrl+Shift+E`
- Balance tag inward or outward with `Ctrl+Alt+I` or `Ctrl+Alt+O`
- Merge lines with `Ctrl+Alt+M`
- Go to previous or next edit point with `Alt+Left` and `Alt+Right`
-- Update tag image size with `Ctrl+Alt+S` (needs ImageMagick, see Installation and Credits)
+- Update tag image size with `Ctrl+Alt+S`
- Remove tag with `Ctrl+Alt+R`
-- Split or join lines with `Ctrl+Alt+J`
+- Split or join tags with `Ctrl+Alt+J`
- Toggle comment with `Ctrl+Alt+C`
+- Create your own abbreviations and snippets.
-Menu entries are also available in the Edit menu.
Shortcuts can be changed in `~/.gnome2/gedit/plugins/zencoding/plugin.py` to fit your needs.
Installation
------------
-1. Download source
-2. Unpack the `zencoding-gedit.plugin` file and the `zencoding` directory into `~/.gnome2/gedit/plugins/`.
-3. In order to use "Wrap with abbreviation", install `gcocoadialog` using [these instructions](http://mikethecoder.com/2010/05/05/compiling-and-installing-gcocoadialog-in-ubuntu/).
-4. In order to use "Update tag image size", install `imagemagick` using your distribution's package manager.
-5. In Gedit, go to Edit -> Preferences -> Plugins to find and enable the plugin.
-6. Try it out!
-
+1. Download [zip](http://github.com/mikecrittenden/zen-coding-gedit/zipball/master) or [tar](http://github.com/mikecrittenden/zen-coding-gedit/tarball/master) source and unpack it.
+2. Run `./install.sh`
+3. In order to use "Update tag image size", install `imagemagick` if not already installed
+4. In Gedit, go to Edit -> Preferences -> Plugins to find and enable the plugin.
+5. Try it out!
+
Credits
-------
-- [Sergey Chikuyonok](http://chikuyonok.ru/) - the music makers, the dreamers of the dream
-- [Mike Crittenden](http://mikethecoder.com) - the maintainer of the Gedit plugin
-- [Stuart Langridge](http://www.kryogenix.org/days/2009/09/21/zen-coding-for-gedit) - the original author of the Gedit plugin
-- [Mitchell Foral](http://caladbolg.net/) - the author of [gcocoadialog](http://code.google.com/p/gcocoadialog/)
-- [ImageMagick Team](http://www.imagemagick.org/) - a software suite to create, edit, and compose bitmap images
-- Franck Marcia - the author of this version of Gedit plugin
+- [Sergey Chikuyonok](http://chikuyonok.ru/) - the creator of Zen Coding
+- [Franck Marcia](http://github.com/fmarcia) - the author of this Gedit plugin
+- [Mike Crittenden](http://mikethecoder.com) - the maintainer of this Gedit plugin
View
11 install.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+#
+# Zen Coding installation
+#
+
+sudo cp zencoding.png /usr/share/icons/hicolor/16x16/apps
+sudo gtk-update-icon-cache /usr/share/icons/hicolor > /dev/null 2>&1
+mkdir -p ~/.gnome2/gedit/plugins
+cp zencoding.gedit-plugin ~/.gnome2/gedit/plugins
+cp -r zencoding ~/.gnome2/gedit/plugins
+
View
10 zencoding.gedit-plugin
@@ -3,9 +3,9 @@ Loader=python
Module=zencoding
IAge=2
Name=Zen Coding
-Description=Enables Zen Coding's CSS and HTML shorthand tools for Gedit.
-Description[fr]=Des sélecteurs CSS pour écrire du code HTML.
-Authors=Mike Crittenden <mike@mikethecoder.com>, Zen Coding team\nFranck Marcia <franck.marcia@gmail.com>
-Copyright=Mike Crittenden <mike@mikethecoder.com>\nFranck Marcia <franck.marcia@gmail.com>
-Website=http://github.com/mikecrittenden/zen-coding-gedit
+Description=Expand expressions similar to CSS selectors into HTML, CSS or XSLT code
+Description[fr]=Développe des expressions similaires à des sélecteurs CSS en code HTML, CSS ou XSLT
+Authors=Franck Marcia <franck.marcia@gmail.com>
+Copyright=Franck Marcia <franck.marcia@gmail.com>
+Website=http://github.com/fmarcia/zen-coding-gedit
View
BIN zencoding.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
71 zencoding/plugin.py
@@ -2,8 +2,10 @@
#
# Connect Zen Coding to Gedit.
#
+# Author Franck Marcia (franck.marcia@gmail.com)
+#
-import gedit, gobject, gtk
+import gedit, gobject, gtk, os
from zen_editor import ZenEditor
@@ -13,21 +15,24 @@
<menu name="EditMenu" action="Edit">
<placeholder name="EditOps_5">
<menu action="ZenCodingMenuAction">
- <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/>
- <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/>
+ <menuitem name="ZenCodingExpand" action="ZenCodingExpandAction"/>
+ <menuitem name="ZenCodingExpandW" action="ZenCodingExpandWAction"/>
+ <menuitem name="ZenCodingWrap" action="ZenCodingWrapAction"/>
+ <separator/>
+ <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/>
+ <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/>
+ <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/>
<separator/>
- <menuitem name="ZenCodingInward" action="ZenCodingInwardAction"/>
- <menuitem name="ZenCodingOutward" action="ZenCodingOutwardAction"/>
- <menuitem name="ZenCodingMerge" action="ZenCodingMergeAction"/>
+ <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/>
+ <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/>
<separator/>
- <menuitem name="ZenCodingPrev" action="ZenCodingPrevAction"/>
- <menuitem name="ZenCodingNext" action="ZenCodingNextAction"/>
+ <menuitem name="ZenCodingSize" action="ZenCodingSizeAction"/>
<separator/>
- <menuitem name="ZenCodingSize" action="ZenCodingSizeAction"/>
+ <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/>
+ <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/>
+ <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/>
<separator/>
- <menuitem name="ZenCodingRemove" action="ZenCodingRemoveAction"/>
- <menuitem name="ZenCodingSplit" action="ZenCodingSplitAction"/>
- <menuitem name="ZenCodingComment" action="ZenCodingCommentAction"/>
+ <menuitem name="ZenCodingSettings" action="ZenCodingSettingsAction"/>
</menu>
</placeholder>
</menu>
@@ -40,18 +45,20 @@ class ZenCodingPlugin(gedit.Plugin):
def activate(self, window):
actions = [
- ('ZenCodingMenuAction', None, 'Zen Coding', None, "Zen Coding framework", None),
- ('ZenCodingExpandAction', None, 'Expand Zen Code', '<Ctrl>E', "Expand Zen code to raw HTML/CSS", self.expand_abbreviation),
- ('ZenCodingWrapAction', None, 'Wrap with Zen Code...', '<Ctrl><Shift>E', "Wrap selection with HTML/CSS expanded from Zen code", 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)
+ ('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)
@@ -62,6 +69,16 @@ def activate(self, window):
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 deactivate(self, window):
windowdata = window.get_data("ZenCodingPluginDataKey")
@@ -76,6 +93,9 @@ def update_ui(self, window):
def expand_abbreviation(self, action, window):
self.editor.expand_abbreviation(window)
+
+ def expand_with_abbreviation(self, action, window):
+ self.editor.expand_with_abbreviation(window)
def wrap_with_abbreviation(self, action, window):
self.editor.wrap_with_abbreviation(window)
@@ -107,4 +127,5 @@ def split_join_tag(self, action, window):
def toggle_comment(self, action, window):
self.editor.toggle_comment(window)
- return True
+ def edit_settings(self, action, window):
+ window.create_tab_from_uri("file:///" + os.path.expanduser("~/.gnome2/gedit/plugins/zencoding/my_zen_settings.py"), None, 0, True, True)
View
8 zencoding/zen_core.py
@@ -234,13 +234,13 @@ def get_elements_collection(resource, type):
else:
return {}
-def replace_variables(text, vars=zen_settings['variables']):
+def replace_variables(text):
"""
Replace variables like ${var} in string
@param text: str
@return: str
"""
- return re.sub(r'\$\{([\w\-]+)\}', lambda m: m.group(1) in vars and vars[m.group(1)] or m.group(0), text)
+ return re.sub(r'\$\{([\w\-]+)\}', lambda m: get_variable(m.group(1)) or m.group(0), text)
def get_abbreviation(res_type, abbr):
"""
@@ -269,7 +269,9 @@ def get_variable(name):
Returns variable value
@return: str
"""
- return zen_settings['variables'][name]
+ if name in zen_settings['variables']:
+ return zen_settings['variables'][name]
+ return None
def set_variable(name, value):
"""
View
93 zencoding/zen_dialog.py
@@ -0,0 +1,93 @@
+import pygtk
+pygtk.require('2.0')
+import gtk
+
+class ZenDialog():
+
+ def __init__(self, editor, x, y, callback, text=""):
+
+ self.editor = editor
+ self.exit = False
+ self.done = False
+ self.abbreviation = text
+ self.callback = callback
+
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.set_decorated(False)
+ self.window.connect("destroy", self.quit)
+ self.window.connect("focus-out-event", self.focus_lost)
+ self.window.connect("key-press-event", self.key_pressed)
+ self.window.set_resizable(False)
+ self.window.move(x - 15, y - 35)
+
+ self.frame = gtk.Frame()
+ self.window.add(self.frame)
+ self.frame.show()
+
+ self.box = gtk.HBox()
+ self.frame.add(self.box)
+ self.box.show()
+
+ self.entry = gtk.Entry()
+ self.entry.connect("changed", self.update)
+ self.entry.set_text(text)
+ self.entry.set_icon_from_icon_name(gtk.ENTRY_ICON_PRIMARY, 'zencoding')
+ self.entry.set_width_chars(48)
+ self.box.pack_start(self.entry, True, True, 4)
+ self.entry.show()
+
+ self.window.show()
+
+ def key_pressed(widget, what, event):
+ if event.keyval == 65293: # Return
+ widget.exit = True
+ widget.quit()
+ elif event.keyval == 65289: # Tab
+ widget.exit = True
+ widget.quit()
+ elif event.keyval == 65307: # Escape
+ widget.exit = False
+ widget.done = widget.callback(widget.done, '')
+ widget.quit()
+ else:
+ return False
+
+ def focus_lost(self, widget=None, event=None):
+ widget.exit = True
+ widget.quit()
+
+ def update(self, entry):
+ self.abbreviation = self.entry.get_text()
+ self.done = self.callback(self.done, self.abbreviation)
+
+ def quit(self, widget=None, event=None):
+ self.window.hide()
+ self.window.destroy()
+ gtk.main_quit()
+
+ def main(self):
+ gtk.main()
+
+def main(editor, window, callback, text=""):
+
+ # ensure the caret is hidden
+ editor.view.set_cursor_visible(False)
+
+ # get coordinates of the cursor
+ offset_start, offset_end = editor.get_selection_range()
+ insert = editor.buffer.get_iter_at_offset(offset_start)
+ location = editor.view.get_iter_location(insert)
+ window = editor.view.get_window(gtk.TEXT_WINDOW_TEXT)
+ xo, yo = window.get_origin()
+ xb, yb = editor.view.buffer_to_window_coords(gtk.TEXT_WINDOW_TEXT, location.x + location.width, location.y)
+
+ # open dialog at coordinates with eventual text
+ my_zen_dialog = ZenDialog(editor, xo + xb, yo + yb, callback, text)
+ my_zen_dialog.main()
+
+ # show the caret again
+ editor.view.set_cursor_visible(True)
+
+ # return exit status and abbreviation
+ return my_zen_dialog.done and my_zen_dialog.exit, my_zen_dialog.abbreviation
+
View
137 zencoding/zen_editor.py
@@ -21,13 +21,15 @@
'''
import zen_core, zen_actions
-import os, re
+import os, re, locale
from image_size import update_image_size
+import zen_dialog
class ZenEditor():
def __init__(self):
self.last_wrap = ''
+ self.last_expand = ''
zen_core.set_caret_placeholder('')
def set_context(self, context):
@@ -36,13 +38,28 @@ def set_context(self, context):
<code>before</code> using any Zen Coding action.
@param context: context object
"""
- self.context = context
+ self.context = context # window
self.buffer = self.context.get_active_view().get_buffer()
+ self.view = context.get_active_view()
self.document = context.get_active_document()
- if context.get_active_view().get_insert_spaces_instead_of_tabs():
+
+ default_locale = locale.getdefaultlocale()[0]
+ lang = re.sub(r'_[^_]+$', '', default_locale)
+ if lang != default_locale:
+ zen_core.set_variable('lang', lang)
+ zen_core.set_variable('locale', default_locale.replace('_', '-'))
+ else:
+ zen_core.set_variable('lang', default_locale)
+ zen_core.set_variable('locale', default_locale)
+
+ self.encoding = self.document.get_encoding().get_charset()
+ zen_core.set_variable('charset', self.encoding)
+
+ if self.view.get_insert_spaces_instead_of_tabs():
zen_core.set_variable('indentation', " " * context.get_active_view().get_tab_width())
else:
zen_core.set_variable('indentation', "\t")
+
#zen_core.set_newline(???)
def get_selection_range(self):
@@ -112,7 +129,7 @@ def get_current_line(self):
offset_start, offset_end = self.get_current_line_range()
iter_start = self.buffer.get_iter_at_offset(offset_start)
iter_end = self.buffer.get_iter_at_offset(offset_end)
- return self.buffer.get_text(iter_start, iter_end)
+ return self.buffer.get_text(iter_start, iter_end).decode(self.encoding)
def replace_content(self, value, offset_start=None, offset_end=None):
"""
@@ -151,8 +168,6 @@ def replace_content(self, value, offset_start=None, offset_end=None):
self.insertion_start = self.get_insert_offset()
padding = zen_actions.get_current_line_padding(self)
- # there's a bug when the snippet contains literal indentation
- value = value.replace('\t', zen_core.get_variable('indentation'))
self.buffer.insert_at_cursor(zen_core.pad_string(value, padding))
self.insertion_end = self.get_insert_offset()
@@ -164,7 +179,7 @@ def get_content(self):
"""
iter_start = self.buffer.get_iter_at_offset(0)
iter_end = self.get_end_iter()
- return self.buffer.get_text(iter_start, iter_end)
+ return self.buffer.get_text(iter_start, iter_end).decode(self.encoding)
def get_syntax(self):
"""
@@ -185,45 +200,43 @@ def get_profile_name(self):
"""
return 'xhtml'
+ #---------------------------------------------------------------------------------------
+
def get_insert_iter(self):
return self.buffer.get_iter_at_mark(self.buffer.get_insert())
def get_insert_offset(self):
return self.get_insert_iter().get_offset()
+ def get_selection_bound_iter(self):
+ return self.buffer.get_iter_at_mark(self.buffer.get_selection_bound())
+
def get_selection_bound_offset(self):
- return self.buffer.get_iter_at_mark(self.buffer.get_selection_bound()).get_offset()
+ return self.get_selection_bound_iter().get_offset()
def get_end_iter(self):
return self.buffer.get_iter_at_offset(self.buffer.get_char_count())
def get_end_offset(self):
return self.get_end_iter().get_offset()
-
- def prompt(self, abbr):
- """
- Prompt user with gCocoaDialog
- @param abbr: Previous abbreviation
- @return: str
- """
- cmd = 'gcocoadialog inputbox --width 400 --title "Wrap text with Zen Coding"'
- cmd += ' --informative-text "Abbreviation:" --text "{0}" --button1 "gtk-ok" --button2 "gtk-cancel"'
- ok = False
- for line in os.popen(cmd.format(abbr)).readlines():
- line = line[:-1]
- if line == "1":
- ok = True
- elif ok and len(line) > 0:
- return line
- return None
-
+
def start_edit(self):
# bug when the cursor is at the very beginning
if self.insertion_start == 0:
- self.insertion_start = 1
+ self.insertion_start = 1
self.set_caret_pos(self.insertion_start)
- if not self.next_edit_point():
+ if not self.next_edit_point() or (self.get_insert_offset() > self.insertion_end):
self.set_caret_pos(self.insertion_end)
+
+ def show_caret(self):
+ self.view.scroll_mark_onscreen(self.buffer.get_insert())
+
+ #---------------------------------------------------------------------------------------
+
+ def get_user_settings_error(self):
+ return zen_core.get_variable('user_settings_error')
+
+ #---------------------------------------------------------------------------------------
def expand_abbreviation(self, window):
self.set_context(window)
@@ -232,17 +245,57 @@ def expand_abbreviation(self, window):
if result:
self.start_edit()
self.buffer.end_user_action()
+
+ #---------------------------------------------------------------------------------------
+
+ def save_selection(self):
+ self.save_offset_insert = self.get_insert_offset()
+ self.save_offset_selection_bound = self.get_selection_bound_offset()
+
+ def restore_selection(self):
+ iter_insert = self.buffer.get_iter_at_offset(self.save_offset_insert)
+ iter_selection_bound = self.buffer.get_iter_at_offset(self.save_offset_selection_bound)
+ self.buffer.select_range(iter_insert, iter_selection_bound)
+
+ #---------------------------------------------------------------------------------------
+
+ def do_expand_with_abbreviation(self, done, abbr):
+ self.buffer.begin_user_action()
+ if done:
+ self.buffer.undo()
+ self.restore_selection()
+ content = zen_core.expand_abbreviation(abbr, self.get_syntax(), self.get_profile_name())
+ if content:
+ self.replace_content(content, self.get_insert_offset())
+ self.buffer.end_user_action()
+ return not not content
+
+ def expand_with_abbreviation(self, window):
+ self.set_context(window)
+ self.save_selection()
+ done, self.last_expand = zen_dialog.main(self, window, self.do_expand_with_abbreviation, self.last_expand)
+ if done:
+ self.start_edit()
+
+ #---------------------------------------------------------------------------------------
+
+ def do_wrap_with_abbreviation(self, done, abbr):
+ self.buffer.begin_user_action()
+ if done:
+ self.buffer.undo()
+ self.restore_selection()
+ result = zen_actions.wrap_with_abbreviation(self, abbr)
+ self.buffer.end_user_action()
+ return result
def wrap_with_abbreviation(self, window):
self.set_context(window)
- abbr = self.prompt(self.last_wrap)
- if abbr:
- self.last_wrap = abbr.replace(r'$', r'\$')
- self.buffer.begin_user_action()
- result = zen_actions.wrap_with_abbreviation(self, abbr.replace(r'\$', r'$'))
- if result:
- self.start_edit()
- self.buffer.end_user_action()
+ self.save_selection()
+ done, self.last_wrap = zen_dialog.main(self, window, self.do_wrap_with_abbreviation, self.last_wrap)
+ if done:
+ self.start_edit()
+
+ #---------------------------------------------------------------------------------------
def match_pair_inward(self, window):
self.set_context(window)
@@ -259,15 +312,23 @@ def merge_lines(self, window):
self.buffer.end_user_action()
return result
+ #---------------------------------------------------------------------------------------
+
def prev_edit_point(self, window=None):
if window:
self.set_context(window)
- return zen_actions.prev_edit_point(self)
+ result = zen_actions.prev_edit_point(self)
+ self.show_caret()
+ return result
def next_edit_point(self, window=None):
if window:
self.set_context(window)
- return zen_actions.next_edit_point(self)
+ result = zen_actions.next_edit_point(self)
+ self.show_caret()
+ return result
+
+ #---------------------------------------------------------------------------------------
def update_image_size(self, window):
self.set_context(window)
View
24 zencoding/zen_settings.py
@@ -510,53 +510,53 @@
'html:4t': '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n' +
'<html lang="${lang}">\n' +
'<head>\n' +
- ' <meta http-equiv="Content-Type" content="text/html;charset=${charset}">\n' +
- ' <title></title>\n' +
+ '${indentation}<meta http-equiv="Content-Type" content="text/html;charset=${charset}">\n' +
+ '${indentation}<title></title>\n' +
'</head>\n' +
'<body>\n\t${child}|\n</body>\n' +
'</html>',
'html:4s': '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n' +
'<html lang="${lang}">\n' +
'<head>\n' +
- ' <meta http-equiv="Content-Type" content="text/html;charset=${charset}">\n' +
- ' <title></title>\n' +
+ '${indentation}<meta http-equiv="Content-Type" content="text/html;charset=${charset}">\n' +
+ '${indentation}<title></title>\n' +
'</head>\n' +
'<body>\n\t${child}|\n</body>\n' +
'</html>',
'html:xt': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n' +
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="${lang}">\n' +
'<head>\n' +
- ' <meta http-equiv="Content-Type" content="text/html;charset=${charset}" />\n' +
- ' <title></title>\n' +
+ '${indentation}<meta http-equiv="Content-Type" content="text/html;charset=${charset}" />\n' +
+ '${indentation}<title></title>\n' +
'</head>\n' +
'<body>\n\t${child}|\n</body>\n' +
'</html>',
'html:xs': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' +
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="${lang}">\n' +
'<head>\n' +
- ' <meta http-equiv="Content-Type" content="text/html;charset=${charset}" />\n' +
- ' <title></title>\n' +
+ '${indentation}<meta http-equiv="Content-Type" content="text/html;charset=${charset}" />\n' +
+ '${indentation}<title></title>\n' +
'</head>\n' +
'<body>\n\t${child}|\n</body>\n' +
'</html>',
'html:xxs': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' +
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="${lang}">\n' +
'<head>\n' +
- ' <meta http-equiv="Content-Type" content="text/html;charset=${charset}" />\n' +
- ' <title></title>\n' +
+ '${indentation}<meta http-equiv="Content-Type" content="text/html;charset=${charset}" />\n' +
+ '${indentation}<title></title>\n' +
'</head>\n' +
'<body>\n\t${child}|\n</body>\n' +
'</html>',
'html:5': '<!DOCTYPE HTML>\n' +
'<html lang="${locale}">\n' +
'<head>\n' +
- ' <meta charset="${charset}">\n' +
- ' <title></title>\n' +
+ '${indentation}<meta charset="${charset}">\n' +
+ '${indentation}<title></title>\n' +
'</head>\n' +
'<body>\n\t${child}|\n</body>\n' +
'</html>'

0 comments on commit dcbefb4

Please sign in to comment.