]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfixc.sed
a60b3add4bbbe5ec33b82080daaad3ca5e11cbdd
[lyx.git] / src / frontends / xforms / forms / fdfixc.sed
1 # file fdfixc.sed
2 # This file is part of LyX, the document processor.
3 # Licence details can be found in the file COPYING.
4 #
5 # author Angus Leeming
6 #
7 # Full author contact details are available in file CREDITS
8 #
9 # Use so:
10 # sed -f fdfixc.sed < somefile.c > fixedfile.C
11 #
12 # It contains the instructions that sed requires to manipulate
13 # the .c files produced by fdesign into a form usable by LyX
14
15 # Pretty formatting; remove trailing whitespace.
16 s/[     ]*$//
17
18
19 # Delete blank lines and fdesign comments.
20 /^$/d
21 /generated with fdesign/d
22 /^\/\*-----/d
23
24
25 # Remove '#include "forms.h"'. It is replace by a macro in fdfix.sh.
26 /^#include \"forms\.h\"/d
27
28
29 # Pretty formatting; replace all leading whitespace with a tab
30 /^[     ]/s/^[  ]*/     /
31
32
33 # Rename struct "FD_form_xxx" as "FD_xxx"
34 s/FD_form_\(.*\)/FD_\1/
35
36
37 # Rename the function create_form_form_xxx(void) as build_xxx()
38 s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\
39 \
40 \1 * build_\2(void * parent)/
41
42
43 # Pretty formatting
44 s/FL_OBJECT \*obj;/FL_OBJECT * obj;\
45 /
46
47 # Insert a line before each new FL_OBJECT
48 /obj = /i\
49
50 # Ditto for fl_bgn
51 /fl_bgn/i\
52
53 # Ditto for fl_end
54 /fl_end/i\
55
56
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/
60
61
62 # We use new/delete not malloc/free so change to suit.
63 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
64
65
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;/
70
71
72 # For all lines containing "bmtable",
73 # replace "fl_add_button" with "fl_add_bmtable"
74 /bmtable/ s/fl_add_button/fl_add_bmtable/
75
76
77 # For all lines containing "combox",
78 # replace "fl_add_choice" with "fl_add_combox"
79 # Note that only two combox types exist, whilst there are four choice types.
80 /combox/ {
81 s/fl_add_choice/fl_add_combox/
82 s/BROWSER/NORMAL/
83 s/CHOICE2/COMBOX/
84 s/CHOICE/COMBOX/
85 }
86
87
88 # For all lines containing fl_add_choice,
89 # add a line that turns off the title. (These titles can contain meta-chars
90 # that just look nasty ;-)
91 /fl_add_choice/a\
92         fl_set_choice_notitle(obj, 1);
93
94
95 # For all lines containing "fl_" and a string _not_ containing |,
96 # replace the string with _(string).c_str()
97 /fl_/ s/".[^|]*"/_(&).c_str()/
98
99
100 #  For all lines containing "_shortcut" and a string containing |, 
101 #  replace the string with scex(_(string)).c_str()
102 /_shortcut/ s/".*[|].*"/scex(_(&)).c_str()/
103
104
105 # For all lines containing "fl_add" and a string containing |
106 # change so:
107 #        fdui->counter_zoom = obj = fl_add_counter(...,"Zoom %|#Z");
108 # becomes
109 #        tmp_str = _("Zoom %|#Z");
110 #        fdui->counter_zoom = obj = fl_add_counter(...,idex(tmp_str).c_str());
111 #        fl_set_button_shortcut(obj,scex(tmp_str).c_str(),1);
112
113 /fl_add.*".*[|].*"/s/fdui\(.*\)"\(.*\)".*/tmp_str = _("\2");\
114         fdui\1idex(tmp_str).c_str());\
115         fl_set_button_shortcut(obj,scex(tmp_str).c_str(),1);/
116
117
118 # gettext will get confused if the string contains a "%" unless the line is
119 # preceeded immediately by "// xgettext:no-c-format"
120 /_(".*[%].*")/i\
121         // xgettext:no-c-format
122
123
124 # Someone got busy and put spaces in after commas but didn't allow for the
125 # autogeneration of the files so their pretty formatting got lost. Not anymore.
126 s/,\([^ ]\)/, \1/g
127
128 # Clean up one special case where a comma appears at the end of a string
129 # while ensuring "...", "..." isn't affected.
130 s/\("[^"]+,\) \("\)/\1\2/g