2 # This file is part of LyX, the document processor.
3 # Licence details can be found in the file COPYING.
7 # Full author contact details are available in file CREDITS
10 # sed -f fdfixc.sed < somefile.c > fixedfile.C
12 # It contains the instructions that sed requires to manipulate
13 # the .c files produced by fdesign into a form usable by LyX
15 # Delete the fdesign comment
16 /generated with fdesign/d
18 # Rename struct FD_form_xxx as FD_xxx
19 s/FD_form_\(.*\)/FD_\1/
21 # In the struct declaration, we have renamed
25 # so we must do so here too.
27 # Rewrite "fdui->form_xxx" as "fdui->form"
28 # xxx is followed by ' ', '->' or ')', so use these to flag when xxx ends.
29 /fdui->form/s/\(fdui->form\)_[^ )-]*/\1/
31 # Replace "forms.h" by FORMS_H_LOCATION in the #include directives
32 s/#include \"forms\.h\"/#include FORMS_H_LOCATION/
34 # Create the destructor.
35 # When the wrappers are here, delete from here
36 /\(.*\) *create_form_form/{
38 s/\(.*\) \*create_form_form[^ ]*/\1::~\1()/p
42 if ( form->visible ) fl_hide_form( form );\
43 fl_free_form( form );\
49 # When the wrappers are here, delete to here
51 # Rename the function create_form_form_xxx(void) as build_xxx()
52 s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\1 * build_\2(void * parent)/
54 # We use new/delete not malloc/free so change to suit
55 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
57 # For all lines containing "bmtable",
58 # replace "fl_add_button" with "fl_add_bmtable"
59 /bmtable/ s/fl_add_button/fl_add_bmtable/
61 # For all lines containing "fl_" and a string _not_ containing |,
62 # replace the string with _(string)
63 /fl_/ s/".[^|]*"/_(&)/
65 # For all lines containing "_shortcut" and a string containing |,
66 # replace the string with scex(_(string))
67 /_shortcut/ s/".*[|].*"/scex(_(&))/
69 # gettext will get confused if the string contains a "%" unless the line is
70 # preceeded immediately by // xgettext:no-c-format
72 // xgettext:no-c-format
74 # For all lines containing "fl_add" and a string containing |
77 # fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,"Zoom %|#Z");
80 # fdui->counter_zoom = obj;
82 # // xgettext:no-c-format
83 # char const * const dummy = _("Zoom %|#Z");
84 # fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,idex(dummy));
85 # fl_set_button_shortcut(obj,scex(dummy),1);
91 s/fdui\(.*\)"\(.*\)".*/ {\
92 char const * const dummy = _("\2");\
94 fl_set_button_shortcut(obj,scex(dummy),1);\
97 /_(".*[%].*");/ s/\(.*\)\(char const [*]\)/\1\/\/ xgettext:no-c-format\
102 # We need to store a pointer to the dialog in u_vdata so that the
103 # callbacks will work.
104 s/\(fdui->form\)\(.*bgn_form.*\)/\1\2\
105 \1->u_vdata = parent;/
107 # Someone got busy and put spaces in after commas but didn't allow for the
108 # autogeneration of the files so their pretty formatting got lost. Not anymore.
112 # Clean up one special case where a comma appears at the end of a string
113 # while ensuring "...", "..." isn't affected.
115 s/\("[^"]+,\) \("\)/\1\2/g