1 /*
2 * keys.c
3 *
4 * Copyright 2010 Alexander Petukhov <devel(at)apetukhov.ru>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22 /*
23 * Contains hotkeys definition and handlers.
24 */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 #include <geanyplugin.h>
30
31 extern GeanyPlugin *geany_plugin;
32
33 #include "keys.h"
34 #include "callbacks.h"
35
36 /* geany debugger key group */
37 struct GeanyKeyGroup* key_group;
38
39 /* type to hold information about a hotkey */
40 typedef struct _keyinfo {
41 const char* key_name;
42 const char* key_label;
43 enum KEYS key_id;
44 } keyinfo;
45
46 /* hotkeys list */
47 keyinfo keys[] = {
48 { "key_debug_run", N_("Run / Continue"), KEY_RUN},
49 { "key_debug_stop", N_("Stop"), KEY_STOP},
50 { "key_debug_restart", N_("Restart"), KEY_RESTART},
51 { "key_debug_step_into", N_("Step into"), KEY_STEP_INTO},
52 { "key_debug_step_over", N_("Step over"), KEY_STEP_OVER},
53 { "key_debug_step_out", N_("Step out"), KEY_STEP_OUT},
54 { "key_debug_exec_until", N_("Run to cursor"), KEY_EXECUTE_UNTIL},
55 { "key_debug_break", N_("Add / Remove breakpoint"), KEY_BREAKPOINT},
56 { "key_current_instruction", N_("Jump to the current instruction"), KEY_CURRENT_INSTRUCTION},
57 { NULL, NULL, 0}
58 };
59
60 /*
61 * init hotkeys
62 */
keys_init(void)63 gboolean keys_init(void)
64 {
65 int _index, count;
66
67 /* keys count */
68 count = 0;
69 while (keys[count++].key_name)
70 ;
71
72 /* set keygroup */
73 key_group = plugin_set_key_group(
74 geany_plugin,
75 _("Debug"),
76 count - 1,
77 keys_callback);
78
79 /* add keys */
80 _index = 0;
81 while (keys[_index].key_name)
82 {
83 keybindings_set_item(
84 key_group,
85 keys[_index].key_id,
86 NULL,
87 0,
88 0,
89 keys[_index].key_name,
90 _(keys[_index].key_label),
91 NULL);
92 _index++;
93 }
94
95 return 1;
96 }
97
98