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.
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. */
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 */
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. */
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 */
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 */
85 GEANY_KEY_GROUP_PROJECT
,
86 GEANY_KEY_GROUP_EDITOR
,
87 GEANY_KEY_GROUP_CLIPBOARD
,
88 GEANY_KEY_GROUP_SELECT
,
89 GEANY_KEY_GROUP_FORMAT
,
90 GEANY_KEY_GROUP_INSERT
,
91 GEANY_KEY_GROUP_SETTINGS
,
92 GEANY_KEY_GROUP_SEARCH
,
95 GEANY_KEY_GROUP_FOCUS
,
96 GEANY_KEY_GROUP_NOTEBOOK
,
97 GEANY_KEY_GROUP_DOCUMENT
,
98 GEANY_KEY_GROUP_BUILD
,
99 GEANY_KEY_GROUP_TOOLS
,
100 GEANY_KEY_GROUP_HELP
,
101 GEANY_KEY_GROUP_COUNT
104 /** File group keybinding command IDs */
108 GEANY_KEYS_FILE_OPEN
,
109 GEANY_KEYS_FILE_OPENSELECTED
,
110 GEANY_KEYS_FILE_SAVE
,
111 GEANY_KEYS_FILE_SAVEAS
,
112 GEANY_KEYS_FILE_SAVEALL
,
113 GEANY_KEYS_FILE_PRINT
,
114 GEANY_KEYS_FILE_CLOSE
,
115 GEANY_KEYS_FILE_CLOSEALL
,
116 GEANY_KEYS_FILE_RELOAD
,
117 GEANY_KEYS_FILE_OPENLASTTAB
,
118 GEANY_KEYS_FILE_COUNT
121 /** Project group keybinding command IDs */
124 GEANY_KEYS_PROJECT_PROPERTIES
,
125 GEANY_KEYS_PROJECT_COUNT
128 /** Editor group keybinding command IDs */
131 GEANY_KEYS_EDITOR_UNDO
,
132 GEANY_KEYS_EDITOR_REDO
,
133 GEANY_KEYS_EDITOR_DELETELINE
,
134 GEANY_KEYS_EDITOR_DUPLICATELINE
,
135 GEANY_KEYS_EDITOR_TRANSPOSELINE
,
136 GEANY_KEYS_EDITOR_SCROLLTOLINE
,
137 GEANY_KEYS_EDITOR_SCROLLLINEUP
,
138 GEANY_KEYS_EDITOR_SCROLLLINEDOWN
,
139 GEANY_KEYS_EDITOR_COMPLETESNIPPET
,
140 GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION
,
141 GEANY_KEYS_EDITOR_SNIPPETNEXTCURSOR
,
142 GEANY_KEYS_EDITOR_CONTEXTACTION
,
143 GEANY_KEYS_EDITOR_AUTOCOMPLETE
,
144 GEANY_KEYS_EDITOR_CALLTIP
,
145 GEANY_KEYS_EDITOR_MACROLIST
,
146 GEANY_KEYS_EDITOR_DELETELINETOEND
,
147 GEANY_KEYS_EDITOR_WORDPARTCOMPLETION
,
148 GEANY_KEYS_EDITOR_MOVELINEUP
,
149 GEANY_KEYS_EDITOR_MOVELINEDOWN
,
150 GEANY_KEYS_EDITOR_COUNT
153 /** Clipboard group keybinding command IDs */
156 GEANY_KEYS_CLIPBOARD_CUT
,
157 GEANY_KEYS_CLIPBOARD_COPY
,
158 GEANY_KEYS_CLIPBOARD_PASTE
,
159 GEANY_KEYS_CLIPBOARD_CUTLINE
,
160 GEANY_KEYS_CLIPBOARD_COPYLINE
,
161 GEANY_KEYS_CLIPBOARD_COUNT
164 /** Select group keybinding command IDs */
168 GEANY_KEYS_SELECT_ALL
,
169 GEANY_KEYS_SELECT_WORD
,
170 GEANY_KEYS_SELECT_LINE
,
171 GEANY_KEYS_SELECT_PARAGRAPH
,
172 GEANY_KEYS_SELECT_WORDPARTLEFT
,
173 GEANY_KEYS_SELECT_WORDPARTRIGHT
,
174 GEANY_KEYS_SELECT_COUNT
177 /** Format group keybinding command IDs */
180 GEANY_KEYS_FORMAT_TOGGLECASE
,
181 GEANY_KEYS_FORMAT_COMMENTLINETOGGLE
,
182 GEANY_KEYS_FORMAT_COMMENTLINE
,
183 GEANY_KEYS_FORMAT_UNCOMMENTLINE
,
184 GEANY_KEYS_FORMAT_INCREASEINDENT
,
185 GEANY_KEYS_FORMAT_DECREASEINDENT
,
186 GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE
,
187 GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE
,
188 GEANY_KEYS_FORMAT_AUTOINDENT
,
189 GEANY_KEYS_FORMAT_SENDTOCMD1
,
190 GEANY_KEYS_FORMAT_SENDTOCMD2
,
191 GEANY_KEYS_FORMAT_SENDTOCMD3
,
192 GEANY_KEYS_FORMAT_SENDTOVTE
,
193 GEANY_KEYS_FORMAT_REFLOWPARAGRAPH
,
194 GEANY_KEYS_FORMAT_COUNT
197 /** Insert group keybinding command IDs */
200 GEANY_KEYS_INSERT_DATE
,
201 GEANY_KEYS_INSERT_ALTWHITESPACE
,
202 GEANY_KEYS_INSERT_COUNT
205 /** Settings group keybinding command IDs */
208 GEANY_KEYS_SETTINGS_PREFERENCES
,
209 GEANY_KEYS_SETTINGS_PLUGINPREFERENCES
,
210 GEANY_KEYS_SETTINGS_COUNT
213 /** Search group keybinding command IDs */
216 GEANY_KEYS_SEARCH_FIND
,
217 GEANY_KEYS_SEARCH_FINDNEXT
,
218 GEANY_KEYS_SEARCH_FINDPREVIOUS
,
219 GEANY_KEYS_SEARCH_FINDINFILES
,
220 GEANY_KEYS_SEARCH_REPLACE
,
221 GEANY_KEYS_SEARCH_FINDNEXTSEL
,
222 GEANY_KEYS_SEARCH_FINDPREVSEL
,
223 GEANY_KEYS_SEARCH_NEXTMESSAGE
,
224 GEANY_KEYS_SEARCH_PREVIOUSMESSAGE
,
225 GEANY_KEYS_SEARCH_FINDUSAGE
,
226 GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE
,
227 GEANY_KEYS_SEARCH_MARKALL
,
228 GEANY_KEYS_SEARCH_COUNT
231 /** Go To group keybinding command IDs */
234 GEANY_KEYS_GOTO_FORWARD
,
235 GEANY_KEYS_GOTO_BACK
,
236 GEANY_KEYS_GOTO_LINE
,
237 GEANY_KEYS_GOTO_LINESTART
,
238 GEANY_KEYS_GOTO_LINEEND
,
239 GEANY_KEYS_GOTO_MATCHINGBRACE
,
240 GEANY_KEYS_GOTO_TOGGLEMARKER
,
241 GEANY_KEYS_GOTO_NEXTMARKER
,
242 GEANY_KEYS_GOTO_PREVIOUSMARKER
,
243 GEANY_KEYS_GOTO_PREVWORDPART
,
244 GEANY_KEYS_GOTO_NEXTWORDPART
,
245 GEANY_KEYS_GOTO_TAGDEFINITION
,
246 GEANY_KEYS_GOTO_TAGDECLARATION
,
247 GEANY_KEYS_GOTO_LINEENDVISUAL
,
248 GEANY_KEYS_GOTO_COUNT
251 /** View group keybinding command IDs */
254 GEANY_KEYS_VIEW_TOGGLEALL
,
255 GEANY_KEYS_VIEW_FULLSCREEN
,
256 GEANY_KEYS_VIEW_MESSAGEWINDOW
,
257 GEANY_KEYS_VIEW_SIDEBAR
,
258 GEANY_KEYS_VIEW_ZOOMIN
,
259 GEANY_KEYS_VIEW_ZOOMOUT
,
260 GEANY_KEYS_VIEW_ZOOMRESET
,
261 GEANY_KEYS_VIEW_COUNT
264 /** Focus group keybinding command IDs */
265 /* TODO when the plugin get increased the next time, re-arrange these keybindings */
268 GEANY_KEYS_FOCUS_EDITOR
,
269 GEANY_KEYS_FOCUS_SCRIBBLE
,
270 GEANY_KEYS_FOCUS_VTE
,
271 GEANY_KEYS_FOCUS_SEARCHBAR
,
272 GEANY_KEYS_FOCUS_SIDEBAR
,
273 GEANY_KEYS_FOCUS_COMPILER
,
274 GEANY_KEYS_FOCUS_MESSAGES
,
275 GEANY_KEYS_FOCUS_MESSAGE_WINDOW
,
276 GEANY_KEYS_FOCUS_SIDEBAR_DOCUMENT_LIST
,
277 GEANY_KEYS_FOCUS_SIDEBAR_SYMBOL_LIST
,
278 GEANY_KEYS_FOCUS_COUNT
281 /** Notebook Tab group keybinding command IDs */
284 GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT
,
285 GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT
,
286 GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED
,
287 GEANY_KEYS_NOTEBOOK_MOVETABLEFT
,
288 GEANY_KEYS_NOTEBOOK_MOVETABRIGHT
,
289 GEANY_KEYS_NOTEBOOK_MOVETABFIRST
,
290 GEANY_KEYS_NOTEBOOK_MOVETABLAST
,
291 GEANY_KEYS_NOTEBOOK_COUNT
294 /** Document group keybinding command IDs */
297 GEANY_KEYS_DOCUMENT_REPLACETABS
,
298 GEANY_KEYS_DOCUMENT_REPLACESPACES
,
299 GEANY_KEYS_DOCUMENT_TOGGLEFOLD
,
300 GEANY_KEYS_DOCUMENT_FOLDALL
,
301 GEANY_KEYS_DOCUMENT_UNFOLDALL
,
302 GEANY_KEYS_DOCUMENT_RELOADTAGLIST
,
303 GEANY_KEYS_DOCUMENT_LINEWRAP
,
304 GEANY_KEYS_DOCUMENT_LINEBREAK
,
305 GEANY_KEYS_DOCUMENT_COUNT
308 /** Build group keybinding command IDs */
311 GEANY_KEYS_BUILD_COMPILE
,
312 GEANY_KEYS_BUILD_LINK
,
313 GEANY_KEYS_BUILD_MAKE
,
314 GEANY_KEYS_BUILD_MAKEOWNTARGET
,
315 GEANY_KEYS_BUILD_MAKEOBJECT
,
316 GEANY_KEYS_BUILD_NEXTERROR
,
317 GEANY_KEYS_BUILD_PREVIOUSERROR
,
318 GEANY_KEYS_BUILD_RUN
,
319 GEANY_KEYS_BUILD_OPTIONS
,
320 GEANY_KEYS_BUILD_COUNT
323 /** Tools group keybinding command IDs */
326 GEANY_KEYS_TOOLS_OPENCOLORCHOOSER
,
327 GEANY_KEYS_TOOLS_COUNT
330 /** Help group keybinding command IDs */
333 GEANY_KEYS_HELP_HELP
,
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
);