2 # Copyright 2002 the LyX Team
3 # Read the file COPYING
5 # \author Angus Leeming, leeming@lyx.org and others
8 # sed -f fdfixc.sed < somefile.c > fixedfile.C
10 # It contains the instructions that sed requires to manipulate
11 # the .c files produced by fdesign into a form usable by LyX
13 # Delete the fdesign comment
14 /generated with fdesign/d
16 # Rename struct FD_form_xxx as FD_xxx
17 s/FD_form_\(.*\)/FD_\1/
19 # In the struct declaration, we have renamed
23 # so we must do so here too.
25 # 1. Rewrite "fdui->form_xxx->fdui = ..." as "fdui->form->fdui = ..."
26 s/fdui->form_\([^ ]*\)->fdui =/fdui->form->fdui =/
28 # 2. Rewrite "fdui->form_xxx = ..." as "fdui->form = ..."
29 s/fdui->form_\([^ ]*\) =/fdui->form =/
31 # 3. Rewrite "fdui->form_xxx->..." as "fdui->form->..."
32 s/fdui->form_\([^ ]*\)->/fdui->form->/
34 # Replace "forms.h" by FORMS_H_LOCATION in the #include directives
35 s/#include \"forms\.h\"/#include FORMS_H_LOCATION/
37 # Create the destructor.
38 # When the wrappers are here, delete from here
39 /\(.*\) *create_form_form/{
41 s/\(.*\) \*create_form_form[^ ]*/\1::~\1()/p
45 if ( form->visible ) fl_hide_form( form );\
46 fl_free_form( form );\
52 # When the wrappers are here, delete to here
54 # Rename the function create_form_form_xxx(void) as build_xxx()
55 s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\1 * build_\2(void * parent)/
57 # We use new/delete not malloc/free so change to suit
58 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
60 # For all lines containing "bmtable",
61 # replace "fl_add_button" with "fl_add_bmtable"
62 /bmtable/ s/fl_add_button/fl_add_bmtable/
64 # For all lines containing "fl_" and a string _not_ containing |,
65 # replace the string with _(string)
66 /fl_/ s/".[^|]*"/_(&)/
68 # For all lines containing "_shortcut" and a string containing |,
69 # replace the string with scex(_(string))
70 /_shortcut/ s/".*[|].*"/scex(_(&))/
72 # gettext will get confused if the string contains a "%" unless the line is
73 # preceeded immediately by // xgettext:no-c-format
75 // xgettext:no-c-format
77 # For all lines containing "fl_add" and a string containing |
80 # fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,"Zoom %|#Z");
83 # fdui->counter_zoom = obj;
85 # // xgettext:no-c-format
86 # char const * const dummy = _("Zoom %|#Z");
87 # fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,idex(dummy));
88 # fl_set_button_shortcut(obj,scex(dummy),1);
94 s/fdui\(.*\)"\(.*\)".*/ {\
95 char const * const dummy = _("\2");\
97 fl_set_button_shortcut(obj,scex(dummy),1);\
100 /_(".*[%].*");/ s/\(.*\)\(char const [*]\)/\1\/\/ xgettext:no-c-format\
105 # We need to store a pointer to the dialog in u_vdata so that the
106 # callbacks will work.
107 s/\(fdui->form\)\(.*bgn_form.*\)/\1\2\
108 \1->u_vdata = parent;/
110 # Someone got busy and put spaces in after commas but didn't allow for the
111 # autogeneration of the files so their pretty formatting got lost. Not anymore.
115 # Clean up one special case where a comma appears at the end of a string
116 # while ensuring "...", "..." isn't affected.
118 s/\("[^"]+,\) \("\)/\1\2/g