Save encoding in session as text
[geany-mirror.git] / src / keybindings.h
blobcabc5db5d5afa2088a79c4028cbd994a502577e2
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 G_BEGIN_DECLS
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 */
44 guint id;
45 guint default_key;
46 GdkModifierType default_mods;
48 GeanyKeyBinding;
51 /** Function pointer type used for keybinding group callbacks.
52 * You should return @c TRUE to indicate handling the callback. (Occasionally, if the keybinding
53 * cannot apply in the current situation, it is useful to return @c FALSE to allow a later keybinding
54 * with the same key combination to handle it). */
55 typedef gboolean (*GeanyKeyGroupCallback) (guint key_id);
57 /** A collection of keybindings grouped together. */
58 typedef struct GeanyKeyGroup GeanyKeyGroup;
60 /* Plugins should not set these fields. */
61 #ifdef GEANY_PRIVATE
62 struct GeanyKeyGroup
64 const gchar *name; /* Group name used in the configuration file, such as @c "html_chars" */
65 const gchar *label; /* Group label used in the preferences dialog keybindings tab */
66 GeanyKeyGroupCallback callback; /* use this or individual keybinding callbacks */
67 gboolean plugin; /* used by plugin */
68 GPtrArray *key_items; /* pointers to GeanyKeyBinding structs */
69 gsize plugin_key_count; /* number of keybindings the group holds */
70 GeanyKeyBinding *plugin_keys; /* array of GeanyKeyBinding structs */
72 #endif
75 extern GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */
78 /* Note: we don't need to break the plugin ABI when appending keybinding or keygroup IDs,
79 * just make sure to insert immediately before the _COUNT item, so
80 * the existing enum values stay the same. */
82 /** Keybinding group IDs for use with keybindings_send_command(). */
83 /* These IDs are used to lookup a group. */
84 enum GeanyKeyGroupID
86 GEANY_KEY_GROUP_FILE, /**< Group. */
87 GEANY_KEY_GROUP_PROJECT, /**< Group. */
88 GEANY_KEY_GROUP_EDITOR, /**< Group. */
89 GEANY_KEY_GROUP_CLIPBOARD, /**< Group. */
90 GEANY_KEY_GROUP_SELECT, /**< Group. */
91 GEANY_KEY_GROUP_FORMAT, /**< Group. */
92 GEANY_KEY_GROUP_INSERT, /**< Group. */
93 GEANY_KEY_GROUP_SETTINGS, /**< Group. */
94 GEANY_KEY_GROUP_SEARCH, /**< Group. */
95 GEANY_KEY_GROUP_GOTO, /**< Group. */
96 GEANY_KEY_GROUP_VIEW, /**< Group. */
97 GEANY_KEY_GROUP_FOCUS, /**< Group. */
98 GEANY_KEY_GROUP_NOTEBOOK, /**< Group. */
99 GEANY_KEY_GROUP_DOCUMENT, /**< Group. */
100 GEANY_KEY_GROUP_BUILD, /**< Group. */
101 GEANY_KEY_GROUP_TOOLS, /**< Group. */
102 GEANY_KEY_GROUP_HELP, /**< Group. */
103 GEANY_KEY_GROUP_COUNT /* must not be used by plugins */
106 /** Keybinding command IDs for use with keybindings_send_command(). */
107 /* These IDs are used to lookup a keybinding. */
108 enum GeanyKeyBindingID
110 GEANY_KEYS_EDITOR_TRANSPOSELINE, /**< Keybinding. */
111 GEANY_KEYS_DOCUMENT_REMOVE_ERROR_INDICATORS, /**< Keybinding. */
112 GEANY_KEYS_FOCUS_SEARCHBAR, /**< Keybinding. */
113 GEANY_KEYS_SEARCH_FIND, /**< Keybinding. */
114 GEANY_KEYS_FILE_SAVEALL, /**< Keybinding. */
115 GEANY_KEYS_GOTO_NEXTMARKER, /**< Keybinding. */
116 GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT, /**< Keybinding. */
117 GEANY_KEYS_VIEW_ZOOMOUT, /**< Keybinding. */
118 GEANY_KEYS_GOTO_LINE, /**< Keybinding. */
119 GEANY_KEYS_DOCUMENT_TOGGLEFOLD, /**< Keybinding. */
120 GEANY_KEYS_BUILD_COMPILE, /**< Keybinding. */
121 GEANY_KEYS_EDITOR_SCROLLTOLINE, /**< Keybinding. */
122 GEANY_KEYS_DOCUMENT_UNFOLDALL, /**< Keybinding. */
123 GEANY_KEYS_GOTO_MATCHINGBRACE, /**< Keybinding. */
124 GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, /**< Keybinding. */
125 GEANY_KEYS_CLIPBOARD_PASTE, /**< Keybinding. */
126 GEANY_KEYS_BUILD_MAKE, /**< Keybinding. */
127 GEANY_KEYS_INSERT_ALTWHITESPACE, /**< Keybinding. */
128 GEANY_KEYS_EDITOR_SCROLLLINEDOWN, /**< Keybinding. */
129 GEANY_KEYS_VIEW_TOGGLEALL, /**< Keybinding. */
130 GEANY_KEYS_VIEW_FULLSCREEN, /**< Keybinding. */
131 GEANY_KEYS_GOTO_LINEEND, /**< Keybinding. */
132 GEANY_KEYS_EDITOR_CALLTIP, /**< Keybinding. */
133 GEANY_KEYS_FILE_PRINT, /**< Keybinding. */
134 GEANY_KEYS_EDITOR_DUPLICATELINE, /**< Keybinding. */
135 GEANY_KEYS_FOCUS_SCRIBBLE, /**< Keybinding. */
136 GEANY_KEYS_TOOLS_OPENCOLORCHOOSER, /**< Keybinding. */
137 GEANY_KEYS_SEARCH_PREVIOUSMESSAGE, /**< Keybinding. */
138 GEANY_KEYS_FILE_CLOSE, /**< Keybinding. */
139 GEANY_KEYS_DOCUMENT_REPLACETABS, /**< Keybinding. */
140 GEANY_KEYS_FILE_RELOAD, /**< Keybinding. */
141 GEANY_KEYS_SEARCH_FINDNEXTSEL, /**< Keybinding. */
142 GEANY_KEYS_FOCUS_MESSAGES, /**< Keybinding. */
143 GEANY_KEYS_BUILD_RUN, /**< Keybinding. */
144 GEANY_KEYS_HELP_HELP, /**< Keybinding. */
145 GEANY_KEYS_SETTINGS_PLUGINPREFERENCES, /**< Keybinding. */
146 GEANY_KEYS_VIEW_ZOOMRESET, /**< Keybinding. */
147 GEANY_KEYS_SELECT_WORD, /**< Keybinding. */
148 GEANY_KEYS_FORMAT_INCREASEINDENT, /**< Keybinding. */
149 GEANY_KEYS_SETTINGS_PREFERENCES, /**< Keybinding. */
150 GEANY_KEYS_FORMAT_SENDTOCMD3, /**< Keybinding. */
151 GEANY_KEYS_DOCUMENT_FOLDALL, /**< Keybinding. */
152 GEANY_KEYS_FORMAT_SENDTOVTE, /**< Keybinding. */
153 GEANY_KEYS_PROJECT_PROPERTIES, /**< Keybinding. */
154 GEANY_KEYS_DOCUMENT_LINEWRAP, /**< Keybinding. */
155 GEANY_KEYS_EDITOR_MACROLIST, /**< Keybinding. */
156 GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION, /**< Keybinding. */
157 GEANY_KEYS_FOCUS_SIDEBAR_SYMBOL_LIST, /**< Keybinding. */
158 GEANY_KEYS_GOTO_LINESTART, /**< Keybinding. */
159 GEANY_KEYS_SEARCH_FINDUSAGE, /**< Keybinding. */
160 GEANY_KEYS_FILE_NEW, /**< Keybinding. */
161 GEANY_KEYS_EDITOR_SNIPPETNEXTCURSOR, /**< Keybinding. */
162 GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT, /**< Keybinding. */
163 GEANY_KEYS_FILE_SAVE, /**< Keybinding. */
164 GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE, /**< Keybinding. */
165 GEANY_KEYS_SEARCH_FINDNEXT, /**< Keybinding. */
166 GEANY_KEYS_GOTO_TOGGLEMARKER, /**< Keybinding. */
167 GEANY_KEYS_GOTO_TAGDEFINITION, /**< Keybinding. */
168 GEANY_KEYS_SEARCH_NEXTMESSAGE, /**< Keybinding. */
169 GEANY_KEYS_EDITOR_DELETELINETOEND, /**< Keybinding. */
170 GEANY_KEYS_FORMAT_AUTOINDENT, /**< Keybinding. */
171 GEANY_KEYS_FILE_OPENSELECTED, /**< Keybinding. */
172 GEANY_KEYS_GOTO_BACK, /**< Keybinding. */
173 GEANY_KEYS_INSERT_DATE, /**< Keybinding. */
174 GEANY_KEYS_BUILD_PREVIOUSERROR, /**< Keybinding. */
175 GEANY_KEYS_GOTO_LINEENDVISUAL, /**< Keybinding. */
176 GEANY_KEYS_DOCUMENT_REPLACESPACES, /**< Keybinding. */
177 GEANY_KEYS_FOCUS_EDITOR, /**< Keybinding. */
178 GEANY_KEYS_SELECT_WORDPARTRIGHT, /**< Keybinding. */
179 GEANY_KEYS_VIEW_MESSAGEWINDOW, /**< Keybinding. */
180 GEANY_KEYS_FOCUS_SIDEBAR_DOCUMENT_LIST, /**< Keybinding. */
181 GEANY_KEYS_FORMAT_REFLOWPARAGRAPH, /**< Keybinding. */
182 GEANY_KEYS_EDITOR_MOVELINEUP, /**< Keybinding. */
183 GEANY_KEYS_NOTEBOOK_MOVETABLEFT, /**< Keybinding. */
184 GEANY_KEYS_SELECT_LINE, /**< Keybinding. */
185 GEANY_KEYS_EDITOR_UNDO, /**< Keybinding. */
186 GEANY_KEYS_EDITOR_MOVELINEDOWN, /**< Keybinding. */
187 GEANY_KEYS_CLIPBOARD_COPYLINE, /**< Keybinding. */
188 GEANY_KEYS_BUILD_MAKEOWNTARGET, /**< Keybinding. */
189 GEANY_KEYS_FORMAT_SENDTOCMD2, /**< Keybinding. */
190 GEANY_KEYS_SEARCH_MARKALL, /**< Keybinding. */
191 GEANY_KEYS_BUILD_LINK, /**< Keybinding. */
192 GEANY_KEYS_FILE_CLOSEALL, /**< Keybinding. */
193 GEANY_KEYS_GOTO_FORWARD, /**< Keybinding. */
194 GEANY_KEYS_CLIPBOARD_CUT, /**< Keybinding. */
195 GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED, /**< Keybinding. */
196 GEANY_KEYS_NOTEBOOK_MOVETABRIGHT, /**< Keybinding. */
197 GEANY_KEYS_BUILD_OPTIONS, /**< Keybinding. */
198 GEANY_KEYS_GOTO_TAGDECLARATION, /**< Keybinding. */
199 GEANY_KEYS_FILE_OPEN, /**< Keybinding. */
200 GEANY_KEYS_EDITOR_COMPLETESNIPPET, /**< Keybinding. */
201 GEANY_KEYS_FORMAT_UNCOMMENTLINE, /**< Keybinding. */
202 GEANY_KEYS_FOCUS_VTE, /**< Keybinding. */
203 GEANY_KEYS_FORMAT_SENDTOCMD1, /**< Keybinding. */
204 GEANY_KEYS_SELECT_WORDPARTLEFT, /**< Keybinding. */
205 GEANY_KEYS_VIEW_ZOOMIN, /**< Keybinding. */
206 GEANY_KEYS_DOCUMENT_LINEBREAK, /**< Keybinding. */
207 GEANY_KEYS_EDITOR_REDO, /**< Keybinding. */
208 GEANY_KEYS_EDITOR_CONTEXTACTION, /**< Keybinding. */
209 GEANY_KEYS_SEARCH_FINDPREVSEL, /**< Keybinding. */
210 GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE, /**< Keybinding. */
211 GEANY_KEYS_FORMAT_COMMENTLINETOGGLE, /**< Keybinding. */
212 GEANY_KEYS_SELECT_ALL, /**< Keybinding. */
213 GEANY_KEYS_DOCUMENT_RELOADTAGLIST, /**< Keybinding. */
214 GEANY_KEYS_BUILD_NEXTERROR, /**< Keybinding. */
215 GEANY_KEYS_NOTEBOOK_MOVETABLAST, /**< Keybinding. */
216 GEANY_KEYS_SELECT_PARAGRAPH, /**< Keybinding. */
217 GEANY_KEYS_EDITOR_DELETELINE, /**< Keybinding. */
218 GEANY_KEYS_CLIPBOARD_COPY, /**< Keybinding. */
219 GEANY_KEYS_VIEW_SIDEBAR, /**< Keybinding. */
220 GEANY_KEYS_FILE_SAVEAS, /**< Keybinding. */
221 GEANY_KEYS_FORMAT_COMMENTLINE, /**< Keybinding. */
222 GEANY_KEYS_GOTO_PREVWORDPART, /**< Keybinding. */
223 GEANY_KEYS_SEARCH_FINDPREVIOUS, /**< Keybinding. */
224 GEANY_KEYS_SEARCH_REPLACE, /**< Keybinding. */
225 GEANY_KEYS_EDITOR_WORDPARTCOMPLETION, /**< Keybinding. */
226 GEANY_KEYS_EDITOR_AUTOCOMPLETE, /**< Keybinding. */
227 GEANY_KEYS_FOCUS_SIDEBAR, /**< Keybinding. */
228 GEANY_KEYS_FOCUS_MESSAGE_WINDOW, /**< Keybinding. */
229 GEANY_KEYS_NOTEBOOK_MOVETABFIRST, /**< Keybinding. */
230 GEANY_KEYS_GOTO_PREVIOUSMARKER, /**< Keybinding. */
231 GEANY_KEYS_EDITOR_SCROLLLINEUP, /**< Keybinding. */
232 GEANY_KEYS_FOCUS_COMPILER, /**< Keybinding. */
233 GEANY_KEYS_FORMAT_TOGGLECASE, /**< Keybinding. */
234 GEANY_KEYS_CLIPBOARD_CUTLINE, /**< Keybinding. */
235 GEANY_KEYS_DOCUMENT_REMOVE_MARKERS, /**< Keybinding. */
236 GEANY_KEYS_BUILD_MAKEOBJECT, /**< Keybinding. */
237 GEANY_KEYS_FORMAT_DECREASEINDENT, /**< Keybinding. */
238 GEANY_KEYS_FILE_OPENLASTTAB, /**< Keybinding. */
239 GEANY_KEYS_SEARCH_FINDINFILES, /**< Keybinding. */
240 GEANY_KEYS_GOTO_NEXTWORDPART, /**< Keybinding. */
241 GEANY_KEYS_INSERT_LINEAFTER, /**< Keybinding. */
242 GEANY_KEYS_INSERT_LINEBEFORE, /**< Keybinding. */
243 GEANY_KEYS_DOCUMENT_REMOVE_MARKERS_INDICATORS, /**< Keybinding. */
244 GEANY_KEYS_PROJECT_OPEN, /**< Keybinding. */
245 GEANY_KEYS_PROJECT_NEW, /**< Keybinding. */
246 GEANY_KEYS_PROJECT_CLOSE, /**< Keybinding. */
247 GEANY_KEYS_FORMAT_JOINLINES, /**< Keybinding. */
248 GEANY_KEYS_GOTO_LINESTARTVISUAL, /**< Keybinding. */
249 GEANY_KEYS_COUNT /* must not be used by plugins */
253 void keybindings_init(void);
255 void keybindings_load_keyfile(void);
257 void keybindings_free(void);
259 GeanyKeyGroup *keybindings_get_core_group(guint id);
261 GeanyKeyGroup *keybindings_set_group(GeanyKeyGroup *group, const gchar *section_name,
262 const gchar *label, gsize count, GeanyKeyGroupCallback callback) G_GNUC_WARN_UNUSED_RESULT;
264 void keybindings_free_group(GeanyKeyGroup *group);
266 GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
267 GeanyKeyCallback callback, guint key, GdkModifierType mod,
268 const gchar *name, const gchar *label, GtkWidget *menu_item);
270 GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id);
272 gchar *keybindings_get_label(GeanyKeyBinding *kb);
274 void keybindings_update_combo(GeanyKeyBinding *kb, guint key, GdkModifierType mods);
276 void keybindings_send_command(guint group_id, guint key_id);
278 GeanyKeyBinding *keybindings_lookup_item(guint group_id, guint key_id);
280 /* just write the content of the keys array to the config file */
281 void keybindings_write_to_file(void);
283 void keybindings_show_shortcuts(void);
285 gboolean keybindings_check_event(GdkEventKey *ev, GeanyKeyBinding *kb);
287 G_END_DECLS
289 #endif