~ubuntu-branches/ubuntu/raring/geany/raring-proposed

« back to all changes in this revision

Viewing changes to src/keybindings.h

  • Committer: Bazaar Package Importer
  • Author(s): Damián Viano
  • Date: 2008-05-02 11:37:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20080502113745-7q62rqhl2ku02ptu
Import upstream version 0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      keybindings.h - this file is part of Geany, a fast and lightweight IDE
3
3
 *
4
 
 *      Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
 
4
 *      Copyright 2006-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
 
5
 *      Copyright 2006-2008 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
5
6
 *
6
7
 *      This program is free software; you can redistribute it and/or modify
7
8
 *      it under the terms of the GNU General Public License as published by
17
18
 *      along with this program; if not, write to the Free Software
18
19
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20
 *
20
 
 * $Id: keybindings.h 814 2006-09-12 08:32:52Z eht16 $
 
21
 * $Id: keybindings.h 2395 2008-03-24 13:40:01Z ntrel $
21
22
 */
22
23
 
 
24
/**
 
25
 * @file keybindings.h
 
26
 * Configurable keyboard shortcuts.
 
27
 **/
 
28
 
23
29
 
24
30
#ifndef GEANY_KEYBINDINGS_H
25
31
#define GEANY_KEYBINDINGS_H 1
26
32
 
27
 
// holds all user-definable key bindings
28
 
typedef struct binding
29
 
{
30
 
        guint key;
31
 
        GdkModifierType mods;
32
 
        // at the moment only needed as keys for the configuration file because indices or tranlatable
33
 
        // strings as keys are not very useful
34
 
        const gchar *name;
35
 
        const gchar *label;
36
 
        // function pointer to a callback function, just to keep the code in keypress event
37
 
        // callback function clear
38
 
        void (*cb_func) (void);
39
 
} binding;
40
 
 
41
 
 
42
 
enum
43
 
{
44
 
        GEANY_KEYS_MENU_NEW = 0,
45
 
        GEANY_KEYS_MENU_OPEN,
46
 
        GEANY_KEYS_MENU_SAVE,
47
 
        GEANY_KEYS_MENU_SAVEALL,
48
 
        GEANY_KEYS_MENU_PRINT,
49
 
        GEANY_KEYS_MENU_CLOSE,
50
 
        GEANY_KEYS_MENU_CLOSEALL,
51
 
        GEANY_KEYS_MENU_RELOADFILE,
52
 
        GEANY_KEYS_MENU_UNDO,
53
 
        GEANY_KEYS_MENU_REDO,
54
 
        GEANY_KEYS_MENU_SELECTALL,
55
 
        GEANY_KEYS_MENU_INSERTDATE,
56
 
        GEANY_KEYS_MENU_PREFERENCES,
57
 
        GEANY_KEYS_MENU_FINDNEXT,
58
 
        GEANY_KEYS_MENU_FINDPREVIOUS,
59
 
        GEANY_KEYS_MENU_REPLACE,
60
 
        GEANY_KEYS_MENU_FINDINFILES,
61
 
        GEANY_KEYS_MENU_GOTOLINE,
62
 
        GEANY_KEYS_MENU_OPENCOLORCHOOSER,
63
 
        GEANY_KEYS_MENU_FULLSCREEN,
64
 
        GEANY_KEYS_MENU_MESSAGEWINDOW,
65
 
        GEANY_KEYS_MENU_SIDEBAR,
66
 
        GEANY_KEYS_MENU_ZOOMIN,
67
 
        GEANY_KEYS_MENU_ZOOMOUT,
68
 
        GEANY_KEYS_MENU_REPLACETABS,
69
 
        GEANY_KEYS_MENU_FOLDALL,
70
 
        GEANY_KEYS_MENU_UNFOLDALL,
 
33
/* allowed modifier keys (especially NOT Caps lock, no Num lock) */
 
34
#if GTK_CHECK_VERSION(2, 10, 0)
 
35
# define GEANY_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | \
 
36
                                                                   GDK_META_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK)
 
37
#else
 
38
# define GEANY_KEYS_MODIFIER_MASK (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
 
39
#endif
 
