]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfix.sh
more FILMagain stuff
[lyx.git] / src / frontends / xforms / forms / fdfix.sh
1 #! /bin/sh
2 #
3 # NOTE: This is NOT the same fdfix.sh as in ${top_srcdir}/forms
4 #       It is a modified version to suit use for gui-indep.
5 #
6 if [ "$1" = "$2" ]; then
7     echo "Input and Output file can not be the same."
8     exit 1
9 fi
10
11 if [ -f $2 ]; then
12         echo "Output file already exists, overwrite?"
13         read
14         if [ "$REPLY" != "y" ]; then
15             exit 0
16         fi
17 fi
18
19 if [ ! -f $1 ]; then
20     echo "Input file does not exist, can not continue"
21     exit 1
22 fi
23
24 # If there is a patch for the outputfile patch the input file with it.
25 if [ -f "$2.patch" ]; then
26     echo "Patching $1 with $2.patch"
27     patch -s $1 < "$2.patch"
28 fi
29
30 echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.86) and gettext" > $2
31 echo "#include <config.h>" >> $2
32 echo "#include \"lyx_gui_misc.h\"" >> $2
33 echo "#include \"gettext.h\"" >> $2
34 echo >> $2
35
36 # The commands to sed does this:
37 #
38 # -e 's/#include "forms\.h"/#include FORMS_H_LOCATION/'
39 #
40 #  Replace "forms.h" by FORMS_H_LOCATION in #include directives. This
41 #  macro is defined in config.h and is either <forms.h> or
42 #  <X11/forms.h>. 
43 #
44 # -e '/fl_/ s/".[^|]*"/_(&)/'
45 #  
46 #  For all lines containing "fl_" and a string _not_ containging |,
47 #  replace the string with _(string)
48 #
49 # -e '/shortcut/ s/".*[|].*"/scex(_(&))/'
50 #
51 #  For all lines containing "shortcut" and a string containing |, replace
52 #  the string with scex(_(string))
53 #
54 # -e '/fl_add/ s/".*[|].*"/idex(_(&))/'
55 #  For all lines containing "fl_add" and a string containing |, replace
56 #  the string with idex(_(string))
57 #
58 # -e '/fl_add/ s/idex("\(.*\)").*$/&fl_set_button_shortcut(obj,"\1",1);/'
59 # For all lines containing "fl_add" and a string containing |, add the
60 # shortcut command after the end of this line
61 #
62 # -e 's/,\([^ ]\)/, \1/g'
63 #
64 # Someone got busy and put spaces in after commas but didn't allow for the
65 # autogeneration of the files so their pretty formatting got lost. Not anymore.
66 #
67 # -e 's/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 dialog_ = new \2/'
68 #
69 # We use new/delete not malloc/free so change to suit.  Also the local
70 # variable for our dialog is called dialog_ so do that fix also.
71 #
72 #-e 's/\(FD_f\([^ ]*\)_\([^ ]*\)\) \*create[^ ]*/void F\2\3::build()/'
73 #
74 # Fixup the name of the create_form... function to have a signature almost
75 # matching that of the method it will become.  You just need to capitalize
76 # the forms name.
77 #
78 #   -e 's/\(fdui->form[^ ]*\)\(.*bgn_form.*\)/\1\2\
79 #     \1->u_vdata = this;/' \
80 #
81 # We need to store a pointer to the dialog in u_vdata so that the callbacks
82 # will work.
83 #
84
85 classname=`basename $1 .c | cut -c6-`
86 firstchar=`echo $classname | cut -c1 | tr a-z A-Z`
87 rest=`echo $classname | cut -c2-`
88 classname=Form$firstchar$rest
89 export classname
90
91 cat $1 | sed \
92 -e 's/#include \"forms\.h\"/#include FORMS_H_LOCATION/' \
93 -e "s/#include \".orm_.*\"/#include \"$classname.h\"/" \
94 -e '/fl_/ s/".[^|]*"/_(&)/' \
95 -e '/shortcut/ s/".*[|].*"/scex(_(&))/' \
96 -e '/fl_add/ s/".*[|].*"/idex(_(&))/' \
97 -e '/fl_add/ s/idex(\(.*\)").*$/&fl_set_button_shortcut(obj,scex(\1")),1);/' \
98 -e 's/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/' \
99 -e "s/\(FD_f\([^ _]*\)_\([^ ]*\)\) \*create_form_form[^ ]*/\1 * $classname::build_\3()/" \
100 -e 's/\(fdui->form[^ ]*\)\(.*bgn_form.*\)/\1\2\
101   \1->u_vdata = this;/' \
102 -e 's/,\([^ ]\)/, \1/g' >> $2
103
104
105
106
107
108
109
110
111
112