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.
6 if [ "$1" = "$2" ]; then
7 echo "Input and Output file can not be the same."
12 echo "Output file already exists, overwrite?"
14 if [ "$REPLY" != "y" ]; then
20 echo "Input file does not exist, can not continue"
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"
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
36 # The commands to sed does this:
38 # -e 's/#include "forms\.h"/#include FORMS_H_LOCATION/'
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
44 # -e '/fl_/ s/".[^|]*"/_(&)/'
46 # For all lines containing "fl_" and a string _not_ containging |,
47 # replace the string with _(string)
49 # -e '/shortcut/ s/".*[|].*"/scex(_(&))/'
51 # For all lines containing "shortcut" and a string containing |, replace
52 # the string with scex(_(string))
54 # -e '/fl_add/ s/".*[|].*"/idex(_(&))/'
55 # For all lines containing "fl_add" and a string containing |, replace
56 # the string with idex(_(string))
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
62 # -e 's/,\([^ ]\)/, \1/g'
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.
67 # -e 's/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 dialog_ = new \2/'
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.
72 #-e 's/\(FD_f\([^ ]*\)_\([^ ]*\)\) \*create[^ ]*/void F\2\3::build()/'
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
78 # -e 's/\(fdui->form[^ ]*\)\(.*bgn_form.*\)/\1\2\
79 # \1->u_vdata = this;/' \
81 # We need to store a pointer to the dialog in u_vdata so that the callbacks
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
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