40
 
 
41
 
 
42
/** Function pointer type used for keybinding callbacks */
 
43
typedef void (*KeyCallback) (guint key_id);
 
44
 
 
45
/** Represents a single keybinding action */
 
46
/* Note: name and label are not const strings so plugins can set them to malloc'd strings
 
47
 * and free them in cleanup(). */
 
48
typedef struct KeyBinding
 
49
{
 
50
        guint key;                              /**< Key value in lower-case, such as @c GDK_a */
 
51
        GdkModifierType mods;   /**< Modifier keys, such as @c GDK_CONTROL_MASK */
 
52
        gchar *name;                    /**< Key name for the configuration file, such as @c "menu_new" */
 
53
        gchar *label;                   /**< Label used in the preferences dialog keybindings tab */
 
54
        KeyCallback callback;   /**< Callback function called when the key combination is pressed */
 
55
        GtkWidget *menu_item;   /**< Menu item widget for setting the menu accelerator */
 
56
} KeyBinding;
 
57
 
 
58
 
 
59
/** A collection of keybindings grouped together. */
 
60
typedef struct KeyBindingGroup
 
61
{
 
62
        const gchar *name;              /**< Group name used in the configuration file, such as @c "html_chars" */
 
63
        const gchar *label;             /**< Group label used in the preferences dialog keybindings tab */
 
64
        gsize count;                    /**< Count of KeyBinding structs in @a keys */
 
65
        KeyBinding *keys;               /**< Fixed array of KeyBinding structs */
 
66
}
 
67
KeyBindingGroup;
 
68
 
 
69
extern GPtrArray *keybinding_groups;    /* array of KeyBindingGroup pointers */
 
70
 
 
71
extern const gchar keybindings_keyfile_group_name[];
 
72
 
 
73
 
 
74
/* Note: keybinding_groups is not in the API, so we don't need to increment the ABI when
 
75
 * appending keybindings or keygroups, as the _COUNT item shouldn't be used by plugins. */
 
76
 
 
77
/** Keybinding group IDs */
 
78
enum
 
79
{
 
80
        GEANY_KEY_GROUP_FILE,
 
81
        GEANY_KEY_GROUP_PROJECT,
 
82
        GEANY_KEY_GROUP_EDITOR,
 
83
        GEANY_KEY_GROUP_CLIPBOARD,
 
84
        GEANY_KEY_GROUP_SELECT,
 
85
        GEANY_KEY_GROUP_FORMAT,
 
86
        GEANY_KEY_GROUP_INSERT,
 
87
        GEANY_KEY_GROUP_SETTINGS,
 
88
        GEANY_KEY_GROUP_SEARCH,
 
89
        GEANY_KEY_GROUP_GOTO,
 
90
        GEANY_KEY_GROUP_VIEW,
 
91
        GEANY_KEY_GROUP_FOCUS,
 
92
        GEANY_KEY_GROUP_NOTEBOOK,
 
93
        GEANY_KEY_GROUP_DOCUMENT,
 
94
        GEANY_KEY_GROUP_BUILD,
 
95
        GEANY_KEY_GROUP_TOOLS,
 
96
        GEANY_KEY_GROUP_HELP,
 
97
        GEANY_KEY_GROUP_COUNT
 
98
};
 
99
 
 
100
/** File group keybinding command IDs */
 
101
enum
 
102
{
 
103
        GEANY_KEYS_FILE_NEW,
 
104
        GEANY_KEYS_FILE_OPEN,
 
105
        GEANY_KEYS_FILE_OPENSELECTED,
 
106
        GEANY_KEYS_FILE_SAVE,
 
107
        GEANY_KEYS_FILE_SAVEAS,
 
108
        GEANY_KEYS_FILE_SAVEALL,
 
109
        GEANY_KEYS_FILE_PRINT,
 
110
        GEANY_KEYS_FILE_CLOSE,
 
111
        GEANY_KEYS_FILE_CLOSEALL,
 
112
        GEANY_KEYS_FILE_RELOAD,
 
113
        GEANY_KEYS_FILE_COUNT
 
114
};
 
115
 
 
116
/** Project group keybinding command IDs */
 
