| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Lua plugin for Geany - Keybindings</title> |
| 5 |
</head> |
| 6 |
<body style="margin: 32px 25% 24px 5%"> |
| 7 |
<hr><h2>How to assign custom key bindings to scripts</h2><hr> |
| 8 |
Beginning with Geany version 0.14, it is now possible to integrate plugin |
| 9 |
key bindings with Geany's built-in preferences system. This allows for |
| 10 |
much easier configuration, and also helps to resolve conflicts between |
| 11 |
the editor's bindings and the bindings associated with plugins.</p> |
| 12 |
<p> |
| 13 |
To use the new method, you simply create a plain text file named |
| 14 |
"<tt><b>hotkeys.cfg</b></tt>" and place it your <b>/plugins/geanylua/</b> |
| 15 |
folder. In this file you will list any scripts that you want to configure |
| 16 |
keybindings for. The scripts should be listed one per line and may be |
| 17 |
specified either by using an absolute path, or with a path relative |
| 18 |
to your <b>/plugins/geanylua/</b> folder.</p><p> |
| 19 |
After reloading the plugin (or restarting Geany) the scripts will |
| 20 |
appear in Geany's <b>Edit->Preferences->Keybindings</b> dialog. |
| 21 |
The names appearing in the dialog are derived from the filenames in a |
| 22 |
manner similar to the way menu items are created from filenames. |
| 23 |
<br><br> |
| 24 |
</p> |
| 25 |
<hr> |
| 26 |
<h3>(The old way)</h3> |
| 27 |
<p> |
| 28 |
<b>Important:</b> The technique described below has been deprecated in favor |
| 29 |
of Geany's built-in keybinding API. It is still working for now, however |
| 30 |
you are strongly urged to convert your scripts over to the new method. |
| 31 |
The reference below is provided mainly for historical reasons... |
| 32 |
|
| 33 |
</p> |
| 34 |
<p> |
| 35 |
Before we begin, it is assumed that you are comfortable with your current |
| 36 |
keybindings in the editor itself. If you are the sort who |
| 37 |
likes to tweak your editor keybindings on a daily basis, adding script keybindings |
| 38 |
into the mix will likely be an exercise in frustration! This is because there is |
| 39 |
absolutely no coordinated way to detect conflicts between the Geany keybindings |
| 40 |
and script keybindings, or even between the individual scripts. So you |
| 41 |
are the only one responsible to insure that such conflicts don't occur, or at |
| 42 |
least that they don't cause you any major problems. |
| 43 |
</p><p> |
| 44 |
The syntax for enabling a keybinding is quite simple, but it <i>must</i> be the very first line in the script file. |
| 45 |
The line should begin with a double dash (the standard single-line Lua comment marker) followed by a space and the string <tt><b>@ACCEL@</b></tt> followed by another space and then the accelerator specification in standard |
| 46 |
<a href="http://www.gtk.org/api/2.6/gtk/gtk-Keyboard-Accelerators.html#gtk-accelerator-parse">GTK syntax</a>. |
| 47 |
</p><p> |
| 48 |
For example, to launch a script by pressing the keys <b> <u>[Ctrl]</u> <u>[Shift]</u> <u>[J]</u> </b> you could write this as the first line of your script:<br> |
| 49 |
<h3><tt>-- @ACCEL@ <Control><Shift>j</tt></h3> |
| 50 |
<p>Note that such tags are scanned once only when the plugin is loaded, so any changes require reloading the plugin before the change will take effect. |
| 51 |
The plugin can be reloaded either by restarting Geany, or |
| 52 |
by toggling it OFF/ON via Geany's Plugin Manager, |
| 53 |
or by calling the <tt>rescan()</tt> function from inside a script. |
| 54 |
</p> |
| 55 |
<br><hr> |
| 56 |
</body> |
| 57 |
</html> |