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:

Key input events are the same as Tk event parterns (To be honest, they ARE Tk events)

Devparrot events are the following:

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 :

This what is done by the an shortcuts.

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 will delete the selected text (replace it by a empty string)