117
enum
 
118
{
 
119
        GEANY_KEYS_PROJECT_PROPERTIES,
 
120
        GEANY_KEYS_PROJECT_COUNT
 
121
};
 
122
 
 
123
/** Editor group keybinding command IDs */
 
124
enum
 
125
{
 
126
        GEANY_KEYS_EDITOR_UNDO,
 
127
        GEANY_KEYS_EDITOR_REDO,
 
128
        GEANY_KEYS_EDITOR_DELETELINE,
 
129
        GEANY_KEYS_EDITOR_DUPLICATELINE,
 
130
        GEANY_KEYS_EDITOR_TRANSPOSELINE,
 
131
        GEANY_KEYS_EDITOR_SCROLLTOLINE,
 
132
        GEANY_KEYS_EDITOR_SCROLLLINEUP,
 
133
        GEANY_KEYS_EDITOR_SCROLLLINEDOWN,
 
134
        GEANY_KEYS_EDITOR_COMPLETESNIPPET,
 
135
        GEANY_KEYS_EDITOR_SUPPRESSSNIPPETCOMPLETION,
 
136
        GEANY_KEYS_EDITOR_CONTEXTACTION,
 
137
        GEANY_KEYS_EDITOR_AUTOCOMPLETE,
 
138
        GEANY_KEYS_EDITOR_CALLTIP,
 
139
        GEANY_KEYS_EDITOR_MACROLIST,
 
140
        GEANY_KEYS_EDITOR_COUNT
 
141
};
 
142
 
 
143
/** Clipboard group keybinding command IDs */
 
144
enum
 
145
{
 
146
        GEANY_KEYS_CLIPBOARD_CUT,
 
147
        GEANY_KEYS_CLIPBOARD_COPY,
 
148
        GEANY_KEYS_CLIPBOARD_PASTE,
 
149
        GEANY_KEYS_CLIPBOARD_CUTLINE,
 
150
        GEANY_KEYS_CLIPBOARD_COPYLINE,
 
151
        GEANY_KEYS_CLIPBOARD_COUNT
 
152
};
 
153
 
 
154
/** Select group keybinding command IDs */
 
155
enum
 
156
{
 
157
 
 
158
        GEANY_KEYS_SELECT_ALL,
 
159
        GEANY_KEYS_SELECT_WORD,
 
160
        GEANY_KEYS_SELECT_LINE,
 
161
        GEANY_KEYS_SELECT_PARAGRAPH,
 
162
        GEANY_KEYS_SELECT_COUNT
 
163
};
 
164
 
 
165
/** Format group keybinding command IDs */
 
166
enum
 
167
{
 
168
        GEANY_KEYS_FORMAT_TOGGLECASE,
 
169
        GEANY_KEYS_FORMAT_COMMENTLINETOGGLE,
 
170
        GEANY_KEYS_FORMAT_COMMENTLINE,
 
171
        GEANY_KEYS_FORMAT_UNCOMMENTLINE,
 
172
        GEANY_KEYS_FORMAT_INCREASEINDENT,
 
173
        GEANY_KEYS_FORMAT_DECREASEINDENT,
 
174
        GEANY_KEYS_FORMAT_INCREASEINDENTBYSPACE,
 
175
        GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE,
 
176
        GEANY_KEYS_FORMAT_AUTOINDENT,
 
177
        GEANY_KEYS_FORMAT_SENDTOCMD1,
 
178
        GEANY_KEYS_FORMAT_SENDTOCMD2,
 
179
        GEANY_KEYS_FORMAT_SENDTOCMD3,
 
180
        GEANY_KEYS_FORMAT_COUNT
 
181
};
 
182
 
 
183
/** Insert group keybinding command IDs */
 
184
enum
 
185
{
 
186
        GEANY_KEYS_INSERT_DATE,
 
187
        GEANY_KEYS_INSERT_ALTWHITESPACE,
 
188
        GEANY_KEYS_INSERT_COUNT
 
189
};
 
190
 
 
191
/** Settings group keybinding command IDs */
 
192
enum
 
193
{
 
194
        GEANY_KEYS_SETTINGS_PREFERENCES,
 
195
        GEANY_KEYS_SETTINGS_COUNT
 
196
};
 
