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 # Pretty formatting; remove trailing whitespace.
19 # Delete blank lines and fdesign comments.
21 /generated with fdesign/d
25 # Remove '#include "forms.h"'. It is replace by a macro in fdfix.sh.
26 /^#include \"forms\.h\"/d
29 # Pretty formatting; replace all leading whitespace with a tab
33 # Rename struct "FD_form_xxx" as "FD_xxx"
34 s/FD_form_\(.*\)/FD_\1/
37 # Rename the function create_form_form_xxx(void) as build_xxx()
38 s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\
40 \1 * build_\2(void * parent)/
44 s/FL_OBJECT \*obj;/FL_OBJECT * obj;\
47 # Insert a line before each new FL_OBJECT
57 # Rewrite "fdui->form_xxx" as "fdui->form"
58 # xxx is followed by ' ', '->' or ')', so use these to flag when xxx ends.
59 /fdui->form/s/\(fdui->form\)_[^ )-]*/\1/
62 # We use new/delete not malloc/free so change to suit.
63 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
66 # We need to store a pointer to the dialog in u_vdata so that the
67 # callbacks will work.
68 s/\( fdui->form\)\(.*bgn_form.*\)/\1\2\
69 \1->u_vdata = parent;/
72 # For all lines containing "bmtable",
73 # replace "fl_add_button" with "fl_add_bmtable"
74 /bmtable/ s/fl_add_button/fl_add_bmtable/
77 # For all lines containing "combox",
78 # replace "fl_add_choice" with "fl_add_combox"
79 /combox/ s/fl_add_choice([^,]*/fl_add_combox(FL_DROPLIST_COMBOX/
82 # For all lines containing fl_add_choice,
83 # add a line that turns off the title. (These titles can contain meta-chars
84 # that just look nasty ;-)
86 fl_set_choice_notitle(obj, 1);
89 # For all lines containing "fl_" and a string _not_ containing |,
90 # replace the string with _(string)
91 /fl_/ s/".[^|]*"/_(&)/
94 # For all lines containing "_shortcut" and a string containing |,
95 # replace the string with scex(_(string)).c_str()
96 /_shortcut/ s/".*[|].*"/scex(_(&)).c_str()/
99 # For all lines containing "fl_add" and a string containing |
101 # fdui->counter_zoom = obj = fl_add_counter(...,"Zoom %|#Z");
103 # c_str = _("Zoom %|#Z");
104 # fdui->counter_zoom = obj = fl_add_counter(...,idex(c_str).c_str());
105 # fl_set_button_shortcut(obj,scex(c_str).c_str(),1);
107 /fl_add.*".*[|].*"/s/fdui\(.*\)"\(.*\)".*/c_str = _("\2");\
108 fdui\1idex(c_str).c_str());\
109 fl_set_button_shortcut(obj,scex(c_str).c_str(),1);/
112 # gettext will get confused if the string contains a "%" unless the line is
113 # preceeded immediately by "// xgettext:no-c-format"
115 // xgettext:no-c-format
118 # Someone got busy and put spaces in after commas but didn't allow for the
119 # autogeneration of the files so their pretty formatting got lost. Not anymore.
122 # Clean up one special case where a comma appears at the end of a string
123 # while ensuring "...", "..." isn't affected.
124 s/\("[^"]+,\) \("\)/\1\2/g