2002-09-05 15:14:23 +00:00
|
|
|
# file fdfixc.sed
|
|
|
|
# This file is part of LyX, the document processor.
|
|
|
|
# Licence details can be found in the file COPYING.
|
2002-06-13 13:43:51 +00:00
|
|
|
#
|
2002-09-05 15:14:23 +00:00
|
|
|
# author Angus Leeming
|
|
|
|
#
|
|
|
|
# Full author contact details are available in file CREDITS
|
2002-06-13 13:43:51 +00:00
|
|
|
#
|
|
|
|
# Use so:
|
|
|
|
# sed -f fdfixc.sed < somefile.c > fixedfile.C
|
|
|
|
#
|
|
|
|
# It contains the instructions that sed requires to manipulate
|
|
|
|
# the .c files produced by fdesign into a form usable by LyX
|
|
|
|
|
|
|
|
# Delete the fdesign comment
|
|
|
|
/generated with fdesign/d
|
|
|
|
|
|
|
|
# Rename struct FD_form_xxx as FD_xxx
|
|
|
|
s/FD_form_\(.*\)/FD_\1/
|
|
|
|
|
|
|
|
# In the struct declaration, we have renamed
|
|
|
|
# FL_FORM * form_xxx;
|
|
|
|
# as
|
|
|
|
# FL_FORM * form;
|
|
|
|
# so we must do so here too.
|
|
|
|
#
|
|
|
|
# 1. Rewrite "fdui->form_xxx->fdui = ..." as "fdui->form->fdui = ..."
|
|
|
|
s/fdui->form_\([^ ]*\)->fdui =/fdui->form->fdui =/
|
|
|
|
|
|
|
|
# 2. Rewrite "fdui->form_xxx = ..." as "fdui->form = ..."
|
|
|
|
s/fdui->form_\([^ ]*\) =/fdui->form =/
|
|
|
|
|
|
|
|
# 3. Rewrite "fdui->form_xxx->..." as "fdui->form->..."
|
|
|
|
s/fdui->form_\([^ ]*\)->/fdui->form->/
|
|
|
|
|
|
|
|
# Replace "forms.h" by FORMS_H_LOCATION in the #include directives
|
|
|
|
s/#include \"forms\.h\"/#include FORMS_H_LOCATION/
|
|
|
|
|
2000-08-14 05:24:35 +00:00
|
|
|
# Create the destructor.
|
2002-06-13 13:43:51 +00:00
|
|
|
# When the wrappers are here, delete from here
|
2000-08-14 05:24:35 +00:00
|
|
|
/\(.*\) *create_form_form/{
|
|
|
|
h
|
|
|
|
s/\(.*\) \*create_form_form[^ ]*/\1::~\1()/p
|
|
|
|
/\(.*\)::~\(.*\)()/{
|
|
|
|
i\
|
|
|
|
{\
|
2000-11-07 06:41:13 +00:00
|
|
|
if ( form->visible ) fl_hide_form( form );\
|
2000-08-14 05:24:35 +00:00
|
|
|
fl_free_form( form );\
|
|
|
|
}\
|
|
|
|
|
|
|
|
}
|
|
|
|
x
|
|
|
|
}
|
2002-06-13 13:43:51 +00:00
|
|
|
# When the wrappers are here, delete to here
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
# Rename the function create_form_form_xxx(void) as build_xxx()
|
|
|
|
s/\(.*\) \*create_form_form_\(.*\)\([(]void[)]\)/\1 * build_\2(void * parent)/
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
# We use new/delete not malloc/free so change to suit
|
|
|
|
s/\(\(FD_[^ ]*\) \*fdui =\).*sizeof(\*fdui))/\1 new \2/
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
# For all lines containing "bmtable",
|
|
|
|
# replace "fl_add_button" with "fl_add_bmtable"
|
|
|
|
/bmtable/ s/fl_add_button/fl_add_bmtable/
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
# For all lines containing "fl_" and a string _not_ containing |,
|
|
|
|
# replace the string with _(string)
|
2000-08-14 05:24:35 +00:00
|
|
|
/fl_/ s/".[^|]*"/_(&)/
|
|
|
|
|
2002-04-26 10:26:37 +00:00
|
|
|
# For all lines containing "_shortcut" and a string containing |,
|
2000-08-14 05:24:35 +00:00
|
|
|
# replace the string with scex(_(string))
|
2002-04-26 10:26:37 +00:00
|
|
|
/_shortcut/ s/".*[|].*"/scex(_(&))/
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
# gettext will get confused if the string contains a "%" unless the line is
|
|
|
|
# preceeded immediately by // xgettext:no-c-format
|
2000-12-06 09:49:54 +00:00
|
|
|
/_(".*[%].*")/i\
|
|
|
|
// xgettext:no-c-format
|
|
|
|
|
2000-12-06 22:24:17 +00:00
|
|
|
# For all lines containing "fl_add" and a string containing |
|
|
|
|
# do several things.
|
|
|
|
# Eg
|
|
|
|
# fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,"Zoom %|#Z");
|
|
|
|
#
|
|
|
|
# becomes
|
|
|
|
# fdui->counter_zoom = obj;
|
|
|
|
# {
|
|
|
|
# // xgettext:no-c-format
|
2002-06-13 13:43:51 +00:00
|
|
|
# char const * const dummy = _("Zoom %|#Z");
|
|
|
|
# fdui->counter_zoom = obj = fl_add_counter(FL_NORMAL_COUNTER,1,2,3,4,idex(dummy));
|
|
|
|
# fl_set_button_shortcut(obj,scex(dummy),1);
|
2000-12-06 22:24:17 +00:00
|
|
|
# }
|
|
|
|
|
|
|
|
/fl_add/{
|
|
|
|
/".*[|].*"/{
|
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
s/fdui\(.*\)"\(.*\)".*/ {\
|
|
|
|
char const * const dummy = _("\2");\
|
|
|
|
fdui\1idex(dummy));\
|
|
|
|
fl_set_button_shortcut(obj,scex(dummy),1);\
|
|
|
|
}/
|
2000-12-06 22:24:17 +00:00
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
/_(".*[%].*");/ s/\(.*\)\(char const [*]\)/\1\/\/ xgettext:no-c-format\
|
|
|
|
\2/
|
2000-12-06 22:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-14 05:24:35 +00:00
|
|
|
# We need to store a pointer to the dialog in u_vdata so that the
|
|
|
|
# callbacks will work.
|
|
|
|
s/\(fdui->form\)\(.*bgn_form.*\)/\1\2\
|
2002-06-13 13:43:51 +00:00
|
|
|
\1->u_vdata = parent;/
|
2000-08-14 05:24:35 +00:00
|
|
|
|
|
|
|
# Someone got busy and put spaces in after commas but didn't allow for the
|
|
|
|
# autogeneration of the files so their pretty formatting got lost. Not anymore.
|
|
|
|
#
|
|
|
|
s/,\([^ ]\)/, \1/g
|
|
|
|
|
|
|
|
# Clean up one special case where a comma appears at the end of a string
|
|
|
|
# while ensuring "...", "..." isn't affected.
|
|
|
|
#
|
|
|
|
s/\("[^"]+,\) \("\)/\1\2/g
|
|
|
|
|