home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff256.lzh / Stevie / stevie.h < prev    next >
C/C++ Source or Header  |  1989-10-19  |  7KB  |  337 lines

  1. /*
  2.  * STEVIE - Simply Try this Editor for VI Enthusiasts
  3.  *
  4.  * Code Contributions By : Tim Thompson           twitch!tjt
  5.  *                         Tony Andrews           onecom!wldrdg!tony 
  6.  *                         G. R. (Fred) Walter    watmath!grwalter 
  7.  */
  8.  
  9. #include "env.h"
  10.  
  11. #include <stdio.h>
  12. #ifndef ATARI
  13. # ifndef UNIX
  14. #   include <stdlib.h>
  15. # endif
  16. #endif
  17. #include <ctype.h>
  18. #ifndef MWC
  19. # include <string.h>
  20. #endif
  21. #include "ascii.h"
  22. #include "keymap.h"
  23. #include "param.h"
  24. #include "term.h"
  25. #include "macros.h"
  26.  
  27. #ifdef AMIGA
  28. /*
  29.  * This is used to disable break signal handling.
  30.  */
  31. #include <signal.h>
  32. #endif
  33.  
  34. extern char    *strchr();
  35.  
  36. #define NORMAL             0
  37. #define CMDLINE             1
  38. #define INSERT             2
  39. #define REPLACE             3
  40. #define APPEND             4
  41. #define UNDO             5
  42. #define REDO             6
  43. #define PUT             7
  44. #define FORWARD             8
  45. #define BACKWARD         9
  46. #define VALID            10
  47. #define NOT_VALID        11
  48. #define VALID_TO_CURSCHAR    12
  49. #define UPDATE_CURSOR           13
  50. #define UPDATE_ALL              14
  51.  
  52. /*
  53.  * Boolean type definition and constants 
  54.  */
  55. typedef int     bool_t;
  56.  
  57. #ifndef    TRUE
  58. # define    FALSE    (0)
  59. # define    TRUE    (1)
  60. #endif
  61. #define    SORTOF    (2)
  62. #define YES      TRUE
  63. #define NO       FALSE
  64. #define MAYBE    SORTOF
  65.  
  66. /*
  67.  * Maximum screen dimensions
  68.  */
  69. #define MAX_COLUMNS 140L
  70.  
  71. /*
  72.  * Buffer sizes
  73.  */
  74. #define CMDBUFFSIZE MAX_COLUMNS    /* size of the command processing buffer */
  75.  
  76. #define LSIZE        512    /* max. size of a line in the tags file */
  77.  
  78. #define IOSIZE     (1024+1)    /* file i/o and sprintf buffer size */
  79.  
  80. #define YANKSIZE    5200    /* yank buffer size */
  81. #define INSERT_SIZE 5300    /* insert, redo and undo buffer size must be
  82.                  * bigger than YANKSIZE */
  83. #define REDO_UNDO_SIZE 5400    /* redo, undo and (undo an undo) buffer size
  84.                  * must be bigger than INSERT_SIZE */
  85. #define READSIZE    5500    /* read buffer size must be bigger than
  86.                  * YANKSIZE and REDO_UNDO_SIZE */
  87.  
  88. /*
  89.  * SLOP is the amount of extra space we get for text on a line during editing
  90.  * operations that need more space. This keeps us from calling alloc every
  91.  * time we get a character during insert mode. No extra space is allocated
  92.  * when the file is initially read. 
  93.  */
  94. #define    SLOP    10
  95.  
  96. /*
  97.  * LINEINC is the gap we leave between the artificial line numbers. This
  98.  * helps to avoid renumbering all the lines every time a new line is
  99.  * inserted. 
  100.  *
  101.  * Since line numbers are stored in longs (32 bits), a LINEINC of 10000
  102.  * lets us have > 200,000 lines and we won't have to renumber very often.
  103.  */
  104. #define    LINEINC    10000
  105.  
  106. #define CHANGED    Changed = TRUE
  107. #define UNCHANGED  Changed = FALSE
  108.  
  109. #define S_NOT_VALID NumLineSizes = -1
  110.  
  111. #define S_LINE_NOT_VALID LineNotValid = TRUE
  112.  
  113. #define S_CHECK_TOPCHAR_AND_BOTCHAR CheckTopcharAndBotchar = TRUE
  114.  
  115. #define S_MUST_UPDATE_BOTCHAR MustUpdateBotchar = TRUE
  116.  
  117. #define S_VALID_TO_CURSCHAR ValidToCurschar = TRUE
  118.  
  119. struct line {
  120.     struct line    *next;    /* next line */
  121.     struct line    *prev;    /* previous line */
  122.     char           *s;        /* text for this line */
  123.     int             size;    /* actual size of space at 's' */
  124.     unsigned long   num;    /* line "number" */
  125. };
  126.  
  127. #define    LINEOF(x)    ((x)->linep->num)
  128.  
  129. struct lptr {
  130.     struct line    *linep;    /* line we're referencing */
  131.     int             index;    /* position within that line */
  132. };
  133.  
  134. typedef struct line LINE;
  135. typedef struct lptr LPtr;
  136.  
  137. struct charinfo {
  138.     char            ch_size;
  139.     char           *ch_str;
  140. };
  141.  
  142. extern struct charinfo chars[];
  143.  
  144. #ifdef AMIGA
  145. extern int      Aux_Device;
  146. #endif
  147. extern int      State;
  148. extern int      Rows;
  149. extern int      Columns;
  150. extern int      CheckTopcharAndBotchar;
  151. extern int      MustUpdateBotchar;
  152. extern int      ValidToCurschar;
  153. extern int      LineNotValid;
  154. extern int      NumLineSizes;
  155. extern LINE   **LinePointers;
  156. extern char    *LineSizes;
  157. extern char    *Filename;
  158. extern LPtr    *Filemem;
  159. extern LPtr    *Filetop;
  160. extern LPtr    *Fileend;
  161. extern LPtr    *Topchar;
  162. extern LPtr    *Botchar;
  163. extern LPtr    *Curschar;
  164. extern LPtr    *Insstart;
  165. extern int      Cursrow;
  166. extern int      Curscol;
  167. extern int      Cursvcol;
  168. extern int      Curswant;
  169. extern bool_t   set_want_col;
  170. extern int      Prenum;
  171. extern bool_t   Changed;
  172. extern bool_t   RedrawingDisabled;
  173. extern bool_t   UndoInProgress;
  174. extern char    *IObuff;
  175. extern char    *Insbuffptr;
  176. extern char    *Insbuff;
  177. extern char    *Readbuffptr;
  178. extern char    *Readbuff;
  179. extern char    *Redobuffptr;
  180. extern char    *Redobuff;
  181. extern char    *Undobuffptr;
  182. extern char    *Undobuff;
  183. extern char    *UndoUndobuffptr;
  184. extern char    *UndoUndobuff;
  185. extern char    *Yankbuffptr;
  186. extern char    *Yankbuff;
  187. extern char     last_command;
  188. extern char     last_command_char;
  189.  
  190. extern char    *strcpy();
  191.  
  192. /* alloc.c */
  193. char  *alloc();
  194. char  *strsave();
  195. void   screenalloc();
  196. void   filealloc();
  197. void   freeall();
  198. LINE  *newline();
  199. bool_t canincrease();
  200.  
  201. /* cmdline.c */
  202. void   readcmdline();
  203. void   dotag();
  204. void   msg();
  205. void   emsg();
  206. void   smsg();
  207. void   gotocmdline();
  208. void   wait_return();
  209.  
  210. /* dec.c */
  211. int    dec();
  212.  
  213. /* edit.c */
  214. void   edit();
  215. void   insertchar();
  216. void   getout();
  217. void   scrollup();
  218. void   scrolldown();
  219. void   beginline();
  220. bool_t oneright();
  221. bool_t oneleft();
  222. bool_t oneup();
  223. bool_t onedown();
  224.  
  225. /* fileio.c */
  226. void   filemess();
  227. void   renum();
  228. bool_t readfile();
  229. bool_t writeit();
  230.  
  231. /* s_io.c */
  232. void   s_cursor_off();
  233. void   s_cursor_on();
  234. void   s_clear();
  235. void   s_refresh();
  236. void   NotValidFromCurschar();
  237. void   Update_Botchar();
  238.  
  239. /* help.c */
  240. bool_t help();
  241.  
  242. /* inc.c */
  243. int    inc();
  244.  
  245. /* linefunc.c */
  246. LPtr  *nextline();
  247. LPtr  *prevline();
  248. void   coladvance();
  249.  
  250. /* main.c */
  251. void   stuffReadbuff();
  252. void   stuffnumReadbuff();
  253. char   vgetc();
  254. char   vpeekc();
  255.  
  256. /* mark.c */
  257. void   setpcmark();
  258. void   clrall();
  259. void   clrmark();
  260. bool_t setmark();
  261. LPtr  *getmark();
  262.  
  263. /* misccmds.c */
  264. bool_t OpenForward();
  265. bool_t OpenBackward();
  266. void   fileinfo();
  267. void   inschar();
  268. void   insstr();
  269. void   delline();
  270. bool_t delchar();
  271. int    cntllines();
  272. int    plines();
  273. LPtr  *gotoline();
  274.  
  275. /* normal.c */
  276. void   normal();
  277. void   ResetBuffers();
  278. void   AppendToInsbuff();
  279. void   AppendToRedobuff();
  280. void   AppendNumberToRedobuff();
  281. void   AppendToUndobuff();
  282. void   AppendNumberToUndobuff();
  283. void   AppendPositionToUndobuff();
  284. void   AppendToUndoUndobuff();
  285. void   AppendNumberToUndoUndobuff();
  286. void   AppendPositionToUndoUndobuff();
  287. bool_t linewhite();
  288.  
  289. /* mk.c */
  290. char  *mkstr();
  291. char  *mkline();
  292.  
  293. /* param.c */
  294. void   doset();
  295.  
  296. /* screen.c */
  297. void   cursupdate();
  298.  
  299. /* search.c */
  300. void   doglob();
  301. void   dosub();
  302. void   searchagain();
  303. bool_t dosearch();
  304. bool_t repsearch();
  305. bool_t searchc();
  306. bool_t crepsearch();
  307. bool_t findfunc();
  308. LPtr  *showmatch();
  309. LPtr  *fwd_word();
  310. LPtr  *bck_word();
  311. LPtr  *end_word();
  312.  
  313. /* format_l.c */
  314. char *format_line();
  315.  
  316. /*
  317.  * Machine-dependent routines. 
  318.  */
  319. #ifdef AMIGA
  320. # include "amiga.h"
  321. #endif
  322. #ifdef BSD
  323. # include "bsd.h"
  324. #endif
  325. #ifdef UNIX
  326. # include "unix.h"
  327. #endif
  328. #ifdef TOS
  329. # include "tos.h"
  330. #endif
  331. #ifdef OS2
  332. # include "os2.h"
  333. #endif
  334. #ifdef DOS
  335. # include "dos.h"
  336. #endif
  337.