gschem

g_register.c

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * gschem - gEDA Schematic Capture
00003  * Copyright (C) 1998-2010 Ales Hvezda
00004  * Copyright (C) 1998-2011 gEDA Contributors (see ChangeLog for details)
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 #include <config.h>
00021 
00022 #include <stdio.h>
00023 #include <sys/stat.h>
00024 #ifdef HAVE_STDLIB_H
00025 #include <stdlib.h>
00026 #endif
00027 #ifdef HAVE_ASSERT_H
00028 #include <assert.h>
00029 #endif
00030 #ifdef HAVE_UNISTD_H
00031 #include <unistd.h>
00032 #endif
00033 
00034 #include "gschem.h"
00035 
00036 #ifdef HAVE_LIBDMALLOC
00037 #include <dmalloc.h>
00038 #endif
00039 
00041 struct gsubr_t {
00042   char* name;
00043   int req;
00044   int opt;
00045   int rst;
00046   SCM (*fnc)();
00047 };
00048 
00050 static struct gsubr_t gschem_funcs[] = {
00051   /* rc file */
00052   { "gschem-version",           1, 0, 0, g_rc_gschem_version },
00053 
00054   { "display-color-map",        0, 1, 0, g_rc_display_color_map },
00055   { "display-outline-color-map", 0, 1, 0, g_rc_display_outline_color_map },
00056 
00057   { "net-endpoint-mode",         1, 0, 0, g_rc_net_endpoint_mode },
00058   { "net-midpoint-mode",         1, 0, 0, g_rc_net_midpoint_mode },
00059   { "net-direction-mode",        1, 0, 0, g_rc_net_direction_mode },
00060   { "net-selection-mode",        1, 0, 0, g_rc_net_selection_mode },
00061   { "net-style",                 1, 0, 0, g_rc_net_style },
00062   { "bus-style",                 1, 0, 0, g_rc_bus_style },
00063   { "pin-style",                 1, 0, 0, g_rc_pin_style },
00064   { "line-style",                1, 0, 0, g_rc_line_style },
00065   { "zoom-with-pan",             1, 0, 0, g_rc_zoom_with_pan },
00066   { "action-feedback-mode",      1, 0, 0, g_rc_action_feedback_mode },
00067   { "text-feedback",             1, 0, 0, g_rc_text_feedback },
00068   { "text-display-zoomfactor",   1, 0, 0, g_rc_text_display_zoomfactor },
00069   { "scrollbars",                1, 0, 0, g_rc_scrollbars },
00070   { "scrollbar-update",          1, 0, 0, g_rc_scrollbar_update },
00071   { "object-clipping",           1, 0, 0, g_rc_object_clipping },
00072   { "embed-components",          1, 0, 0, g_rc_embed_components },
00073   { "component-dialog-attributes",1, 0, 0, g_rc_component_dialog_attributes },
00074   { "logging",                   1, 0, 0, g_rc_logging },
00075   { "text-size",                 1, 0, 0, g_rc_text_size },
00076   { "snap-size",                 1, 0, 0, g_rc_snap_size },
00077 
00078   { "text-caps-style",           1, 0, 0, g_rc_text_caps_style },
00079   { "logging-destination",       1, 0, 0, g_rc_logging_destination },
00080 
00081   { "attribute-name",            1, 0, 0, g_rc_attribute_name },
00082   { "paper-size",                2, 0, 0, g_rc_paper_size },
00083   { "paper-sizes",               3, 0, 0, g_rc_paper_sizes },
00084 
00085   { "output-type",               1, 0, 0, g_rc_output_type },
00086   { "output-orientation",        1, 0, 0, g_rc_output_orientation },
00087   { "output-color",              1, 0, 0, g_rc_output_color },
00088   { "output-capstyle",           1, 0, 0, g_rc_output_capstyle },
00089   { "image-color",               1, 0, 0, g_rc_image_color },
00090   { "image-size",                2, 0, 0, g_rc_image_size },
00091   { "log-window",                1, 0, 0, g_rc_log_window },
00092   { "log-window-type",           1, 0, 0, g_rc_log_window_type },
00093   { "third-button",              1, 0, 0, g_rc_third_button },
00094   { "middle-button",             1, 0, 0, g_rc_middle_button },
00095   { "scroll-wheel",              1, 0, 0, g_rc_scroll_wheel },
00096   { "net-consolidate",           1, 0, 0, g_rc_net_consolidate },
00097   { "file-preview",              1, 0, 0, g_rc_file_preview },
00098   { "enforce-hierarchy",         1, 0, 0, g_rc_enforce_hierarchy },
00099   { "text-origin-marker",        1, 0, 0, g_rc_text_origin_marker },
00100   { "fast-mousepan",             1, 0, 0, g_rc_fast_mousepan },
00101   { "raise-dialog-boxes-on-expose", 1, 0, 0, g_rc_raise_dialog_boxes_on_expose },
00102   { "continue-component-place",  1, 0, 0, g_rc_continue_component_place },
00103   { "undo-levels",               1, 0, 0, g_rc_undo_levels },
00104   { "undo-control",              1, 0, 0, g_rc_undo_control },
00105   { "undo-type",                 1, 0, 0, g_rc_undo_type },
00106   { "undo-panzoom",              1, 0, 0, g_rc_undo_panzoom },
00107 
00108   { "draw-grips",                1, 0, 0, g_rc_draw_grips },
00109   { "netconn-rubberband",        1, 0, 0, g_rc_netconn_rubberband },
00110   { "magnetic-net-mode",         1, 0, 0, g_rc_magnetic_net_mode },
00111   { "sort-component-library",    1, 0, 0, g_rc_sort_component_library },
00112   { "add-menu",                  2, 0, 0, g_rc_add_menu },
00113   { "window-size",               2, 0, 0, g_rc_window_size },
00114   { "warp-cursor",               1, 0, 0, g_rc_warp_cursor },
00115   { "toolbars",                  1, 0, 0, g_rc_toolbars },
00116   { "handleboxes",               1, 0, 0, g_rc_handleboxes },
00117   { "setpagedevice-orientation", 1, 0, 0, g_rc_setpagedevice_orientation },
00118   { "setpagedevice-pagesize",    1, 0, 0, g_rc_setpagedevice_pagesize },
00119   { "bus-ripper-size",           1, 0, 0, g_rc_bus_ripper_size },
00120   { "bus-ripper-type",           1, 0, 0, g_rc_bus_ripper_type },
00121   { "bus-ripper-rotation",       1, 0, 0, g_rc_bus_ripper_rotation },
00122   { "force-boundingbox",         1, 0, 0, g_rc_force_boundingbox },
00123   { "dots-grid-dot-size",        1, 0, 0, g_rc_dots_grid_dot_size },
00124   { "dots-grid-mode",            1, 0, 0, g_rc_dots_grid_mode },
00125   { "dots-grid-fixed-threshold", 1, 0, 0, g_rc_dots_grid_fixed_threshold },
00126   { "mesh-grid-display-threshold", 1, 0, 0, g_rc_mesh_grid_display_threshold },
00127   { "add-attribute-offset",      1, 0, 0, g_rc_add_attribute_offset },
00128   { "mousepan-gain",             1, 0, 0, g_rc_mousepan_gain },
00129   { "keyboardpan-gain",          1, 0, 0, g_rc_keyboardpan_gain },
00130   { "print-command",             1, 0, 0, g_rc_print_command },
00131   { "select-slack-pixels",       1, 0, 0, g_rc_select_slack_pixels },
00132   { "zoom-gain",                 1, 0, 0, g_rc_zoom_gain },
00133   { "scrollpan-steps",           1, 0, 0, g_rc_scrollpan_steps },
00134 
00135   /* backup functions */
00136   { "auto-save-interval",        1, 0, 0, g_rc_auto_save_interval },
00137 
00138   /* general guile functions */
00139   { "gschem-print",              1, 0, 0, g_funcs_print },
00140   { "gschem-postscript",         1, 0, 0, g_funcs_postscript },
00141   { "gschem-image",              1, 0, 0, g_funcs_image },
00142   { "gschem-use-rc-values",      0, 0, 0, g_funcs_use_rc_values },
00143   { "gschem-exit",               0, 0, 0, g_funcs_exit },
00144   { "gschem-log",                1, 0, 0, g_funcs_log },
00145   { "gschem-msg",                1, 0, 0, g_funcs_msg },
00146   { "gschem-confirm",            1, 0, 0, g_funcs_confirm },
00147   { "gschem-filesel",            2, 0, 1, g_funcs_filesel },
00148 
00149   /* keymapping callbacks */
00150   { "file-new-window",           0, 0, 0, g_keys_file_new_window },
00151   { "file-new",                  0, 0, 0, g_keys_file_new },
00152   { "file-open",                 0, 0, 0, g_keys_file_open },
00153   { "file-script",               0, 0, 0, g_keys_file_script },
00154   { "file-save",                 0, 0, 0, g_keys_file_save },
00155   { "file-save-as",              0, 0, 0, g_keys_file_save_as },
00156   { "file-save-all",             0, 0, 0, g_keys_file_save_all },
00157   { "file-print",                0, 0, 0, g_keys_file_print },
00158   { "file-image",                0, 0, 0, g_keys_file_write_png },
00159   { "file-close-window",         0, 0, 0, g_keys_file_close },
00160   { "file-quit",                 0, 0, 0, g_keys_file_quit },
00161   { "edit-undo",                 0, 0, 0, g_keys_edit_undo },
00162   { "edit-redo",                 0, 0, 0, g_keys_edit_redo },
00163   { "edit-select",               0, 0, 0, g_keys_edit_select },
00164   { "edit-select-all",           0, 0, 0, g_keys_edit_select_all },
00165   { "edit-deselect",             0, 0, 0, g_keys_edit_deselect },
00166   { "edit-copy",                 0, 0, 0, g_keys_edit_copy },
00167   { "edit-copy-hotkey",          0, 0, 0, g_keys_edit_copy_hotkey },
00168   { "edit-mcopy",                0, 0, 0, g_keys_edit_mcopy },
00169   { "edit-mcopy-hotkey",         0, 0, 0, g_keys_edit_mcopy_hotkey },
00170   { "edit-move",                 0, 0, 0, g_keys_edit_move },
00171   { "edit-move-hotkey",          0, 0, 0, g_keys_edit_move_hotkey },
00172   { "edit-delete",               0, 0, 0, g_keys_edit_delete },
00173   { "edit-rotate-90",            0, 0, 0, g_keys_edit_rotate_90 },
00174   { "edit-rotate-90-hotkey",     0, 0, 0, g_keys_edit_rotate_90_hotkey },
00175   { "edit-mirror",               0, 0, 0, g_keys_edit_mirror },
00176   { "edit-mirror-hotkey",        0, 0, 0, g_keys_edit_mirror_hotkey },
00177   { "edit-slot",                 0, 0, 0, g_keys_edit_slot },
00178   { "edit-color",                0, 0, 0, g_keys_edit_color },
00179   { "edit-edit",                 0, 0, 0, g_keys_edit_edit },
00180   { "edit-text",                 0, 0, 0, g_keys_edit_text },
00181   { "edit-lock",                 0, 0, 0, g_keys_edit_lock },
00182   { "edit-unlock",               0, 0, 0, g_keys_edit_unlock },
00183   { "edit-linetype",             0, 0, 0, g_keys_edit_linetype },
00184   { "edit-filltype",             0, 0, 0, g_keys_edit_filltype },
00185   { "edit-translate",            0, 0, 0, g_keys_edit_translate },
00186   { "edit-invoke-macro",         0, 0, 0, g_keys_edit_invoke_macro },
00187   { "edit-embed",                0, 0, 0, g_keys_edit_embed },
00188   { "edit-unembed",              0, 0, 0, g_keys_edit_unembed },
00189   { "edit-update",               0, 0, 0, g_keys_edit_update },
00190   { "edit-show-hidden",          0, 0, 0, g_keys_edit_show_hidden },
00191   { "edit-find-text",            0, 0, 0, g_keys_edit_find },
00192   { "edit-show-text",            0, 0, 0, g_keys_edit_show_text },
00193   { "edit-hide-text",            0, 0, 0, g_keys_edit_hide_text },
00194   { "edit-autonumber",           0, 0, 0, g_keys_edit_autonumber_text },
00195 
00196   { "clipboard-copy",            0, 0, 0, g_keys_clipboard_copy },
00197   { "clipboard-cut",             0, 0, 0, g_keys_clipboard_cut },
00198   { "clipboard-paste",           0, 0, 0, g_keys_clipboard_paste },
00199   { "clipboard-paste-hotkey",    0, 0, 0, g_keys_clipboard_paste_hotkey },
00200 
00201   { "buffer-copy1",              0, 0, 0, g_keys_buffer_copy1 },
00202   { "buffer-copy2",              0, 0, 0, g_keys_buffer_copy2 },
00203   { "buffer-copy3",              0, 0, 0, g_keys_buffer_copy3 },
00204   { "buffer-copy4",              0, 0, 0, g_keys_buffer_copy4 },
00205   { "buffer-copy5",              0, 0, 0, g_keys_buffer_copy5 },
00206   { "buffer-cut1",               0, 0, 0, g_keys_buffer_cut1 },
00207   { "buffer-cut2",               0, 0, 0, g_keys_buffer_cut2 },
00208   { "buffer-cut3",               0, 0, 0, g_keys_buffer_cut3 },
00209   { "buffer-cut4",               0, 0, 0, g_keys_buffer_cut4 },
00210   { "buffer-cut5",               0, 0, 0, g_keys_buffer_cut5 },
00211   { "buffer-paste1",             0, 0, 0, g_keys_buffer_paste1 },
00212   { "buffer-paste2",             0, 0, 0, g_keys_buffer_paste2 },
00213   { "buffer-paste3",             0, 0, 0, g_keys_buffer_paste3 },
00214   { "buffer-paste4",             0, 0, 0, g_keys_buffer_paste4 },
00215   { "buffer-paste5",             0, 0, 0, g_keys_buffer_paste5 },
00216   { "buffer-paste1-hotkey",      0, 0, 0, g_keys_buffer_paste1_hotkey },
00217   { "buffer-paste2-hotkey",      0, 0, 0, g_keys_buffer_paste2_hotkey },
00218   { "buffer-paste3-hotkey",      0, 0, 0, g_keys_buffer_paste3_hotkey },
00219   { "buffer-paste4-hotkey",      0, 0, 0, g_keys_buffer_paste4_hotkey },
00220   { "buffer-paste5-hotkey",      0, 0, 0, g_keys_buffer_paste5_hotkey },
00221 
00222   { "view-redraw",               0, 0, 0, g_keys_view_redraw },
00223   { "view-zoom-full",            0, 0, 0, g_keys_view_zoom_full },
00224   { "view-zoom-extents",         0, 0, 0, g_keys_view_zoom_extents },
00225   { "view-zoom-in",              0, 0, 0, g_keys_view_zoom_in },
00226   { "view-zoom-out",             0, 0, 0, g_keys_view_zoom_out },
00227   { "view-zoom-in-hotkey",       0, 0, 0, g_keys_view_zoom_in_hotkey },
00228   { "view-zoom-out-hotkey",      0, 0, 0, g_keys_view_zoom_out_hotkey },
00229   { "view-zoom-box",             0, 0, 0, g_keys_view_zoom_box },
00230   { "view-zoom-box-hotkey",      0, 0, 0, g_keys_view_zoom_box_hotkey },
00231   { "view-pan",                  0, 0, 0, g_keys_view_pan },
00232   { "view-pan-hotkey",           0, 0, 0, g_keys_view_pan_hotkey },
00233   { "view-pan-left",         0, 0, 0, g_keys_view_pan_left },
00234   { "view-pan-right",        0, 0, 0, g_keys_view_pan_right },
00235   { "view-pan-up",       0, 0, 0, g_keys_view_pan_up },
00236   { "view-pan-down",         0, 0, 0, g_keys_view_pan_down },
00237   { "view-dark-colors",          0, 0, 0, g_keys_view_dark_colors },
00238   { "view-light-colors",         0, 0, 0, g_keys_view_light_colors },
00239   { "view-bw-colors",            0, 0, 0, g_keys_view_bw_colors },
00240   { "page-manager",              0, 0, 0, g_keys_page_manager },
00241   { "page-next",                 0, 0, 0, g_keys_page_next },
00242   { "page-prev",                 0, 0, 0, g_keys_page_prev },
00243   { "page-new",                  0, 0, 0, g_keys_page_new },
00244   { "page-close",                0, 0, 0, g_keys_page_close },
00245   { "page-revert",               0, 0, 0, g_keys_page_revert },
00246   { "page-discard",              0, 0, 0, g_keys_page_discard },
00247   { "page-print",                0, 0, 0, g_keys_page_print },
00248   { "add-component",             0, 0, 0, g_keys_add_component },
00249   { "add-attribute",             0, 0, 0, g_keys_add_attribute },
00250   { "add-attribute-hotkey",      0, 0, 0, g_keys_add_attribute_hotkey },
00251   { "add-net",                   0, 0, 0, g_keys_add_net },
00252   { "add-net-hotkey",            0, 0, 0, g_keys_add_net_hotkey },
00253   { "add-bus",                   0, 0, 0, g_keys_add_bus },
00254   { "add-bus-hotkey",            0, 0, 0, g_keys_add_bus_hotkey },
00255   { "add-text",                  0, 0, 0, g_keys_add_text },
00256   { "add-line",                  0, 0, 0, g_keys_add_line },
00257   { "add-line-hotkey",           0, 0, 0, g_keys_add_line_hotkey },
00258   { "add-box",                   0, 0, 0, g_keys_add_box },
00259   { "add-box-hotkey",            0, 0, 0, g_keys_add_box_hotkey },
00260   { "add-picture",               0, 0, 0, g_keys_add_picture},
00261   { "add-picture-hotkey",        0, 0, 0, g_keys_add_picture_hotkey},
00262   { "add-circle",                0, 0, 0, g_keys_add_circle },
00263   { "add-circle-hotkey",         0, 0, 0, g_keys_add_circle_hotkey },
00264   { "add-arc",                   0, 0, 0, g_keys_add_arc },
00265   { "add-arc-hotkey",            0, 0, 0, g_keys_add_arc_hotkey },
00266   { "add-pin",                   0, 0, 0, g_keys_add_pin },
00267   { "add-pin-hotkey",            0, 0, 0, g_keys_add_pin_hotkey },
00268   { "hierarchy-down-schematic",  0, 0, 0, g_keys_hierarchy_down_schematic },
00269   { "hierarchy-down-symbol",     0, 0, 0, g_keys_hierarchy_down_symbol },
00270   { "hierarchy-up",              0, 0, 0, g_keys_hierarchy_up },
00271   { "attributes-attach",         0, 0, 0, g_keys_attributes_attach },
00272   { "attributes-detach",         0, 0, 0, g_keys_attributes_detach },
00273   { "attributes-show-name",      0, 0, 0, g_keys_attributes_show_name },
00274   { "attributes-show-value",     0, 0, 0, g_keys_attributes_show_value },
00275   { "attributes-show-both",      0, 0, 0, g_keys_attributes_show_both },
00276   { "attributes-visibility-toggle", 0, 0, 0, g_keys_attributes_visibility_toggle },
00277   { "options-text-size",         0, 0, 0, g_keys_options_text_size },
00278   { "options-snap-size",         0, 0, 0, g_keys_options_snap_size },
00279   { "options-scale-up-snap-size",  0, 0, 0, g_keys_options_scale_up_snap_size },
00280   { "options-scale-down-snap-size",0, 0, 0, g_keys_options_scale_down_snap_size },
00281   { "options-action-feedback",   0, 0, 0, g_keys_options_afeedback },
00282   { "options-grid",              0, 0, 0, g_keys_options_grid },
00283   { "options-snap",              0, 0, 0, g_keys_options_snap },
00284   { "options-rubberband",        0, 0, 0, g_keys_options_rubberband },
00285   { "options-magneticnet",       0, 0, 0, g_keys_options_magneticnet },
00286   { "options-show-log-window",   0, 0, 0, g_keys_options_show_log_window },
00287   { "options-show-coord-window", 0, 0, 0, g_keys_options_show_coord_window },
00288   { "help-about",                0, 0, 0, g_keys_help_about },
00289   { "help-hotkeys",              0, 0, 0, g_keys_help_hotkeys },
00290   { "misc-misc",                 0, 0, 0, g_keys_misc },
00291   { "misc-misc2",                0, 0, 0, g_keys_misc2 },
00292   { "misc-misc3",                0, 0, 0, g_keys_misc3 },
00293   { "cancel",                    0, 0, 0, g_keys_cancel },
00294 
00295   { NULL,                        0, 0, 0, NULL } };
00296 
00307 static SCM
00308 create_hook (const char *name, int n_args)
00309 {
00310   SCM hook = scm_make_hook (scm_from_int (n_args));
00311   scm_c_define (name, hook);
00312   return scm_permanent_object (hook);
00313 }
00314 
00319 void g_register_funcs (void)
00320 {
00321   struct gsubr_t *tmp = gschem_funcs;
00322  
00323   while (tmp->name != NULL) {
00324     scm_c_define_gsubr (tmp->name, tmp->req, tmp->opt, tmp->rst, tmp->fnc);
00325     tmp++;
00326   }
00327 
00328   /* Hook stuff */
00329   complex_place_list_changed_hook = create_hook ("complex-place-list-changed-hook", 1);
00330 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines