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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
|
/*++
Copyright (c) 1990 Microsoft Corporation
Module Name:
ext.h
Abstract:
Microsoft Editor extension definitions.
#ifndef SHIP
NOTES:
THIS FILE IS SHIPPED WITH THE PRODUCT!!!!
BE VERY carefull what gets put into this file. Technically, if it
is NOT required for extension writers, it does NOT belong here.
1) This note, the file history and all code within "#ifndef SHIP" and
"#if defined EDITOR" conditionals should be REMOVED before shipping.
Author:
Ramon Juan San Andres (ramonsa) 06-Nov-1990 ported from M 1.02
Revision History:
26-Nov-1991 mz Strip off near/far
#endif
--*/
#include <windows.h>
//
// Macro Definitions
//
// BUFLEN is the maximum line length that can be passed or will be returned
// by the editor.
//
#define BUFLEN 251
//
// NT versions of the editor no longer use 16-bit specific attributes.
// Set them into ignore state
//
#define near
#define far
#define LOADDS
#define EXPORT
#define EXTERNAL
#define INTERNAL
#undef pascal
#define pascal
//
// RQ_... are various request types supported for Get/Set EditorObject
//
#define RQ_FILE 0x1000 // GetEditorObject: File request
#define RQ_FILE_HANDLE 0x1000 // File Handle
#define RQ_FILE_NAME 0x1100 // ASCIIZ filename
#define RQ_FILE_FLAGS 0x1200 // flags
#define RQ_FILE_REFCNT 0x1300 // reference count
#define RQ_WIN 0x2000 // Window request
#define RQ_WIN_HANDLE 0x2000 // Window Handle
#define RQ_WIN_CONTENTS 0x2100 // Window Contents
#define RQ_WIN_CUR 0x2200 // Current Window
#define RQ_COLOR 0x9000 // Color request
#define RQ_CLIP 0xf000 // clipboard type
#define RQ_THIS_OBJECT 0x00FF // function is directed to input object
#define RQ_FILE_INIT 0x00FE // file is init file
//
// toPif is used when placing numeric or boolean switches in the swiDesc table
// to eliminate C 5.X compiler warnings.
//
// For example: { "Switchname", toPIF(switchvar), SWI_BOOLEAN },
//
#define toPIF(x) (PIF)(long)(void *)&x
//
// Editor color table endicies. (Colors USERCOLORMIN - USERCOLORMAX are
// unassigned and available for extension use).
//
#define FGCOLOR 21 // foreground (normal) color
#define HGCOLOR (1 + FGCOLOR) // highlighted region color
#define INFCOLOR (1 + HGCOLOR) // information color
#define SELCOLOR (1 + INFCOLOR) // selection color
#define WDCOLOR (1 + SELCOLOR) // window border color
#define STACOLOR (1 + WDCOLOR) // status line color
#define ERRCOLOR (1 + STACOLOR) // error message color
#define USERCOLORMIN (1 + ERRCOLOR) // begining of extension colors
#define USERCOLORMAX 35 // end of extension colors
//
// General type Definitions
//
typedef int COL; // column or position with line
#if !defined (EDITOR)
#if !defined( _FLAGTYPE_DEFINED_ )
#define _FLAGTYPE_DEFINED_ 1
typedef char flagType;
#endif
typedef long LINE; // line number within file
typedef void* PFILE; // editor file handle
#if !defined (EXTINT)
typedef void* PWND; // editor window handle
#endif // EXTINT
#endif // EDITOR
typedef char buffer[BUFLEN]; // miscellaneous buffer
typedef char linebuf[BUFLEN]; // line buffer
typedef char pathbuf[MAX_PATH]; // Pathname buffer
typedef struct fl { // file location
LINE lin; // - line number
COL col; // - column
} fl;
typedef struct sl { // screen location
int lin; // - line number
int col; // - column
} sl;
typedef struct rn { // file range
fl flFirst; // - Lower line, or leftmost col
fl flLast; // - Higher, or rightmost
} rn;
typedef struct lineAttr { // Line color attribute info
unsigned char attr; // - Attribute of piece
unsigned char len; // - Bytes in colored piece
} lineAttr;
#if !defined (cwExtraWnd)
typedef struct ARC {
BYTE axLeft;
BYTE ayTop;
BYTE axRight;
BYTE ayBottom;
} ARC;
#endif // cwExtraWnd
//
// Argument defininition structures.
//
// We define a structure for each of the argument types that may be
// passed to an extension function. Then, we define the structure
// argType which is used to pass these arguments around in a union.
//
typedef struct noargType { // no argument specified
LINE y; // - cursor line
COL x; // - cursor column
} NOARGTYPE;
typedef struct textargType { // text argument specified
int cArg; // - count of <arg>s pressed
LINE y; // - cursor line
COL x; // - cursor column
char *pText; // - ptr to text of arg
} TEXTARGTYPE;
typedef struct nullargType { // null argument specified
int cArg; // - count of <arg>s pressed
LINE y; // - cursor line
COL x; // - cursor column
} NULLARGTYPE;
typedef struct lineargType { // line argument specified
int cArg; // - count of <arg>s pressed
LINE yStart; // - starting line of range
LINE yEnd; // - ending line of range
} LINEARGTYPE;
typedef struct streamargType { // stream argument specified
int cArg; // - count of <arg>s pressed
LINE yStart; // - starting line of region
COL xStart; // - starting column of region
LINE yEnd; // - ending line of region
COL xEnd; // - ending column of region
} STREAMARGTYPE;
typedef struct boxargType { // box argument specified
int cArg; // - count of <arg>s pressed
LINE yTop; // - top line of box
LINE yBottom; // - bottom line of bix
COL xLeft; // - left column of box
COL xRight; // - right column of box
} BOXARGTYPE;
typedef union ARGUNION {
struct noargType noarg;
struct textargType textarg;
struct nullargType nullarg;
struct lineargType linearg;
struct streamargType streamarg;
struct boxargType boxarg;
} ARGUNION;
typedef struct argType {
int argType;
ARGUNION arg;
} ARG;
//
// Function definition table definitions
//
typedef unsigned long CMDDATA;
typedef flagType (*funcCmd)(CMDDATA argData, ARG *pArg, flagType fMeta);
typedef struct cmdDesc { // function definition entry
char *name; // - pointer to name of fcn
funcCmd func; // - pointer to function
CMDDATA arg; // - used internally by editor
unsigned argType; // - user args allowed
} CMD, *PCMD;
typedef unsigned short KeyHandle;
#define NOARG 0x0001 // no argument specified
#define TEXTARG 0x0002 // text specified
#define NULLARG 0x0004 // arg + no cursor movement
#define NULLEOL 0x0008 // null arg => text from arg->eol
#define NULLEOW 0x0010 // null arg => text from arg->end word
#define LINEARG 0x0020 // range of entire lines
#define STREAMARG 0x0040 // from low-to-high, viewed 1-D
#define BOXARG 0x0080 // box delimited by arg, cursor
#define NUMARG 0x0100 // text => delta to y position
#define MARKARG 0x0200 // text => mark at end of arg
#define BOXSTR 0x0400 // single-line box => text
#define FASTKEY 0x0800 // Fast repeat function
#define MODIFIES 0x1000 // modifies file
#define KEEPMETA 0x2000 // do not eat meta flag
#define WINDOWFUNC 0x4000 // moves window
#define CURSORFUNC 0x8000 // moves cursor
//
// Switch definition table defintions
//
typedef flagType (*PIF)(char *);
typedef char* (*PIFC)(char *);
typedef union swiAct { // switch location or routine
PIF pFunc; // - routine for text
PIFC pFunc2; // - routine for text
int *ival; // - integer value for NUMERIC
flagType *fval; // - flag value for BOOLEAN
} swiAct;
typedef struct swiDesc { // switch definition entry
char *name; // - pointer to name of switch
swiAct act; // - pointer to value or fcn
int type; // - flags defining switch type
} SWI, *PSWI;
#define SWI_BOOLEAN 0 // Boolean switch
#define SWI_NUMERIC 1 // hex or decimal switch
#define SWI_SCREEN 4 // switch affects screen
#define SWI_SPECIAL 5 // textual switch
#define SWI_SPECIAL2 6 // #5, returning an error string
#define RADIX10 (0x0A << 8) // numeric switch is decimal
#define RADIX16 (0x10 << 8) // numeric switch is hex
//
// Get/Set EditorObject data structures
//
typedef struct winContents{ // define window contents
PFILE pFile; // - handle of file displayed
ARC arcWin; // - location of window
fl flPos; // - upper left corner wrt file
} winContents;
//
// FILE flags values
//
#define DIRTY 0x01 // file had been modified
#define FAKE 0x02 // file is a pseudo file
#define REAL 0x04 // file has been read from disk
#define DOSFILE 0x08 // file has CR-LF
#define TEMP 0x10 // file is a temp file
#define NEW 0x20 // file has been created by editor
#define REFRESH 0x40 // file needs to be refreshed
#define READONLY 0x80 // file may not be editted
#define DISKRO 0x0100 // file on disk is read only
#define MODE1 0x0200 // Meaning depends on the file
#define VALMARKS 0x0400 // file has valid marks defined
//
// Event processing definitions
//
typedef struct mouseevent { // mouse event data
short msg; // type of message
short wParam; // CW wParam
long lParam; // CW lParam
sl sl; // screen location of mouse event
fl fl; // file location (if event in win)
} MOUSEEVENT, *PMOUSEEVENT;
typedef struct KEY_DATA {
BYTE Ascii; // Ascii code
BYTE Scan; // Scan code
BYTE Flags; // Flags
BYTE Unused; // Unused byte
} KEY_DATA, *PKEY_DATA;
//
// Following are the values for the Flags field of KEY_DATA
//
#define FLAG_SHIFT 0x01
#define FLAG_CTRL 0x04
#define FLAG_ALT 0x08
#define FLAG_NUMLOCK 0x20
typedef union KEY_INFO {
KEY_DATA KeyData;
long LongData;
} KEY_INFO, *PKEY_INFO;
typedef union EVTARGUNION {
KEY_INFO key; // keystroke for key event
char * pfn; // asciiz filename
PMOUSEEVENT pmouse; // ptr to mouse event data
union Rec *pUndoRec; // undo information
} EVTARGUNION;
typedef struct EVTargs { // arguments to event dispatches
PFILE pfile; // -file handle for file events
EVTARGUNION arg;
} EVTargs, *PEVTARGS;
typedef struct eventType { // event definition struct
unsigned evtType; // - type
flagType (*func)(EVTargs *); // - handler
struct eventType *pEVTNext; // - next handler in list
PFILE focus; // - applicable focus
EVTargs arg; // - applicable agruments
} EVT, *PEVT;
#define EVT_RAWKEY 1 // ALL keystrokes
#define EVT_KEY 2 // Editting keystrokes
#define EVT_GETFOCUS 3 // file GETs focus.
#define EVT_LOSEFOCUS 4 // file looses focus.
#define EVT_EXIT 5 // about to exit.
#define EVT_SHELL 6 // about to sell or compile
#define EVT_UNLOAD 7 // about to be unloaded.
#define EVT_IDLE 8 // idle event
#define EVT_CANCEL 9 // do-nothing cancel
#define EVT_REFRESH 10 // about to refresh a file
#define EVT_FILEREADSTART 11 // about to read file
#define EVT_FILEREADEND 12 // finshed reading file
#define EVT_FILEWRITESTART 13 // about to write file
#define EVT_FILEWRITEEND 14 // finshed writing file
// 15
// 16
// 17
// 18
// 19
#define EVT_EDIT 20 // editting action
#define EVT_UNDO 21 // undone action
#define EVT_REDO 22 // redone action
//
// Undo, Redo and Edit event structs
//
#define EVENT_REPLACE 0
#define EVENT_INSERT 1
#define EVENT_DELETE 2
#define EVENT_BOUNDARY 3
#if !defined (EDITOR)
typedef struct replaceRec {
int op; // operation
long dummy[2]; // editor interal
LINE length; // length of repalcement
LINE line; // start of replacement
} REPLACEREC;
typedef struct insertRec {
int op; // operation
long dummy[2]; // editor interal
LINE length; // length of file
LINE line; // line number that was operated on
LINE cLine; // number of lines inserted
} INSERTREC;
typedef struct deleteRec {
int op; // operation
long dummy[2]; // editor interal
LINE length; // length of file
LINE line; // line number that was operated on
LINE cLine; // Number of lines deleted
} DELETEREC;
typedef struct boundRec {
int op; // operation (BOUND)
long dummy[2]; // editor interal
int flags; // flags of file
long modify; // Date/Time of last modify
fl flWindow; // position in file of window
fl flCursor; // position in file of cursor
} BOUNDREC;
typedef union Rec {
struct replaceRec r;
struct insertRec i;
struct deleteRec d;
struct boundRec b;
} REC;
#endif // editor
//
// Build command definitions
//
#define MAKE_FILE 1 // rule is for a filename
#define MAKE_SUFFIX 2 // rule is a suffix rule
#define MAKE_TOOL 4 // rule is for a tool
#define MAKE_BLDMACRO 8 // rule is for a build macro
#define MAKE_DEBUG 0x80 // rule is debug version
#define LOWVERSION 0x0014 // lowest version of extensions we handle
#define HIGHVERSION 0x0014 // highest version of extensions we handle
#define VERSION 0x0014 // our current version
typedef struct ExtensionTable {
long version;
long cbStruct;
PCMD cmdTable;
PSWI swiTable;
struct CallBack {
PFILE (*AddFile) (char *);
flagType (*BadArg) (void);
char (*Confirm) (char *, char *);
void (*CopyBox) (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
void (*CopyLine) (PFILE, PFILE, LINE, LINE, LINE);
void (*CopyStream) (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
void (*DeRegisterEvent) (EVT *);
flagType (*DeclareEvent) (unsigned, EVTargs *);
void (*DelBox) (PFILE, COL, LINE, COL, LINE);
void (*DelFile) (PFILE);
void (*DelLine) (PFILE, LINE, LINE);
void (*DelStream) (PFILE, COL, LINE, COL, LINE);
void (*Display) (void);
int (*DoMessage) (char *);
flagType (*fChangeFile) (flagType, char *);
void (*Free) (void *);
flagType (*fExecute) (char *);
int (*fGetMake) (int, char *, char *);
LINE (*FileLength) (PFILE);
PFILE (*FileNameToHandle) (char *, char *);
flagType (*FileRead) (char *, PFILE);
flagType (*FileWrite) (char *, PFILE);
PSWI (*FindSwitch) (char *);
flagType (*fSetMake) (int, char *, char *);
flagType (*GetColor) (LINE, lineAttr *, PFILE);
void (*GetTextCursor) (COL *, LINE *);
flagType (*GetEditorObject) (unsigned, void *, void *);
char * (*GetEnv) (char *);
int (*GetLine) (LINE, char *, PFILE);
char * (*GetListEntry) (PCMD, int, flagType);
flagType (*GetString) (char *, char *, flagType);
int (*KbHook) (void);
void (*KbUnHook) (void);
void * (*Malloc) (size_t);
void (*MoveCur) (COL, LINE);
char * (*NameToKeys) (char *, char *);
PCMD (*NameToFunc) (char *);
flagType (*pFileToTop) (PFILE);
void (*PutColor) (LINE, lineAttr *, PFILE);
void (*PutLine) (LINE, char *, PFILE);
int (*REsearch) (PFILE, flagType, flagType, flagType, flagType, char *, fl *);
long (*ReadChar) (void);
PCMD (*ReadCmd) (void);
void (*RegisterEvent) (EVT *);
void (*RemoveFile) (PFILE);
flagType (*Replace) (char, COL, LINE, PFILE, flagType);
char * (*ScanList) (PCMD, flagType);
int (*search) (PFILE, flagType, flagType, flagType, flagType, char *, fl *);
void (*SetColor) (PFILE, LINE, COL, COL, int);
flagType (*SetEditorObject) (unsigned, void *, void *);
void (*SetHiLite) (PFILE, rn, int);
flagType (*SetKey) (char *, char *);
flagType (*SplitWnd) (PWND, flagType, int);
} CallBack;
} EXTTAB;
//
// Editor low level function prototypes.
//
// This list defines the routines within the editor which may be called
// by extension functions.
//
#if !defined (EDITOR)
extern EXTTAB ModInfo;
#define AddFile(x) ModInfo.CallBack.AddFile(x)
#define BadArg ModInfo.CallBack.BadArg
#define Confirm(x,y) ModInfo.CallBack.Confirm(x,y)
#define CopyBox(x,y,z,a,b,c,d,e) ModInfo.CallBack.CopyBox(x,y,z,a,b,c,d,e)
#define CopyLine(x,y,z,a,b) ModInfo.CallBack.CopyLine(x,y,z,a,b)
#define CopyStream(x,y,z,a,b,c,d,e) ModInfo.CallBack.CopyStream(x,y,z,a,b,c,d,e)
#define DeRegisterEvent(x) ModInfo.CallBack.DeRegisterEvent(x)
#define DeclareEvent(x,y) ModInfo.CallBack.DeclareEvent(x,y)
#define DelBox(x,y,z,a,b) ModInfo.CallBack.DelBox(x,y,z,a,b)
#define DelFile(x) ModInfo.CallBack.DelFile(x)
#define DelLine(x,y,z) ModInfo.CallBack.DelLine(x,y,z)
#define DelStream(x,y,z,a,b) ModInfo.CallBack.DelStream(x,y,z,a,b)
#define Display ModInfo.CallBack.Display
#define DoMessage(x) ModInfo.CallBack.DoMessage(x)
#define fChangeFile(x,y) ModInfo.CallBack.fChangeFile(x,y)
#define Free(x) ModInfo.CallBack.Free(x)
#define fExecute(x) ModInfo.CallBack.fExecute(x)
#define fGetMake(x,y,z) ModInfo.CallBack.fGetMake(x,y,z)
#define FileLength(x) ModInfo.CallBack.FileLength(x)
#define FileNameToHandle(x,y) ModInfo.CallBack.FileNameToHandle(x,y)
#define FileRead(x,y) ModInfo.CallBack.FileRead(x,y)
#define FileWrite(x,y) ModInfo.CallBack.FileWrite(x,y)
#define FindSwitch(x) ModInfo.CallBack.FindSwitch(x)
#define fSetMake(x,y,z) ModInfo.CallBack.fSetMake(x,y,z)
#define GetColor(x,y,z) ModInfo.CallBack.GetColor(x,y,z)
#define GetTextCursor(x,y) ModInfo.CallBack.GetTextCursor(x,y)
#define GetEditorObject(x,y,z) ModInfo.CallBack.GetEditorObject(x,y,z)
#define GetEnv(x) ModInfo.CallBack.GetEnv(x)
#define GetLine(x,y,z) ModInfo.CallBack.GetLine(x,y,z)
#define GetListEntry(x,y,z) ModInfo.CallBack.GetListEntry(x,y,z)
#define GetString(x,y,z) ModInfo.CallBack.GetString(x,y,z)
#define KbHook ModInfo.CallBack.KbHook
#define KbUnHook ModInfo.CallBack.KbUnHook
#define Malloc(x) ModInfo.CallBack.Malloc(x)
#define MoveCur(x,y) ModInfo.CallBack.MoveCur(x,y)
#define NameToKeys(x,y) ModInfo.CallBack.NameToKeys(x,y)
#define NameToFunc(x) ModInfo.CallBack.NameToFunc(x)
#define pFileToTop(x) ModInfo.CallBack.pFileToTop(x)
#define PutColor(x,y,z) ModInfo.CallBack.PutColor(x,y,z)
#define PutLine(x,y,z) ModInfo.CallBack.PutLine(x,y,z)
#define REsearch(x,y,z,a,b,c,d) ModInfo.CallBack.REsearch(x,y,z,a,b,c,d)
#define ReadChar ModInfo.CallBack.ReadChar
#define ReadCmd ModInfo.CallBack.ReadCmd
#define RegisterEvent(x) ModInfo.CallBack.RegisterEvent(x)
#define RemoveFile(x) ModInfo.CallBack.RemoveFile(x)
#define Replace(x,y,z,a,b) ModInfo.CallBack.Replace(x,y,z,a,b)
#define ScanList(x,y) ModInfo.CallBack.ScanList(x,y)
#define search(x,y,z,a,b,c,d) ModInfo.CallBack.search(x,y,z,a,b,c,d)
#define SetColor(x,y,z,a,b) ModInfo.CallBack.SetColor(x,y,z,a,b)
#define SetEditorObject(x,y,z) ModInfo.CallBack.SetEditorObject(x,y,z)
#define SetHiLite(x,y,z) ModInfo.CallBack.SetHiLite(x,y,z)
#define SetKey(x,y) ModInfo.CallBack.SetKey(x,y)
#define SplitWnd(x,y,z) ModInfo.CallBack.SplitWnd(x,y,z)
void WhenLoaded (void);
#endif // EDITOR
|