]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfixc.sed
Change the semantics of 'none' and 'auto' viewers/editors: 'none' means now
[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 # Immediately after line "#include form_xxx.h"
20 # open namespace lyx::frontend.
21 /^#include "form_/a\
22 \
23 namespace lyx {\
24 namespace frontend {
25
26
27 # When the end of the file is reached, close namespace lyx::frontend.
28 $ a\
29 \
30 } // namespace frontend\
31 } // namespace lyx
32
33
34 # Delete blank lines and fdesign comments.
35 /^$/d
36 /generated with fdesign/d
37 /^\/\*-----/d
38
39
40 # Remove '#include "forms.h"'. It is replace by a macro in fdfix.sh.
41 /^#include "forms\.h"/d
42
43
44 # Pretty formatting; replace all leading whitespace with a tab
45 /^[     ]/s/^[  ]*/     /
46
47
48 # Rename struct "FD_form_xxx" as "FD_xxx"
49 s/FD_form_\(.*\)/FD_\1/
50
51
52 # Rename the function create_form_form_xxx(void) as build_xxx()
53 s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\
54 \
55 \1 * build_\2(void * parent)/
56
57
58 # Pretty formatting
59 s/FL_OBJECT \*obj;/FL_OBJECT * obj;\
60 /
61
62 # Insert a line before each new FL_OBJECT
63 /obj = /i\
64
65 # Ditto for fl_bgn
66 /fl_bgn/i\
67
68 # Ditto for fl_end
69 /fl_end/i\
70
71
72 # Rewrite "fdui->form_xxx" as "fdui->form"
73 # xxx is followed by ' ', '->' or ')', so use these to flag when xxx ends.
74 /fdui->form/s/\(fdui->form\)_[^ )-]*/\1/
75
76
77 # We use new/delete not malloc/free so change to suit.
78 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
79
80
81 # We need to store a pointer to the dialog in u_vdata so that the
82 # callbacks will work.
83 s/\(    fdui->form\)\(.*bgn_form.*\)/\1\2\
84 \1->u_vdata = parent;/
85
86
87 # For all lines containing "bmtable",
88 # replace "fl_add_button" with "fl_add_bmtable"
89 /bmtable/ s/fl_add_button/fl_add_bmtable/
90
91
92 # For all lines containing "combox",
93 # replace "fl_add_choice" with "fl_add_combox"
94 # Note that only two combox types exist, whilst there are four choice types.
95 /combox/ {
96 s/fl_add_choice/fl_add_combox/
97 s/BROWSER/NORMAL/
98 s/CHOICE2/COMBOX/
99 s/CHOICE/COMBOX/
100 }
101
102
103 # For all lines containing fl_add_choice,
104 # add a line that turns off the title. (These titles can contain meta-chars
105 # that just look nasty ;-)
106 /fl_add_choice/a\
107         fl_set_choice_notitle(obj, 1);
108
109
110 # For all lines containing "fl_" and a string _not_ containing |,
111 # replace the string with _(string).c_str()
112 /fl_/ s/".[^|]*"/_(&).c_str()/
113
114
115 #  For all lines containing "_shortcut" and a string containing |,
116 #  replace the string with scex(_(string)).c_str()
117 /_shortcut/ s/".*[|].*"/scex(_(&)).c_str()/
118
119
120 # For all lines containing "fl_add" and a string containing |
121 # change so:
122 #        fdui->counter_zoom = obj = fl_add_counter(...,"Zoom %|#Z");
123 # becomes
124 #        tmp_str = _("Zoom %|#Z");
125 #        fdui->counter_zoom = obj = fl_add_counter(...,idex(tmp_str).c_str());
126 #        fl_set_button_shortcut(obj,scex(tmp_str).c_str(),1);
127
128 /fl_add.*".*[|].*"/s/fdui\(.*\)"\(.*\)".*/tmp_str = _("\2");\
129         fdui\1idex(tmp_str).c_str());\
130         fl_set_button_shortcut(obj,scex(tmp_str).c_str(),1);/
131
132
133 # gettext will get confused if the string contains a "%" unless the line is
134 # preceeded immediately by "// xgettext:no-c-format"
135 /_(".*[%].*")/i\
136         // xgettext:no-c-format
137
138
139 # Someone got busy and put spaces in after commas but didn't allow for the
140 # autogeneration of the files so their pretty formatting got lost. Not anymore.
141 s/,\([^ ]\)/, \1/g
142
143 # Clean up one special case where a comma appears at the end of a string
144 # while ensuring "...", "..." isn't affected.
145 s/\("[^"]+,\) \("\)/\1\2/g