]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfixc.sed
7b2e21c9dfc40eb2ffbaf213ea2a3ddb74539a02
[lyx.git] / src / frontends / xforms / forms / fdfixc.sed
1 # Create the destructor.
2 /\(.*\) *create_form_form/{
3 h
4 s/\(.*\) \*create_form_form[^ ]*/\1::~\1()/p
5 /\(.*\)::~\(.*\)()/{
6 i\
7 {\
8   if ( form->visible ) fl_hide_form( form );\
9   fl_free_form( form );\
10 }\
11 \
12
13 }
14 x
15 }
16
17 # Rewrite "fdui->form_xxx->fdui = ..." as "fdui->form->fdui = ..."
18 s/fdui->form_\([^ ]*\)->fdui =/fdui->form->fdui =/
19
20 # Rewrite "fdui->form_xxx = ..." as "fdui->form = ..."
21 s/fdui->form_\([^ ]*\) =/fdui->form =/
22
23 # Rewrite "fdui->form_xxx->..." as "fdui->form->..."
24 s/fdui->form_\([^ ]*\)->/fdui->form->/
25
26 #  Replace "forms.h" by FORMS_H_LOCATION in #include directives. This
27 #  macro is defined in config.h and is either <forms.h> or
28 #  <X11/forms.h>. 
29 s/#include \"forms\.h\"/#include FORMS_H_LOCATION/
30
31 #   For all lines containing "#include "form_*"", append a line
32 #   containing the header file of the parent class
33 /#include \"form_.*\"/a\
34 #include \"CLASSNAME.h\"
35
36 #  For all lines containing "fl_" and a string _not_ containing |,
37 #  replace the string with _(string)
38 /fl_/ s/".[^|]*"/_(&)/
39
40 # For all lines containing "bmtable", replace "fl_add_button" by
41 # "fl_add_bmtable"
42 /bmtable/ s/fl_add_button/fl_add_bmtable/
43
44 #  For all lines containing "_shortcut" and a string containing |, 
45 #  replace the string with scex(_(string))
46 /_shortcut/ s/".*[|].*"/scex(_(&))/
47
48 #  gettext will get confused if the string contains a "%" unless the line is
49 #  preceeded immediately by // xgettext:no-c-format
50 /_(".*[%].*")/i\
51   // xgettext:no-c-format
52
53 # For all lines containing "fl_add" and a string containing |
54 # do several things.
55 # Eg
56 #   fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,"Zoom %|#Z");
57 #
58 # becomes
59 #   fdui->counter_zoom = obj;
60 #   {
61 #     // xgettext:no-c-format
62 #     char const * const dummy = N_("Zoom %|#Z");
63 #     fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,idex(_(dummy)));
64 #     fl_set_button_shortcut(obj,scex(_(dummy)),1);
65 #   }
66
67 /fl_add/{
68 /".*[|].*"/{
69
70   s/fdui\(.*\)"\(.*\)".*/{\
71     char const * const dummy = N_("\2");\
72     fdui\1idex(_(dummy)));\
73     fl_set_button_shortcut(obj,scex(_(dummy)),1);\
74   }/
75
76   /N_(".*[%].*");/ s/\(.*\)\(char const [*]\)/\1\/\/ xgettext:no-c-format\
77     \2/
78 }
79 }
80
81 # /fl_add/{
82 # /".*[|].*"/{
83
84 #   s/ = fl_add\(.*\)"\(.*\)".*/;\
85 #   {\
86 #     char const * dummy = N_("\2");\
87 #     obj = fl_add\1idex(_(dummy)));\
88 #     fl_set_button_shortcut(obj,scex(_(dummy)),1);\
89 #   }/
90
91 #   /N_(".*[%].*");/ s/\(.*\)\(char const [*]\)/\1\/\/ xgettext:no-c-format\
92 #     \2/
93 # }
94 # }
95
96 # We use new/delete not malloc/free so change to suit.
97 s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
98
99 # Fixup the name of the create_form... function to have a signature
100 # matching that of the method it will become.
101 s/\(FD_f\([^ _]*\)_\([^ ]*\)\) \*create_form_form[^ ]*/\1 * CLASSNAME::build_\3()/
102
103 # We need to store a pointer to the dialog in u_vdata so that the
104 # callbacks will work.
105 s/\(fdui->form\)\(.*bgn_form.*\)/\1\2\
106   \1->u_vdata = this;/
107
108 # Someone got busy and put spaces in after commas but didn't allow for the
109 # autogeneration of the files so their pretty formatting got lost. Not anymore.
110 #
111 s/,\([^ ]\)/, \1/g
112
113 # Clean up one special case where a comma appears at the end of a string
114 # while ensuring "...", "..." isn't affected.
115 #
116 s/\("[^"]+,\) \("\)/\1\2/g
117