/************************************************************************ * * * copyright Richard Bornat 1981 * * * ************************************************************************/ /* Modified 30/4/82 to add Next Page and Last Page control chars -PLS */ /* " 20/5/82 to add Execute Cmd & stay in edmode ctrl char -PLS */ /* " 25/5/82 to add diag_printed flag external declaration -PLS */ /* " 18/12/82 to add tab width param external declaration -PLS */ /* " 22/12/82 to add second unix buff external declaration -PLS */ /* " 15/2/83 to add Read Pipe char for interactive compile -PLS */ /* " 17/2/84 to add Overtype mode toggle char & flag extrn -PLS */ /* " 13/4/84 to add tab preserve flag external declaration -PLS */ #define true 1 #define false 0 /* alternative versions, forced by the MAD design of setjmp and longjmp. * Come back BCPL, you are lovely. */ #define OK 1 #define NOT_OK (-1) /* editor modes - defined as 2 and -2 for non-conflict with OK/NOT_OK. * (see beginning of mainloop procedure) */ #define INMODE 2 #define EDMODE (-2) /* screen size parameters - variables initialised * from the characteristics of the terminal (see * ttysetup procedure) */ extern int nrows, ncols; #define BELLMARGIN (ncols/5*4) /* 64 chars per line */ #define ENOUGH 131 /* enough for one screen line */ #define MARGIN 2 /* room for line tag */ /* condition of end and top of file */ #define TOF (topl==0) #define EOF (topl+LASTINROW>=maxl) /* number of letters in the alphabet! */ #define NLETTS 26 /* input character classes */ #define IGN 0 #define ONE 1 #define TWO 2 #define TAB 3 #define MODIFY 4 #define SPACE 5 #define CR 6 #define NL 7 #define WLEFT 8 #define WRIGHT 9 #define LEFT 10 #define RIGHT 11 #define UP 12 #define DOWN 13 #define CONTROL 14 #define SPECIAL 15 #define LSTART 16 /* start of line */ #define LEND 17 /* end of line */ #define TOPSCREEN 18 /* top of screen */ #define BOTSCREEN 19 /* bottom of screen */ #define NEXTPAGE 20 /* same as " command - UMIST */ #define LASTPAGE 21 /* same as & command - UMIST */ /* characters which are commands */ #define SEND 30 /* modify interpretation of next line typed */ #define ENTERedit 31 /* wipe edit line and enter edit mode */ #define CHMODE 32 /* change mode (input <-> command) */ #define COMMAND 33 /* execute command shown in command line */ #define CMDSTAY 34 /* execute cmd and stay in cmd line - UMIST */ #define READPIPE 35 /* read in next compiler error msg - UMIST */ #define OVER 36 /* overtype/insert mode toggle - UMIST */ /* erasing commands */ #define RUBOUT 40 /* erase PREVIOUS character */ #define ERASE 41 /* erase PRESENT character */ #define WRUBOUT 42 /* erase PREVIOUS word */ #define WERASE 43 /* erase PRESENT word */ #define HEADRUBOUT 44 /* erase row up to cursor */ #define TAILERASE 45 /* erase row from cursor */ #define LINEERASE 46 /* delete entire line */ #define LMIDDLE 60 /* move to middle of line */ /* normal/dlog input discrimination */ #define NORMAL_INPUT (tty_input==std_in) /* input channels */ #define STD_IN 0 #define STD_OUT 1 #define STD_TER 2 /* structure definitions */ struct iobuf { int fildes; int nleft; char *nextp; char buf[512]; }; struct CURSOR { int row; int col; }; /* * external structures */ extern struct CURSOR virt_c,real_c; extern struct CURSOR in_c, edit_c; extern char **rowmap, **auxscreen; extern char auxl[]; extern unsigned l_offset[]; extern char f_cache[]; extern char ictab[], ectab[]; extern char filename[], tempname[]; extern char pidname[], pathname[]; extern char tailname[]; extern char dlogname[]; /* things preserved in dlog file */ extern char erow[ENOUGH]; extern int b_range[NLETTS], e_range[NLETTS]; extern char old_search[ENOUGH]; extern char old_pat[ENOUGH]; extern char unixbuffer[ENOUGH]; extern char plusbuffer[ENOUGH]; /* separate unix buff for '+' command */ /* * external variables */ extern char *curr_break; extern int topl, maxl; extern int txin, tbout; extern int ringing; extern int mode; extern int toprow,bottomrow,leftcol,rightcol; extern int tmp_changed; extern int filewritten; extern int dlogger, tty_input; extern int std_in, std_out, std_ter; extern int setup_done; /* ttysetup */ extern int modopt; /* to say whether a modifier has been selected */ extern int Pswitch, Prows, Pcols; /* to say whether io is from pipe */ extern int editright; extern int diag_printed; /* to say if a diagnostic has been printed */ extern int tabsiz; /* current tab width */ extern int tab_preserve; /* true if not expanding tabs on input */ extern int overtype; /* true if in overtype mode */ /* * external functions (some included here for the benefit * of lint). */ extern int itoe(); extern int etoi(); extern int mainloop(); extern int do_command(); extern int set_dbug(), unset_dbug(), dbug(); extern void (*ttyinterrupt)(int); extern char lastchar(); extern char **newscreen(); extern char lcase(); /* * variables to address the screen */ extern int NINROWS; /* (nrows-1) */ extern int LASTINROW; /* (nrows-2) */ extern int EDITROW; /* (nrows-1) */ extern int FOOTROW; /* (nrows-1) */ extern int SCROLL; /* (nrows/3) */ extern int RIGHTCOL; /* (ncols-1) */