17
18
* along with this program; if not, write to the Free Software
18
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
* $Id: keybindings.h 814 2006-09-12 08:32:52Z eht16 $
21
* $Id: keybindings.h 2395 2008-03-24 13:40:01Z ntrel $
26
* Configurable keyboard shortcuts.
24
30
#ifndef GEANY_KEYBINDINGS_H
25
31
#define GEANY_KEYBINDINGS_H 1
27
// holds all user-definable key bindings
28
typedef struct binding
32
// at the moment only needed as keys for the configuration file because indices or tranlatable
33
// strings as keys are not very useful
36
// function pointer to a callback function, just to keep the code in keypress event
37
// callback function clear
38
void (*cb_func) (void);
44
GEANY_KEYS_MENU_NEW = 0,
47
GEANY_KEYS_MENU_SAVEALL,
48
GEANY_KEYS_MENU_PRINT,
49
GEANY_KEYS_MENU_CLOSE,
50
GEANY_KEYS_MENU_CLOSEALL,
51
GEANY_KEYS_MENU_RELOADFILE,
54
GEANY_KEYS_MENU_SELECTALL,
55
GEANY_KEYS_MENU_INSERTDATE,
56
GEANY_KEYS_MENU_PREFERENCES,
57
GEANY_KEYS_MENU_FINDNEXT,
58
GEANY_KEYS_MENU_FINDPREVIOUS,
59
GEANY_KEYS_MENU_REPLACE,
60
GEANY_KEYS_MENU_FINDINFILES,
61
GEANY_KEYS_MENU_GOTOLINE,
62
GEANY_KEYS_MENU_OPENCOLORCHOOSER,
63
GEANY_KEYS_MENU_FULLSCREEN,
64
GEANY_KEYS_MENU_MESSAGEWINDOW,
65
GEANY_KEYS_MENU_SIDEBAR,
66
GEANY_KEYS_MENU_ZOOMIN,
67
GEANY_KEYS_MENU_ZOOMOUT,
68
GEANY_KEYS_MENU_REPLACETABS,
69
GEANY_KEYS_MENU_FOLDALL,
70
GEANY_KEYS_MENU_UNFOLDALL,
33
/* allowed modifier keys (especially NOT Caps lock, no Num lock) */
34
#if GTK_CHECK_VERSION(2, 10, 0)
35
# define GEANY_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | \
36
GDK_META_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK)
38
# define GEANY_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
42
/** Function pointer type used for keybinding callbacks */
43
typedef void (*KeyCallback) (guint key_id);
45
/** Represents a single keybinding action */
46
/* Note: name and label are not const strings so plugins can set them to malloc'd strings
47
* and free them in cleanup(). */
48
typedef struct KeyBinding
50
guint key; /**< Key value in lower-case, such as @c GDK_a */
51
GdkModifierType mods; /**< Modifier keys, such as @c GDK_CONTROL_MASK */
52
gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */
53
gchar *label; /**< Label used in the preferences dialog keybindings tab */
54
KeyCallback callback; /**< Callback function called when the key combination is pressed */
55
GtkWidget *menu_item; /**< Menu item widget for setting the menu accelerator */
59
/** A collection of keybindings grouped together. */
60
typedef struct KeyBindingGroup
62
const gchar *name; /**< Group name used in the configuration file, such as @c "html_chars" */
63
const gchar *label; /**< Group label used in the preferences dialog keybindings tab */
64
gsize count; /**< Count of KeyBinding structs in @a keys */
65
KeyBinding *keys; /**< Fixed array of KeyBinding structs */
69
extern GPtrArray *keybinding_groups; /* array of KeyBindingGroup pointers */
71
extern const gchar keybindings_keyfile_group_name[];
74
/* Note: keybinding_groups is not in the API, so we don't need to increment the ABI when
75
* appending keybindings or keygroups, as the _COUNT item shouldn't be used by plugins. */
77
/** Keybinding group IDs */
81
GEANY_KEY_GROUP_PROJECT,
82
GEANY_KEY_GROUP_EDITOR,
83
GEANY_KEY_GROUP_CLIPBOARD,
84
GEANY_KEY_GROUP_SELECT,
85
GEANY_KEY_GROUP_FORMAT,
86
GEANY_KEY_GROUP_INSERT,
87
GEANY_KEY_GROUP_SETTINGS,
88
GEANY_KEY_GROUP_SEARCH,
91
GEANY_KEY_GROUP_FOCUS,
92
GEANY_KEY_GROUP_NOTEBOOK,
93
GEANY_KEY_GROUP_DOCUMENT,
94
GEANY_KEY_GROUP_BUILD,
95
GEANY_KEY_GROUP_TOOLS,
100
/** File group keybinding command IDs */
104
GEANY_KEYS_FILE_OPEN,
105
GEANY_KEYS_FILE_OPENSELECTED,
106
GEANY_KEYS_FILE_SAVE,
107
GEANY_KEYS_FILE_SAVEAS,
108
GEANY_KEYS_FILE_SAVEALL,
109
GEANY_KEYS_FILE_PRINT,
110
GEANY_KEYS_FILE_CLOSE,
111
GEANY_KEYS_FILE_CLOSEALL,
112
GEANY_KEYS_FILE_RELOAD,
113
GEANY_KEYS_FILE_COUNT
116
/** Project group keybinding command IDs */
119
GEANY_KEYS_PROJECT_PROPERTIES,
120
GEANY_KEYS_PROJECT_COUNT
123
/** Editor group keybinding command IDs */
126
GEANY_KEYS_EDITOR_UNDO,
127
GEANY_KEYS_EDITOR_REDO,
128
GEANY_KEYS_EDITOR_DELETELINE,
129
GEANY_KEYS_EDITOR_DUPLICATELINE,
130
GEANY_KEYS_EDITOR_TRANSPOSELINE,
131
GEANY_KEYS_EDITOR_SCROLLTOLINE,
132
GEANY_KEYS_EDITOR_SCROLLLINEUP,
133
GEANY_KEYS_EDITOR_SCROLLLINEDOWN,
134
GEANY_KEYS_EDITOR_COMPLETESNIPPET,
135
GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION,
136
GEANY_KEYS_EDITOR_CONTEXTACTION,
137
GEANY_KEYS_EDITOR_AUTOCOMPLETE,
138
GEANY_KEYS_EDITOR_CALLTIP,
139
GEANY_KEYS_EDITOR_MACROLIST,
140
GEANY_KEYS_EDITOR_COUNT
143
/** Clipboard group keybinding command IDs */
146
GEANY_KEYS_CLIPBOARD_CUT,
147
GEANY_KEYS_CLIPBOARD_COPY,
148
GEANY_KEYS_CLIPBOARD_PASTE,
149
GEANY_KEYS_CLIPBOARD_CUTLINE,
150
GEANY_KEYS_CLIPBOARD_COPYLINE,
151
GEANY_KEYS_CLIPBOARD_COUNT
154
/** Select group keybinding command IDs */
158
GEANY_KEYS_SELECT_ALL,
159
GEANY_KEYS_SELECT_WORD,
160
GEANY_KEYS_SELECT_LINE,
161
GEANY_KEYS_SELECT_PARAGRAPH,
162
GEANY_KEYS_SELECT_COUNT
165
/** Format group keybinding command IDs */
168
GEANY_KEYS_FORMAT_TOGGLECASE,
169
GEANY_KEYS_FORMAT_COMMENTLINETOGGLE,
170
GEANY_KEYS_FORMAT_COMMENTLINE,
171
GEANY_KEYS_FORMAT_UNCOMMENTLINE,
172
GEANY_KEYS_FORMAT_INCREASEINDENT,
173
GEANY_KEYS_FORMAT_DECREASEINDENT,
174
GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE,
175
GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE,
176
GEANY_KEYS_FORMAT_AUTOINDENT,
177
GEANY_KEYS_FORMAT_SENDTOCMD1,
178
GEANY_KEYS_FORMAT_SENDTOCMD2,
179
GEANY_KEYS_FORMAT_SENDTOCMD3,
180
GEANY_KEYS_FORMAT_COUNT
183
/** Insert group keybinding command IDs */
186
GEANY_KEYS_INSERT_DATE,
187
GEANY_KEYS_INSERT_ALTWHITESPACE,
188
GEANY_KEYS_INSERT_COUNT
191
/** Settings group keybinding command IDs */
194
GEANY_KEYS_SETTINGS_PREFERENCES,
195
GEANY_KEYS_SETTINGS_COUNT
198
/** Search group keybinding command IDs */
201
GEANY_KEYS_SEARCH_FIND,
202
GEANY_KEYS_SEARCH_FINDNEXT,
203
GEANY_KEYS_SEARCH_FINDPREVIOUS,
204
GEANY_KEYS_SEARCH_FINDINFILES,
205
GEANY_KEYS_SEARCH_REPLACE,
206
GEANY_KEYS_SEARCH_FINDNEXTSEL,
207
GEANY_KEYS_SEARCH_FINDPREVSEL,
208
GEANY_KEYS_SEARCH_NEXTMESSAGE,
209
GEANY_KEYS_SEARCH_FINDUSAGE,
210
GEANY_KEYS_SEARCH_COUNT
213
/** Go To group keybinding command IDs */
216
GEANY_KEYS_GOTO_FORWARD,
217
GEANY_KEYS_GOTO_BACK,
218
GEANY_KEYS_GOTO_LINE,
219
GEANY_KEYS_GOTO_MATCHINGBRACE,
220
GEANY_KEYS_GOTO_TOGGLEMARKER,
221
GEANY_KEYS_GOTO_NEXTMARKER,
222
GEANY_KEYS_GOTO_PREVIOUSMARKER,
223
GEANY_KEYS_GOTO_TAGDEFINITION,
224
GEANY_KEYS_GOTO_TAGDECLARATION,
225
GEANY_KEYS_GOTO_COUNT
228
/** View group keybinding command IDs */
231
GEANY_KEYS_VIEW_TOGGLEALL,
232
GEANY_KEYS_VIEW_FULLSCREEN,
233
GEANY_KEYS_VIEW_MESSAGEWINDOW,
234
GEANY_KEYS_VIEW_SIDEBAR,
235
GEANY_KEYS_VIEW_ZOOMIN,
236
GEANY_KEYS_VIEW_ZOOMOUT,
237
GEANY_KEYS_VIEW_COUNT
240
/** Focus group keybinding command IDs */
243
GEANY_KEYS_FOCUS_EDITOR,
244
GEANY_KEYS_FOCUS_SCRIBBLE,
245
GEANY_KEYS_FOCUS_VTE,
246
GEANY_KEYS_FOCUS_SEARCHBAR,
247
GEANY_KEYS_FOCUS_SIDEBAR,
248
GEANY_KEYS_FOCUS_COUNT
251
/** Notebook Tab group keybinding command IDs */
254
GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT,
255
GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT,
256
GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED,
257
GEANY_KEYS_NOTEBOOK_MOVETABLEFT,
258
GEANY_KEYS_NOTEBOOK_MOVETABRIGHT,
259
GEANY_KEYS_NOTEBOOK_MOVETABFIRST,
260
GEANY_KEYS_NOTEBOOK_MOVETABLAST,
261
GEANY_KEYS_NOTEBOOK_COUNT
264
/** Document group keybinding command IDs */
267
GEANY_KEYS_DOCUMENT_REPLACETABS,
268
GEANY_KEYS_DOCUMENT_FOLDALL,
269
GEANY_KEYS_DOCUMENT_UNFOLDALL,
270
GEANY_KEYS_DOCUMENT_RELOADTAGLIST,
271
GEANY_KEYS_DOCUMENT_COUNT
274
/** Build group keybinding command IDs */
71
277
GEANY_KEYS_BUILD_COMPILE,
72
278
GEANY_KEYS_BUILD_LINK,
73
279
GEANY_KEYS_BUILD_MAKE,
74
280
GEANY_KEYS_BUILD_MAKEOWNTARGET,
75
281
GEANY_KEYS_BUILD_MAKEOBJECT,
282
GEANY_KEYS_BUILD_NEXTERROR,
76
283
GEANY_KEYS_BUILD_RUN,
77
284
GEANY_KEYS_BUILD_RUN2,
78
285
GEANY_KEYS_BUILD_OPTIONS,
79
GEANY_KEYS_RELOADTAGLIST,
80
GEANY_KEYS_SWITCH_EDITOR,
81
GEANY_KEYS_SWITCH_SCRIBBLE,
82
GEANY_KEYS_SWITCH_VTE,
83
GEANY_KEYS_SWITCH_TABLEFT,
84
GEANY_KEYS_SWITCH_TABRIGHT,
85
GEANY_KEYS_EDIT_TOLOWERCASE,
86
GEANY_KEYS_EDIT_TOUPPERCASE,
87
GEANY_KEYS_EDIT_DUPLICATELINE,
88
GEANY_KEYS_EDIT_COMMENTLINETOGGLE,
89
GEANY_KEYS_EDIT_COMMENTLINE,
90
GEANY_KEYS_EDIT_UNCOMMENTLINE,
91
GEANY_KEYS_EDIT_INCREASEINDENT,
92
GEANY_KEYS_EDIT_DECREASEINDENT,
93
GEANY_KEYS_EDIT_AUTOCOMPLETE,
94
GEANY_KEYS_EDIT_CALLTIP,
95
GEANY_KEYS_EDIT_MACROLIST,
96
GEANY_KEYS_EDIT_SUPPRESSCOMPLETION,
97
GEANY_KEYS_POPUP_FINDUSAGE,
98
GEANY_KEYS_POPUP_GOTOTAGDEFINITION,
99
GEANY_KEYS_POPUP_GOTOTAGDECLARATION,
103
binding *keys[GEANY_MAX_KEYS];
286
GEANY_KEYS_BUILD_COUNT
289
/** Tools group keybinding command IDs */
292
GEANY_KEYS_TOOLS_OPENCOLORCHOOSER,
293
GEANY_KEYS_TOOLS_COUNT
296
/** Help group keybinding command IDs */
299
GEANY_KEYS_HELP_HELP,
300
GEANY_KEYS_HELP_COUNT
107
304
void keybindings_init(void);
306
void keybindings_load_keyfile(void);
109
308
void keybindings_free(void);
310
void keybindings_set_item(KeyBindingGroup *group, gsize key_id,
311
KeyCallback callback, guint key, GdkModifierType mod,
312
gchar *name, gchar *label, GtkWidget *menu_item);
314
void keybindings_send_command(guint group_id, guint key_id);
316
KeyBinding *keybindings_lookup_item(guint group_id, guint key_id);
111
318
/* just write the content of the keys array to the config file */
112
319
void keybindings_write_to_file(void);
321
void keybindings_show_shortcuts(void);
114
323
/* central keypress event handler, almost all keypress events go to this function */
115
324
gboolean keybindings_got_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data);