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 inputfile patch the input file with it.
25 if [ -f "$1.patch" ]; then
26 echo "Patching $1 with $1.patch"
27 patch -s $1 < "$1.patch"
30 echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) 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 "/#include \"form_.*\"/a\\
45 # #include \"$classname.h\" "
47 # For all lines containing "#include "form_*"", append a line
48 # containing the header file of the parent class
50 # -e '/fl_/ s/".[^|]*"/_(&)/'
52 # For all lines containing "fl_" and a string _not_ containing |,
53 # replace the string with _(string)
55 # -e '/shortcut/ s/".*[|].*"/scex(_(&))/'
57 # For all lines containing "shortcut" and a string containing |, replace
58 # the string with scex(_(string))
60 # -e '/fl_add/ s/".*[|].*"/idex(_(&))/'
62 # For all lines containing "fl_add" and a string containing |, replace
63 # the string with idex(_(string))
65 # -e '/fl_add/ s/idex("\(.*\)").*$/&\
66 # fl_set_button_shortcut(obj,"\1",1);/'
68 # For all lines containing "fl_add" and a string containing |, add the
69 # shortcut command after the end of this line
71 # -e 's/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/'
73 # We use new/delete not malloc/free so change to suit.
75 # -e "s/\(FD_f\([^ _]*\)_\([^ ]*\)\) \*create_form_form[^ ]*/\1 * $classname::build_\3()/"
77 # Fixup the name of the create_form... function to have a signature matching
78 # that of the method it will become.
80 # -e 's/\(fdui->form[^ ]*\)\(.*bgn_form.*\)/\1\2\
81 # \1->u_vdata = this;/' \
83 # We need to store a pointer to the dialog in u_vdata so that the callbacks
86 # -e 's/,\([^ ]\)/, \1/g'
88 # Someone got busy and put spaces in after commas but didn't allow for the
89 # autogeneration of the files so their pretty formatting got lost. Not anymore.
92 classname=`basename $1 .c | cut -c6-`
93 firstchar=`echo $classname | cut -c1 | tr a-z A-Z`
94 rest=`echo $classname | cut -c2-`
95 classname=Form$firstchar$rest
99 -e 's/#include \"forms\.h\"/#include FORMS_H_LOCATION/' \
100 -e "/#include \"form_.*\"/a\\
101 #include \"$classname.h\" " \
102 -e '/fl_/ s/".[^|]*"/_(&)/' \
103 -e '/shortcut/ s/".*[|].*"/scex(_(&))/' \
104 -e '/fl_add/ s/".*[|].*"/idex(_(&))/' \
105 -e '/fl_add/ s/idex(\(.*\)").*$/&\
106 fl_set_button_shortcut(obj,scex(\1")),1);/' \
107 -e 's/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/' \
108 -e "s/\(FD_f\([^ _]*\)_\([^ ]*\)\) \*create_form_form[^ ]*/\1 * $classname::build_\3()/" \
109 -e 's/\(fdui->form[^ ]*\)\(.*bgn_form.*\)/\1\2\
110 \1->u_vdata = this;/' \
111 -e 's/,\([^ ]\)/, \1/g' >> $2