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 # 1. Rewrite "fdui->form_xxx->fdui = ..." as "fdui->form->fdui = ..."
28 s/fdui->form_\([^ ]*\)->fdui =/fdui->form->fdui =/
30 # 2. Rewrite "fdui->form_xxx = ..." as "fdui->form = ..."
31 s/fdui->form_\([^ ]*\) =/fdui->form =/
33 # 3. Rewrite "fdui->form_xxx->..." as "fdui->form->..."
34 s/fdui->form_\([^ ]*\)->/fdui->form->/
36 # Replace "forms.h" by FORMS_H_LOCATION in the #include directives
37 s/#include \"forms\.h\"/#include FORMS_H_LOCATION/
39 # Create the destructor.
40 # When the wrappers are here, delete from here
41 /\(.*\) *create_form_form/{
43 s/\(.*\) \*create_form_form[^ ]*/\1::~\1()/p
47 if ( form->visible ) fl_hide_form( form );\
48 fl_free_form( form );\
54 # When the wrappers are here, delete to here
56 # Rename the function create_form_form_xxx(void) as build_xxx()
57 s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\1 * build_\2(void * parent)/
59 # We use new/delete not malloc/free so change to suit
60 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
62 # For all lines containing "bmtable",
63 # replace "fl_add_button" with "fl_add_bmtable"
64 /bmtable/ s/fl_add_button/fl_add_bmtable/
66 # For all lines containing "fl_" and a string _not_ containing |,
67 # replace the string with _(string)
68 /fl_/ s/".[^|]*"/_(&)/
70 # For all lines containing "_shortcut" and a string containing |,
71 # replace the string with scex(_(string))
72 /_shortcut/ s/".*[|].*"/scex(_(&))/
74 # gettext will get confused if the string contains a "%" unless the line is
75 # preceeded immediately by // xgettext:no-c-format
77 // xgettext:no-c-format
79 # For all lines containing "fl_add" and a string containing |
82 # fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,"Zoom %|#Z");
85 # fdui->counter_zoom = obj;
87 # // xgettext:no-c-format
88 # char const * const dummy = _("Zoom %|#Z");
89 # fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,idex(dummy));
90 # fl_set_button_shortcut(obj,scex(dummy),1);
96 s/fdui\(.*\)"\(.*\)".*/ {\
97 char const * const dummy = _("\2");\
99 fl_set_button_shortcut(obj,scex(dummy),1);\
102 /_(".*[%].*");/ s/\(.*\)\(char const [*]\)/\1\/\/ xgettext:no-c-format\
107 # We need to store a pointer to the dialog in u_vdata so that the
108 # callbacks will work.
109 s/\(fdui->form\)\(.*bgn_form.*\)/\1\2\
110 \1->u_vdata = parent;/
112 # Someone got busy and put spaces in after commas but didn't allow for the
113 # autogeneration of the files so their pretty formatting got lost. Not anymore.
117 # Clean up one special case where a comma appears at the end of a string
118 # while ensuring "...", "..." isn't affected.
120 s/\("[^"]+,\) \("\)/\1\2/g