Merge branch 'master' of https://github.com/konsolebox/geany into konsolebox-master
[geany-mirror.git] / src / keybindings.h
blob064801005ae0ebb697a7459f8cc9b91f6d7cd0c5
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 "gtkcompat.h"
27 G_BEGIN_DECLS
29 /** Defines the primary modifier mask which is the Ctrl key mask on
30 * UNIX/Windows and Command key mask on OS X. When testing for the mask
31 * presence, use together with keybindings_get_modifiers() which adds
32 * @c GEANY_PRIMARY_MOD_MASK when needed.
33 * @since 1.25. */
34 #ifdef __APPLE__
35 #define GEANY_PRIMARY_MOD_MASK GDK_META_MASK
36 #else
37 #define GEANY_PRIMARY_MOD_MASK GDK_CONTROL_MASK
38 #endif
40 /** Function pointer type used for keybinding callbacks. */
41 typedef void (*GeanyKeyCallback) (guint key_id);
43 /** Represents a single keybinding action.
44 * Use keybindings_set_item() to set. */
45 typedef struct GeanyKeyBinding
47 guint key; /**< Key value in lower-case, such as @c GDK_a or 0 */
48 GdkModifierType mods; /**< Modifier keys, such as @c GDK_CONTROL_MASK or 0 */
49 gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */
50 /** Label used in the preferences dialog keybindings tab.
51 * May contain underscores - these won't be displayed. */
52 gchar *label;
53 /** Function called when the key combination is pressed, or @c NULL to use the group callback
54 * (preferred). @see plugin_set_key_group(). */
55 GeanyKeyCallback callback;
56 GtkWidget *menu_item; /**< Optional widget to set an accelerator for, or @c NULL */
57 guint id;
58 guint default_key;
59 GdkModifierType default_mods;
61 GeanyKeyBinding;
64 /** Function pointer type used for keybinding group callbacks.
65 * You should return @c TRUE to indicate handling the callback. (Occasionally, if the keybinding
66 * cannot apply in the current situation, it is useful to return @c FALSE to allow a later keybinding
67 * with the same key combination to handle it). */
68 typedef gboolean (*GeanyKeyGroupCallback) (guint key_id);
70 /** A collection of keybindings grouped together. */
71 typedef struct GeanyKeyGroup GeanyKeyGroup;
74 /* Note: we don't need to break the plugin ABI when appending keybinding or keygroup IDs,
75 * just make sure to insert immediately before the _COUNT item, so
76 * the existing enum values stay the same. */
78 /** Keybinding group IDs for use with keybindings_send_command(). */
79 /* These IDs are used to lookup a group. */
80 enum GeanyKeyGroupID
82 GEANY_KEY_GROUP_FILE, /**< Group. */
83 GEANY_KEY_GROUP_PROJECT, /**< Group. */
84 GEANY_KEY_GROUP_EDITOR, /**< Group. */
85 GEANY_KEY_GROUP_CLIPBOARD, /**< Group. */
86 GEANY_KEY_GROUP_SELECT, /**< Group. */
87 GEANY_KEY_GROUP_FORMAT, /**< Group. */
88 GEANY_KEY_GROUP_INSERT, /**< Group. */
89 GEANY_KEY_GROUP_SETTINGS, /**< Group. */
90 GEANY_KEY_GROUP_SEARCH, /**< Group. */
91 GEANY_KEY_GROUP_GOTO, /**< Group. */
92 GEANY_KEY_GROUP_VIEW, /**< Group. */
93 GEANY_KEY_GROUP_FOCUS, /**< Group. */
94 GEANY_KEY_GROUP_NOTEBOOK, /**< Group. */
95 GEANY_KEY_GROUP_DOCUMENT, /**< Group. */
96 GEANY_KEY_GROUP_BUILD, /**< Group. */
97 GEANY_KEY_GROUP_TOOLS, /**< Group. */
98 GEANY_KEY_GROUP_HELP, /**< Group. */
99 GEANY_KEY_GROUP_COUNT /* must not be used by plugins */
102 /** Keybinding command IDs for use with keybindings_send_command(). */
103 /* These IDs are used to lookup a keybinding. */
104 enum GeanyKeyBindingID
106 GEANY_KEYS_EDITOR_TRANSPOSELINE, /**< Keybinding. */
107 GEANY_KEYS_DOCUMENT_REMOVE_ERROR_INDICATORS, /**< Keybinding. */
108 GEANY_KEYS_FOCUS_SEARCHBAR, /**< Keybinding. */
109 GEANY_KEYS_SEARCH_FIND, /**< Keybinding. */
110 GEANY_KEYS_FILE_SAVEALL, /**< Keybinding. */
111 GEANY_KEYS_GOTO_NEXTMARKER, /**< Keybinding. */
112 GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT, /**< Keybinding. */
113 GEANY_KEYS_VIEW_ZOOMOUT, /**< Keybinding. */
114 GEANY_KEYS_GOTO_LINE, /**< Keybinding. */
115 GEANY_KEYS_DOCUMENT_TOGGLEFOLD, /**< Keybinding. */
116 GEANY_KEYS_BUILD_COMPILE, /**< Keybinding. */
117 GEANY_KEYS_EDITOR_SCROLLTOLINE, /**< Keybinding. */
118 GEANY_KEYS_DOCUMENT_UNFOLDALL, /**< Keybinding. */
119 GEANY_KEYS_GOTO_MATCHINGBRACE, /**< Keybinding. */
120 GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, /**< Keybinding. */
121 GEANY_KEYS_CLIPBOARD_PASTE, /**< Keybinding. */
122 GEANY_KEYS_BUILD_MAKE, /**< Keybinding. */
123 GEANY_KEYS_INSERT_ALTWHITESPACE, /**< Keybinding. */
124 GEANY_KEYS_EDITOR_SCROLLLINEDOWN, /**< Keybinding. */
125 GEANY_KEYS_VIEW_TOGGLEALL, /**< Keybinding. */
126 GEANY_KEYS_VIEW_FULLSCREEN, /**< Keybinding. */
127 GEANY_KEYS_GOTO_LINEEND, /**< Keybinding. */
128 GEANY_KEYS_EDITOR_CALLTIP, /**< Keybinding. */
129 GEANY_KEYS_FILE_PRINT, /**< Keybinding. */
130 GEANY_KEYS_EDITOR_DUPLICATELINE, /**< Keybinding. */
131 GEANY_KEYS_FOCUS_SCRIBBLE, /**< Keybinding. */
132 GEANY_KEYS_TOOLS_OPENCOLORCHOOSER, /**< Keybinding. */
133 GEANY_KEYS_SEARCH_PREVIOUSMESSAGE, /**< Keybinding. */
134 GEANY_KEYS_FILE_CLOSE, /**< Keybinding. */
135 GEANY_KEYS_DOCUMENT_REPLACETABS, /**< Keybinding. */
136 GEANY_KEYS_FILE_RELOAD, /**< Keybinding. */
137 GEANY_KEYS_SEARCH_FINDNEXTSEL, /**< Keybinding. */
138 GEANY_KEYS_FOCUS_MESSAGES, /**< Keybinding. */
139 GEANY_KEYS_BUILD_RUN, /**< Keybinding. */
140 GEANY_KEYS_HELP_HELP, /**< Keybinding. */
141 GEANY_KEYS_SETTINGS_PLUGINPREFERENCES, /**< Keybinding. */
142 GEANY_KEYS_VIEW_ZOOMRESET, /**< Keybinding. */
143 GEANY_KEYS_SELECT_WORD, /**< Keybinding. */
144 GEANY_KEYS_FORMAT_INCREASEINDENT, /**< Keybinding. */
145 GEANY_KEYS_SETTINGS_PREFERENCES, /**< Keybinding. */
146 GEANY_KEYS_FORMAT_SENDTOCMD3, /**< Keybinding. */
147 GEANY_KEYS_DOCUMENT_FOLDALL, /**< Keybinding. */
148 GEANY_KEYS_FORMAT_SENDTOVTE, /**< Keybinding. */
149 GEANY_KEYS_PROJECT_PROPERTIES, /**< Keybinding. */
150 GEANY_KEYS_DOCUMENT_LINEWRAP, /**< Keybinding. */
151 GEANY_KEYS_EDITOR_MACROLIST, /**< Keybinding.
152 * @deprecated 1.25, it doesn't do anything anymore */
153 GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION, /**< Keybinding. */
154 GEANY_KEYS_FOCUS_SIDEBAR_SYMBOL_LIST, /**< Keybinding. */
155 GEANY_KEYS_GOTO_LINESTART, /**< Keybinding. */
156 GEANY_KEYS_SEARCH_FINDUSAGE, /**< Keybinding. */
157 GEANY_KEYS_FILE_NEW, /**< Keybinding. */
158 GEANY_KEYS_EDITOR_SNIPPETNEXTCURSOR, /**< Keybinding. */
159 GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT, /**< Keybinding. */
160 GEANY_KEYS_FILE_SAVE, /**< Keybinding. */
161 GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE, /**< Keybinding. */
162 GEANY_KEYS_SEARCH_FINDNEXT, /**< Keybinding. */
163 GEANY_KEYS_GOTO_TOGGLEMARKER, /**< Keybinding. */
164 GEANY_KEYS_GOTO_TAGDEFINITION, /**< Keybinding. */
165 GEANY_KEYS_SEARCH_NEXTMESSAGE, /**< Keybinding. */
166 GEANY_KEYS_EDITOR_DELETELINETOEND, /**< Keybinding. */
167 GEANY_KEYS_FORMAT_AUTOINDENT, /**< Keybinding. */
168 GEANY_KEYS_FILE_OPENSELECTED, /**< Keybinding. */
169 GEANY_KEYS_GOTO_BACK, /**< Keybinding. */
170 GEANY_KEYS_INSERT_DATE, /**< Keybinding. */
171 GEANY_KEYS_BUILD_PREVIOUSERROR, /**< Keybinding. */
172 GEANY_KEYS_GOTO_LINEENDVISUAL, /**< Keybinding. */
173 GEANY_KEYS_DOCUMENT_REPLACESPACES, /**< Keybinding. */
174 GEANY_KEYS_FOCUS_EDITOR, /**< Keybinding. */
175 GEANY_KEYS_SELECT_WORDPARTRIGHT, /**< Keybinding. */
176 GEANY_KEYS_VIEW_MESSAGEWINDOW, /**< Keybinding. */
177 GEANY_KEYS_FOCUS_SIDEBAR_DOCUMENT_LIST, /**< Keybinding. */
178 GEANY_KEYS_FORMAT_REFLOWPARAGRAPH, /**< Keybinding. */
179 GEANY_KEYS_EDITOR_MOVELINEUP, /**< Keybinding. */
180 GEANY_KEYS_NOTEBOOK_MOVETABLEFT, /**< Keybinding. */
181 GEANY_KEYS_SELECT_LINE, /**< Keybinding. */
182 GEANY_KEYS_EDITOR_UNDO, /**< Keybinding. */
183 GEANY_KEYS_EDITOR_MOVELINEDOWN, /**< Keybinding. */
184 GEANY_KEYS_CLIPBOARD_COPYLINE, /**< Keybinding. */
185 GEANY_KEYS_BUILD_MAKEOWNTARGET, /**< Keybinding. */
186 GEANY_KEYS_FORMAT_SENDTOCMD2, /**< Keybinding. */
187 GEANY_KEYS_SEARCH_MARKALL, /**< Keybinding. */
188 GEANY_KEYS_BUILD_LINK, /**< Keybinding. */
189 GEANY_KEYS_FILE_CLOSEALL, /**< Keybinding. */
190 GEANY_KEYS_GOTO_FORWARD, /**< Keybinding. */
191 GEANY_KEYS_CLIPBOARD_CUT, /**< Keybinding. */
192 GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED, /**< Keybinding. */
193 GEANY_KEYS_NOTEBOOK_MOVETABRIGHT, /**< Keybinding. */
194 GEANY_KEYS_BUILD_OPTIONS, /**< Keybinding. */
195 GEANY_KEYS_GOTO_TAGDECLARATION, /**< Keybinding. */
196 GEANY_KEYS_FILE_OPEN, /**< Keybinding. */
197 GEANY_KEYS_EDITOR_COMPLETESNIPPET, /**< Keybinding. */
198 GEANY_KEYS_FORMAT_UNCOMMENTLINE, /**< Keybinding. */
199 GEANY_KEYS_FOCUS_VTE, /**< Keybinding. */
200 GEANY_KEYS_FORMAT_SENDTOCMD1, /**< Keybinding. */
201 GEANY_KEYS_SELECT_WORDPARTLEFT, /**< Keybinding. */
202 GEANY_KEYS_VIEW_ZOOMIN, /**< Keybinding. */
203 GEANY_KEYS_DOCUMENT_LINEBREAK, /**< Keybinding. */
204 GEANY_KEYS_EDITOR_REDO, /**< Keybinding. */
205 GEANY_KEYS_EDITOR_CONTEXTACTION, /**< Keybinding. */
206 GEANY_KEYS_SEARCH_FINDPREVSEL, /**< Keybinding. */
207 GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE, /**< Keybinding. */
208 GEANY_KEYS_FORMAT_COMMENTLINETOGGLE, /**< Keybinding. */
209 GEANY_KEYS_SELECT_ALL, /**< Keybinding. */
210 GEANY_KEYS_DOCUMENT_RELOADTAGLIST, /**< Keybinding. */
211 GEANY_KEYS_BUILD_NEXTERROR, /**< Keybinding. */
212 GEANY_KEYS_NOTEBOOK_MOVETABLAST, /**< Keybinding. */
213 GEANY_KEYS_SELECT_PARAGRAPH, /**< Keybinding. */
214 GEANY_KEYS_EDITOR_DELETELINE, /**< Keybinding. */
215 GEANY_KEYS_CLIPBOARD_COPY, /**< Keybinding. */
216 GEANY_KEYS_VIEW_SIDEBAR, /**< Keybinding. */
217 GEANY_KEYS_FILE_SAVEAS, /**< Keybinding. */
218 GEANY_KEYS_FORMAT_COMMENTLINE, /**< Keybinding. */
219 GEANY_KEYS_GOTO_PREVWORDPART, /**< Keybinding. */
220 GEANY_KEYS_SEARCH_FINDPREVIOUS, /**< Keybinding. */
221 GEANY_KEYS_SEARCH_REPLACE, /**< Keybinding. */
222 GEANY_KEYS_EDITOR_WORDPARTCOMPLETION, /**< Keybinding. */
223 GEANY_KEYS_EDITOR_AUTOCOMPLETE, /**< Keybinding. */
224 GEANY_KEYS_FOCUS_SIDEBAR, /**< Keybinding. */
225 GEANY_KEYS_FOCUS_MESSAGE_WINDOW, /**< Keybinding. */
226 GEANY_KEYS_NOTEBOOK_MOVETABFIRST, /**< Keybinding. */
227 GEANY_KEYS_GOTO_PREVIOUSMARKER, /**< Keybinding. */
228 GEANY_KEYS_EDITOR_SCROLLLINEUP, /**< Keybinding. */
229 GEANY_KEYS_FOCUS_COMPILER, /**< Keybinding. */
230 GEANY_KEYS_FORMAT_TOGGLECASE, /**< Keybinding. */
231 GEANY_KEYS_CLIPBOARD_CUTLINE, /**< Keybinding. */
232 GEANY_KEYS_DOCUMENT_REMOVE_MARKERS, /**< Keybinding. */
233 GEANY_KEYS_BUILD_MAKEOBJECT, /**< Keybinding. */
234 GEANY_KEYS_FORMAT_DECREASEINDENT, /**< Keybinding. */
235 GEANY_KEYS_FILE_OPENLASTTAB, /**< Keybinding. */
236 GEANY_KEYS_SEARCH_FINDINFILES, /**< Keybinding. */
237 GEANY_KEYS_GOTO_NEXTWORDPART, /**< Keybinding. */
238 GEANY_KEYS_INSERT_LINEAFTER, /**< Keybinding. */
239 GEANY_KEYS_INSERT_LINEBEFORE, /**< Keybinding. */
240 GEANY_KEYS_DOCUMENT_REMOVE_MARKERS_INDICATORS, /**< Keybinding. */
241 GEANY_KEYS_PROJECT_OPEN, /**< Keybinding. */
242 GEANY_KEYS_PROJECT_NEW, /**< Keybinding. */
243 GEANY_KEYS_PROJECT_CLOSE, /**< Keybinding. */
244 GEANY_KEYS_FORMAT_JOINLINES, /**< Keybinding. */
245 GEANY_KEYS_GOTO_LINESTARTVISUAL, /**< Keybinding. */
246 GEANY_KEYS_DOCUMENT_CLONE, /**< Keybinding. */
247 GEANY_KEYS_FILE_QUIT, /**< Keybinding. */
248 GEANY_KEYS_COUNT /* must not be used by plugins */
252 void keybindings_send_command(guint group_id, guint key_id);
254 GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
255 GeanyKeyCallback callback, guint key, GdkModifierType mod,
256 const gchar *name, const gchar *label, GtkWidget *menu_item);
258 GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id);
260 GdkModifierType keybindings_get_modifiers(GdkModifierType mods);
262 #ifdef GEANY_PRIVATE
264 extern GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */
267 void keybindings_init(void);
269 void keybindings_load_keyfile(void);
271 void keybindings_free(void);
273 GeanyKeyGroup *keybindings_get_core_group(guint id);
275 GeanyKeyGroup *keybindings_set_group(GeanyKeyGroup *group, const gchar *section_name,
276 const gchar *label, gsize count, GeanyKeyGroupCallback callback) G_GNUC_WARN_UNUSED_RESULT;
278 void keybindings_free_group(GeanyKeyGroup *group);
280 gchar *keybindings_get_label(GeanyKeyBinding *kb);
282 void keybindings_update_combo(GeanyKeyBinding *kb, guint key, GdkModifierType mods);
284 GeanyKeyBinding *keybindings_lookup_item(guint group_id, guint key_id);
286 /* just write the content of the keys array to the config file */
287 void keybindings_write_to_file(void);
289 void keybindings_show_shortcuts(void);
291 gboolean keybindings_check_event(GdkEventKey *ev, GeanyKeyBinding *kb);
293 void keybindings_dialog_show_prefs_scroll(const gchar *name);
295 #endif /* GEANY_PRIVATE */
297 G_END_DECLS
299 #endif /* GEANY_KEYBINDINGS_H */