'''
High-level editor interface that communicates with underlying editor (like
Espresso, Coda, etc.) or browser.
Basically, you should call set_context(obj) method to
set up undelying editor context before using any other method.
This interface is used by zen_actions.py for performing different
actions like Expand abbreviation
@example
import zen_editor
zen_editor.set_context(obj);
//now you are ready to use editor object
zen_editor.get_selection_range();
@author Sergey Chikuyonok (serge.che@gmail.com)
@link http://chikuyonok.ru
'''
class ZenEditor():
def __init__(self):
pass
def set_context(self, context):
"""
Setup underlying editor context. You should call this method
before using any Zen Coding action.
@param context: context object
"""
pass
def get_selection_range(self):
"""
Returns character indexes of selected text
@return: list of start and end indexes
@example
start, end = zen_editor.get_selection_range();
print('%s, %s' % (start, end))
"""
return 0, 0
def create_selection(self, start, end=None):
"""
Creates selection from start to end character
indexes. If end is ommited, this method should place caret
and start index
@type start: int
@type end: int
@example
zen_editor.create_selection(10, 40)
# move caret to 15th character
zen_editor.create_selection(15)
"""
pass
def get_current_line_range(self):
"""
Returns current line's start and end indexes
@return: list of start and end indexes
@example
start, end = zen_editor.get_current_line_range();
print('%s, %s' % (start, end))
"""
return 0, 0
def get_caret_pos(self):
""" Returns current caret position """
return 0
def set_caret_pos(self, pos):
"""
Set new caret position
@type pos: int
"""
pass
def get_current_line(self):
"""
Returns content of current line
@return: str
"""
return ''
def replace_content(self, value, start=None, end=None):
"""
Replace editor's content or it's part (from start to
end index). If value contains
caret_placeholder, the editor will put caret into
this position. If you skip start and end
arguments, the whole target's content will be replaced with
value.
If you pass start argument only,
the value will be placed at start string
index of current content.
If you pass start and end arguments,
the corresponding substring of current target's content will be
replaced with value
@param value: Content you want to paste
@type value: str
@param start: Start index of editor's content
@type start: int
@param end: End index of editor's content
@type end: int
"""
pass
def get_content(self):
"""
Returns editor's content
@return: str
"""
return ''
def get_syntax(self):
"""
Returns current editor's syntax mode
@return: str
"""
return 'html'
def get_profile_name(self):
"""
Returns current output profile name (@see zen_coding#setup_profile)
@return {String}
"""
return 'xhtml'