Add API docs for keybinding enums.
[geany-mirror.git] / src / keybindings.h
blob893005b4065c71f98f3764e02617b611dd4b2a07
1 /*
2 * keybindings.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2006-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * $Id$
24 #ifndef GEANY_KEYBINDINGS_H
25 #define GEANY_KEYBINDINGS_H 1
27 /** Function pointer type used for keybinding callbacks. */
28 typedef void (*GeanyKeyCallback) (guint key_id);
30 /** Represents a single keybinding action.
31 * Use keybindings_set_item() to set. */
32 typedef struct GeanyKeyBinding
34 guint key; /**< Key value in lower-case, such as @c GDK_a or 0 */
35 GdkModifierType mods; /**< Modifier keys, such as @c GDK_CONTROL_MASK or 0 */
36 gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */
37 /** Label used in the preferences dialog keybindings tab.
38 * May contain underscores - these won't be displayed. */
39 gchar *label;
40 /** Function called when the key combination is pressed, or @c NULL to use the group callback
41 * (preferred). @see plugin_set_key_group(). */
42 GeanyKeyCallback callback;
43 GtkWidget *menu_item; /**< Optional widget to set an accelerator for, or @c NULL */
45 GeanyKeyBinding;
48 /** Function pointer type used for keybinding group callbacks.
49 * You should return @c TRUE to indicate handling the callback. (Occasionally, if the keybinding
50 * cannot apply in the current situation, it is useful to return @c FALSE to allow a later keybinding
51 * with the same key combination to handle it). */
52 typedef gboolean (*GeanyKeyGroupCallback) (guint key_id);
54 /** A collection of keybindings grouped together. */
55 typedef struct GeanyKeyGroup GeanyKeyGroup;
57 /* Plugins should not set these fields. */
58 #ifdef GEANY_PRIVATE
59 struct GeanyKeyGroup
61 const gchar *name; /* Group name used in the configuration file, such as @c "html_chars" */
62 const gchar *label; /* Group label used in the preferences dialog keybindings tab */
63 gsize count; /* number of keybindings the group holds */
64 GeanyKeyBinding *keys; /* array of GeanyKeyBinding structs */
65 gboolean plugin; /* used by plugin */
66 GeanyKeyGroupCallback callback; /* use this or individual keybinding callbacks */
68 #endif
71 extern GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */
73 extern const gchar keybindings_keyfile_group_name[];
76 /* Note: we don't need to increment the plugin ABI when appending keybindings or keygroups,
77 * just make sure to only insert keybindings/groups immediately before the _COUNT item, so
78 * the existing enum values stay the same.
79 * The _COUNT item should not be used by plugins, as it may well change. */
81 /** Keybinding group IDs */
82 enum GeanyKeyGroupID
84 GEANY_KEY_GROUP_FILE, /**< Group for @ref GeanyKeysFileID. */
85 GEANY_KEY_GROUP_PROJECT, /**< Group for @ref GeanyKeysProjectID. */
86 GEANY_KEY_GROUP_EDITOR, /**< Group for @ref GeanyKeysEditorID. */
87 GEANY_KEY_GROUP_CLIPBOARD, /**< Group for @ref GeanyKeysClipboardID. */
88 GEANY_KEY_GROUP_SELECT, /**< Group for @ref GeanyKeysSelectID. */
89 GEANY_KEY_GROUP_FORMAT, /**< Group for @ref GeanyKeysFormatID. */
90 GEANY_KEY_GROUP_INSERT, /**< Group for @ref GeanyKeysInsertID. */
91 GEANY_KEY_GROUP_SETTINGS, /**< Group for @ref GeanyKeysSettingsID. */
92 GEANY_KEY_GROUP_SEARCH, /**< Group for @ref GeanyKeysSearchID. */
93 GEANY_KEY_GROUP_GOTO, /**< Group for @ref GeanyKeysGoToID. */
94 GEANY_KEY_GROUP_VIEW, /**< Group for @ref GeanyKeysViewID. */
95 GEANY_KEY_GROUP_FOCUS, /**< Group for @ref GeanyKeysFocusID. */
96 GEANY_KEY_GROUP_NOTEBOOK, /**< Group for @ref GeanyKeysNotebookTabID. */
97 GEANY_KEY_GROUP_DOCUMENT, /**< Group for @ref GeanyKeysDocumentID. */
98 GEANY_KEY_GROUP_BUILD, /**< Group for @ref GeanyKeysBuildID. */
99 GEANY_KEY_GROUP_TOOLS, /**< Group for @ref GeanyKeysToolsID. */
100 GEANY_KEY_GROUP_HELP, /**< Group for @ref GeanyKeysHelpID. */
101 GEANY_KEY_GROUP_COUNT
104 /** File group keybinding command IDs */
105 enum GeanyKeysFileID
107 GEANY_KEYS_FILE_NEW, /**< Keybinding. */
108 GEANY_KEYS_FILE_OPEN, /**< Keybinding. */
109 GEANY_KEYS_FILE_OPENSELECTED, /**< Keybinding. */
110 GEANY_KEYS_FILE_SAVE, /**< Keybinding. */
111 GEANY_KEYS_FILE_SAVEAS, /**< Keybinding. */
112 GEANY_KEYS_FILE_SAVEALL, /**< Keybinding. */
113 GEANY_KEYS_FILE_PRINT, /**< Keybinding. */
114 GEANY_KEYS_FILE_CLOSE, /**< Keybinding. */
115 GEANY_KEYS_FILE_CLOSEALL, /**< Keybinding. */
116 GEANY_KEYS_FILE_RELOAD, /**< Keybinding. */
117 GEANY_KEYS_FILE_OPENLASTTAB, /**< Keybinding. */
118 GEANY_KEYS_FILE_COUNT
121 /** Project group keybinding command IDs */
122 enum GeanyKeysProjectID
124 GEANY_KEYS_PROJECT_PROPERTIES, /**< Keybinding. */
125 GEANY_KEYS_PROJECT_COUNT
128 /** Editor group keybinding command IDs */
129 enum GeanyKeysEditorID
131 GEANY_KEYS_EDITOR_UNDO, /**< Keybinding. */
132 GEANY_KEYS_EDITOR_REDO, /**< Keybinding. */
133 GEANY_KEYS_EDITOR_DELETELINE, /**< Keybinding. */
134 GEANY_KEYS_EDITOR_DUPLICATELINE, /**< Keybinding. */
135 GEANY_KEYS_EDITOR_TRANSPOSELINE, /**< Keybinding. */
136 GEANY_KEYS_EDITOR_SCROLLTOLINE, /**< Keybinding. */
137 GEANY_KEYS_EDITOR_SCROLLLINEUP, /**< Keybinding. */
138 GEANY_KEYS_EDITOR_SCROLLLINEDOWN, /**< Keybinding. */
139 GEANY_KEYS_EDITOR_COMPLETESNIPPET, /**< Keybinding. */
140 GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION, /**< Keybinding. */
141 GEANY_KEYS_EDITOR_SNIPPETNEXTCURSOR, /**< Keybinding. */
142 GEANY_KEYS_EDITOR_CONTEXTACTION, /**< Keybinding. */
143 GEANY_KEYS_EDITOR_AUTOCOMPLETE, /**< Keybinding. */
144 GEANY_KEYS_EDITOR_CALLTIP, /**< Keybinding. */
145 GEANY_KEYS_EDITOR_MACROLIST, /**< Keybinding. */
146 GEANY_KEYS_EDITOR_DELETELINETOEND, /**< Keybinding. */
147 GEANY_KEYS_EDITOR_WORDPARTCOMPLETION, /**< Keybinding. */
148 GEANY_KEYS_EDITOR_MOVELINEUP, /**< Keybinding. */
149 GEANY_KEYS_EDITOR_MOVELINEDOWN, /**< Keybinding. */
150 GEANY_KEYS_EDITOR_COUNT
153 /** Clipboard group keybinding command IDs */
154 enum GeanyKeysClipboardID
156 GEANY_KEYS_CLIPBOARD_CUT, /**< Keybinding. */
157 GEANY_KEYS_CLIPBOARD_COPY, /**< Keybinding. */
158 GEANY_KEYS_CLIPBOARD_PASTE, /**< Keybinding. */
159 GEANY_KEYS_CLIPBOARD_CUTLINE, /**< Keybinding. */
160 GEANY_KEYS_CLIPBOARD_COPYLINE, /**< Keybinding. */
161 GEANY_KEYS_CLIPBOARD_COUNT
164 /** Select group keybinding command IDs */
165 enum GeanyKeysSelectID
168 GEANY_KEYS_SELECT_ALL, /**< Keybinding. */
169 GEANY_KEYS_SELECT_WORD, /**< Keybinding. */
170 GEANY_KEYS_SELECT_LINE, /**< Keybinding. */
171 GEANY_KEYS_SELECT_PARAGRAPH, /**< Keybinding. */
172 GEANY_KEYS_SELECT_WORDPARTLEFT, /**< Keybinding. */
173 GEANY_KEYS_SELECT_WORDPARTRIGHT, /**< Keybinding. */
174 GEANY_KEYS_SELECT_COUNT
177 /** Format group keybinding command IDs */
178 enum GeanyKeysFormatID
180 GEANY_KEYS_FORMAT_TOGGLECASE, /**< Keybinding. */
181 GEANY_KEYS_FORMAT_COMMENTLINETOGGLE, /**< Keybinding. */
182 GEANY_KEYS_FORMAT_COMMENTLINE, /**< Keybinding. */
183 GEANY_KEYS_FORMAT_UNCOMMENTLINE, /**< Keybinding. */
184 GEANY_KEYS_FORMAT_INCREASEINDENT, /**< Keybinding. */
185 GEANY_KEYS_FORMAT_DECREASEINDENT, /**< Keybinding. */
186 GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE, /**< Keybinding. */
187 GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE, /**< Keybinding. */
188 GEANY_KEYS_FORMAT_AUTOINDENT, /**< Keybinding. */
189 GEANY_KEYS_FORMAT_SENDTOCMD1, /**< Keybinding. */
190 GEANY_KEYS_FORMAT_SENDTOCMD2, /**< Keybinding. */
191 GEANY_KEYS_FORMAT_SENDTOCMD3, /**< Keybinding. */
192 GEANY_KEYS_FORMAT_SENDTOVTE, /**< Keybinding. */
193 GEANY_KEYS_FORMAT_REFLOWPARAGRAPH, /**< Keybinding. */
194 GEANY_KEYS_FORMAT_COUNT
197 /** Insert group keybinding command IDs */
198 enum GeanyKeysInsertID
200 GEANY_KEYS_INSERT_DATE, /**< Keybinding. */
201 GEANY_KEYS_INSERT_ALTWHITESPACE, /**< Keybinding. */
202 GEANY_KEYS_INSERT_COUNT
205 /** Settings group keybinding command IDs */
206 enum GeanyKeysSettingsID
208 GEANY_KEYS_SETTINGS_PREFERENCES, /**< Keybinding. */
209 GEANY_KEYS_SETTINGS_PLUGINPREFERENCES, /**< Keybinding. */
210 GEANY_KEYS_SETTINGS_COUNT
213 /** Search group keybinding command IDs */
214 enum GeanyKeysSearchID
216 GEANY_KEYS_SEARCH_FIND, /**< Keybinding. */
217 GEANY_KEYS_SEARCH_FINDNEXT, /**< Keybinding. */
218 GEANY_KEYS_SEARCH_FINDPREVIOUS, /**< Keybinding. */
219 GEANY_KEYS_SEARCH_FINDINFILES, /**< Keybinding. */
220 GEANY_KEYS_SEARCH_REPLACE, /**< Keybinding. */
221 GEANY_KEYS_SEARCH_FINDNEXTSEL, /**< Keybinding. */
222 GEANY_KEYS_SEARCH_FINDPREVSEL, /**< Keybinding. */
223 GEANY_KEYS_SEARCH_NEXTMESSAGE, /**< Keybinding. */
224 GEANY_KEYS_SEARCH_PREVIOUSMESSAGE, /**< Keybinding. */
225 GEANY_KEYS_SEARCH_FINDUSAGE, /**< Keybinding. */
226 GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, /**< Keybinding. */
227 GEANY_KEYS_SEARCH_MARKALL, /**< Keybinding. */
228 GEANY_KEYS_SEARCH_COUNT
231 /** Go To group keybinding command IDs */
232 enum GeanyKeysGoToID
234 GEANY_KEYS_GOTO_FORWARD, /**< Keybinding. */
235 GEANY_KEYS_GOTO_BACK, /**< Keybinding. */
236 GEANY_KEYS_GOTO_LINE, /**< Keybinding. */
237 GEANY_KEYS_GOTO_LINESTART, /**< Keybinding. */
238 GEANY_KEYS_GOTO_LINEEND, /**< Keybinding. */
239 GEANY_KEYS_GOTO_MATCHINGBRACE, /**< Keybinding. */
240 GEANY_KEYS_GOTO_TOGGLEMARKER, /**< Keybinding. */
241 GEANY_KEYS_GOTO_NEXTMARKER, /**< Keybinding. */
242 GEANY_KEYS_GOTO_PREVIOUSMARKER, /**< Keybinding. */
243 GEANY_KEYS_GOTO_PREVWORDPART, /**< Keybinding. */
244 GEANY_KEYS_GOTO_NEXTWORDPART, /**< Keybinding. */
245 GEANY_KEYS_GOTO_TAGDEFINITION, /**< Keybinding. */
246 GEANY_KEYS_GOTO_TAGDECLARATION, /**< Keybinding. */
247 GEANY_KEYS_GOTO_LINEENDVISUAL, /**< Keybinding. */
248 GEANY_KEYS_GOTO_COUNT
251 /** View group keybinding command IDs */
252 enum GeanyKeysViewID
254 GEANY_KEYS_VIEW_TOGGLEALL, /**< Keybinding. */
255 GEANY_KEYS_VIEW_FULLSCREEN, /**< Keybinding. */
256 GEANY_KEYS_VIEW_MESSAGEWINDOW, /**< Keybinding. */
257 GEANY_KEYS_VIEW_SIDEBAR, /**< Keybinding. */
258 GEANY_KEYS_VIEW_ZOOMIN, /**< Keybinding. */
259 GEANY_KEYS_VIEW_ZOOMOUT, /**< Keybinding. */
260 GEANY_KEYS_VIEW_ZOOMRESET, /**< Keybinding. */
261 GEANY_KEYS_VIEW_COUNT
264 /** Focus group keybinding command IDs */
265 /* TODO when the plugin ABI get increased the next time, rearrange these keybindings */
266 enum GeanyKeysFocusID
268 GEANY_KEYS_FOCUS_EDITOR, /**< Keybinding. */
269 GEANY_KEYS_FOCUS_SCRIBBLE, /**< Keybinding. */
270 GEANY_KEYS_FOCUS_VTE, /**< Keybinding. */
271 GEANY_KEYS_FOCUS_SEARCHBAR, /**< Keybinding. */
272 GEANY_KEYS_FOCUS_SIDEBAR, /**< Keybinding. */
273 GEANY_KEYS_FOCUS_COMPILER, /**< Keybinding. */
274 GEANY_KEYS_FOCUS_MESSAGES, /**< Keybinding. */
275 GEANY_KEYS_FOCUS_MESSAGE_WINDOW, /**< Keybinding. */
276 GEANY_KEYS_FOCUS_SIDEBAR_DOCUMENT_LIST, /**< Keybinding. */
277 GEANY_KEYS_FOCUS_SIDEBAR_SYMBOL_LIST, /**< Keybinding. */
278 GEANY_KEYS_FOCUS_COUNT
281 /** Notebook Tab group keybinding command IDs */
282 enum GeanyKeysNotebookTabID
284 GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT, /**< Keybinding. */
285 GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT, /**< Keybinding. */
286 GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED, /**< Keybinding. */
287 GEANY_KEYS_NOTEBOOK_MOVETABLEFT, /**< Keybinding. */
288 GEANY_KEYS_NOTEBOOK_MOVETABRIGHT, /**< Keybinding. */
289 GEANY_KEYS_NOTEBOOK_MOVETABFIRST, /**< Keybinding. */
290 GEANY_KEYS_NOTEBOOK_MOVETABLAST, /**< Keybinding. */
291 GEANY_KEYS_NOTEBOOK_COUNT
294 /** Document group keybinding command IDs */
295 enum GeanyKeysDocumentID
297 GEANY_KEYS_DOCUMENT_REPLACETABS, /**< Keybinding. */
298 GEANY_KEYS_DOCUMENT_REPLACESPACES, /**< Keybinding. */
299 GEANY_KEYS_DOCUMENT_TOGGLEFOLD, /**< Keybinding. */
300 GEANY_KEYS_DOCUMENT_FOLDALL, /**< Keybinding. */
301 GEANY_KEYS_DOCUMENT_UNFOLDALL, /**< Keybinding. */
302 GEANY_KEYS_DOCUMENT_RELOADTAGLIST, /**< Keybinding. */
303 GEANY_KEYS_DOCUMENT_LINEWRAP, /**< Keybinding. */
304 GEANY_KEYS_DOCUMENT_LINEBREAK, /**< Keybinding. */
305 GEANY_KEYS_DOCUMENT_COUNT
308 /** Build group keybinding command IDs */
309 enum GeanyKeysBuildID
311 GEANY_KEYS_BUILD_COMPILE, /**< Keybinding. */
312 GEANY_KEYS_BUILD_LINK, /**< Keybinding. */
313 GEANY_KEYS_BUILD_MAKE, /**< Keybinding. */
314 GEANY_KEYS_BUILD_MAKEOWNTARGET, /**< Keybinding. */
315 GEANY_KEYS_BUILD_MAKEOBJECT, /**< Keybinding. */
316 GEANY_KEYS_BUILD_NEXTERROR, /**< Keybinding. */
317 GEANY_KEYS_BUILD_PREVIOUSERROR, /**< Keybinding. */
318 GEANY_KEYS_BUILD_RUN, /**< Keybinding. */
319 GEANY_KEYS_BUILD_OPTIONS, /**< Keybinding. */
320 GEANY_KEYS_BUILD_COUNT
323 /** Tools group keybinding command IDs */
324 enum GeanyKeysToolsID
326 GEANY_KEYS_TOOLS_OPENCOLORCHOOSER, /**< Keybinding. */
327 GEANY_KEYS_TOOLS_COUNT
330 /** Help group keybinding command IDs */
331 enum GeanyKeysHelpID
333 GEANY_KEYS_HELP_HELP, /**< Keybinding. */
334 GEANY_KEYS_HELP_COUNT
338 void keybindings_init(void);
340 void keybindings_load_keyfile(void);
342 void keybindings_free(void);
344 GeanyKeyGroup *keybindings_set_group(GeanyKeyGroup *group, const gchar *section_name,
345 const gchar *label, gsize count, GeanyKeyGroupCallback callback) G_GNUC_WARN_UNUSED_RESULT;
347 void keybindings_free_group(GeanyKeyGroup *group);
349 GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
350 GeanyKeyCallback callback, guint key, GdkModifierType mod,
351 gchar *name, gchar *label, GtkWidget *menu_item);
353 GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id);
355 gchar *keybindings_get_label(GeanyKeyBinding *kb);
357 void keybindings_update_combo(GeanyKeyBinding *kb, guint key, GdkModifierType mods);
359 void keybindings_send_command(guint group_id, guint key_id);
361 GeanyKeyBinding *keybindings_lookup_item(guint group_id, guint key_id);
363 /* just write the content of the keys array to the config file */
364 void keybindings_write_to_file(void);
366 void keybindings_show_shortcuts(void);
368 const GeanyKeyBinding *keybindings_check_event(GdkEventKey *ev, gint *group_id, gint *binding_id);
370 #endif