197
 
 
198
/** Search group keybinding command IDs */
 
199
enum
 
200
{
 
201
        GEANY_KEYS_SEARCH_FIND,
 
202
        GEANY_KEYS_SEARCH_FINDNEXT,
 
203
        GEANY_KEYS_SEARCH_FINDPREVIOUS,
 
204
        GEANY_KEYS_SEARCH_FINDINFILES,
 
205
        GEANY_KEYS_SEARCH_REPLACE,
 
206
        GEANY_KEYS_SEARCH_FINDNEXTSEL,
 
207
        GEANY_KEYS_SEARCH_FINDPREVSEL,
 
208
        GEANY_KEYS_SEARCH_NEXTMESSAGE,
 
209
        GEANY_KEYS_SEARCH_FINDUSAGE,
 
210
        GEANY_KEYS_SEARCH_COUNT
 
211
};
 
212
 
 
213
/** Go To group keybinding command IDs */
 
214
enum
 
215
{
 
216
        GEANY_KEYS_GOTO_FORWARD,
 
217
        GEANY_KEYS_GOTO_BACK,
 
218
        GEANY_KEYS_GOTO_LINE,
 
219
        GEANY_KEYS_GOTO_MATCHINGBRACE,
 
220
        GEANY_KEYS_GOTO_TOGGLEMARKER,
 
221
        GEANY_KEYS_GOTO_NEXTMARKER,
 
222
        GEANY_KEYS_GOTO_PREVIOUSMARKER,
 
223
        GEANY_KEYS_GOTO_TAGDEFINITION,
 
224
        GEANY_KEYS_GOTO_TAGDECLARATION,
 
225
        GEANY_KEYS_GOTO_COUNT
 
226
};
 
227
 
 
228
/** View group keybinding command IDs */
 
229
enum
 
230
{
 
231
        GEANY_KEYS_VIEW_TOGGLEALL,
 
232
        GEANY_KEYS_VIEW_FULLSCREEN,
 
233
        GEANY_KEYS_VIEW_MESSAGEWINDOW,
 
234
        GEANY_KEYS_VIEW_SIDEBAR,
 
235
        GEANY_KEYS_VIEW_ZOOMIN,
 
236
        GEANY_KEYS_VIEW_ZOOMOUT,
 
237
        GEANY_KEYS_VIEW_COUNT
 
238
};
 
239
 
 
240
/** Focus group keybinding command IDs */
 
241
enum
 
242
{
 
243
        GEANY_KEYS_FOCUS_EDITOR,
 
244
        GEANY_KEYS_FOCUS_SCRIBBLE,
 
245
        GEANY_KEYS_FOCUS_VTE,
 
246
        GEANY_KEYS_FOCUS_SEARCHBAR,
 
247
        GEANY_KEYS_FOCUS_SIDEBAR,
 
248
        GEANY_KEYS_FOCUS_COUNT
 
249
};
 
250
 
 
251
/** Notebook Tab group keybinding command IDs */
 
252
enum
 
253
{
 
254
        GEANY_KEYS_NOTEBOOK_SWITCHTABLEFT,
 
255
        GEANY_KEYS_NOTEBOOK_SWITCHTABRIGHT,
 
256
        GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED,
 
257
        GEANY_KEYS_NOTEBOOK_MOVETABLEFT,
 
258
        GEANY_KEYS_NOTEBOOK_MOVETABRIGHT,
 
259
        GEANY_KEYS_NOTEBOOK_MOVETABFIRST,
 
260
        GEANY_KEYS_NOTEBOOK_MOVETABLAST,
 
261
        GEANY_KEYS_NOTEBOOK_COUNT
 
262
};
 
263
 
 
264
/** Document group keybinding command IDs */
 
265
enum
 
266
{
 
267
        GEANY_KEYS_DOCUMENT_REPLACETABS,
 
268
        GEANY_KEYS_DOCUMENT_FOLDALL,
 
269
        GEANY_KEYS_DOCUMENT_UNFOLDALL,
 
270
        GEANY_KEYS_DOCUMENT_RELOADTAGLIST,
 
271
        GEANY_KEYS_DOCUMENT_COUNT
 
272
};
 
