Moved 3 rc promotion keywords from gschem into libgeda (fix for bug#1748143)
[geda-gaf/peter-b.git] / gschem / src / g_register.c
blob05fb1cdf52cf620b909f6056c2b2079a36e60815
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 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., 59 Temple Place, Suite 330, Boston, MA 02111 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 <libgeda/libgeda.h>
36 #include "../include/globals.h"
37 #include "../include/prototype.h"
39 #ifdef HAVE_LIBDMALLOC
40 #include <dmalloc.h>
41 #endif
43 /*! \brief */
44 struct gsubr_t {
45 char* name;
46 int req;
47 int opt;
48 int rst;
49 SCM (*fnc)();
52 /*! \brief */
53 static struct gsubr_t gschem_funcs[] = {
54 /* rc file */
55 { "gschem-version", 1, 0, 0, g_rc_gschem_version },
57 { "override-net-color", 7, 0, 0, g_rc_override_net_color },
58 { "override-bus-color", 7, 0, 0, g_rc_override_bus_color },
59 { "override-pin-color", 7, 0, 0, g_rc_override_pin_color },
60 { "attribute-color", 7, 0, 0, g_rc_attribute_color },
61 { "detached-attribute-color", 7, 0, 0, g_rc_detachedattr_color },
62 { "text-color", 7, 0, 0, g_rc_text_color },
63 { "logic-bubble-color", 7, 0, 0, g_rc_logic_bubble_color },
64 { "lock-color", 7, 0, 0, g_rc_lock_color },
65 { "zoom-box-color", 7, 0, 0, g_rc_zoom_box_color },
66 { "net-color", 7, 0, 0, g_rc_net_color },
67 { "bus-color", 7, 0, 0, g_rc_bus_color },
68 { "pin-color", 7, 0, 0, g_rc_pin_color },
69 { "graphic-color", 7, 0, 0, g_rc_graphic_color },
70 { "grid-color", 7, 0, 0, g_rc_grid_color },
71 { "background-color", 7, 0, 0, g_rc_background_color },
72 { "select-color", 7, 0, 0, g_rc_select_color },
73 { "boundingbox-color", 7, 0, 0, g_rc_boundingbox_color },
74 { "net-endpoint-color", 7, 0, 0, g_rc_net_endpoint_color },
75 { "junction-color", 7, 0, 0, g_rc_junction_color },
76 { "stroke-color", 7, 0, 0, g_rc_stroke_color },
77 { "output-color-background", 7, 0, 0, g_rc_output_color_background },
78 { "freestyle-color", 7, 0, 0, g_rc_freestyle_color },
80 { "net-endpoint-mode", 1, 0, 0, g_rc_net_endpoint_mode },
81 { "net-midpoint-mode", 1, 0, 0, g_rc_net_midpoint_mode },
82 { "net-style", 1, 0, 0, g_rc_net_style },
83 { "bus-style", 1, 0, 0, g_rc_bus_style },
84 { "pin-style", 1, 0, 0, g_rc_pin_style },
85 { "line-style", 1, 0, 0, g_rc_line_style },
86 { "zoom-with-pan", 1, 0, 0, g_rc_zoom_with_pan },
87 { "action-feedback-mode", 1, 0, 0, g_rc_action_feedback_mode },
88 { "text-feedback", 1, 0, 0, g_rc_text_feedback },
89 { "text-display-zoomfactor", 1, 0, 0, g_rc_text_display_zoomfactor },
90 { "scrollbars", 1, 0, 0, g_rc_scrollbars },
91 { "scrollbar-update", 1, 0, 0, g_rc_scrollbar_update },
92 { "object-clipping", 1, 0, 0, g_rc_object_clipping },
93 { "embed-components", 1, 0, 0, g_rc_embed_components },
94 { "logging", 1, 0, 0, g_rc_logging },
95 { "text-size", 1, 0, 0, g_rc_text_size },
96 { "snap-size", 1, 0, 0, g_rc_snap_size },
98 { "text-caps-style", 1, 0, 0, g_rc_text_caps_style },
99 { "logging-destination", 1, 0, 0, g_rc_logging_destination },
101 { "attribute-name", 1, 0, 0, g_rc_attribute_name },
102 { "paper-size", 2, 0, 0, g_rc_paper_size },
103 { "paper-sizes", 3, 0, 0, g_rc_paper_sizes },
104 { "postscript-font-scale", 1, 0, 0, g_rc_postscript_font_scale },
106 /* text-output is old... will eventually be removed! */
107 { "text-output", 1, 0, 0, g_rc_output_text },
108 { "output-text", 1, 0, 0, g_rc_output_text },
109 { "output-type", 1, 0, 0, g_rc_output_type },
110 { "output-orientation", 1, 0, 0, g_rc_output_orientation },
111 { "output-color", 1, 0, 0, g_rc_output_color },
112 { "output-capstyle", 1, 0, 0, g_rc_output_capstyle },
113 { "image-color", 1, 0, 0, g_rc_image_color },
114 { "image-size", 2, 0, 0, g_rc_image_size },
115 { "log-window", 1, 0, 0, g_rc_log_window },
116 { "log-window-type", 1, 0, 0, g_rc_log_window_type },
117 { "third-button", 1, 0, 0, g_rc_third_button },
118 { "middle-button", 1, 0, 0, g_rc_middle_button },
119 { "net-consolidate", 1, 0, 0, g_rc_net_consolidate },
120 { "file-preview", 1, 0, 0, g_rc_file_preview },
121 { "enforce-hierarchy", 1, 0, 0, g_rc_enforce_hierarchy },
122 { "text-origin-marker", 1, 0, 0, g_rc_text_origin_marker },
123 { "fast-mousepan", 1, 0, 0, g_rc_fast_mousepan },
124 { "raise-dialog-boxes-on-expose", 1, 0, 0, g_rc_raise_dialog_boxes_on_expose },
125 { "continue-component-place", 1, 0, 0, g_rc_continue_component_place },
126 { "undo-levels", 1, 0, 0, g_rc_undo_levels },
127 { "undo-control", 1, 0, 0, g_rc_undo_control },
128 { "undo-type", 1, 0, 0, g_rc_undo_type },
130 { "drag-can-move", 1, 0, 0, g_rc_drag_can_move },
132 { "draw-grips", 1, 0, 0, g_rc_draw_grips },
133 { "netconn-rubberband", 1, 0, 0, g_rc_netconn_rubberband },
134 { "sort-component-library", 1, 0, 0, g_rc_sort_component_library },
135 { "add-menu", 2, 0, 0, g_rc_add_menu },
136 { "window-size", 2, 0, 0, g_rc_window_size },
137 { "warp-cursor", 1, 0, 0, g_rc_warp_cursor },
138 { "toolbars", 1, 0, 0, g_rc_toolbars },
139 { "handleboxes", 1, 0, 0, g_rc_handleboxes },
140 { "setpagedevice-orientation", 1, 0, 0, g_rc_setpagedevice_orientation },
141 { "setpagedevice-pagesize", 1, 0, 0, g_rc_setpagedevice_pagesize },
142 { "bus-ripper-size", 1, 0, 0, g_rc_bus_ripper_size },
143 { "bus-ripper-type", 1, 0, 0, g_rc_bus_ripper_type },
144 { "bus-ripper-rotation", 1, 0, 0, g_rc_bus_ripper_rotation },
145 { "force-boundingbox", 1, 0, 0, g_rc_force_boundingbox },
146 { "grid-dot-size", 1, 0, 0, g_rc_grid_dot_size },
147 { "grid-mode", 1, 0, 0, g_rc_grid_mode },
148 { "grid-fixed-threshold", 1, 0, 0, g_rc_grid_fixed_threshold },
149 { "output-vector-threshold", 1, 0, 0, g_rc_output_vector_threshold },
150 { "add-attribute-offset", 1, 0, 0, g_rc_add_attribute_offset },
151 { "mousepan-gain", 1, 0, 0, g_rc_mousepan_gain },
152 { "keyboardpan-gain", 1, 0, 0, g_rc_keyboardpan_gain },
153 { "print-command", 1, 0, 0, g_rc_print_command },
154 { "select-slack-pixels", 1, 0, 0, g_rc_select_slack_pixels },
156 /* backup functions */
157 { "auto-save-interval", 1, 0, 0, g_rc_auto_save_interval },
159 /* general guile functions */
160 { "gschem-print", 1, 0, 0, g_funcs_print },
161 { "gschem-postscript", 1, 0, 0, g_funcs_postscript },
162 { "gschem-image", 1, 0, 0, g_funcs_image },
163 { "gschem-use-rc-values", 0, 0, 0, g_funcs_use_rc_values },
164 { "gschem-exit", 0, 0, 0, g_funcs_exit },
165 { "gschem-log", 1, 0, 0, g_funcs_log },
166 { "gschem-msg", 1, 0, 0, g_funcs_msg },
167 { "gschem-confirm", 1, 0, 0, g_funcs_confirm },
168 { "gschem-filesel", 2, 0, 1, g_funcs_filesel },
169 { "gschem-browse-wiki", 0, 1, 0, g_funcs_browse_wiki },
171 /* keymapping callbacks */
172 { "file-new-window", 0, 0, 0, g_keys_file_new_window },
173 { "file-new", 0, 0, 0, g_keys_file_new },
174 { "file-open", 0, 0, 0, g_keys_file_open },
175 { "file-script", 0, 0, 0, g_keys_file_script },
176 { "file-save", 0, 0, 0, g_keys_file_save },
177 { "file-save-as", 0, 0, 0, g_keys_file_save_as },
178 { "file-save-all", 0, 0, 0, g_keys_file_save_all },
179 { "file-print", 0, 0, 0, g_keys_file_print },
180 { "file-image", 0, 0, 0, g_keys_file_write_png },
181 { "file-close-window", 0, 0, 0, g_keys_file_close },
182 { "file-quit", 0, 0, 0, g_keys_file_quit },
183 { "edit-undo", 0, 0, 0, g_keys_edit_undo },
184 { "edit-redo", 0, 0, 0, g_keys_edit_redo },
185 { "edit-select", 0, 0, 0, g_keys_edit_select },
186 { "edit-copy", 0, 0, 0, g_keys_edit_copy },
187 { "edit-copy-hotkey", 0, 0, 0, g_keys_edit_copy_hotkey },
188 { "edit-mcopy", 0, 0, 0, g_keys_edit_mcopy },
189 { "edit-mcopy-hotkey", 0, 0, 0, g_keys_edit_mcopy_hotkey },
190 { "edit-move", 0, 0, 0, g_keys_edit_move },
191 { "edit-move-hotkey", 0, 0, 0, g_keys_edit_move_hotkey },
192 { "edit-delete", 0, 0, 0, g_keys_edit_delete },
193 { "edit-rotate-90", 0, 0, 0, g_keys_edit_rotate_90 },
194 { "edit-rotate-90-hotkey", 0, 0, 0, g_keys_edit_rotate_90_hotkey },
195 { "edit-mirror", 0, 0, 0, g_keys_edit_mirror },
196 { "edit-mirror-hotkey", 0, 0, 0, g_keys_edit_mirror_hotkey },
197 { "edit-slot", 0, 0, 0, g_keys_edit_slot },
198 { "edit-color", 0, 0, 0, g_keys_edit_color },
199 { "edit-edit", 0, 0, 0, g_keys_edit_edit },
200 { "edit-text", 0, 0, 0, g_keys_edit_text },
201 { "edit-lock", 0, 0, 0, g_keys_edit_lock },
202 { "edit-unlock", 0, 0, 0, g_keys_edit_unlock },
203 { "edit-linetype", 0, 0, 0, g_keys_edit_linetype },
204 { "edit-filltype", 0, 0, 0, g_keys_edit_filltype },
205 { "edit-translate", 0, 0, 0, g_keys_edit_translate },
206 { "edit-embed", 0, 0, 0, g_keys_edit_embed },
207 { "edit-unembed", 0, 0, 0, g_keys_edit_unembed },
208 { "edit-update", 0, 0, 0, g_keys_edit_update },
209 { "edit-show-hidden", 0, 0, 0, g_keys_edit_show_hidden },
210 { "edit-make-text-visible", 0, 0, 0, g_keys_edit_make_visible },
211 { "edit-find-text", 0, 0, 0, g_keys_edit_find },
212 { "edit-show-text", 0, 0, 0, g_keys_edit_show_text },
213 { "edit-hide-text", 0, 0, 0, g_keys_edit_hide_text },
214 { "edit-autonumber", 0, 0, 0, g_keys_edit_autonumber_text },
216 { "buffer-copy1", 0, 0, 0, g_keys_buffer_copy1 },
217 { "buffer-copy2", 0, 0, 0, g_keys_buffer_copy2 },
218 { "buffer-copy3", 0, 0, 0, g_keys_buffer_copy3 },
219 { "buffer-copy4", 0, 0, 0, g_keys_buffer_copy4 },
220 { "buffer-copy5", 0, 0, 0, g_keys_buffer_copy5 },
221 { "buffer-cut1", 0, 0, 0, g_keys_buffer_cut1 },
222 { "buffer-cut2", 0, 0, 0, g_keys_buffer_cut2 },
223 { "buffer-cut3", 0, 0, 0, g_keys_buffer_cut3 },
224 { "buffer-cut4", 0, 0, 0, g_keys_buffer_cut4 },
225 { "buffer-cut5", 0, 0, 0, g_keys_buffer_cut5 },
226 { "buffer-paste1", 0, 0, 0, g_keys_buffer_paste1 },
227 { "buffer-paste2", 0, 0, 0, g_keys_buffer_paste2 },
228 { "buffer-paste3", 0, 0, 0, g_keys_buffer_paste3 },
229 { "buffer-paste4", 0, 0, 0, g_keys_buffer_paste4 },
230 { "buffer-paste5", 0, 0, 0, g_keys_buffer_paste5 },
231 { "buffer-paste1-hotkey", 0, 0, 0, g_keys_buffer_paste1_hotkey },
232 { "buffer-paste2-hotkey", 0, 0, 0, g_keys_buffer_paste2_hotkey },
233 { "buffer-paste3-hotkey", 0, 0, 0, g_keys_buffer_paste3_hotkey },
234 { "buffer-paste4-hotkey", 0, 0, 0, g_keys_buffer_paste4_hotkey },
235 { "buffer-paste5-hotkey", 0, 0, 0, g_keys_buffer_paste5_hotkey },
237 { "view-redraw", 0, 0, 0, g_keys_view_redraw },
238 { "view-zoom-full", 0, 0, 0, g_keys_view_zoom_full },
239 { "view-zoom-extents", 0, 0, 0, g_keys_view_zoom_extents },
240 { "view-zoom-in", 0, 0, 0, g_keys_view_zoom_in },
241 { "view-zoom-out", 0, 0, 0, g_keys_view_zoom_out },
242 { "view-zoom-in-hotkey", 0, 0, 0, g_keys_view_zoom_in_hotkey },
243 { "view-zoom-out-hotkey", 0, 0, 0, g_keys_view_zoom_out_hotkey },
244 { "view-zoom-box", 0, 0, 0, g_keys_view_zoom_box },
245 { "view-zoom-box-hotkey", 0, 0, 0, g_keys_view_zoom_box_hotkey },
246 { "view-pan", 0, 0, 0, g_keys_view_pan },
247 { "view-pan-hotkey", 0, 0, 0, g_keys_view_pan_hotkey },
248 { "view-pan-left", 0, 0, 0, g_keys_view_pan_left },
249 { "view-pan-right", 0, 0, 0, g_keys_view_pan_right },
250 { "view-pan-up", 0, 0, 0, g_keys_view_pan_up },
251 { "view-pan-down", 0, 0, 0, g_keys_view_pan_down },
252 { "view-update-cues", 0, 0, 0, g_keys_view_update_cues },
253 { "page-manager", 0, 0, 0, g_keys_page_manager },
254 { "page-next", 0, 0, 0, g_keys_page_next },
255 { "page-prev", 0, 0, 0, g_keys_page_prev },
256 { "page-new", 0, 0, 0, g_keys_page_new },
257 { "page-close", 0, 0, 0, g_keys_page_close },
258 { "page-revert", 0, 0, 0, g_keys_page_revert },
259 { "page-discard", 0, 0, 0, g_keys_page_discard },
260 { "page-print", 0, 0, 0, g_keys_page_print },
261 { "add-component", 0, 0, 0, g_keys_add_component },
262 { "add-attribute", 0, 0, 0, g_keys_add_attribute },
263 { "add-attribute-hotkey", 0, 0, 0, g_keys_add_attribute_hotkey },
264 { "add-net", 0, 0, 0, g_keys_add_net },
265 { "add-net-hotkey", 0, 0, 0, g_keys_add_net_hotkey },
266 { "add-bus", 0, 0, 0, g_keys_add_bus },
267 { "add-bus-hotkey", 0, 0, 0, g_keys_add_bus_hotkey },
268 { "add-text", 0, 0, 0, g_keys_add_text },
269 { "add-line", 0, 0, 0, g_keys_add_line },
270 { "add-line-hotkey", 0, 0, 0, g_keys_add_line_hotkey },
271 { "add-box", 0, 0, 0, g_keys_add_box },
272 { "add-box-hotkey", 0, 0, 0, g_keys_add_box_hotkey },
273 { "add-picture", 0, 0, 0, g_keys_add_picture},
274 { "add-picture-hotkey", 0, 0, 0, g_keys_add_picture_hotkey},
275 { "add-circle", 0, 0, 0, g_keys_add_circle },
276 { "add-circle-hotkey", 0, 0, 0, g_keys_add_circle_hotkey },
277 { "add-arc", 0, 0, 0, g_keys_add_arc },
278 { "add-arc-hotkey", 0, 0, 0, g_keys_add_arc_hotkey },
279 { "add-pin", 0, 0, 0, g_keys_add_pin },
280 { "add-pin-hotkey", 0, 0, 0, g_keys_add_pin_hotkey },
281 { "hierarchy-down-schematic", 0, 0, 0, g_keys_hierarchy_down_schematic },
282 { "hierarchy-down-symbol", 0, 0, 0, g_keys_hierarchy_down_symbol },
283 { "hierarchy-up", 0, 0, 0, g_keys_hierarchy_up },
284 { "hierarchy-documentation", 0, 0, 0, g_keys_hierarchy_documentation },
285 { "attributes-attach", 0, 0, 0, g_keys_attributes_attach },
286 { "attributes-detach", 0, 0, 0, g_keys_attributes_detach },
287 { "attributes-show-name", 0, 0, 0, g_keys_attributes_show_name },
288 { "attributes-show-value", 0, 0, 0, g_keys_attributes_show_value },
289 { "attributes-show-both", 0, 0, 0, g_keys_attributes_show_both },
290 { "attributes-visibility-toggle", 0, 0, 0, g_keys_attributes_visibility_toggle },
291 { "options-text-size", 0, 0, 0, g_keys_options_text_size },
292 { "options-snap-size", 0, 0, 0, g_keys_options_snap_size },
293 { "options-scale-up-snap-size", 0, 0, 0, g_keys_options_scale_up_snap_size },
294 { "options-scale-down-snap-size",0, 0, 0, g_keys_options_scale_down_snap_size },
295 { "options-action-feedback", 0, 0, 0, g_keys_options_afeedback },
296 { "options-grid", 0, 0, 0, g_keys_options_grid },
297 { "options-snap", 0, 0, 0, g_keys_options_snap },
298 { "options-rubberband", 0, 0, 0, g_keys_options_rubberband },
299 { "options-show-log-window", 0, 0, 0, g_keys_options_show_log_window },
300 { "options-show-coord-window", 0, 0, 0, g_keys_options_show_coord_window },
301 { "help-about", 0, 0, 0, g_keys_help_about },
302 { "help-hotkeys", 0, 0, 0, g_keys_help_hotkeys },
303 { "help-component", 0, 0, 0, g_keys_hierarchy_documentation },
304 { "misc-misc", 0, 0, 0, g_keys_misc },
305 { "misc-misc2", 0, 0, 0, g_keys_misc2 },
306 { "misc-misc3", 0, 0, 0, g_keys_misc3 },
307 { "cancel", 0, 0, 0, g_keys_cancel },
309 /*help functions for generating netlists*/
310 { "get-selected-filename", 0, 0, 0, g_get_selected_filename },
311 { "get-selected-component-attributes", 0, 0, 0, g_get_selected_component_attributes },
313 { NULL, 0, 0, 0, NULL } };
315 /*! \brief Register function with Scheme.
316 * \par Function Description
317 * 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.
319 void g_register_funcs (void)
321 struct gsubr_t *tmp = gschem_funcs;
323 while (tmp->name != NULL) {
324 scm_c_define_gsubr (tmp->name, tmp->req, tmp->opt, tmp->rst, tmp->fnc);
325 tmp++;
328 g_init_attrib_smob ();
329 g_init_object_smob ();
330 g_init_page_smob ();
332 /* Hook stuff */
333 scm_c_define_gsubr ("add-attribute-to-object", 5, 0, 0, g_add_attrib);
334 scm_c_define_gsubr ("get-object-attributes", 1, 0, 0, g_get_object_attributes);
335 scm_c_define_gsubr ("get-object-bounds", 3, 0, 0, g_get_object_bounds);
336 scm_c_define_gsubr ("get-object-pins", 1, 0, 0, g_get_object_pins);
337 scm_c_define_gsubr ("get-pin-ends", 1, 0, 0, g_get_pin_ends);
338 scm_c_define_gsubr ("set-attribute-text-properties!", 7, 0, 0, g_set_attrib_text_properties);
339 scm_c_define_gsubr ("set-attribute-value!", 2, 0, 0, g_set_attrib_value_x);
340 scm_c_define_gsubr ("add-component-at-xy", 7, 0, 0, g_add_component);
341 scm_c_define_gsubr ("get-objects-in-page", 1, 0, 0, g_get_objects_in_page);
343 add_component_hook = scm_create_hook ("add-component-hook", 1);
344 add_component_object_hook = scm_create_hook ("add-component-object-hook",
346 rotate_component_object_hook = scm_create_hook ("rotate-component-object-hook",
348 mirror_component_object_hook = scm_create_hook ("mirror-component-object-hook",
350 copy_component_hook = scm_create_hook ("copy-component-hook", 1);
351 move_component_hook = scm_create_hook ("move-component-hook", 1);
352 deselect_component_hook = scm_create_hook ("deselect-component-hook", 1);
353 deselect_net_hook = scm_create_hook ("deselect-net-hook", 1);
354 deselect_all_hook = scm_create_hook ("deselect-all-hook", 1);
355 select_component_hook = scm_create_hook ("select-component-hook", 1);
356 select_net_hook = scm_create_hook ("select-net-hook", 1);
358 add_pin_hook = scm_create_hook ("add-pin-hook", 1);
359 mirror_pin_hook = scm_create_hook ("mirror-pin-hook", 1);
360 rotate_pin_hook = scm_create_hook ("rotate-pin-hook", 1);
361 add_attribute_hook = scm_create_hook ("add-attribute-hook", 1);
362 new_page_hook = scm_create_hook ("new-page-hook", 1);
363 complex_place_list_changed_hook =
364 scm_create_hook ("complex-place-list-changed-hook", 1);