2 # This file is part of LyX, the document processor.
3 # Licence details can be found in the file COPYING.
7 # Full author contact details are available in file CREDITS
10 # sed -f fdfixh.sed < somefile.h > fixedfile.h
12 # It contains the instructions that sed requires to manipulate
13 # the .h files produced by fdesign into a form usable by LyX
15 # Strip multiple blank lines, leaving only one
21 # Rewrite FD_form_xxx as FD_xxx
22 # This is done both for the structs and for the #define bounding the header
23 s/\(.*\) FD_form_\(.*\)/\1 FD_\2/
25 # Forward declare FL_FORM and FL_OBJECT
28 #include "forms_fwd.h"
30 # Delete the fdesign comments
32 /generated with fdesign/d
35 # Replace lines such as "extern void func(args);"
36 # with "extern "C" void func(args);"
37 # Note that these should not occur because we should be using signals. See the
38 # README file for further information.
39 s/\(extern \)\(void \)\(.*\)/\1 "C" \2\3/
41 # Rename the function create_form_form_xxx(void) as build_xxx(void * parent)
42 s/extern \(.*\) create_form_form_\(.*\)\([(]void[)]\)/\1 build_\2(void *)/
44 # Manipulate the structs
47 # typedef struct { struct FD_xxx {
48 # FL_FORM *form_xxx; ~FD_xxx();
49 # void *vdata; FL_FORM * form;
50 # char *cdata; FL_OBJECT * some_obj;
52 # FL_OBJECT *some_obj; };
56 # This is detailed more closely below
58 # Delete lines containing:
64 # Place all lines containing FL_FORM and FL_OBJECT in the hold space, deleting
65 # them from the pattern space.
67 # For all lines containing FL_FORM...
70 # Rewrite "FL_FORM *form_xxx;" as "FL_FORM * form;
71 # Note that the spaces before FL_FORM are replaced with a <tab>
72 s/\(.*\)FL_FORM \(.*\)/ FL_FORM * form;/
74 # We know that FL_FORM comes before any FL_OBJECT, so can initialise
75 # the hold space with it.
81 # For all lines containing FL_OBJECT and not containing extern...
85 # perform a little pretty formatting
86 s/\(.*\)FL_OBJECT \([*]\)\(.*\)/ FL_OBJECT * \3/
88 # append to the hold space
95 # The struct is ended by "} FD_xxx;", so now's the time to paste back the
96 # contents of the hold space.
98 # 1. Insert an empty line.
101 # 2. Rewrite "} FD_xxx;" as "struct FD_xxx {" and append a d-tor.
102 s/} \(.*\);/struct \1 {/p
103 # When the wrappers are here, delete this line and the p-print command above
104 /struct/s/struct \(.*\) {/ ~\1();/
106 # 3. Paste the contents of the hold space beneath it
109 # 4. Close the struct