273
 
 
274
/** Build group keybinding command IDs */
 
275
enum
 
276
{
71
277
        GEANY_KEYS_BUILD_COMPILE,
72
278
        GEANY_KEYS_BUILD_LINK,
73
279
        GEANY_KEYS_BUILD_MAKE,
74
280
        GEANY_KEYS_BUILD_MAKEOWNTARGET,
75
281
        GEANY_KEYS_BUILD_MAKEOBJECT,
 
282
        GEANY_KEYS_BUILD_NEXTERROR,
76
283
        GEANY_KEYS_BUILD_RUN,
77
284
        GEANY_KEYS_BUILD_RUN2,
78
285
        GEANY_KEYS_BUILD_OPTIONS,
79
 
        GEANY_KEYS_RELOADTAGLIST,
80
 
        GEANY_KEYS_SWITCH_EDITOR,
81
 
        GEANY_KEYS_SWITCH_SCRIBBLE,
82
 
        GEANY_KEYS_SWITCH_VTE,
83
 
        GEANY_KEYS_SWITCH_TABLEFT,
84
 
        GEANY_KEYS_SWITCH_TABRIGHT,
85
 
        GEANY_KEYS_EDIT_TOLOWERCASE,
86
 
        GEANY_KEYS_EDIT_TOUPPERCASE,
87
 
        GEANY_KEYS_EDIT_DUPLICATELINE,
88
 
        GEANY_KEYS_EDIT_COMMENTLINETOGGLE,
89
 
        GEANY_KEYS_EDIT_COMMENTLINE,
90
 
        GEANY_KEYS_EDIT_UNCOMMENTLINE,
91
 
        GEANY_KEYS_EDIT_INCREASEINDENT,
92
 
        GEANY_KEYS_EDIT_DECREASEINDENT,
93
 
        GEANY_KEYS_EDIT_AUTOCOMPLETE,
94
 
        GEANY_KEYS_EDIT_CALLTIP,
95
 
        GEANY_KEYS_EDIT_MACROLIST,
96
 
        GEANY_KEYS_EDIT_SUPPRESSCOMPLETION,
97
 
        GEANY_KEYS_POPUP_FINDUSAGE,
98
 
        GEANY_KEYS_POPUP_GOTOTAGDEFINITION,
99
 
        GEANY_KEYS_POPUP_GOTOTAGDECLARATION,
100
 
        GEANY_MAX_KEYS
101
 
};
102
 
 
103
 
binding *keys[GEANY_MAX_KEYS];
104
 
 
 
286
        GEANY_KEYS_BUILD_COUNT
 
287
};
 
288
 
 
289
/** Tools group keybinding command IDs */
 
290
enum
 
291
{
 
292
        GEANY_KEYS_TOOLS_OPENCOLORCHOOSER,
 
293
        GEANY_KEYS_TOOLS_COUNT
 
294
};
 
295
 
 
296
/** Help group keybinding command IDs */
 
297
enum
 
298
{
 
299
        GEANY_KEYS_HELP_HELP,
 
300
        GEANY_KEYS_HELP_COUNT
 
301
};
105
302
 
106
303
 
107
304
void keybindings_init(void);
108
305
 
 
306
void keybindings_load_keyfile(void);
 
307
 
109
308
void keybindings_free(void);
110
309
 
 
310
void keybindings_set_item(KeyBindingGroup *group, gsize key_id,
 
311
                KeyCallback callback, guint key, GdkModifierType mod,
 
312
                gchar *name, gchar *label, GtkWidget *menu_item);
 
313
 
 
314
void keybindings_send_command(guint group_id, guint key_id);
 
315
 
 
316
KeyBinding *keybindings_lookup_item(guint group_id, guint key_id);
 
317
 
111
318
/* just write the content of the keys array to the config file */
112
319
void keybindings_write_to_file(void);
113
320
 
 
321
void keybindings_show_shortcuts(void);
 
322
 
114
323
/* central keypress event handler, almost all keypress events go to this function */
115
324
gboolean keybindings_got_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
116
325