Bindings
The command bar is not the only way to launch commands, you can also bind a event to a command.
Event
There is two kinds of event:
- A particular set of key inputs
- An Devparrot internal event.
Key input events are the same as Tk event parterns (To be honest, they ARE Tk events)
Devparrot events are the following:
- pathChanged (The path of a document has changed. (After a saveas))
- textSet (The text of a document has been set (After a load))
- save (The document as been saved (After save or saveas))
- documentAdded (A document has been added (After a open or a new/buffer))
- documentDeleted (A document has been removed (After a close))
- currentChanged (The current document has change (After a change of focus))
- pathAccess (A file in this directory (or subdirectory) has been accessed (Before a load))
- modified (A document text has been modified (insertion/supression of text))
- selection (The current selection has changed)
- mark_set (A mark has been set. 'insert' (the cursor position) is a mark.)
- insert (A text has been inserted) -delete (A text has been deleted)
- replace (A text has been replaced)
Command string
Every event can be bind to a command or serie of commands.
The command string to use is almost the same as what you type on the command bar. But they are few differences :
The first one is that you can bind several command to a event. So the command string can be a serie of command separated by a '\n'.
The second one is that if a command doesn't finish by a '\n' the command text is inserted in the command bar instead of beeing executed (The commandbar will also earn the focus). So if you want you command being executed, you must postfix it with '\n'
You can see the '\n' as if the user pressed <Enter> in the command bar.
For exemple :
- "search" will insert the text "search" in the commandbar.
- "search\n'" will launch the command search with no argument.
This what is done by the
Bind
To bind a event to a command, you must use the bind command :
bind add "event_pattern" "commandString"
For exemple :
bind add "<ctrl-d>" "replace %range(sel) ''\n"
After this binding, pressing