]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfixc.sed
Yet more dialog tweaking from Rob.
[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 # Delete the fdesign comment
16 /generated with fdesign/d
17
18 # Rename struct FD_form_xxx as FD_xxx
19 s/FD_form_\(.*\)/FD_\1/
20
21 # In the struct declaration, we have renamed
22 #       FL_FORM * form_xxx;
23 # as
24 #       FL_FORM * form;
25 # so we must do so here too.
26 #
27 # 1. Rewrite "fdui->form_xxx->fdui = ..." as "fdui->form->fdui = ..."
28 s/fdui->form_\([^ ]*\)->fdui =/fdui->form->fdui =/
29
30 # 2. Rewrite "fdui->form_xxx = ..." as "fdui->form = ..."
31 s/fdui->form_\([^ ]*\) =/fdui->form =/
32
33 # 3. Rewrite "fdui->form_xxx->..." as "fdui->form->..."
34 s/fdui->form_\([^ ]*\)->/fdui->form->/
35
36 # Replace "forms.h" by FORMS_H_LOCATION in the #include directives
37 s/#include \"forms\.h\"/#include FORMS_H_LOCATION/
38
39 # Create the destructor.
40 # When the wrappers are here, delete from here
41 /\(.*\) *create_form_form/{
42 h
43 s/\(.*\) \*create_form_form[^ ]*/\1::~\1()/p
44 /\(.*\)::~\(.*\)()/{
45 i\
46 {\
47   if ( form->visible ) fl_hide_form( form );\
48   fl_free_form( form );\
49 }\
50
51 }
52 x
53 }
54 # When the wrappers are here, delete to here
55
56 # Rename the function create_form_form_xxx(void) as build_xxx()
57 s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\1 * build_\2(void * parent)/
58
59 # We use new/delete not malloc/free so change to suit
60 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
61
62 # For all lines containing "bmtable",
63 # replace "fl_add_button" with "fl_add_bmtable"
64 /bmtable/ s/fl_add_button/fl_add_bmtable/
65
66 # For all lines containing "fl_" and a string _not_ containing |,
67 # replace the string with _(string)
68 /fl_/ s/".[^|]*"/_(&)/
69
70 #  For all lines containing "_shortcut" and a string containing |, 
71 #  replace the string with scex(_(string))
72 /_shortcut/ s/".*[|].*"/scex(_(&))/
73
74 # gettext will get confused if the string contains a "%" unless the line is
75 # preceeded immediately by // xgettext:no-c-format
76 /_(".*[%].*")/i\
77   // xgettext:no-c-format
78
79 # For all lines containing "fl_add" and a string containing |
80 # do several things.
81 # Eg
82 #   fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,"Zoom %|#Z");
83 #
84 # becomes
85 #   fdui->counter_zoom = obj;
86 #   {
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);
91 #   }
92
93 /fl_add/{
94 /".*[|].*"/{
95
96   s/fdui\(.*\)"\(.*\)".*/  {\
97       char const * const dummy = _("\2");\
98       fdui\1idex(dummy));\
99       fl_set_button_shortcut(obj,scex(dummy),1);\
100     }/
101
102   /_(".*[%].*");/ s/\(.*\)\(char const [*]\)/\1\/\/ xgettext:no-c-format\
103       \2/
104 }
105 }
106
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;/
111
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.
114 #
115 s/,\([^ ]\)/, \1/g
116
117 # Clean up one special case where a comma appears at the end of a string
118 # while ensuring "...", "..." isn't affected.
119 #
120 s/\("[^"]+,\) \("\)/\1\2/g
121