gschem: Add keybinding and menu entries for "Add Path" function.
[geda-gaf.git] / gschem / src / g_register.c
blobc3c341bfc06d849231979a6cb632dd2e13960d40
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2011 gEDA Contributors (see ChangeLog for details)
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.
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.
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, MA 02110-1301 USA
20 #include <config.h>
22 #include <stdio.h>
23 #include <sys/stat.h>
24 #ifdef HAVE_STDLIB_H
25 #include <stdlib.h>
26 #endif
27 #ifdef HAVE_ASSERT_H
28 #include <assert.h>
29 #endif
30 #ifdef HAVE_UNISTD_H
31 #include <unistd.h>
32 #endif
34 #include "gschem.h"
36 #ifdef HAVE_LIBDMALLOC
37 #include <dmalloc.h>
38 #endif
40 /*! \brief */
41 struct gsubr_t {
42 char* name;
43 int req;
44 int opt;
45 int rst;
46 SCM (*fnc)();
49 /*! \brief */
50 static struct gsubr_t gschem_funcs[] = {
51 /* rc file */
52 { "gschem-version", 1, 0, 0, g_rc_gschem_version },
54 { "display-color-map", 0, 1, 0, g_rc_display_color_map },
55 { "display-outline-color-map", 0, 1, 0, g_rc_display_outline_color_map },
57 { "net-direction-mode", 1, 0, 0, g_rc_net_direction_mode },
58 { "net-selection-mode", 1, 0, 0, g_rc_net_selection_mode },
59 { "zoom-with-pan", 1, 0, 0, g_rc_zoom_with_pan },
60 { "action-feedback-mode", 1, 0, 0, g_rc_action_feedback_mode },
61 { "scrollbars", 1, 0, 0, g_rc_scrollbars },
62 { "embed-components", 1, 0, 0, g_rc_embed_components },
63 { "logging", 1, 0, 0, g_rc_logging },
64 { "text-size", 1, 0, 0, g_rc_text_size },
65 { "snap-size", 1, 0, 0, g_rc_snap_size },
67 { "text-caps-style", 1, 0, 0, g_rc_text_caps_style },
68 { "logging-destination", 1, 0, 0, g_rc_logging_destination },
70 { "attribute-name", 1, 0, 0, g_rc_attribute_name },
72 { "image-color", 1, 0, 0, g_rc_image_color },
73 { "image-size", 2, 0, 0, g_rc_image_size },
74 { "log-window", 1, 0, 0, g_rc_log_window },
75 { "log-window-type", 1, 0, 0, g_rc_log_window_type },
76 { "third-button", 1, 0, 0, g_rc_third_button },
77 { "middle-button", 1, 0, 0, g_rc_middle_button },
78 { "scroll-wheel", 1, 0, 0, g_rc_scroll_wheel },
79 { "net-consolidate", 1, 0, 0, g_rc_net_consolidate },
80 { "file-preview", 1, 0, 0, g_rc_file_preview },
81 { "enforce-hierarchy", 1, 0, 0, g_rc_enforce_hierarchy },
82 { "fast-mousepan", 1, 0, 0, g_rc_fast_mousepan },
83 { "raise-dialog-boxes-on-expose", 1, 0, 0, g_rc_raise_dialog_boxes_on_expose },
84 { "continue-component-place", 1, 0, 0, g_rc_continue_component_place },
85 { "undo-levels", 1, 0, 0, g_rc_undo_levels },
86 { "undo-control", 1, 0, 0, g_rc_undo_control },
87 { "undo-type", 1, 0, 0, g_rc_undo_type },
88 { "undo-panzoom", 1, 0, 0, g_rc_undo_panzoom },
90 { "draw-grips", 1, 0, 0, g_rc_draw_grips },
91 { "netconn-rubberband", 1, 0, 0, g_rc_netconn_rubberband },
92 { "magnetic-net-mode", 1, 0, 0, g_rc_magnetic_net_mode },
93 { "add-menu", 2, 0, 0, g_rc_add_menu },
94 { "window-size", 2, 0, 0, g_rc_window_size },
95 { "warp-cursor", 1, 0, 0, g_rc_warp_cursor },
96 { "toolbars", 1, 0, 0, g_rc_toolbars },
97 { "handleboxes", 1, 0, 0, g_rc_handleboxes },
98 { "bus-ripper-size", 1, 0, 0, g_rc_bus_ripper_size },
99 { "bus-ripper-type", 1, 0, 0, g_rc_bus_ripper_type },
100 { "bus-ripper-rotation", 1, 0, 0, g_rc_bus_ripper_rotation },
101 { "force-boundingbox", 1, 0, 0, g_rc_force_boundingbox },
102 { "dots-grid-dot-size", 1, 0, 0, g_rc_dots_grid_dot_size },
103 { "dots-grid-mode", 1, 0, 0, g_rc_dots_grid_mode },
104 { "dots-grid-fixed-threshold", 1, 0, 0, g_rc_dots_grid_fixed_threshold },
105 { "mesh-grid-display-threshold", 1, 0, 0, g_rc_mesh_grid_display_threshold },
106 { "add-attribute-offset", 1, 0, 0, g_rc_add_attribute_offset },
107 { "mousepan-gain", 1, 0, 0, g_rc_mousepan_gain },
108 { "keyboardpan-gain", 1, 0, 0, g_rc_keyboardpan_gain },
109 { "select-slack-pixels", 1, 0, 0, g_rc_select_slack_pixels },
110 { "zoom-gain", 1, 0, 0, g_rc_zoom_gain },
111 { "scrollpan-steps", 1, 0, 0, g_rc_scrollpan_steps },
113 /* backup functions */
114 { "auto-save-interval", 1, 0, 0, g_rc_auto_save_interval },
116 /* general guile functions */
117 { "gschem-pdf", 1, 0, 0, g_funcs_pdf },
118 { "gschem-image", 1, 0, 0, g_funcs_image },
119 { "gschem-use-rc-values", 0, 0, 0, g_funcs_use_rc_values },
120 { "gschem-exit", 0, 0, 0, g_funcs_exit },
121 { "gschem-log", 1, 0, 0, g_funcs_log },
122 { "gschem-msg", 1, 0, 0, g_funcs_msg },
123 { "gschem-confirm", 1, 0, 0, g_funcs_confirm },
124 { "gschem-filesel", 2, 0, 1, g_funcs_filesel },
126 /* keymapping callbacks */
127 { "file-new-window", 0, 0, 0, g_keys_file_new_window },
128 { "file-new", 0, 0, 0, g_keys_file_new },
129 { "file-open", 0, 0, 0, g_keys_file_open },
130 { "file-script", 0, 0, 0, g_keys_file_script },
131 { "file-save", 0, 0, 0, g_keys_file_save },
132 { "file-save-as", 0, 0, 0, g_keys_file_save_as },
133 { "file-save-all", 0, 0, 0, g_keys_file_save_all },
134 { "file-print", 0, 0, 0, g_keys_file_print },
135 { "file-image", 0, 0, 0, g_keys_file_write_png },
136 { "file-close-window", 0, 0, 0, g_keys_file_close },
137 { "file-quit", 0, 0, 0, g_keys_file_quit },
138 { "edit-undo", 0, 0, 0, g_keys_edit_undo },
139 { "edit-redo", 0, 0, 0, g_keys_edit_redo },
140 { "edit-select", 0, 0, 0, g_keys_edit_select },
141 { "edit-select-all", 0, 0, 0, g_keys_edit_select_all },
142 { "edit-deselect", 0, 0, 0, g_keys_edit_deselect },
143 { "edit-copy", 0, 0, 0, g_keys_edit_copy },
144 { "edit-copy-hotkey", 0, 0, 0, g_keys_edit_copy_hotkey },
145 { "edit-mcopy", 0, 0, 0, g_keys_edit_mcopy },
146 { "edit-mcopy-hotkey", 0, 0, 0, g_keys_edit_mcopy_hotkey },
147 { "edit-move", 0, 0, 0, g_keys_edit_move },
148 { "edit-move-hotkey", 0, 0, 0, g_keys_edit_move_hotkey },
149 { "edit-delete", 0, 0, 0, g_keys_edit_delete },
150 { "edit-rotate-90", 0, 0, 0, g_keys_edit_rotate_90 },
151 { "edit-rotate-90-hotkey", 0, 0, 0, g_keys_edit_rotate_90_hotkey },
152 { "edit-mirror", 0, 0, 0, g_keys_edit_mirror },
153 { "edit-mirror-hotkey", 0, 0, 0, g_keys_edit_mirror_hotkey },
154 { "edit-slot", 0, 0, 0, g_keys_edit_slot },
155 { "edit-color", 0, 0, 0, g_keys_edit_color },
156 { "edit-edit", 0, 0, 0, g_keys_edit_edit },
157 { "edit-text", 0, 0, 0, g_keys_edit_text },
158 { "edit-lock", 0, 0, 0, g_keys_edit_lock },
159 { "edit-unlock", 0, 0, 0, g_keys_edit_unlock },
160 { "edit-linetype", 0, 0, 0, g_keys_edit_linetype },
161 { "edit-filltype", 0, 0, 0, g_keys_edit_filltype },
162 { "edit-translate", 0, 0, 0, g_keys_edit_translate },
163 { "edit-invoke-macro", 0, 0, 0, g_keys_edit_invoke_macro },
164 { "edit-embed", 0, 0, 0, g_keys_edit_embed },
165 { "edit-unembed", 0, 0, 0, g_keys_edit_unembed },
166 { "edit-update", 0, 0, 0, g_keys_edit_update },
167 { "edit-show-hidden", 0, 0, 0, g_keys_edit_show_hidden },
168 { "edit-find-text", 0, 0, 0, g_keys_edit_find },
169 { "edit-show-text", 0, 0, 0, g_keys_edit_show_text },
170 { "edit-hide-text", 0, 0, 0, g_keys_edit_hide_text },
171 { "edit-autonumber", 0, 0, 0, g_keys_edit_autonumber_text },
173 { "clipboard-copy", 0, 0, 0, g_keys_clipboard_copy },
174 { "clipboard-cut", 0, 0, 0, g_keys_clipboard_cut },
175 { "clipboard-paste", 0, 0, 0, g_keys_clipboard_paste },
176 { "clipboard-paste-hotkey", 0, 0, 0, g_keys_clipboard_paste_hotkey },
178 { "buffer-copy1", 0, 0, 0, g_keys_buffer_copy1 },
179 { "buffer-copy2", 0, 0, 0, g_keys_buffer_copy2 },
180 { "buffer-copy3", 0, 0, 0, g_keys_buffer_copy3 },
181 { "buffer-copy4", 0, 0, 0, g_keys_buffer_copy4 },
182 { "buffer-copy5", 0, 0, 0, g_keys_buffer_copy5 },
183 { "buffer-cut1", 0, 0, 0, g_keys_buffer_cut1 },
184 { "buffer-cut2", 0, 0, 0, g_keys_buffer_cut2 },
185 { "buffer-cut3", 0, 0, 0, g_keys_buffer_cut3 },
186 { "buffer-cut4", 0, 0, 0, g_keys_buffer_cut4 },
187 { "buffer-cut5", 0, 0, 0, g_keys_buffer_cut5 },
188 { "buffer-paste1", 0, 0, 0, g_keys_buffer_paste1 },
189 { "buffer-paste2", 0, 0, 0, g_keys_buffer_paste2 },
190 { "buffer-paste3", 0, 0, 0, g_keys_buffer_paste3 },
191 { "buffer-paste4", 0, 0, 0, g_keys_buffer_paste4 },
192 { "buffer-paste5", 0, 0, 0, g_keys_buffer_paste5 },
193 { "buffer-paste1-hotkey", 0, 0, 0, g_keys_buffer_paste1_hotkey },
194 { "buffer-paste2-hotkey", 0, 0, 0, g_keys_buffer_paste2_hotkey },
195 { "buffer-paste3-hotkey", 0, 0, 0, g_keys_buffer_paste3_hotkey },
196 { "buffer-paste4-hotkey", 0, 0, 0, g_keys_buffer_paste4_hotkey },
197 { "buffer-paste5-hotkey", 0, 0, 0, g_keys_buffer_paste5_hotkey },
199 { "view-redraw", 0, 0, 0, g_keys_view_redraw },
200 { "view-zoom-full", 0, 0, 0, g_keys_view_zoom_full },
201 { "view-zoom-extents", 0, 0, 0, g_keys_view_zoom_extents },
202 { "view-zoom-in", 0, 0, 0, g_keys_view_zoom_in },
203 { "view-zoom-out", 0, 0, 0, g_keys_view_zoom_out },
204 { "view-zoom-in-hotkey", 0, 0, 0, g_keys_view_zoom_in_hotkey },
205 { "view-zoom-out-hotkey", 0, 0, 0, g_keys_view_zoom_out_hotkey },
206 { "view-zoom-box", 0, 0, 0, g_keys_view_zoom_box },
207 { "view-zoom-box-hotkey", 0, 0, 0, g_keys_view_zoom_box_hotkey },
208 { "view-pan", 0, 0, 0, g_keys_view_pan },
209 { "view-pan-hotkey", 0, 0, 0, g_keys_view_pan_hotkey },
210 { "view-pan-left", 0, 0, 0, g_keys_view_pan_left },
211 { "view-pan-right", 0, 0, 0, g_keys_view_pan_right },
212 { "view-pan-up", 0, 0, 0, g_keys_view_pan_up },
213 { "view-pan-down", 0, 0, 0, g_keys_view_pan_down },
214 { "view-dark-colors", 0, 0, 0, g_keys_view_dark_colors },
215 { "view-light-colors", 0, 0, 0, g_keys_view_light_colors },
216 { "view-bw-colors", 0, 0, 0, g_keys_view_bw_colors },
217 { "page-manager", 0, 0, 0, g_keys_page_manager },
218 { "page-next", 0, 0, 0, g_keys_page_next },
219 { "page-prev", 0, 0, 0, g_keys_page_prev },
220 { "page-new", 0, 0, 0, g_keys_page_new },
221 { "page-close", 0, 0, 0, g_keys_page_close },
222 { "page-revert", 0, 0, 0, g_keys_page_revert },
223 { "page-discard", 0, 0, 0, g_keys_page_discard },
224 { "page-print", 0, 0, 0, g_keys_page_print },
225 { "add-component", 0, 0, 0, g_keys_add_component },
226 { "add-attribute", 0, 0, 0, g_keys_add_attribute },
227 { "add-attribute-hotkey", 0, 0, 0, g_keys_add_attribute_hotkey },
228 { "add-net", 0, 0, 0, g_keys_add_net },
229 { "add-net-hotkey", 0, 0, 0, g_keys_add_net_hotkey },
230 { "add-bus", 0, 0, 0, g_keys_add_bus },
231 { "add-bus-hotkey", 0, 0, 0, g_keys_add_bus_hotkey },
232 { "add-text", 0, 0, 0, g_keys_add_text },
233 { "add-path", 0, 0, 0, g_keys_add_path },
234 { "add-line", 0, 0, 0, g_keys_add_line },
235 { "add-line-hotkey", 0, 0, 0, g_keys_add_line_hotkey },
236 { "add-box", 0, 0, 0, g_keys_add_box },
237 { "add-box-hotkey", 0, 0, 0, g_keys_add_box_hotkey },
238 { "add-picture", 0, 0, 0, g_keys_add_picture},
239 { "add-picture-hotkey", 0, 0, 0, g_keys_add_picture_hotkey},
240 { "add-circle", 0, 0, 0, g_keys_add_circle },
241 { "add-circle-hotkey", 0, 0, 0, g_keys_add_circle_hotkey },
242 { "add-arc", 0, 0, 0, g_keys_add_arc },
243 { "add-arc-hotkey", 0, 0, 0, g_keys_add_arc_hotkey },
244 { "add-pin", 0, 0, 0, g_keys_add_pin },
245 { "add-pin-hotkey", 0, 0, 0, g_keys_add_pin_hotkey },
246 { "hierarchy-down-schematic", 0, 0, 0, g_keys_hierarchy_down_schematic },
247 { "hierarchy-down-symbol", 0, 0, 0, g_keys_hierarchy_down_symbol },
248 { "hierarchy-up", 0, 0, 0, g_keys_hierarchy_up },
249 { "attributes-attach", 0, 0, 0, g_keys_attributes_attach },
250 { "attributes-detach", 0, 0, 0, g_keys_attributes_detach },
251 { "attributes-show-name", 0, 0, 0, g_keys_attributes_show_name },
252 { "attributes-show-value", 0, 0, 0, g_keys_attributes_show_value },
253 { "attributes-show-both", 0, 0, 0, g_keys_attributes_show_both },
254 { "attributes-visibility-toggle", 0, 0, 0, g_keys_attributes_visibility_toggle },
255 { "options-text-size", 0, 0, 0, g_keys_options_text_size },
256 { "options-snap-size", 0, 0, 0, g_keys_options_snap_size },
257 { "options-scale-up-snap-size", 0, 0, 0, g_keys_options_scale_up_snap_size },
258 { "options-scale-down-snap-size",0, 0, 0, g_keys_options_scale_down_snap_size },
259 { "options-action-feedback", 0, 0, 0, g_keys_options_afeedback },
260 { "options-grid", 0, 0, 0, g_keys_options_grid },
261 { "options-snap", 0, 0, 0, g_keys_options_snap },
262 { "options-rubberband", 0, 0, 0, g_keys_options_rubberband },
263 { "options-magneticnet", 0, 0, 0, g_keys_options_magneticnet },
264 { "options-show-log-window", 0, 0, 0, g_keys_options_show_log_window },
265 { "options-show-coord-window", 0, 0, 0, g_keys_options_show_coord_window },
266 { "help-about", 0, 0, 0, g_keys_help_about },
267 { "help-hotkeys", 0, 0, 0, g_keys_help_hotkeys },
268 { "misc-misc", 0, 0, 0, g_keys_misc },
269 { "misc-misc2", 0, 0, 0, g_keys_misc2 },
270 { "misc-misc3", 0, 0, 0, g_keys_misc3 },
271 { "cancel", 0, 0, 0, g_keys_cancel },
273 { NULL, 0, 0, 0, NULL } };
275 /*! \brief Define a hook.
276 * \par Function Description
277 * Creates a Guile new hook with \a n_args arguments, and binds it to
278 * the variable \a name, returning the newly created hook.
280 * \param n_args Number of arguments the hook should take.
281 * \param name Name of variable to bind the hook to.
283 * \return the newly-created hook.
285 static SCM
286 create_hook (const char *name, int n_args)
288 SCM hook = scm_make_hook (scm_from_int (n_args));
289 scm_c_define (name, hook);
290 return scm_permanent_object (hook);
293 /*! \brief Register function with Scheme.
294 * \par Function Description
295 * Creates <B>subr</B> objects to make <B>g_rc_*</B> functions that are defined * #g_rc.c, #g_keys.c and #g_funcs.c visible to Scheme.
297 void g_register_funcs (void)
299 struct gsubr_t *tmp = gschem_funcs;
301 while (tmp->name != NULL) {
302 scm_c_define_gsubr (tmp->name, tmp->req, tmp->opt, tmp->rst, tmp->fnc);
303 tmp++;
306 /* Hook stuff */
307 complex_place_list_changed_hook = create_hook ("complex-place-list-changed-hook", 1);