[wingide-users] A couple WingIDE newbie questions
Wing IDE Support
support at wingware.com
Fri Dec 17 14:33:14 EST 2004
On Fri, 17 Dec 2004, Brian Almond wrote:
> Apologies if these have been asked before, I tried googling the
> archive and didn't come up with answers.
> I'm new to WingIDE, and have been walking through the tutorial and
> browsing the manual.
> While I was playing around in the editor, I noticed that there didn't
> seem to be a shortcut to delete the current line. I then figured I'd
> look up the existing shortcuts. This led me to the keymap files. I
> tried to make a keybinding which called multiple commands (I saw
> another keybinding that had a couple commands separated by commas and
> thought that was the way to go) in order to delete the current line.
> This didn't seem to work, as though it was only performing one of the
> I next tried it as a macro, and it's easy to do. However, is there a
> place to save macros and recall them later? From the looks of things,
> you can only have one macro defined at a time?
You can't save macros yet -- we plan to add that but currently are
concentrating on scripting since that's much more powerful.
> Is writing some sort of external script (to create your own command)
> and binding it to a key the only way to create a keybinding which
> executes multiple commands? (ie. wrap up the functionality of those
> multiple commands into your external script/custom command)
Yes, you can do this. The support is quite rough and undocumented in
2.0.1 but we're currently working on cleaning this up for 2.0.2. I've
implemented it using hacks to work around the problems in 2.0.1. The code
is below and should work if you drop it into scripts/editor-extensions.py
in your Wing installation (note many of the _* functions are already
there). The cleaned up version of this will be in this file in 2.0.2.
# All the _* functions are temporary to compensate for 2.0.1 bugs
editor = app.fSingletons.fGuiMgr.GetActiveDocument()
if editor is None or not isinstance(editor, edit.editor.CSourceEditor):
return wingapi.CAPIEditor(app.fSingletons, editor)
return wingapi.CAPIDocument(editor.fSingletons, editor.fEditor.fCache)
def _get_line_from_position(doc, pos):
def _get_line_start(doc, lineno):
def _get_line_end(doc, lineno):
def _delete_chars(doc, start, end):
return doc.fCache.fDoc.delete_chars(start, end - start + 1)
def _get_char_range(doc, start, end):
if start == end:
return doc.fCache.fDoc.get_char_range(start, end - start)
def _insert_chars(editor, pos, chars):
def _move_right(editor, count):
for i in range(0, count):
"""Deletes current line"""
editor = _get_active_editor(app)
tab_size = _get_tab_size(editor)
doc = _get_document(editor)
start, end = _get_selection(editor)
lineno = _get_line_from_position(doc, start)
line_start = _get_line_start(doc, lineno)
line_end = _get_line_end(doc, lineno)
_delete_chars(doc, line_start, line_end)
More information about the wingide-users