1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/************************************************************/
/* Windows Write, Copyright 1985-1992 Microsoft Corporation */
/************************************************************/
#define NOCLIPBOARD
#define NOGDICAPMASKS
#define NOCTLMGR
#define NOVIRTUALKEYCODES
#define NOWINMESSAGES
#define NOWINSTYLES
#define NOSYSMETRICS
#define NOMENUS
#define NOKEYSTATE
#define NOGDI
#define NORASTEROPS
#define NOSYSCOMMANDS
#define NOSHOWWINDOW
#define NOCOLOR
#define NOATOM
#define NOBITMAP
#define NOICON
#define NOBRUSH
#define NOCREATESTRUCT
#define NOMB
#define NOFONT
#define NOMSG
#define NOOPENFILE
#define NOPEN
#define NOPOINT
#define NOREGION
#define NOSCROLL
#define NOSOUND
#define NOWH
#define NOWINOFFSETS
#define NOWNDCLASS
#define NOCOMM
#include <windows.h>
/*#include "toolbox.h"*/
#include "mw.h"
#include "cmddefs.h"
#include "dispdefs.h"
#include "wwdefs.h"
#include "docdefs.h"
#include "editdefs.h"
#include "filedefs.h"
#include "str.h"
#include "propdefs.h"
#include "fkpdefs.h"
#include "printdef.h" /* printdefs.h */
#include "debug.h"
extern int docMode;
extern struct FCB (**hpfnfcb)[];
int **HAllocate();
#ifdef CASHMERE /* Only if we support multiple sections */
AddSects(docDest, cpDest, docSrc, cpFirst, cpLim, hsetbSrc)
int docDest, docSrc;
typeCP cpDest, cpFirst, cpLim;
struct SETB **hsetbSrc;
{ /* Add SED's to correspond with inserted section marks */
/* Called after inserting docSrc[cpFirst:cpLim) into docDest@cpDest */
struct SETB *psetbSrc, **hsetbDest, *psetbDest;
struct SED *psedSrc, *psedDest;
int csedDest, isedSrc, csedIns, isedDest;
psedSrc = &(psetbSrc = *hsetbSrc)->rgsed[0];
psedSrc += (isedSrc = IcpSearch(cpFirst + 1, psedSrc,
cchSED, bcpSED, psetbSrc->csed));
/* Find all section marks in inserted area. */
for (csedIns = 0; psedSrc->cp <= cpLim; psedSrc++, csedIns++)
;
if (csedIns != 0)
{ /* Insert sed's. */
/* Ensure destination setb large enough */
/* HEAP MOVEMENT */
if (FNoHeap(hsetbDest = HsetbEnsure(docDest, csedIns)))
return;
psedDest = &(psetbDest = *hsetbDest)->rgsed[0];
/* Find ised to insert new sed's */
psedDest += (isedDest = IcpSearch(cpDest + 1, psedDest,
cchSED, bcpSED, csedDest = psetbDest->csed));
/* Insert new sed's */
psedSrc = &(psetbSrc = *hsetbSrc)->rgsed[isedSrc];
psetbDest->csed += csedIns; /* Update sed count */
blt(psedDest, psedDest + csedIns,
cwSED * (csedDest - isedDest)); /* Open up setb */
blt(psedSrc, psedDest, cwSED * csedIns);
while (csedIns--)
(psedDest++)->cp = cpDest + (psedSrc++)->cp - cpFirst;
}
} /* end of A d d S e c t s */
#endif /* CASHMERE */
#ifdef CASHMERE /* Only if we support separate sections */
RemoveDelSeds(doc, cpFirst, cpLim, hsetb)
int doc;
typeCP cpFirst, cpLim;
struct SETB **hsetb;
{
struct SETB *psetb;
struct SED *psed, *psedT;
int ised, csed, csedDel;
{
psetb = *hsetb;
psed = &psetb->rgsed[0];
psed += (ised =
IcpSearch(cpFirst + 1, psed, cchSED, bcpSED, csed = psetb->csed));
/* Find all section marks in deleted area. */
for (psedT = psed, csedDel = 0; psedT->cp <= cpLim; psedT++, csedDel++)
;
Assert(ised + csedDel < csed);
if (csedDel != 0)
{ /* Close up setb. */
blt(psedT, psed, cwSED * ((csed -= csedDel) - ised));
(*hsetb)->csed = csed;
docMode = docNil;
}
}
} /* end of R e m o v e D e l S e d s */
#endif /* CASHMERE */
#ifdef CASHMERE /* This loads a complete section table */
struct SETB **HsetbCreate(fn)
int fn;
{ /* Create a section table from a formatted file */
struct SETB *psetbFile;
typePN pn;
int cchT;
int csed, ised;
struct SETB **hsetb;
int *pwSetb;
int cw;
struct SED *psed;
Assert(fn != fnNil && (**hpfnfcb)[fn].fFormatted);
if ((pn = (**hpfnfcb)[fn].pnSetb) == (**hpfnfcb)[fn].pnBftb)
return (struct SETB **) 0;
psetbFile = (struct SETB *) PchGetPn(fn, pn, &cchT, false);
if ((csed = psetbFile->csed) == 0)
return (struct SETB **)0;
hsetb = (struct SETB **) HAllocate(cw = cwSETBBase + csed * cwSED);
if (FNoHeap(hsetb))
return (struct SETB **)hOverflow;
pwSetb = (int *) *hsetb;
blt(psetbFile, pwSetb, min(cwSector, cw));
while ((cw -= cwSector) > 0)
{ /* Copy the sed's to heap */
blt(PchGetPn(fn, ++pn, &cchT, false), pwSetb += cwSector,
min(cwSector, cw));
}
for (ised = 0, psed = &(**hsetb).rgsed[0]; ised < csed; ised++, psed++)
psed->fn = fn;
(**hsetb).csedMax = csed;
return hsetb;
} /* end of H s e t b C r e a t e */
#endif /* CASHMERE */
|