Add FoundColor to resource settings, distinct from the Connected color
[geda-pcb/pcjc2.git] / src / gather-actions
blobd8b9e9d27ef60d41b1fef7fcff15e66c628200f6
1 #!/usr/bin/perl
2 # -*- perl -*-
4 # COPYRIGHT
5 # PCB, interactive printed circuit board design
6 # Copyright (C) 2004 DJ Delorie
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 # Contact addresses for paper mail and Email:
23 # DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA
24 # dj@delorie.com
26 #-----------------------------------------------------------------------------
27 # Include a comment like this anywhere in your source to automatically
28 # register an action. The gather-actions script looks for these and
29 # generates the list, but the comment keeps it from actually doing
30 # anything in your source. Note: do not quote the name, and include no
31 # extra spaces.
33 # /* ACTION(name,func) */
35 # Similarly, but for menu flags. The parm is passed to the func, so
36 # you can have one function support multiple flags. */
38 # /* FLAG(name,func,parm) */
40 # Similarly, but for menu generators. In the menu resource, entries of
41 # the form "@func" will call the func named in this table to include a
42 # dynamically generated set of buttons. */
44 # /* MENU(name,func) */
45 #-----------------------------------------------------------------------------
47 $verbose = 0;
49 open(OUT, "> actionlist.c");
50 select OUT;
52 print "/* This file is generated by gather-actions. DO NOT EDIT. */\n";
53 print "\n";
54 print "#include \"global.h\"\n";
55 print "#include \"X11/Intrinsic.h\"\n";
56 print "\n";
58 foreach $file (@ARGV) {
59 next if $file =~ /\.h$/;
60 open(F, $file);
61 while (<F>) {
62 if (/\/\* ACTION\((.*)\) *(POPUP|CREATE)?/) {
63 print STDERR "action: $1 $2\n" if $verbose;
64 ($name, $func) = split(',', $1, 2);
65 push(@actions, "$name\0$func\0$2");
66 push(@actionfuncs, "$func");
67 } elsif (/\/\* FLAG\((.*)\)/) {
68 print STDERR "flag: $1\n" if $verbose;
69 ($name, $func, $parm) = split(',', $1, 3);
70 $parm = 0 unless $parm =~ /\S/;
71 push(@flags, "$name\0$func\0$parm");
72 push(@flagfuncs, "$func");
73 } elsif (/\/\* MENU\((.*)\)/) {
74 print STDERR "menu: $1\n" if $verbose;
75 ($name, $func) = split(',', $1,2);
76 push(@menus, "$name\0$func");
77 push(@menufuncs, "$func");
80 close(F);
83 #-----------------------------------------------------------------------------
85 for $func (sort @actionfuncs) {
86 print "extern void $func(Widget,XEvent *,String *, Cardinal *);\n";
89 print "\n";
90 print "XtActionsRec ActionList[] = {\n";
91 for $a (sort @actions) {
92 ($name, $func, $types) = split(/\0/, $a);
93 print " {\"$name\", $func},\n";
96 print " {0,0}\n";
97 print "};\n";
98 print "\n";
100 print "struct { char *name; int type; } ActionTypeList[] = {\n";
101 for $a (sort @actions) {
102 ($name, $func, $types) = split(/\0/, $a);
103 $type = 0;
104 $type = "'p'" if $types =~ /popup/i;
105 $type = "'c'" if $types =~ /create/i;
106 print " {\"$name\", $type},\n";
108 print " {0,0}\n";
109 print "};\n";
110 print "\n";
112 $n = $#actions + 1;
113 print "int ActionListSize = $n;\n";
115 #-----------------------------------------------------------------------------
117 for $func (sort @flagfuncs) {
118 print "extern int $func(int);\n";
121 print "\n";
122 print "struct {\n";
123 print " char *name;\n";
124 print " int (*func)(int);\n";
125 print " int parm;\n";
126 print "} FlagFuncList[] = {\n";
128 for $f (sort @flags) {
129 ($name, $func, $parm) = split(/\0/, $f);
130 print " {\"$name\", $func, $parm },\n";
133 print " {0,0,0}\n";
134 print "};\n";
135 print "\n";
137 $n = $#flags + 1;
138 print "int FlagFuncListSize = $n;\n";
140 #-----------------------------------------------------------------------------
142 print "struct Resource;\n";
143 for $func (sort @menufuncs) {
144 print "extern void $func(struct Resource *);\n";
147 print "\n";
148 print "struct {\n";
149 print " char *name;\n";
150 print " void (*func)(struct Resource *);\n";
151 print "} MenuFuncList[] = {\n";
153 for $f (sort @menus) {
154 ($name, $func) = split(/\0/, $f);
155 print " {\"$name\", $func },\n";
158 print " {0,0}\n";
159 print "};\n";
160 print "\n";
162 $n = $#menus + 1;
163 print "int MenuFuncListSize = $n;\n";
165 #-----------------------------------------------------------------------------
167 close(OUT);