Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

599 lines
22 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. ext.h
  5. Abstract:
  6. Microsoft Editor extension definitions.
  7. #ifndef SHIP
  8. NOTES:
  9. THIS FILE IS SHIPPED WITH THE PRODUCT!!!!
  10. BE VERY carefull what gets put into this file. Technically, if it
  11. is NOT required for extension writers, it does NOT belong here.
  12. 1) This note, the file history and all code within "#ifndef SHIP" and
  13. "#if defined EDITOR" conditionals should be REMOVED before shipping.
  14. Author:
  15. Ramon Juan San Andres (ramonsa) 06-Nov-1990 ported from M 1.02
  16. Revision History:
  17. 26-Nov-1991 mz Strip off near/far
  18. #endif
  19. --*/
  20. #include <windows.h>
  21. //
  22. // Macro Definitions
  23. //
  24. // BUFLEN is the maximum line length that can be passed or will be returned
  25. // by the editor.
  26. //
  27. #define BUFLEN 251
  28. //
  29. // NT versions of the editor no longer use 16-bit specific attributes.
  30. // Set them into ignore state
  31. //
  32. #define near
  33. #define far
  34. #define LOADDS
  35. #define EXPORT
  36. #define EXTERNAL
  37. #define INTERNAL
  38. #undef pascal
  39. #define pascal
  40. //
  41. // RQ_... are various request types supported for Get/Set EditorObject
  42. //
  43. #define RQ_FILE 0x1000 // GetEditorObject: File request
  44. #define RQ_FILE_HANDLE 0x1000 // File Handle
  45. #define RQ_FILE_NAME 0x1100 // ASCIIZ filename
  46. #define RQ_FILE_FLAGS 0x1200 // flags
  47. #define RQ_FILE_REFCNT 0x1300 // reference count
  48. #define RQ_WIN 0x2000 // Window request
  49. #define RQ_WIN_HANDLE 0x2000 // Window Handle
  50. #define RQ_WIN_CONTENTS 0x2100 // Window Contents
  51. #define RQ_WIN_CUR 0x2200 // Current Window
  52. #define RQ_COLOR 0x9000 // Color request
  53. #define RQ_CLIP 0xf000 // clipboard type
  54. #define RQ_THIS_OBJECT 0x00FF // function is directed to input object
  55. #define RQ_FILE_INIT 0x00FE // file is init file
  56. //
  57. // toPif is used when placing numeric or boolean switches in the swiDesc table
  58. // to eliminate C 5.X compiler warnings.
  59. //
  60. // For example: { "Switchname", toPIF(switchvar), SWI_BOOLEAN },
  61. //
  62. #define toPIF(x) (PIF)(void *)&x
  63. //
  64. // Editor color table endicies. (Colors USERCOLORMIN - USERCOLORMAX are
  65. // unassigned and available for extension use).
  66. //
  67. #define FGCOLOR 21 // foreground (normal) color
  68. #define HGCOLOR (1 + FGCOLOR) // highlighted region color
  69. #define INFCOLOR (1 + HGCOLOR) // information color
  70. #define SELCOLOR (1 + INFCOLOR) // selection color
  71. #define WDCOLOR (1 + SELCOLOR) // window border color
  72. #define STACOLOR (1 + WDCOLOR) // status line color
  73. #define ERRCOLOR (1 + STACOLOR) // error message color
  74. #define USERCOLORMIN (1 + ERRCOLOR) // begining of extension colors
  75. #define USERCOLORMAX 35 // end of extension colors
  76. //
  77. // General type Definitions
  78. //
  79. typedef int COL; // column or position with line
  80. #if !defined (EDITOR)
  81. #if !defined( _FLAGTYPE_DEFINED_ )
  82. #define _FLAGTYPE_DEFINED_ 1
  83. typedef char flagType;
  84. #endif
  85. typedef long LINE; // line number within file
  86. typedef void* PFILE; // editor file handle
  87. #if !defined (EXTINT)
  88. typedef void* PWND; // editor window handle
  89. #endif // EXTINT
  90. #endif // EDITOR
  91. typedef char buffer[BUFLEN]; // miscellaneous buffer
  92. typedef char linebuf[BUFLEN]; // line buffer
  93. typedef char pathbuf[MAX_PATH]; // Pathname buffer
  94. typedef struct fl { // file location
  95. LINE lin; // - line number
  96. COL col; // - column
  97. } fl;
  98. typedef struct sl { // screen location
  99. int lin; // - line number
  100. int col; // - column
  101. } sl;
  102. typedef struct rn { // file range
  103. fl flFirst; // - Lower line, or leftmost col
  104. fl flLast; // - Higher, or rightmost
  105. } rn;
  106. typedef struct lineAttr { // Line color attribute info
  107. unsigned char attr; // - Attribute of piece
  108. unsigned char len; // - Bytes in colored piece
  109. } lineAttr;
  110. #if !defined (cwExtraWnd)
  111. typedef struct ARC {
  112. BYTE axLeft;
  113. BYTE ayTop;
  114. BYTE axRight;
  115. BYTE ayBottom;
  116. } ARC;
  117. #endif // cwExtraWnd
  118. //
  119. // Argument defininition structures.
  120. //
  121. // We define a structure for each of the argument types that may be
  122. // passed to an extension function. Then, we define the structure
  123. // argType which is used to pass these arguments around in a union.
  124. //
  125. typedef struct noargType { // no argument specified
  126. LINE y; // - cursor line
  127. COL x; // - cursor column
  128. } NOARGTYPE;
  129. typedef struct textargType { // text argument specified
  130. int cArg; // - count of <arg>s pressed
  131. LINE y; // - cursor line
  132. COL x; // - cursor column
  133. char *pText; // - ptr to text of arg
  134. } TEXTARGTYPE;
  135. typedef struct nullargType { // null argument specified
  136. int cArg; // - count of <arg>s pressed
  137. LINE y; // - cursor line
  138. COL x; // - cursor column
  139. } NULLARGTYPE;
  140. typedef struct lineargType { // line argument specified
  141. int cArg; // - count of <arg>s pressed
  142. LINE yStart; // - starting line of range
  143. LINE yEnd; // - ending line of range
  144. } LINEARGTYPE;
  145. typedef struct streamargType { // stream argument specified
  146. int cArg; // - count of <arg>s pressed
  147. LINE yStart; // - starting line of region
  148. COL xStart; // - starting column of region
  149. LINE yEnd; // - ending line of region
  150. COL xEnd; // - ending column of region
  151. } STREAMARGTYPE;
  152. typedef struct boxargType { // box argument specified
  153. int cArg; // - count of <arg>s pressed
  154. LINE yTop; // - top line of box
  155. LINE yBottom; // - bottom line of bix
  156. COL xLeft; // - left column of box
  157. COL xRight; // - right column of box
  158. } BOXARGTYPE;
  159. typedef union ARGUNION {
  160. struct noargType noarg;
  161. struct textargType textarg;
  162. struct nullargType nullarg;
  163. struct lineargType linearg;
  164. struct streamargType streamarg;
  165. struct boxargType boxarg;
  166. } ARGUNION;
  167. typedef struct argType {
  168. int argType;
  169. ARGUNION arg;
  170. } ARG;
  171. //
  172. // Function definition table definitions
  173. //
  174. typedef ULONG_PTR CMDDATA;
  175. typedef flagType (*funcCmd)(CMDDATA argData, ARG *pArg, flagType fMeta);
  176. typedef struct cmdDesc { // function definition entry
  177. char *name; // - pointer to name of fcn
  178. funcCmd func; // - pointer to function
  179. CMDDATA arg; // - used internally by editor
  180. unsigned argType; // - user args allowed
  181. } CMD, *PCMD;
  182. typedef unsigned short KeyHandle;
  183. #define NOARG 0x0001 // no argument specified
  184. #define TEXTARG 0x0002 // text specified
  185. #define NULLARG 0x0004 // arg + no cursor movement
  186. #define NULLEOL 0x0008 // null arg => text from arg->eol
  187. #define NULLEOW 0x0010 // null arg => text from arg->end word
  188. #define LINEARG 0x0020 // range of entire lines
  189. #define STREAMARG 0x0040 // from low-to-high, viewed 1-D
  190. #define BOXARG 0x0080 // box delimited by arg, cursor
  191. #define NUMARG 0x0100 // text => delta to y position
  192. #define MARKARG 0x0200 // text => mark at end of arg
  193. #define BOXSTR 0x0400 // single-line box => text
  194. #define FASTKEY 0x0800 // Fast repeat function
  195. #define MODIFIES 0x1000 // modifies file
  196. #define KEEPMETA 0x2000 // do not eat meta flag
  197. #define WINDOWFUNC 0x4000 // moves window
  198. #define CURSORFUNC 0x8000 // moves cursor
  199. //
  200. // Switch definition table defintions
  201. //
  202. typedef flagType (*PIF)(char *);
  203. typedef char* (*PIFC)(char *);
  204. typedef union swiAct { // switch location or routine
  205. PIF pFunc; // - routine for text
  206. PIFC pFunc2; // - routine for text
  207. int *ival; // - integer value for NUMERIC
  208. flagType *fval; // - flag value for BOOLEAN
  209. } swiAct;
  210. typedef struct swiDesc { // switch definition entry
  211. char *name; // - pointer to name of switch
  212. swiAct act; // - pointer to value or fcn
  213. int type; // - flags defining switch type
  214. } SWI, *PSWI;
  215. #define SWI_BOOLEAN 0 // Boolean switch
  216. #define SWI_NUMERIC 1 // hex or decimal switch
  217. #define SWI_SCREEN 4 // switch affects screen
  218. #define SWI_SPECIAL 5 // textual switch
  219. #define SWI_SPECIAL2 6 // #5, returning an error string
  220. #define RADIX10 (0x0A << 8) // numeric switch is decimal
  221. #define RADIX16 (0x10 << 8) // numeric switch is hex
  222. //
  223. // Get/Set EditorObject data structures
  224. //
  225. typedef struct winContents{ // define window contents
  226. PFILE pFile; // - handle of file displayed
  227. ARC arcWin; // - location of window
  228. fl flPos; // - upper left corner wrt file
  229. } winContents;
  230. //
  231. // FILE flags values
  232. //
  233. #define DIRTY 0x01 // file had been modified
  234. #define FAKE 0x02 // file is a pseudo file
  235. #define REAL 0x04 // file has been read from disk
  236. #define DOSFILE 0x08 // file has CR-LF
  237. #define TEMP 0x10 // file is a temp file
  238. #define NEW 0x20 // file has been created by editor
  239. #define REFRESH 0x40 // file needs to be refreshed
  240. #define READONLY 0x80 // file may not be editted
  241. #define DISKRO 0x0100 // file on disk is read only
  242. #define MODE1 0x0200 // Meaning depends on the file
  243. #define VALMARKS 0x0400 // file has valid marks defined
  244. //
  245. // Event processing definitions
  246. //
  247. typedef struct mouseevent { // mouse event data
  248. short msg; // type of message
  249. short wParam; // CW wParam
  250. long lParam; // CW lParam
  251. sl sl; // screen location of mouse event
  252. fl fl; // file location (if event in win)
  253. } MOUSEEVENT, *PMOUSEEVENT;
  254. typedef struct KEY_DATA {
  255. BYTE Ascii; // Ascii code
  256. BYTE Scan; // Scan code
  257. BYTE Flags; // Flags
  258. BYTE Unused; // Unused byte
  259. } KEY_DATA, *PKEY_DATA;
  260. //
  261. // Following are the values for the Flags field of KEY_DATA
  262. //
  263. #define FLAG_SHIFT 0x01
  264. #define FLAG_CTRL 0x04
  265. #define FLAG_ALT 0x08
  266. #define FLAG_NUMLOCK 0x20
  267. typedef union KEY_INFO {
  268. KEY_DATA KeyData;
  269. long LongData;
  270. } KEY_INFO, *PKEY_INFO;
  271. typedef union EVTARGUNION {
  272. KEY_INFO key; // keystroke for key event
  273. char * pfn; // asciiz filename
  274. PMOUSEEVENT pmouse; // ptr to mouse event data
  275. union Rec *pUndoRec; // undo information
  276. } EVTARGUNION;
  277. typedef struct EVTargs { // arguments to event dispatches
  278. PFILE pfile; // -file handle for file events
  279. EVTARGUNION arg;
  280. } EVTargs, *PEVTARGS;
  281. typedef struct eventType { // event definition struct
  282. unsigned evtType; // - type
  283. flagType (*func)(EVTargs *); // - handler
  284. struct eventType *pEVTNext; // - next handler in list
  285. PFILE focus; // - applicable focus
  286. EVTargs arg; // - applicable agruments
  287. } EVT, *PEVT;
  288. #define EVT_RAWKEY 1 // ALL keystrokes
  289. #define EVT_KEY 2 // Editting keystrokes
  290. #define EVT_GETFOCUS 3 // file GETs focus.
  291. #define EVT_LOSEFOCUS 4 // file looses focus.
  292. #define EVT_EXIT 5 // about to exit.
  293. #define EVT_SHELL 6 // about to sell or compile
  294. #define EVT_UNLOAD 7 // about to be unloaded.
  295. #define EVT_IDLE 8 // idle event
  296. #define EVT_CANCEL 9 // do-nothing cancel
  297. #define EVT_REFRESH 10 // about to refresh a file
  298. #define EVT_FILEREADSTART 11 // about to read file
  299. #define EVT_FILEREADEND 12 // finshed reading file
  300. #define EVT_FILEWRITESTART 13 // about to write file
  301. #define EVT_FILEWRITEEND 14 // finshed writing file
  302. // 15
  303. // 16
  304. // 17
  305. // 18
  306. // 19
  307. #define EVT_EDIT 20 // editting action
  308. #define EVT_UNDO 21 // undone action
  309. #define EVT_REDO 22 // redone action
  310. //
  311. // Undo, Redo and Edit event structs
  312. //
  313. #define EVENT_REPLACE 0
  314. #define EVENT_INSERT 1
  315. #define EVENT_DELETE 2
  316. #define EVENT_BOUNDARY 3
  317. #if !defined (EDITOR)
  318. typedef struct replaceRec {
  319. int op; // operation
  320. long dummy[2]; // editor interal
  321. LINE length; // length of repalcement
  322. LINE line; // start of replacement
  323. } REPLACEREC;
  324. typedef struct insertRec {
  325. int op; // operation
  326. long dummy[2]; // editor interal
  327. LINE length; // length of file
  328. LINE line; // line number that was operated on
  329. LINE cLine; // number of lines inserted
  330. } INSERTREC;
  331. typedef struct deleteRec {
  332. int op; // operation
  333. long dummy[2]; // editor interal
  334. LINE length; // length of file
  335. LINE line; // line number that was operated on
  336. LINE cLine; // Number of lines deleted
  337. } DELETEREC;
  338. typedef struct boundRec {
  339. int op; // operation (BOUND)
  340. long dummy[2]; // editor interal
  341. int flags; // flags of file
  342. long modify; // Date/Time of last modify
  343. fl flWindow; // position in file of window
  344. fl flCursor; // position in file of cursor
  345. } BOUNDREC;
  346. typedef union Rec {
  347. struct replaceRec r;
  348. struct insertRec i;
  349. struct deleteRec d;
  350. struct boundRec b;
  351. } REC;
  352. #endif // editor
  353. //
  354. // Build command definitions
  355. //
  356. #define MAKE_FILE 1 // rule is for a filename
  357. #define MAKE_SUFFIX 2 // rule is a suffix rule
  358. #define MAKE_TOOL 4 // rule is for a tool
  359. #define MAKE_BLDMACRO 8 // rule is for a build macro
  360. #define MAKE_DEBUG 0x80 // rule is debug version
  361. #define LOWVERSION 0x0014 // lowest version of extensions we handle
  362. #define HIGHVERSION 0x0014 // highest version of extensions we handle
  363. #define VERSION 0x0014 // our current version
  364. typedef struct ExtensionTable {
  365. long version;
  366. long cbStruct;
  367. PCMD cmdTable;
  368. PSWI swiTable;
  369. struct CallBack {
  370. PFILE (*AddFile) (char *);
  371. flagType (*BadArg) (void);
  372. char (*Confirm) (char *, char *);
  373. void (*CopyBox) (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
  374. void (*CopyLine) (PFILE, PFILE, LINE, LINE, LINE);
  375. void (*CopyStream) (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
  376. void (*DeRegisterEvent) (EVT *);
  377. flagType (*DeclareEvent) (unsigned, EVTargs *);
  378. void (*DelBox) (PFILE, COL, LINE, COL, LINE);
  379. void (*DelFile) (PFILE);
  380. void (*DelLine) (PFILE, LINE, LINE);
  381. void (*DelStream) (PFILE, COL, LINE, COL, LINE);
  382. void (*Display) (void);
  383. int (*DoMessage) (char *);
  384. flagType (*fChangeFile) (flagType, char *);
  385. void (*Free) (void *);
  386. flagType (*fExecute) (char *);
  387. int (*fGetMake) (int, char *, char *);
  388. LINE (*FileLength) (PFILE);
  389. PFILE (*FileNameToHandle) (char *, char *);
  390. flagType (*FileRead) (char *, PFILE);
  391. flagType (*FileWrite) (char *, PFILE);
  392. PSWI (*FindSwitch) (char *);
  393. flagType (*fSetMake) (int, char *, char *);
  394. flagType (*GetColor) (LINE, lineAttr *, PFILE);
  395. void (*GetTextCursor) (COL *, LINE *);
  396. flagType (*GetEditorObject) (unsigned, void *, void *);
  397. char * (*GetEnv) (char *);
  398. int (*GetLine) (LINE, char *, PFILE);
  399. char * (*GetListEntry) (PCMD, int, flagType);
  400. flagType (*GetString) (char *, char *, flagType);
  401. int (*KbHook) (void);
  402. void (*KbUnHook) (void);
  403. void * (*Malloc) (size_t);
  404. void (*MoveCur) (COL, LINE);
  405. char * (*NameToKeys) (char *, char *);
  406. PCMD (*NameToFunc) (char *);
  407. flagType (*pFileToTop) (PFILE);
  408. void (*PutColor) (LINE, lineAttr *, PFILE);
  409. void (*PutLine) (LINE, char *, PFILE);
  410. int (*REsearch) (PFILE, flagType, flagType, flagType, flagType, char *, fl *);
  411. long (*ReadChar) (void);
  412. PCMD (*ReadCmd) (void);
  413. void (*RegisterEvent) (EVT *);
  414. void (*RemoveFile) (PFILE);
  415. flagType (*Replace) (char, COL, LINE, PFILE, flagType);
  416. char * (*ScanList) (PCMD, flagType);
  417. int (*search) (PFILE, flagType, flagType, flagType, flagType, char *, fl *);
  418. void (*SetColor) (PFILE, LINE, COL, COL, int);
  419. flagType (*SetEditorObject) (unsigned, void *, void *);
  420. void (*SetHiLite) (PFILE, rn, int);
  421. flagType (*SetKey) (char *, char *);
  422. flagType (*SplitWnd) (PWND, flagType, int);
  423. } CallBack;
  424. } EXTTAB;
  425. //
  426. // Editor low level function prototypes.
  427. //
  428. // This list defines the routines within the editor which may be called
  429. // by extension functions.
  430. //
  431. #if !defined (EDITOR)
  432. extern EXTTAB ModInfo;
  433. #define AddFile(x) ModInfo.CallBack.AddFile(x)
  434. #define BadArg ModInfo.CallBack.BadArg
  435. #define Confirm(x,y) ModInfo.CallBack.Confirm(x,y)
  436. #define CopyBox(x,y,z,a,b,c,d,e) ModInfo.CallBack.CopyBox(x,y,z,a,b,c,d,e)
  437. #define CopyLine(x,y,z,a,b) ModInfo.CallBack.CopyLine(x,y,z,a,b)
  438. #define CopyStream(x,y,z,a,b,c,d,e) ModInfo.CallBack.CopyStream(x,y,z,a,b,c,d,e)
  439. #define DeRegisterEvent(x) ModInfo.CallBack.DeRegisterEvent(x)
  440. #define DeclareEvent(x,y) ModInfo.CallBack.DeclareEvent(x,y)
  441. #define DelBox(x,y,z,a,b) ModInfo.CallBack.DelBox(x,y,z,a,b)
  442. #define DelFile(x) ModInfo.CallBack.DelFile(x)
  443. #define DelLine(x,y,z) ModInfo.CallBack.DelLine(x,y,z)
  444. #define DelStream(x,y,z,a,b) ModInfo.CallBack.DelStream(x,y,z,a,b)
  445. #define Display ModInfo.CallBack.Display
  446. #define DoMessage(x) ModInfo.CallBack.DoMessage(x)
  447. #define fChangeFile(x,y) ModInfo.CallBack.fChangeFile(x,y)
  448. #define Free(x) ModInfo.CallBack.Free(x)
  449. #define fExecute(x) ModInfo.CallBack.fExecute(x)
  450. #define fGetMake(x,y,z) ModInfo.CallBack.fGetMake(x,y,z)
  451. #define FileLength(x) ModInfo.CallBack.FileLength(x)
  452. #define FileNameToHandle(x,y) ModInfo.CallBack.FileNameToHandle(x,y)
  453. #define FileRead(x,y) ModInfo.CallBack.FileRead(x,y)
  454. #define FileWrite(x,y) ModInfo.CallBack.FileWrite(x,y)
  455. #define FindSwitch(x) ModInfo.CallBack.FindSwitch(x)
  456. #define fSetMake(x,y,z) ModInfo.CallBack.fSetMake(x,y,z)
  457. #define GetColor(x,y,z) ModInfo.CallBack.GetColor(x,y,z)
  458. #define GetTextCursor(x,y) ModInfo.CallBack.GetTextCursor(x,y)
  459. #define GetEditorObject(x,y,z) ModInfo.CallBack.GetEditorObject(x,y,z)
  460. #define GetEnv(x) ModInfo.CallBack.GetEnv(x)
  461. #define GetLine(x,y,z) ModInfo.CallBack.GetLine(x,y,z)
  462. #define GetListEntry(x,y,z) ModInfo.CallBack.GetListEntry(x,y,z)
  463. #define GetString(x,y,z) ModInfo.CallBack.GetString(x,y,z)
  464. #define KbHook ModInfo.CallBack.KbHook
  465. #define KbUnHook ModInfo.CallBack.KbUnHook
  466. #define Malloc(x) ModInfo.CallBack.Malloc(x)
  467. #define MoveCur(x,y) ModInfo.CallBack.MoveCur(x,y)
  468. #define NameToKeys(x,y) ModInfo.CallBack.NameToKeys(x,y)
  469. #define NameToFunc(x) ModInfo.CallBack.NameToFunc(x)
  470. #define pFileToTop(x) ModInfo.CallBack.pFileToTop(x)
  471. #define PutColor(x,y,z) ModInfo.CallBack.PutColor(x,y,z)
  472. #define PutLine(x,y,z) ModInfo.CallBack.PutLine(x,y,z)
  473. #define REsearch(x,y,z,a,b,c,d) ModInfo.CallBack.REsearch(x,y,z,a,b,c,d)
  474. #define ReadChar ModInfo.CallBack.ReadChar
  475. #define ReadCmd ModInfo.CallBack.ReadCmd
  476. #define RegisterEvent(x) ModInfo.CallBack.RegisterEvent(x)
  477. #define RemoveFile(x) ModInfo.CallBack.RemoveFile(x)
  478. #define Replace(x,y,z,a,b) ModInfo.CallBack.Replace(x,y,z,a,b)
  479. #define ScanList(x,y) ModInfo.CallBack.ScanList(x,y)
  480. #define search(x,y,z,a,b,c,d) ModInfo.CallBack.search(x,y,z,a,b,c,d)
  481. #define SetColor(x,y,z,a,b) ModInfo.CallBack.SetColor(x,y,z,a,b)
  482. #define SetEditorObject(x,y,z) ModInfo.CallBack.SetEditorObject(x,y,z)
  483. #define SetHiLite(x,y,z) ModInfo.CallBack.SetHiLite(x,y,z)
  484. #define SetKey(x,y) ModInfo.CallBack.SetKey(x,y)
  485. #define SplitWnd(x,y,z) ModInfo.CallBack.SplitWnd(x,y,z)
  486. void WhenLoaded (void);
  487. #endif // EDITOR