gschem: Wrap many built-in commands using new actions system.
[geda-gaf.git] / gschem / src / g_builtins.c
blob1937ea12ed1676b4494ef168f9fe2f726aa7bec6
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 2013 Peter Brett <peter@peter-b.co.uk>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
20 /*! \file g_builtins.c
21 * \brief gschem built-in actions
24 #include <config.h>
25 #include <missing.h>
27 #include "gschem.h"
29 struct BuiltinInfo {
30 const char *name;
31 int req, opt, rst;
32 SCM (*func)();
35 static struct BuiltinInfo builtins[] = {
36 { "%file-new-window", 0, 0, 0, g_keys_file_new_window },
37 { "%file-new", 0, 0, 0, g_keys_file_new },
38 { "%file-open", 0, 0, 0, g_keys_file_open },
39 { "%file-script", 0, 0, 0, g_keys_file_script },
40 { "%file-save", 0, 0, 0, g_keys_file_save },
41 { "%file-save-as", 0, 0, 0, g_keys_file_save_as },
42 { "%file-save-all", 0, 0, 0, g_keys_file_save_all },
43 { "%file-print", 0, 0, 0, g_keys_file_print },
44 { "%file-image", 0, 0, 0, g_keys_file_write_png },
45 { "%file-close-window", 0, 0, 0, g_keys_file_close },
46 { "%file-quit", 0, 0, 0, g_keys_file_quit },
47 { "%edit-undo", 0, 0, 0, g_keys_edit_undo },
48 { "%edit-redo", 0, 0, 0, g_keys_edit_redo },
49 { "%edit-select", 0, 0, 0, g_keys_edit_select },
50 { "%edit-select-all", 0, 0, 0, g_keys_edit_select_all },
51 { "%edit-deselect", 0, 0, 0, g_keys_edit_deselect },
52 { "%edit-copy", 0, 0, 0, g_keys_edit_copy },
53 { "%edit-mcopy", 0, 0, 0, g_keys_edit_mcopy },
54 { "%edit-move", 0, 0, 0, g_keys_edit_move },
55 { "%edit-delete", 0, 0, 0, g_keys_edit_delete },
56 { "%edit-rotate-90", 0, 0, 0, g_keys_edit_rotate_90 },
57 { "%edit-mirror", 0, 0, 0, g_keys_edit_mirror },
58 { "%edit-slot", 0, 0, 0, g_keys_edit_slot },
59 { "%edit-color", 0, 0, 0, g_keys_edit_color },
60 { "%edit-edit", 0, 0, 0, g_keys_edit_edit },
61 { "%edit-text", 0, 0, 0, g_keys_edit_text },
62 { "%edit-lock", 0, 0, 0, g_keys_edit_lock },
63 { "%edit-unlock", 0, 0, 0, g_keys_edit_unlock },
64 { "%edit-linetype", 0, 0, 0, g_keys_edit_linetype },
65 { "%edit-filltype", 0, 0, 0, g_keys_edit_filltype },
66 { "%edit-pin-type", 0, 0, 0, g_keys_edit_pin_type },
67 { "%edit-translate", 0, 0, 0, g_keys_edit_translate },
68 { "%edit-invoke-macro", 0, 0, 0, g_keys_edit_invoke_macro },
69 { "%edit-embed", 0, 0, 0, g_keys_edit_embed },
70 { "%edit-unembed", 0, 0, 0, g_keys_edit_unembed },
71 { "%edit-update", 0, 0, 0, g_keys_edit_update },
72 { "%edit-show-hidden", 0, 0, 0, g_keys_edit_show_hidden },
73 { "%edit-find-text", 0, 0, 0, g_keys_edit_find },
74 { "%edit-show-text", 0, 0, 0, g_keys_edit_show_text },
75 { "%edit-hide-text", 0, 0, 0, g_keys_edit_hide_text },
76 { "%edit-autonumber", 0, 0, 0, g_keys_edit_autonumber_text },
78 { "%clipboard-copy", 0, 0, 0, g_keys_clipboard_copy },
79 { "%clipboard-cut", 0, 0, 0, g_keys_clipboard_cut },
80 { "%clipboard-paste", 0, 0, 0, g_keys_clipboard_paste },
82 { "%buffer-copy1", 0, 0, 0, g_keys_buffer_copy1 },
83 { "%buffer-copy2", 0, 0, 0, g_keys_buffer_copy2 },
84 { "%buffer-copy3", 0, 0, 0, g_keys_buffer_copy3 },
85 { "%buffer-copy4", 0, 0, 0, g_keys_buffer_copy4 },
86 { "%buffer-copy5", 0, 0, 0, g_keys_buffer_copy5 },
87 { "%buffer-cut1", 0, 0, 0, g_keys_buffer_cut1 },
88 { "%buffer-cut2", 0, 0, 0, g_keys_buffer_cut2 },
89 { "%buffer-cut3", 0, 0, 0, g_keys_buffer_cut3 },
90 { "%buffer-cut4", 0, 0, 0, g_keys_buffer_cut4 },
91 { "%buffer-cut5", 0, 0, 0, g_keys_buffer_cut5 },
92 { "%buffer-paste1", 0, 0, 0, g_keys_buffer_paste1 },
93 { "%buffer-paste2", 0, 0, 0, g_keys_buffer_paste2 },
94 { "%buffer-paste3", 0, 0, 0, g_keys_buffer_paste3 },
95 { "%buffer-paste4", 0, 0, 0, g_keys_buffer_paste4 },
96 { "%buffer-paste5", 0, 0, 0, g_keys_buffer_paste5 },
98 { "%view-redraw", 0, 0, 0, g_keys_view_redraw },
99 { "%view-zoom-full", 0, 0, 0, g_keys_view_zoom_full },
100 { "%view-zoom-extents", 0, 0, 0, g_keys_view_zoom_extents },
101 { "%view-zoom-in", 0, 0, 0, g_keys_view_zoom_in },
102 { "%view-zoom-out", 0, 0, 0, g_keys_view_zoom_out },
103 { "%view-zoom-box", 0, 0, 0, g_keys_view_zoom_box },
104 { "%view-pan", 0, 0, 0, g_keys_view_pan },
105 { "%view-pan-left", 0, 0, 0, g_keys_view_pan_left },
106 { "%view-pan-right", 0, 0, 0, g_keys_view_pan_right },
107 { "%view-pan-up", 0, 0, 0, g_keys_view_pan_up },
108 { "%view-pan-down", 0, 0, 0, g_keys_view_pan_down },
109 { "%view-dark-colors", 0, 0, 0, g_keys_view_dark_colors },
110 { "%view-light-colors", 0, 0, 0, g_keys_view_light_colors },
111 { "%view-bw-colors", 0, 0, 0, g_keys_view_bw_colors },
112 { "%page-manager", 0, 0, 0, g_keys_page_manager },
113 { "%page-next", 0, 0, 0, g_keys_page_next },
114 { "%page-prev", 0, 0, 0, g_keys_page_prev },
115 { "%page-close", 0, 0, 0, g_keys_page_close },
116 { "%page-revert", 0, 0, 0, g_keys_page_revert },
117 { "%page-print", 0, 0, 0, g_keys_page_print },
118 { "%add-component", 0, 0, 0, g_keys_add_component },
119 { "%add-attribute", 0, 0, 0, g_keys_add_attribute },
120 { "%add-net", 0, 0, 0, g_keys_add_net },
121 { "%add-bus", 0, 0, 0, g_keys_add_bus },
122 { "%add-text", 0, 0, 0, g_keys_add_text },
123 { "%add-path", 0, 0, 0, g_keys_add_path },
124 { "%add-line", 0, 0, 0, g_keys_add_line },
125 { "%add-box", 0, 0, 0, g_keys_add_box },
126 { "%add-picture", 0, 0, 0, g_keys_add_picture},
127 { "%add-circle", 0, 0, 0, g_keys_add_circle },
128 { "%add-arc", 0, 0, 0, g_keys_add_arc },
129 { "%add-pin", 0, 0, 0, g_keys_add_pin },
130 { "%hierarchy-down-schematic", 0, 0, 0, g_keys_hierarchy_down_schematic },
131 { "%hierarchy-down-symbol", 0, 0, 0, g_keys_hierarchy_down_symbol },
132 { "%hierarchy-up", 0, 0, 0, g_keys_hierarchy_up },
133 { "%attributes-attach", 0, 0, 0, g_keys_attributes_attach },
134 { "%attributes-detach", 0, 0, 0, g_keys_attributes_detach },
135 { "%attributes-show-name", 0, 0, 0, g_keys_attributes_show_name },
136 { "%attributes-show-value", 0, 0, 0, g_keys_attributes_show_value },
137 { "%attributes-show-both", 0, 0, 0, g_keys_attributes_show_both },
138 { "%attributes-visibility-toggle", 0, 0, 0, g_keys_attributes_visibility_toggle },
139 { "%options-text-size", 0, 0, 0, g_keys_options_text_size },
140 { "%options-snap-size", 0, 0, 0, g_keys_options_snap_size },
141 { "%options-scale-up-snap-size", 0, 0, 0, g_keys_options_scale_up_snap_size },
142 { "%options-scale-down-snap-size",0, 0, 0, g_keys_options_scale_down_snap_size },
143 { "%options-action-feedback", 0, 0, 0, g_keys_options_afeedback },
144 { "%options-grid", 0, 0, 0, g_keys_options_grid },
145 { "%options-snap", 0, 0, 0, g_keys_options_snap },
146 { "%options-rubberband", 0, 0, 0, g_keys_options_rubberband },
147 { "%options-magneticnet", 0, 0, 0, g_keys_options_magneticnet },
148 { "%options-show-log-window", 0, 0, 0, g_keys_options_show_log_window },
149 { "%options-show-coord-window", 0, 0, 0, g_keys_options_show_coord_window },
150 { "%help-about", 0, 0, 0, g_keys_help_about },
151 { "%help-hotkeys", 0, 0, 0, g_keys_help_hotkeys },
152 { "%cancel", 0, 0, 0, g_keys_cancel },
154 { NULL, 0, 0, 0, NULL }, /* Custodian */
157 /*! \brief Create the (gschem core builtins) Scheme module.
158 * \par Function Description
159 * Defines procedures in the (gschem core builtins) module. The module can
160 * be accessed using (use-modules (gschem core builtins)).
162 static void
163 init_module_gschem_core_builtins ()
165 int i;
167 /* Register the functions and add them to the module's public
168 * definitions. */
169 for (i = 0; builtins[i].name != NULL; ++i) {
170 struct BuiltinInfo b = builtins[i];
171 scm_c_define_gsubr (b.name, b.req, b.opt, b.rst, b.func);
172 scm_c_export (b.name, NULL);
177 * \brief Initialise gschem built-in actions.
178 * \par Function Description
180 * Registers the Scheme procedures used to access gschem's built-in
181 * editing actions implemented in C. Should only be called by
182 * main_prog().
184 void
185 g_init_builtins ()
187 /* Define the (gschem core builtins) module */
188 scm_c_define_module ("gschem core builtins",
189 init_module_gschem_core_builtins,
190 NULL);