Normalize use of header guards and extern "C" guards
[geany-mirror.git] / src / keybindings.h
blobac874e37c87d20a6fb1ed38fedea77d923dd824b
1 /*
2 * keybindings.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2006-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef GEANY_KEYBINDINGS_H
23 #define GEANY_KEYBINDINGS_H 1
25 #include <gtk/gtk.h>
27 G_BEGIN_DECLS
29 /** Function pointer type used for keybinding callbacks. */
30 typedef void (*GeanyKeyCallback) (guint key_id);
32 /** Represents a single keybinding action.
33 * Use keybindings_set_item() to set. */
34 typedef struct GeanyKeyBinding
36 guint key; /**< Key value in lower-case, such as @c GDK_a or 0 */
37 GdkModifierType mods; /**< Modifier keys, such as @c GDK_CONTROL_MASK or 0 */
38 gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */
39 /** Label used in the preferences dialog keybindings tab.
40 * May contain underscores - these won't be displayed. */
41 gchar *label;
42 /** Function called when the key combination is pressed, or @c NULL to use the group callback
43 * (preferred). @see plugin_set_key_group(). */
44 GeanyKeyCallback callback;
45 GtkWidget *menu_item; /**< Optional widget to set an accelerator for, or @c NULL */
46 guint id;
47 guint default_key;
48 GdkModifierType default_mods;
50 GeanyKeyBinding;
53 /** Function pointer type used for keybinding group callbacks.
54 * You should return @c TRUE to indicate handling the callback. (Occasionally, if the keybinding
55 * cannot apply in the current situation, it is useful to return @c FALSE to allow a later keybinding
56 * with the same key combination to handle it). */
57 typedef gboolean (*GeanyKeyGroupCallback) (guint key_id);
59 /** A collection of keybindings grouped together. */
60 typedef struct GeanyKeyGroup GeanyKeyGroup;
63 extern GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */
66 /* Note: we don't need to break the plugin ABI when appending keybinding or keygroup IDs,
67 * just make sure to insert immediately before the _COUNT item, so
68 * the existing enum values stay the same. */
70 /** Keybinding group IDs for use with keybindings_send_command(). */
71 /* These IDs are used to lookup a group. */
72 enum GeanyKeyGroupID
74 GEANY_KEY_GROUP_FILE, /**< Group. */
75 GEANY_KEY_GROUP_PROJECT, /**< Group. */
76 GEANY_KEY_GROUP_EDITOR, /**< Group. */
77 GEANY_KEY_GROUP_CLIPBOARD, /**< Group. */
78 GEANY_KEY_GROUP_SELECT, /**< Group. */
79 GEANY_KEY_GROUP_FORMAT, /**< Group. */
80 GEANY_KEY_GROUP_INSERT, /**< Group. */
81 GEANY_KEY_GROUP_SETTINGS, /**< Group. */
82 GEANY_KEY_GROUP_SEARCH, /**< Group. */
83 GEANY_KEY_GROUP_GOTO, /**< Group. */
84 GEANY_KEY_GROUP_VIEW, /**< Group. */
85 GEANY_KEY_GROUP_FOCUS, /**< Group. */
86 GEANY_KEY_GROUP_NOTEBOOK, /**< Group. */
87 GEANY_KEY_GROUP_DOCUMENT, /**< Group. */
88 GEANY_KEY_GROUP_BUILD, /**< Group. */
89 GEANY_KEY_GROUP_TOOLS, /**< Group. */
90 GEANY_KEY_GROUP_HELP, /**< Group. */
91 GEANY_KEY_GROUP_COUNT /* must not be used by plugins */
94 /** Keybinding command IDs for use with keybindings_send_command(). */
95 /* These IDs are used to lookup a keybinding. */
96 enum GeanyKeyBindingID
98 GEANY_KEYS_EDITOR_TRANSPOSELINE, /**< Keybinding. */
99 GEANY_KEYS_DOCUMENT_REMOVE_ERROR_INDICATORS, /**< Keybinding. */
100 GEANY_KEYS_FOCUS_SEARCHBAR, /**< Keybinding. */
101 GEANY_KEYS_SEARCH_FIND, /**< Keybinding. */
102 GEANY_KEYS_FILE_SAVEALL, /**< Keybinding. */
103 GEANY_KEYS_GOTO_NEXTMARKER, /**< Keybinding. */
104 GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT, /**< Keybinding. */
105 GEANY_KEYS_VIEW_ZOOMOUT, /**< Keybinding. */
106 GEANY_KEYS_GOTO_LINE, /**< Keybinding. */
107 GEANY_KEYS_DOCUMENT_TOGGLEFOLD, /**< Keybinding. */
108 GEANY_KEYS_BUILD_COMPILE, /**< Keybinding. */
109 GEANY_KEYS_EDITOR_SCROLLTOLINE, /**< Keybinding. */
110 GEANY_KEYS_DOCUMENT_UNFOLDALL, /**< Keybinding. */
111 GEANY_KEYS_GOTO_MATCHINGBRACE, /**< Keybinding. */
112 GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, /**< Keybinding. */
113 GEANY_KEYS_CLIPBOARD_PASTE, /**< Keybinding. */
114 GEANY_KEYS_BUILD_MAKE, /**< Keybinding. */
115 GEANY_KEYS_INSERT_ALTWHITESPACE, /**< Keybinding. */
116 GEANY_KEYS_EDITOR_SCROLLLINEDOWN, /**< Keybinding. */
117 GEANY_KEYS_VIEW_TOGGLEALL, /**< Keybinding. */
118 GEANY_KEYS_VIEW_FULLSCREEN, /**< Keybinding. */
119 GEANY_KEYS_GOTO_LINEEND, /**< Keybinding. */
120 GEANY_KEYS_EDITOR_CALLTIP, /**< Keybinding. */
121 GEANY_KEYS_FILE_PRINT, /**< Keybinding. */
122 GEANY_KEYS_EDITOR_DUPLICATELINE, /**< Keybinding. */
123 GEANY_KEYS_FOCUS_SCRIBBLE, /**< Keybinding. */
124 GEANY_KEYS_TOOLS_OPENCOLORCHOOSER, /**< Keybinding. */
125 GEANY_KEYS_SEARCH_PREVIOUSMESSAGE, /**< Keybinding. */
126 GEANY_KEYS_FILE_CLOSE, /**< Keybinding. */
127 GEANY_KEYS_DOCUMENT_REPLACETABS, /**< Keybinding. */
128 GEANY_KEYS_FILE_RELOAD, /**< Keybinding. */
129 GEANY_KEYS_SEARCH_FINDNEXTSEL, /**< Keybinding. */
130 GEANY_KEYS_FOCUS_MESSAGES, /**< Keybinding. */
131 GEANY_KEYS_BUILD_RUN, /**< Keybinding. */
132 GEANY_KEYS_HELP_HELP, /**< Keybinding. */
133 GEANY_KEYS_SETTINGS_PLUGINPREFERENCES, /**< Keybinding. */
134 GEANY_KEYS_VIEW_ZOOMRESET, /**< Keybinding. */
135 GEANY_KEYS_SELECT_WORD, /**< Keybinding. */
136 GEANY_KEYS_FORMAT_INCREASEINDENT, /**< Keybinding. */
137 GEANY_KEYS_SETTINGS_PREFERENCES, /**< Keybinding. */
138 GEANY_KEYS_FORMAT_SENDTOCMD3, /**< Keybinding. */
139 GEANY_KEYS_DOCUMENT_FOLDALL, /**< Keybinding. */
140 GEANY_KEYS_FORMAT_SENDTOVTE, /**< Keybinding. */
141 GEANY_KEYS_PROJECT_PROPERTIES, /**< Keybinding. */
142 GEANY_KEYS_DOCUMENT_LINEWRAP, /**< Keybinding. */
143 GEANY_KEYS_EDITOR_MACROLIST, /**< Keybinding. */
144 GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION, /**< Keybinding. */
145 GEANY_KEYS_FOCUS_SIDEBAR_SYMBOL_LIST, /**< Keybinding. */
146 GEANY_KEYS_GOTO_LINESTART, /**< Keybinding. */
147 GEANY_KEYS_SEARCH_FINDUSAGE, /**< Keybinding. */
148 GEANY_KEYS_FILE_NEW, /**< Keybinding. */
149 GEANY_KEYS_EDITOR_SNIPPETNEXTCURSOR, /**< Keybinding. */
150 GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT, /**< Keybinding. */
151 GEANY_KEYS_FILE_SAVE, /**< Keybinding. */
152 GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE, /**< Keybinding. */
153 GEANY_KEYS_SEARCH_FINDNEXT, /**< Keybinding. */
154 GEANY_KEYS_GOTO_TOGGLEMARKER, /**< Keybinding. */
155 GEANY_KEYS_GOTO_TAGDEFINITION, /**< Keybinding. */
156 GEANY_KEYS_SEARCH_NEXTMESSAGE, /**< Keybinding. */
157 GEANY_KEYS_EDITOR_DELETELINETOEND, /**< Keybinding. */
158 GEANY_KEYS_FORMAT_AUTOINDENT, /**< Keybinding. */
159 GEANY_KEYS_FILE_OPENSELECTED, /**< Keybinding. */
160 GEANY_KEYS_GOTO_BACK, /**< Keybinding. */
161 GEANY_KEYS_INSERT_DATE, /**< Keybinding. */
162 GEANY_KEYS_BUILD_PREVIOUSERROR, /**< Keybinding. */
163 GEANY_KEYS_GOTO_LINEENDVISUAL, /**< Keybinding. */
164 GEANY_KEYS_DOCUMENT_REPLACESPACES, /**< Keybinding. */
165 GEANY_KEYS_FOCUS_EDITOR, /**< Keybinding. */
166 GEANY_KEYS_SELECT_WORDPARTRIGHT, /**< Keybinding. */
167 GEANY_KEYS_VIEW_MESSAGEWINDOW, /**< Keybinding. */
168 GEANY_KEYS_FOCUS_SIDEBAR_DOCUMENT_LIST, /**< Keybinding. */
169 GEANY_KEYS_FORMAT_REFLOWPARAGRAPH, /**< Keybinding. */
170 GEANY_KEYS_EDITOR_MOVELINEUP, /**< Keybinding. */
171 GEANY_KEYS_NOTEBOOK_MOVETABLEFT, /**< Keybinding. */
172 GEANY_KEYS_SELECT_LINE, /**< Keybinding. */
173 GEANY_KEYS_EDITOR_UNDO, /**< Keybinding. */
174 GEANY_KEYS_EDITOR_MOVELINEDOWN, /**< Keybinding. */
175 GEANY_KEYS_CLIPBOARD_COPYLINE, /**< Keybinding. */
176 GEANY_KEYS_BUILD_MAKEOWNTARGET, /**< Keybinding. */
177 GEANY_KEYS_FORMAT_SENDTOCMD2, /**< Keybinding. */
178 GEANY_KEYS_SEARCH_MARKALL, /**< Keybinding. */
179 GEANY_KEYS_BUILD_LINK, /**< Keybinding. */
180 GEANY_KEYS_FILE_CLOSEALL, /**< Keybinding. */
181 GEANY_KEYS_GOTO_FORWARD, /**< Keybinding. */
182 GEANY_KEYS_CLIPBOARD_CUT, /**< Keybinding. */
183 GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED, /**< Keybinding. */
184 GEANY_KEYS_NOTEBOOK_MOVETABRIGHT, /**< Keybinding. */
185 GEANY_KEYS_BUILD_OPTIONS, /**< Keybinding. */
186 GEANY_KEYS_GOTO_TAGDECLARATION, /**< Keybinding. */
187 GEANY_KEYS_FILE_OPEN, /**< Keybinding. */
188 GEANY_KEYS_EDITOR_COMPLETESNIPPET, /**< Keybinding. */
189 GEANY_KEYS_FORMAT_UNCOMMENTLINE, /**< Keybinding. */
190 GEANY_KEYS_FOCUS_VTE, /**< Keybinding. */
191 GEANY_KEYS_FORMAT_SENDTOCMD1, /**< Keybinding. */
192 GEANY_KEYS_SELECT_WORDPARTLEFT, /**< Keybinding. */
193 GEANY_KEYS_VIEW_ZOOMIN, /**< Keybinding. */
194 GEANY_KEYS_DOCUMENT_LINEBREAK, /**< Keybinding. */
195 GEANY_KEYS_EDITOR_REDO, /**< Keybinding. */
196 GEANY_KEYS_EDITOR_CONTEXTACTION, /**< Keybinding. */
197 GEANY_KEYS_SEARCH_FINDPREVSEL, /**< Keybinding. */
198 GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE, /**< Keybinding. */
199 GEANY_KEYS_FORMAT_COMMENTLINETOGGLE, /**< Keybinding. */
200 GEANY_KEYS_SELECT_ALL, /**< Keybinding. */
201 GEANY_KEYS_DOCUMENT_RELOADTAGLIST, /**< Keybinding. */
202 GEANY_KEYS_BUILD_NEXTERROR, /**< Keybinding. */
203 GEANY_KEYS_NOTEBOOK_MOVETABLAST, /**< Keybinding. */
204 GEANY_KEYS_SELECT_PARAGRAPH, /**< Keybinding. */
205 GEANY_KEYS_EDITOR_DELETELINE, /**< Keybinding. */
206 GEANY_KEYS_CLIPBOARD_COPY, /**< Keybinding. */
207 GEANY_KEYS_VIEW_SIDEBAR, /**< Keybinding. */
208 GEANY_KEYS_FILE_SAVEAS, /**< Keybinding. */
209 GEANY_KEYS_FORMAT_COMMENTLINE, /**< Keybinding. */
210 GEANY_KEYS_GOTO_PREVWORDPART, /**< Keybinding. */
211 GEANY_KEYS_SEARCH_FINDPREVIOUS, /**< Keybinding. */
212 GEANY_KEYS_SEARCH_REPLACE, /**< Keybinding. */
213 GEANY_KEYS_EDITOR_WORDPARTCOMPLETION, /**< Keybinding. */
214 GEANY_KEYS_EDITOR_AUTOCOMPLETE, /**< Keybinding. */
215 GEANY_KEYS_FOCUS_SIDEBAR, /**< Keybinding. */
216 GEANY_KEYS_FOCUS_MESSAGE_WINDOW, /**< Keybinding. */
217 GEANY_KEYS_NOTEBOOK_MOVETABFIRST, /**< Keybinding. */
218 GEANY_KEYS_GOTO_PREVIOUSMARKER, /**< Keybinding. */
219 GEANY_KEYS_EDITOR_SCROLLLINEUP, /**< Keybinding. */
220 GEANY_KEYS_FOCUS_COMPILER, /**< Keybinding. */
221 GEANY_KEYS_FORMAT_TOGGLECASE, /**< Keybinding. */
222 GEANY_KEYS_CLIPBOARD_CUTLINE, /**< Keybinding. */
223 GEANY_KEYS_DOCUMENT_REMOVE_MARKERS, /**< Keybinding. */
224 GEANY_KEYS_BUILD_MAKEOBJECT, /**< Keybinding. */
225 GEANY_KEYS_FORMAT_DECREASEINDENT, /**< Keybinding. */
226 GEANY_KEYS_FILE_OPENLASTTAB, /**< Keybinding. */
227 GEANY_KEYS_SEARCH_FINDINFILES, /**< Keybinding. */
228 GEANY_KEYS_GOTO_NEXTWORDPART, /**< Keybinding. */
229 GEANY_KEYS_INSERT_LINEAFTER, /**< Keybinding. */
230 GEANY_KEYS_INSERT_LINEBEFORE, /**< Keybinding. */
231 GEANY_KEYS_DOCUMENT_REMOVE_MARKERS_INDICATORS, /**< Keybinding. */
232 GEANY_KEYS_PROJECT_OPEN, /**< Keybinding. */
233 GEANY_KEYS_PROJECT_NEW, /**< Keybinding. */
234 GEANY_KEYS_PROJECT_CLOSE, /**< Keybinding. */
235 GEANY_KEYS_FORMAT_JOINLINES, /**< Keybinding. */
236 GEANY_KEYS_GOTO_LINESTARTVISUAL, /**< Keybinding. */
237 GEANY_KEYS_DOCUMENT_CLONE, /**< Keybinding. */
238 GEANY_KEYS_FILE_QUIT, /**< Keybinding. */
239 GEANY_KEYS_COUNT /* must not be used by plugins */
243 void keybindings_init(void);
245 void keybindings_load_keyfile(void);
247 void keybindings_free(void);
249 GeanyKeyGroup *keybindings_get_core_group(guint id);
251 GeanyKeyGroup *keybindings_set_group(GeanyKeyGroup *group, const gchar *section_name,
252 const gchar *label, gsize count, GeanyKeyGroupCallback callback) G_GNUC_WARN_UNUSED_RESULT;
254 void keybindings_free_group(GeanyKeyGroup *group);
256 GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
257 GeanyKeyCallback callback, guint key, GdkModifierType mod,
258 const gchar *name, const gchar *label, GtkWidget *menu_item);
260 GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id);
262 gchar *keybindings_get_label(GeanyKeyBinding *kb);
264 void keybindings_update_combo(GeanyKeyBinding *kb, guint key, GdkModifierType mods);
266 void keybindings_send_command(guint group_id, guint key_id);
268 GeanyKeyBinding *keybindings_lookup_item(guint group_id, guint key_id);
270 /* just write the content of the keys array to the config file */
271 void keybindings_write_to_file(void);
273 void keybindings_show_shortcuts(void);
275 gboolean keybindings_check_event(GdkEventKey *ev, GeanyKeyBinding *kb);
277 void keybindings_dialog_show_prefs_scroll(const gchar *name);
279 G_END_DECLS
281 #endif /* GEANY_KEYBINDINGS_H */