def act(context, actionObject, action_name, undo_name=None): zen_editor = ZenEditor(context) if action_name == 'wrap_with_abbreviation': abbr = actionObject.userInput().stringValue() if abbr: return zen_coding.run_action(action_name, zen_editor, abbr) else: return zen_coding.run_action(action_name, zen_editor) return False
def wrap(self, context, abbr): # Set up the config variables if abbr: editor = ZenEditor(context) return zen_coding.run_action('wrap_with_abbreviation', editor, abbr) else: return False
def act(context, direction='out', mode='auto'): zen_target = 'html, html *, xml, xml *' if (mode.lower() == 'auto' and tea.cursor_in_zone(context, zen_target)) or \ mode.lower() == 'zen': # HTML or XML, so use Zen-coding's excellent balancing commands # Using this method rather than tea.get_single_range() is better # because it won't cause the action to fail if there's more than # one selection editor = ZenEditor(context) action_name = 'match_pair_inward' if direction == 'in' else 'match_pair_outward' return zen_coding.run_action(action_name, editor) else: # No HTML or XML, so we'll rely on itemizers ranges = tea.get_ranges(context) targets = [] for range in ranges: if direction.lower() == 'in': item = tea.get_item_for_range(context, range) if item is None: # No item, so jump to next iteration continue new_range = item.range() if new_range.location == range.location and \ new_range.length == range.length: items = item.childItems() if len(items) > 0: new_range = items[0].range() targets.append(new_range) else: item = tea.get_item_parent_for_range(context, range) if item is None: continue targets.append(item.range()) # Set the selections, and return if len(targets) > 0: context.setSelectedRanges_([NSValue.valueWithRange_(range) for range in targets]) return True else: return False
def act(controller, bundle, options): context = tea.get_context(controller) action_name = tea.get_option(options, "action", "") editor = ZenEditor(context) return zen_coding.run_action(action_name, editor)
#!/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)
#!/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('update_image_size', editor)
#!/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('match_pair', editor)
#!/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('encode_decode_base64', editor)
#!/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('split_join_tag', editor)
#!/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('remove_tag', editor)
#!/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('prev_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() zen_coding.run_action('toggle_comment', editor)