home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / edit / point20 / pt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-04  |  12.1 KB  |  478 lines

  1. #define LINT_ARGS
  2. #include "funcdecl.h"
  3. #include "stdio.h"
  4. #include "dos.h"
  5. #include "ctype.h"
  6. #include "signal.h"
  7. #include "setjmp.h"
  8. #include "conio.h"
  9.  
  10. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  11. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  12.  
  13. /******* parameters -- can be changed *****/
  14. #define    NBUFFERS      300  /* buffers for file blocks (in address space) */
  15. #define    NHISTORY      100  /* history kept in memory */
  16. #define    NBUFHASH       16  /* buffer hash chains */
  17. #define    MSGBUFFERSIZE 256  /* size of two generally used buffers */
  18. #define    STRINGSIZE     50  /* size of input strings for search */
  19. #define    NEVENTS           30  /* number of mouse button events to queue */
  20. #define    MAXMENUITEMS   24  /* maximum number of items on a menu */
  21. #define    MENUSPACE    4500  /* size of the buffer for user menu items */
  22. #define    NMENUS           17  /* number of pop-up menus */
  23. #define SPACELOW     1024  /* low memory message threshold */
  24. #define NCOLORCYCLES   10  /* number of color combinations */
  25.  
  26. /****** constants that are rarely changed */
  27. #define    BUFFERSIZE    1024    /* size of a buffer in bytes */
  28. #define    BUFFERSHIFT    10    /* shift to convert: bytes<-->buffers */
  29. #ifdef GENIUS66
  30. #define    MAXROWS        66    /* max number of rows on the display */
  31. #else
  32. #define    MAXROWS        43    /* max number of rows on the display */
  33. #endif
  34. #define    MAXCOLS        80    /* max number of columns on the display */
  35. #define FILENAMESIZE    68    /* includes drive identifier */
  36.  
  37. /* string names */
  38. #define HANDLEMSG        1
  39. #define FULLMSG            2
  40. #define MENUSPMSG        3
  41. #define NOSPACEMSG        4
  42. #define LOWSPACEMSG        5
  43. #define OUTOFWINDOWS        6
  44. #define NOBUFFERMEMORY        7
  45. #define OUTOFFILESTRUCT        8
  46. #define CANNOTOPEN        9
  47. #define READONLYFILE        10
  48. #define WRITINGFILE        11
  49. #define CLOSEFAILED        12
  50. #define RENAMEFAILED        13
  51. #define DELETEFAILED        14
  52. #define RENAMEFAILED2        15
  53. #define WRITECANCELLED        16
  54. #define FILEEXISTS        17
  55. #define XXXXXXXX        18
  56. #define FILEWRITTEN        19
  57. #define WRITEFAILED        20
  58. #define CREATEFAILED        21
  59. #define WRITEPROGRESS        22
  60. #define WASREADONLY        23
  61. #define YTOSAVE            24
  62. #define CLOSECANCELLED        25
  63. #define NOTOPEN            26
  64. #define CLOSEFAILED2        27
  65. #define REANMEFAILED2        28
  66. #define DELETEFAILED2        29
  67. #define RENAMEFAILED3        30
  68.  
  69. /* Define the functions to be mapped to keys */
  70. #define FNOTMAPPED    0
  71. #define FCHARACTER    1
  72. #define FCOPY        2
  73. #define FMOVE        3
  74. #define FDELETE        4
  75. #define FQUITASK    5
  76. #define FDEBUG        6
  77. #define FNEWWINDOW    7
  78. #define FTOPFILE    8
  79. #define FBOTFILE    9
  80. #define FREDRAW        10
  81. #define FZOOM        11
  82. #define FTOP        12
  83. #define FRESIZE        13
  84. #define FPGUP        14
  85. #define FPGDN        15
  86. #define FGOTO        16
  87. #define FCLOSEWINDOW    17
  88. #define FWRITEFILE    18
  89. #define FSEARCH        19
  90. #define FREPLACE    20
  91. #define FINFORM        21
  92. #define FCANCEL        22
  93. #define FASCII        23
  94. #define FREDO        24
  95. #define FUNDO        25
  96. #define FSELECT        26
  97. #define FREPSEARCH    27
  98. #define FTOPBOTTOM    28
  99. #define FBOTTOM        29
  100. #define FEXECCMD    30
  101. #define FDONOTHING    31
  102. #define FEXECSHELL    32
  103. #define FLOADFILE    33
  104. #define FCURUP        34
  105. #define FCURDOWN    35
  106. #define FCURLEFT    36
  107. #define FCURRIGHT    37
  108. #define FHIDE        38
  109. #define FEXTEND        39
  110. #define FUNDOBACK    40
  111. #define FBEGINLINE    41
  112. #define FENDLINE    42
  113. #define FLEFTMBUTTON    43
  114. #define FRIGHTMBUTTON    44
  115. #define FMOUSECOM1    45
  116. #define FMOUSECOM2    46
  117. #define FSAVEALL    47
  118. #define FQUITSAVE    48
  119. #define FQUITNOSAVE    49
  120. #define FMENU1        50
  121. #define FMENU2        51
  122. #define FMENU3        52
  123. #define FCONTEXTMENU    53
  124. #define FSAVEFILE    54
  125. #define FINSKEY        55
  126. #define FGOBACKTO    56
  127. #define FCOPYSCRAP    57
  128. #define FGOTOSELECTION    58
  129. #define FCTAG        59
  130. #define FMENU4        60
  131. #define FDELNOSCRAP    61
  132. #define FEXCHSCRAP    62
  133. #define FCTAGSEL    63
  134. #define FHELP        64
  135. #define FMENU5        65
  136. #define FBACKSEARCH    66
  137. #define FMENU6        67
  138. #define FTOPLINE    68
  139. #define FCOPYTO        69
  140. #define FMOVETO        70
  141. #define FCHANGEMENU    71
  142. #define FCLOSESAVE    72
  143. #define FLOADSEL    73
  144. #define FWORDLEFT    74
  145. #define FWORDRIGHT    75
  146. #define FRECORDMACRO    76
  147. #define FPLAYMACRO    77
  148. #define FTOPSELFILE    78
  149. #define FMENU7        79
  150. #define FMENU8        80
  151. #define FRECAPITALIZE    81
  152. #define FNEWSEL        82
  153. #define FMATCHCHAR    83
  154. #define FSELGOTO    84
  155. #define FJUSTIFY    85
  156. #define FREADONLY    86
  157. #define FCYCLECOLORS    87
  158. #define FSWAPTOP    88
  159. #define FOVERLAY    89
  160. #define FREPLACECMD    90
  161. #define FTAG        91
  162. #define FTAGSEL        92
  163. #define FKEYWORD    93
  164. #define FKEYWORDSEL    94
  165. #define F66LINES    95
  166. #define FMENU9        96
  167. #define FMENU10        97
  168. #define FMENU11        98
  169. #define FMENU12        99
  170. #define FMENU13        100
  171. #define FMENU14        101
  172. #define FMENU15        102
  173. #define FMENU16        103
  174.  
  175. /* option setting commands */
  176. #define FFIRSTOPTION    104
  177. #define FUNUSED1    104
  178. #define FAUTOSAVEINTERVAL 105
  179. #define FAUTOSCROLLRATE    106
  180. #define FAUTOINDENT    107
  181. #define FBORDERCOLORS    108
  182. #define FCENTERMENUS    109
  183. #define FDOUBLECLICKDELAY 110
  184. #define FFILEPATTERN    111
  185. #define FFILESORT    112
  186. #define FFINDWHOLEWORDS    113
  187. #define FFSDIRS        114
  188. #define FFSMENU        115
  189. #define FFSPATTERNS    116
  190. #define FHELPMODE    117
  191. #define FI43LINES    118
  192. #define FIGNORECASE    119
  193. #define FUNUSED2    120
  194. #define FLINESOVERFIND    121
  195. #define FUNUSED11    122
  196. #define FUNUSED3    123
  197. #define FMSGCOLORS    124
  198. #define FUNUSED4    125
  199. #define FUNUSED14    126
  200. #define FUNUSED12    127
  201. #define FPATHNAMES    128
  202. #define FOVERTYPE    129
  203. #define FOREADONLY    130
  204. #define FREDEFINE    131
  205. #define FRESEARCH    132
  206. #define FRIGHTMARGIN    133
  207. #define FSCROLLDELAY    134
  208. #define FSCROLLRATE    135
  209. #define FSEARCHMODE    136
  210. #define FSMOOTHSCROLL    137
  211. #define FTABWIDTH    138
  212. #define FUNUSED15    139
  213. #define FTOPONFIND    140
  214. #define FTAGPATTERN    141
  215. #define FTAGMARKER    142
  216. #define FTEXTCOLORS    143
  217. #define FUNUSED5    144
  218. #define FUNIXMODE    145
  219. #define FVIDEOMODE    146
  220. #define FUNUSED6    147
  221. /* room for more options */
  222. #define FLASTOPTION    169
  223.  
  224. /* mouse positions -- returned by xyToPos */
  225. #define    OUTSIDEWINDOW    0
  226. #define    UPPERLEFT    1
  227. #define    UPPERRIGHT    2
  228. #define    UPPERBORDER    3
  229. #define    LOWERLEFT    4
  230. #define    LOWERRIGHT    5
  231. #define    LOWERBORDER    6
  232. #define    RIGHTBORDER    7
  233. #define    LEFTBORDER    8
  234. #define    INSIDEWINDOW    9
  235. #define    TOPLINE        10
  236.  
  237. /* buttons pressed -- used in mouse.c */
  238. #define LEFTBUTTON        0
  239. #define RIGHTBUTTON        11
  240. #define BOTHBUTTONS        22
  241.  
  242. /* used in the piece table -- original or new characters file */
  243. #define    ORIGFILE    0
  244. #define    ADDFILE        1
  245.  
  246. /* deleteSelection update type */
  247. #define NOUPDATE    0
  248. #define UPDATEWINDOWS    1
  249.  
  250. /* copyMove modes */
  251. #define    COPY        0
  252. #define    MOVE        1
  253. #define    REDO        2
  254.  
  255. /* create modes */
  256. #define    CRTOP        0
  257. #define    CRBOTTOM    1
  258.  
  259. /* shift, control, and alt keys masks */
  260. #define    RIGHTSHIFT    0x1
  261. #define    LEFTSHIFT    0x2
  262. #define    SHIFTKEYS    6x3
  263. #define    CONTROLKEY    0x4
  264. #define    SFTCONKEYS    0x7
  265. #define    ALTKEY        0x8
  266.  
  267.  
  268. /* selection modes */
  269. #define    SELCHAR    0
  270. #define    SELWORD    1
  271. #define    SELLINE    2
  272. #define    SELALL    3
  273.  
  274. /* color cycle stucture */
  275. /* XTAG:colorCycle */
  276. struct colorCycle {
  277.     unsigned char textColor, selColor;
  278.     unsigned char bannerColor, borderColor, elevColor;
  279. };
  280.  
  281.  
  282. /* long pointer structure */
  283. /* XTAG:longPointer */
  284. struct longPointer {
  285.     char *offset;
  286.     char *segment;
  287. };
  288.  
  289. /* XTAG:menuBlock */
  290. struct menuBlock {
  291.     int nItems;
  292.     unsigned char far *cmdName[MAXMENUITEMS];
  293.     int cmdNumber[MAXMENUITEMS];
  294. };
  295.  
  296. /* mouse button event */
  297. /* XTAG:event */
  298. struct event {
  299.     int mask, buttons;
  300.     int horizontal, vertical;
  301. };
  302.  
  303. /* change history */
  304. /* XTAG:changeItem */
  305. struct changeItem {
  306.     int type;
  307.     int fileId;
  308.     long position;
  309.     long length;
  310.     struct piece *firstPiece;
  311. };
  312.  
  313. /* change types */
  314. #define CNULL        0
  315. #define CINSERT        1
  316. #define CDELETE        2
  317. #define CMOVE        3
  318. #define CCOPY        4
  319.  
  320. /* option items */
  321. /* XTAG:optionItem */
  322. struct optionItem {
  323.     unsigned char *name;
  324.     int index;
  325.     int *variable;
  326.     int type;
  327.     int commandNumber;
  328. };
  329.  
  330. /* option type values */
  331. #define OBOOLEAN    0
  332. #define OINTEGER    1
  333. #define OOTHERS        2
  334. #define UBOOLEAN    3
  335. #define UINTEGER    4
  336. #define UOTHERS        5
  337. #define OSTRING        6
  338. #define USTRING        7
  339.  
  340. /* option index values */
  341. #define OFILESORT    0
  342. #define OMSGCOLORS    1
  343. #define ONBUFFERS    2
  344. #define OTEXTCOLORS    3
  345. #define OBORDERCOLORS    4
  346. #define OFSDIRS        5
  347. #define OUNDOSIZE    6
  348. #define O43LINES    7
  349. #define OFSPATTERNS    8
  350. #define OUNUSED2    9
  351. #define OREDEFINE    10
  352. #define OLASTITEM    -1
  353.  
  354. /* the window structure */
  355.  
  356. /* XTAG:window */
  357. struct window {
  358.     /* linked list of active windows */
  359.     struct window *nextWindow;
  360.     struct window *prevWindow;
  361.  
  362.     /* boundries of the window*/
  363.     int row1, row2, col1, col2;
  364.  
  365.     /* saved (after zoom) window boundries */
  366.     int saveRow1, saveRow2, saveCol1, saveCol2;
  367.  
  368.     /* cursor position and line number */
  369.     /* of the top and bottom lines in the window */
  370.     long posTopline, posBotline;
  371.     int numTopline, numBotline;
  372.  
  373.     /* remember the line we last jumped from */
  374.     int rowLastline;
  375.     
  376.     /* remember the last line the found the mouse cursor on */
  377.     int rowCurLast;
  378.     long posCurLast, lastPosTop;
  379.  
  380.     /* indent of the first character in each line visible */
  381.     int indent;
  382.     
  383.     /* state of the window */
  384.     /* Meaning of the bits in the window state: */
  385.     /* bit 0 : 0 => free window; 1 => used window */
  386.     /* bit 1 : 0 => DOS window; 1 => UNIX window */
  387.     /* bit 2 : 0 => regular window; 1 => temporary window */
  388.     /* bit 3 : 0 => no banner; 1 => filename only on banner */
  389.         /* bit 3 meaningful only if bit 2 == 1 */
  390.     int state;
  391.  
  392.     /* name and internal (to this program) identifier */
  393.     /* of the file the window is displaying */
  394.     int fileId;    /* of the file in the window */
  395.     int nameOffset;    /* into the file name in the backing file */
  396.  
  397.     /* colors */
  398.     unsigned char textColor;
  399.     unsigned char selColor;
  400.     unsigned char bannerColor;
  401.     unsigned char borderColor;
  402.     unsigned char elevColor;
  403.     unsigned char textCycle, borderCycle;
  404. };
  405.  
  406. /* a PIECE is a sequence of characters that is contiguous in the logical */
  407. /* and physical files.  Originally the file is one (big) piece.  As edits */
  408. /* are made it is divided into more pieces.  The characters in a piece */
  409. /* are either in the original (unchanged) file or in the add file (which) */
  410. /* contains all characters that have been added to the file in this editing */
  411. /* session */
  412.  
  413. /* XTAG:piece */
  414. struct piece {
  415.     int  file;    /* DOS file handle */
  416.     long position;    /* start of the piece */
  417.     long length;    /* length of the piece */
  418.     struct piece *nextPiece;    /* next piece in the list */
  419.     struct piece *prevPiece;    /* previous piece in the list */
  420. };
  421.  
  422. /* An open file consists of the original file (which is not changed during */
  423. /* an editing session) and an add file (where all new characters go). */
  424. /* The logical file is described in the pieces table which shows where */
  425. /* the logically contiguous characters in the file are physically located */
  426.  
  427. /* XTAG:openFile */
  428. struct openFile {
  429.  
  430.     /* the original file size */
  431.     long origFileSize;
  432.  
  433.     /* the current logical file size -- changed as the file is edited */
  434.     /* NOT the same as the size of origfile or addfile or their sum */
  435.     long fileSize;
  436.  
  437.     /* the file being edited -- this is read only */
  438.     unsigned char origName[FILENAMESIZE];
  439.     int origHandle;
  440.  
  441.     /* the piece list */
  442.     struct piece *pieceList;
  443.  
  444.     /* optimization fields */
  445.     /* loLogPiece and hiLogPiece are the low and high logical addresses */
  446.     /* that are mapped by piece number logPiece which is the last piece */
  447.     /* where a byte was found and is initialized to the one big piece */
  448.     /* that is the whole file when you start editing. */
  449.     /* The idea is that once you map a logical byte to a piece, it is */
  450.     /* likely that the next mapping is in the same piece. */
  451.     /* loLogBuffer and hiLogBuffer are the logical character limits of */
  452.     /* some valid characters in a buffer pointed to by logBuffer. */
  453.     long loLogPiece, hiLogPiece, loLogBuffer, hiLogBuffer;
  454.     struct piece *logPiece;
  455.     unsigned char *logBufSegment;
  456.     unsigned char *logBufOffset;
  457.  
  458.     /* some file status flags */
  459.     unsigned char useCount;    /* the number of windows using the file */
  460.  
  461.     unsigned char bakMade;    /* .bak file has been made */
  462.  
  463.     unsigned char readOnly;    /* file cannot be changed */
  464.  
  465.     unsigned char isChanged;    /* file has been edited */
  466. };
  467.  
  468. /* a disk buffer (both in and out of the address space) */
  469. /* XTAG:diskBuffer */
  470. struct diskBuffer {
  471.     int handle;    /* DOS file handle */
  472.     /* double linked hash chain links */
  473.     struct diskBuffer *forwardHash, *backwardHash;
  474.     long blockNumber;
  475.     unsigned char far *bufferAddress;
  476.     unsigned char written;    /* =1 if an add file block */
  477. };
  478.