gschem: Dispose of redundant "misc" commands.
[geda-gaf.git] / gschem / src / g_register.c
blob6eaa8f9e24f2cb5d8f470e9d7c14df668fb5f639
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-mcopy", 0, 0, 0, g_keys_edit_mcopy },
145 { "edit-move", 0, 0, 0, g_keys_edit_move },
146 { "edit-delete", 0, 0, 0, g_keys_edit_delete },
147 { "edit-rotate-90", 0, 0, 0, g_keys_edit_rotate_90 },
148 { "edit-mirror", 0, 0, 0, g_keys_edit_mirror },
149 { "edit-slot", 0, 0, 0, g_keys_edit_slot },
150 { "edit-color", 0, 0, 0, g_keys_edit_color },
151 { "edit-edit", 0, 0, 0, g_keys_edit_edit },
152 { "edit-text", 0, 0, 0, g_keys_edit_text },
153 { "edit-lock", 0, 0, 0, g_keys_edit_lock },
154 { "edit-unlock", 0, 0, 0, g_keys_edit_unlock },
155 { "edit-linetype", 0, 0, 0, g_keys_edit_linetype },
156 { "edit-filltype", 0, 0, 0, g_keys_edit_filltype },
157 { "edit-pin-type", 0, 0, 0, g_keys_edit_pin_type },
158 { "edit-translate", 0, 0, 0, g_keys_edit_translate },
159 { "edit-invoke-macro", 0, 0, 0, g_keys_edit_invoke_macro },
160 { "edit-embed", 0, 0, 0, g_keys_edit_embed },
161 { "edit-unembed", 0, 0, 0, g_keys_edit_unembed },
162 { "edit-update", 0, 0, 0, g_keys_edit_update },
163 { "edit-show-hidden", 0, 0, 0, g_keys_edit_show_hidden },
164 { "edit-find-text", 0, 0, 0, g_keys_edit_find },
165 { "edit-show-text", 0, 0, 0, g_keys_edit_show_text },
166 { "edit-hide-text", 0, 0, 0, g_keys_edit_hide_text },
167 { "edit-autonumber", 0, 0, 0, g_keys_edit_autonumber_text },
169 { "clipboard-copy", 0, 0, 0, g_keys_clipboard_copy },
170 { "clipboard-cut", 0, 0, 0, g_keys_clipboard_cut },
171 { "clipboard-paste", 0, 0, 0, g_keys_clipboard_paste },
173 { "buffer-copy1", 0, 0, 0, g_keys_buffer_copy1 },
174 { "buffer-copy2", 0, 0, 0, g_keys_buffer_copy2 },
175 { "buffer-copy3", 0, 0, 0, g_keys_buffer_copy3 },
176 { "buffer-copy4", 0, 0, 0, g_keys_buffer_copy4 },
177 { "buffer-copy5", 0, 0, 0, g_keys_buffer_copy5 },
178 { "buffer-cut1", 0, 0, 0, g_keys_buffer_cut1 },
179 { "buffer-cut2", 0, 0, 0, g_keys_buffer_cut2 },
180 { "buffer-cut3", 0, 0, 0, g_keys_buffer_cut3 },
181 { "buffer-cut4", 0, 0, 0, g_keys_buffer_cut4 },
182 { "buffer-cut5", 0, 0, 0, g_keys_buffer_cut5 },
183 { "buffer-paste1", 0, 0, 0, g_keys_buffer_paste1 },
184 { "buffer-paste2", 0, 0, 0, g_keys_buffer_paste2 },
185 { "buffer-paste3", 0, 0, 0, g_keys_buffer_paste3 },
186 { "buffer-paste4", 0, 0, 0, g_keys_buffer_paste4 },
187 { "buffer-paste5", 0, 0, 0, g_keys_buffer_paste5 },
189 { "view-redraw", 0, 0, 0, g_keys_view_redraw },
190 { "view-zoom-full", 0, 0, 0, g_keys_view_zoom_full },
191 { "view-zoom-extents", 0, 0, 0, g_keys_view_zoom_extents },
192 { "view-zoom-in", 0, 0, 0, g_keys_view_zoom_in },
193 { "view-zoom-out", 0, 0, 0, g_keys_view_zoom_out },
194 { "view-zoom-box", 0, 0, 0, g_keys_view_zoom_box },
195 { "view-pan", 0, 0, 0, g_keys_view_pan },
196 { "view-pan-left", 0, 0, 0, g_keys_view_pan_left },
197 { "view-pan-right", 0, 0, 0, g_keys_view_pan_right },
198 { "view-pan-up", 0, 0, 0, g_keys_view_pan_up },
199 { "view-pan-down", 0, 0, 0, g_keys_view_pan_down },
200 { "view-dark-colors", 0, 0, 0, g_keys_view_dark_colors },
201 { "view-light-colors", 0, 0, 0, g_keys_view_light_colors },
202 { "view-bw-colors", 0, 0, 0, g_keys_view_bw_colors },
203 { "page-manager", 0, 0, 0, g_keys_page_manager },
204 { "page-next", 0, 0, 0, g_keys_page_next },
205 { "page-prev", 0, 0, 0, g_keys_page_prev },
206 { "page-new", 0, 0, 0, g_keys_page_new },
207 { "page-close", 0, 0, 0, g_keys_page_close },
208 { "page-revert", 0, 0, 0, g_keys_page_revert },
209 { "page-print", 0, 0, 0, g_keys_page_print },
210 { "add-component", 0, 0, 0, g_keys_add_component },
211 { "add-attribute", 0, 0, 0, g_keys_add_attribute },
212 { "add-net", 0, 0, 0, g_keys_add_net },
213 { "add-bus", 0, 0, 0, g_keys_add_bus },
214 { "add-text", 0, 0, 0, g_keys_add_text },
215 { "add-path", 0, 0, 0, g_keys_add_path },
216 { "add-line", 0, 0, 0, g_keys_add_line },
217 { "add-box", 0, 0, 0, g_keys_add_box },
218 { "add-picture", 0, 0, 0, g_keys_add_picture},
219 { "add-circle", 0, 0, 0, g_keys_add_circle },
220 { "add-arc", 0, 0, 0, g_keys_add_arc },
221 { "add-pin", 0, 0, 0, g_keys_add_pin },
222 { "hierarchy-down-schematic", 0, 0, 0, g_keys_hierarchy_down_schematic },
223 { "hierarchy-down-symbol", 0, 0, 0, g_keys_hierarchy_down_symbol },
224 { "hierarchy-up", 0, 0, 0, g_keys_hierarchy_up },
225 { "attributes-attach", 0, 0, 0, g_keys_attributes_attach },
226 { "attributes-detach", 0, 0, 0, g_keys_attributes_detach },
227 { "attributes-show-name", 0, 0, 0, g_keys_attributes_show_name },
228 { "attributes-show-value", 0, 0, 0, g_keys_attributes_show_value },
229 { "attributes-show-both", 0, 0, 0, g_keys_attributes_show_both },
230 { "attributes-visibility-toggle", 0, 0, 0, g_keys_attributes_visibility_toggle },
231 { "options-text-size", 0, 0, 0, g_keys_options_text_size },
232 { "options-snap-size", 0, 0, 0, g_keys_options_snap_size },
233 { "options-scale-up-snap-size", 0, 0, 0, g_keys_options_scale_up_snap_size },
234 { "options-scale-down-snap-size",0, 0, 0, g_keys_options_scale_down_snap_size },
235 { "options-action-feedback", 0, 0, 0, g_keys_options_afeedback },
236 { "options-grid", 0, 0, 0, g_keys_options_grid },
237 { "options-snap", 0, 0, 0, g_keys_options_snap },
238 { "options-rubberband", 0, 0, 0, g_keys_options_rubberband },
239 { "options-magneticnet", 0, 0, 0, g_keys_options_magneticnet },
240 { "options-show-log-window", 0, 0, 0, g_keys_options_show_log_window },
241 { "options-show-coord-window", 0, 0, 0, g_keys_options_show_coord_window },
242 { "help-about", 0, 0, 0, g_keys_help_about },
243 { "help-hotkeys", 0, 0, 0, g_keys_help_hotkeys },
244 { "cancel", 0, 0, 0, g_keys_cancel },
246 { NULL, 0, 0, 0, NULL } };
248 /*! \brief Define a hook.
249 * \par Function Description
250 * Creates a Guile new hook with \a n_args arguments, and binds it to
251 * the variable \a name, returning the newly created hook.
253 * \param n_args Number of arguments the hook should take.
254 * \param name Name of variable to bind the hook to.
256 * \return the newly-created hook.
258 static SCM
259 create_hook (const char *name, int n_args)
261 SCM hook = scm_make_hook (scm_from_int (n_args));
262 scm_c_define (name, hook);
263 return scm_permanent_object (hook);
266 /*! \brief Register function with Scheme.
267 * \par Function Description
268 * 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.
270 void g_register_funcs (void)
272 struct gsubr_t *tmp = gschem_funcs;
274 while (tmp->name != NULL) {
275 scm_c_define_gsubr (tmp->name, tmp->req, tmp->opt, tmp->rst, tmp->fnc);
276 tmp++;
279 /* Hook stuff */
280 complex_place_list_changed_hook = create_hook ("complex-place-list-changed-hook", 1);