summaryrefslogtreecommitdiff
path: root/freebsdtvision/lib/helpbase.h
blob: 7dd737ef9d0ecdb24895038fe0dd325b79118ee9 (plain)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/*
 * helpbase.h
 *
 * Turbo Vision - Version 2.0
 *
 * Copyright (c) 1994 by Borland International
 * All Rights Reserved.
 *
 * Modified by Sergio Sigala <sergio@sigala.it>
 */

/** \file helpbase.h
 * helpbase.h
 */

/**
 * Undocumented.
 */
const long magicHeader = 0x46484246L; //"FBHF"

#define cHelpViewer "\x06\x07\x08"
#define cHelpWindow "\x80\x81\x82\x83\x84\x85\x86\x87"

// TParagraph

/**
 * Part of the help system.
 * @short Part of the help system
 */
class TParagraph
{
public:
    /**
     * Undocumented.
     */
    TParagraph() {}
    /**
     * Undocumented.
     */
    TParagraph *next;
    /**
     * Undocumented.
     */
    Boolean wrap;
    /**
     * Undocumented.
     */
    ushort size;
    /**
     * Undocumented.
     */
    char *text;
};

// TCrossRef

/**
 * Part of the help system.
 * @short Part of the help system
 */
class TCrossRef
{
public:
    /**
     * Undocumented.
     */
    TCrossRef() {}
    /**
     * Undocumented.
     */
    int ref;
    /**
     * Undocumented.
     */
    int offset;
    /**
     * Undocumented.
     */
    uchar length;
};

/**
 * Undocumented.
 */
typedef void (*TCrossRefHandler) ( opstream&, int );

/**
 * Part of the help system.
 * @short Part of the help system
 */
class THelpTopic: public TObject, public TStreamable
{
public:
    /**
     * Undocumented.
     */
    THelpTopic();
    /**
     * Undocumented.
     */
    THelpTopic( StreamableInit ) {};
    /**
     * Undocumented.
     */
    virtual ~THelpTopic();
    /**
     * Undocumented.
     */
    void addCrossRef( TCrossRef ref );
    /**
     * Undocumented.
     */
    void addParagraph( TParagraph *p );
    /**
     * Undocumented.
     */
    void getCrossRef( int i, TPoint& loc, uchar& length, int& ref );
    /**
     * Undocumented.
     */
    char *getLine( int line, char *buffer, int buflen );
    /**
     * Undocumented.
     */
    int getNumCrossRefs();
    /**
     * Undocumented.
     */
    int numLines();
    /**
     * Undocumented.
     */
    void setCrossRef( int i, TCrossRef& ref );
    /**
     * Undocumented.
     */
    void setNumCrossRefs( int i );
    /**
     * Undocumented.
     */
    void setWidth( int aWidth );
    /**
     * Undocumented.
     */
    TParagraph *paragraphs;
    /**
     * Undocumented.
     */
    int numRefs;
    /**
     * Undocumented.
     */
    TCrossRef *crossRefs;
private:
    char *wrapText( char *text, int size, int& offset, Boolean wrap, char *lineBuf, int lineBufLen );
    void readParagraphs( ipstream& s );
    void readCrossRefs( ipstream& s );
    void writeParagraphs( opstream& s );
    void writeCrossRefs( opstream& s );
    void disposeParagraphs();
    const char *streamableName() const
        { return name; }
    int width;
    int lastOffset;
    int lastLine;
    TParagraph *lastParagraph;
protected:
    virtual void write( opstream& os );
    virtual void *read( ipstream& is );
public:
    /**
     * Undocumented.
     */
    static const char * const name;
    /**
     * Undocumented.
     */
    static TStreamable *build();
};

/**
 * Undocumented.
 */
inline ipstream& operator >> ( ipstream& is, THelpTopic& cl )
    { return is >> (TStreamable&)cl; }
/**
 * Undocumented.
 */
inline ipstream& operator >> ( ipstream& is, THelpTopic*& cl )
    { return is >> (void *&)cl; }

/**
 * Undocumented.
 */
inline opstream& operator << ( opstream& os, THelpTopic& cl )
    { return os << (TStreamable&)cl; }
/**
 * Undocumented.
 */
inline opstream& operator << ( opstream& os, THelpTopic* cl )
    { return os << (TStreamable *)cl; }


// THelpIndex

/**
 * Part of the help system.
 * @short Part of the help system
 */
class THelpIndex : public TObject, public TStreamable
{
public:
    /**
     * Undocumented.
     */
    THelpIndex();
    /**
     * Undocumented.
     */
    THelpIndex( StreamableInit ) {};
    /**
     * Undocumented.
     */
    virtual ~THelpIndex();
    /**
     * Undocumented.
     */
    long position( int );
    /**
     * Undocumented.
     */
    void add( int, long );
    /**
     * Undocumented.
     */
    ushort size;
    /**
     * Undocumented.
     */
    long *index;
private:
    const char *streamableName() const
        { return name; }
protected:
    virtual void write( opstream& os );
    virtual void *read( ipstream& is );
public:
    /**
     * Undocumented.
     */
    static const char * const name;
    /**
     * Undocumented.
     */
    static TStreamable *build();
};

/**
 * Undocumented.
 */
inline ipstream& operator >> ( ipstream& is, THelpIndex& cl )
    { return is >> (TStreamable&)cl; }
/**
 * Undocumented.
 */
inline ipstream& operator >> ( ipstream& is, THelpIndex*& cl )
    { return is >> (void *&)cl; }

/**
 * Undocumented.
 */
inline opstream& operator << ( opstream& os, THelpIndex& cl )
    { return os << (TStreamable&)cl; }
/**
 * Undocumented.
 */
inline opstream& operator << ( opstream& os, THelpIndex* cl )
    { return os << (TStreamable *)cl; }


// THelpFile

/**
 * Part of the help system.
 * @short Part of the help system
 */
class THelpFile : public TObject
{
    static const char * invalidContext;
public:
    /**
     * Undocumented.
     */
    THelpFile( fpstream& s );
    /**
     * Undocumented.
     */
    virtual ~THelpFile();
    /**
     * Undocumented.
     */
    THelpTopic *getTopic( int );
    /**
     * Undocumented.
     */
    THelpTopic *invalidTopic();
    /**
     * Undocumented.
     */
    void recordPositionInIndex( int );
    /**
     * Undocumented.
     */
    void putTopic( THelpTopic* );
    /**
     * Undocumented.
     */
    fpstream *stream;
    /**
     * Undocumented.
     */
    Boolean modified;
    /**
     * Undocumented.
     */
    THelpIndex *index;
    /**
     * Undocumented.
     */
    long indexPos;
};

/**
 * Undocumented.
 */
extern void notAssigned( opstream& s, int value );

/**
 * Undocumented.
 */
extern TCrossRefHandler crossRefHandler;