1 /* 2 ** se.h --- definitions for the screen editor 3 ** 4 ** This file is in the public domain. 5 */ 6 7 #ifndef __SE_H 8 #define __SE_H 9 10 #include <stdio.h> 11 #include <ctype.h> 12 #include <signal.h> 13 14 /* some standard definitions used throughout the screen editor */ 15 #include "constdefs.h" 16 #include "ascii.h" /* definitions of ascii characters */ 17 18 /* new data types */ 19 20 typedef struct ldesc { /* line descriptor */ 21 unsigned Seekaddr; /* scratch file seek address / 8 */ 22 unsigned Lineleng : 16; /* line length including NL EOS */ 23 unsigned Globmark : 1; /* mark for global commands */ 24 unsigned Markname : 7; /* mark name associated with line */ 25 } LINEDESC; 26 27 /* Language extensions */ 28 #define min(a,b) ((a)<(b)?(a):(b)) 29 #define max(a,b) ((a)>(b)?(a):(b)) 30 #define SKIPBL(l,i) while (l[i] == ' ') (i)++ 31 32 /* save a little procedure call overhead... */ 33 #define remark(text) mesg(text, REMARK_MSG) 34 35 /* Arbitrary definitions */ 36 #define BACKWARD -1 37 #define FORWARD 0 38 #define NOSTATUS 1 39 #define NOMORE 0 40 #define NEWLINE '\n' 41 #define TAB '\t' 42 #define RETERR 1 43 #define RETOK 0 44 45 /* Array dimensions and other limit values */ 46 #define MAXBUF 8192 47 #define MAXTOBUF 512 48 #define MAXCHARS 10 49 #define MAXROWS 200 50 #define MINROWS 16 51 #define MAXCOLS 200 52 #define MAXLINE 512 53 #define MAXPAT 512 54 #define GARB_FACTOR 2 55 #define GARB_THRESHOLD 1000 56 #define BUFENT 1 57 #define KEYSIZE 11 58 59 /* Message classes for status line at bottom of screen */ 60 #define NOMSG 0 61 #define REMARK_MSG 1 62 #define CHAR_MSG 2 63 #define CASE_MSG 3 64 #define INS_MSG 4 65 #define TIME_MSG 5 66 #define FILE_MSG 6 67 #define COL_MSG 7 68 #define LINE_MSG 8 69 #define COMPRESS_MSG 9 70 #define HELP_MSG 10 71 #define MODE_MSG 11 72 #define CRYPT_MSG 12 73 74 /* Characters typed by the user */ 75 #define ANYWAY '!' 76 #define APPENDCOM 'a' 77 #define UCAPPENDCOM 'A' 78 #define BACKSCAN '?' 79 #define BACKSEARCH '<' 80 #define CHANGE 'c' 81 #define UCCHANGE 'C' 82 #define COPYCOM 't' 83 #define UCCOPYCOM 'T' 84 #define CURLINE '.' 85 #define DEFAULTNAME ' ' 86 #define DELCOM 'd' 87 #define UCDELCOM 'D' 88 #define ENTER 'e' 89 #define UCENTER 'E' 90 #define ESCAPE '\\' 91 #define EXCLUDE 'x' 92 #define UCEXCLUDE 'X' 93 #define GLOBAL 'g' 94 #define UCGLOBAL 'G' 95 #define GMARK '\'' 96 #define HELP 'h' 97 #define UCHELP 'H' 98 #define INSERT 'i' 99 #define UCINSERT 'I' 100 #define JOINCOM 'j' 101 #define UCJOINCOM 'J' 102 #define LASTLINE '$' 103 #define LOCATECMD 'l' 104 #define UCLOCATECMD 'L' 105 #define MARKCOM 'k' 106 #define UCMARKCOM 'K' 107 #define MOVECOM 'm' 108 #define UCMOVECOM 'M' 109 #define NAMECOM 'n' 110 #define UCNAMECOM 'N' 111 #define NOTINCCL '^' 112 #define OPTCOM 'o' 113 #define UCOPTCOM 'O' 114 #define PAGECOM ':' 115 #define OVERLAYCOM 'v' 116 #define UCOVERLAYCOM 'V' 117 #define PREVLN '^' 118 #define PREVLN2 '-' 119 #define PRINT 'p' 120 #define UCPRINT 'P' 121 #define PRINTCUR '=' 122 #define PRINTFIL 'f' 123 #define UCPRINTFIL 'F' 124 #define QUIT 'q' 125 #define UCQUIT 'Q' 126 #define READCOM 'r' 127 #define UCREADCOM 'R' 128 #define SCAN '/' 129 #define SEARCH '>' 130 #define SUBSTITUTE 's' 131 #define UCSUBSTITUTE 'S' 132 #define TLITCOM 'y' 133 #define UCTLITCOM 'Y' 134 #define TOPLINE '#' 135 #define UNDOCOM 'u' 136 #define UCUNDOCOM 'U' 137 #define WRITECOM 'w' 138 #define UCWRITECOM 'W' 139 #define XMARK '~' 140 #define MISCCOM 'z' 141 #define UCMISCCOM 'Z' 142 #define SHELLCOM '!' 143 144 /* Error message numbers. Arbitrary so long as they are different. */ 145 #define EBACKWARD 1 146 #define ENOPAT 2 147 #define EBADPAT 3 148 #define EBADSTR 4 149 #define EBADSUB 5 150 #define ECANTREAD 6 151 #define EEGARB 7 152 #define EFILEN 8 153 #define EBADTABS 9 154 #define EINSIDEOUT 10 155 #define EKNOTFND 11 156 #define ELINE1 12 157 #define E2LONG 13 158 #define ENOERR 14 159 #define ENOLIMBO 15 160 #define EODLSSGTR 16 161 #define EORANGE 17 162 #define EOWHAT 18 163 #define EPNOTFND 19 164 #define ESTUPID 20 165 #define EWHATZAT 21 166 #define EBREAK 22 167 #define ELINE2 23 168 #define ECANTWRITE 24 169 #define ECANTINJECT 25 170 #define ENOMATCH 26 171 #define ENOFN 27 172 #define EBADLIST 28 173 #define ENOLIST 29 174 #define ENONSENSE 30 175 #define ENOHELP 31 176 #define EBADLNR 32 177 #define EFEXISTS 33 178 #define EBADCOL 34 179 #define ENOLANG 35 180 #define ETRUNC 36 181 #define ENOSHELL 37 182 #define ECANTFORK 38 183 #define EHANGUP 39 184 #define ENOSUB 40 185 #define ENOCMD 41 186 187 /* Screen design positions */ 188 #define NAMECOL 5 /* column to put mark name in */ 189 #define BARCOL 6 /* column for "|" divider */ 190 #define POOPCOL 7 /* column for text to start in */ 191 192 /* Control characters */ 193 194 /* Leftward cursor motion */ 195 #define CURSOR_LEFT CTRL_H /* left one column */ 196 #define TAB_LEFT CTRL_E /* left one tab stop */ 197 #define SKIP_LEFT CTRL_W /* go to column 1 */ 198 #define SCAN_LEFT CTRL_L /* scan left for a char */ 199 #define G_LEFT CTRL_U /* erase char to left */ 200 #define G_TAB_LEFT FS /* erase to prev tab stop */ 201 #define KILL_LEFT CTRL_Y /* erase to column 1 */ 202 #define G_SCAN_LEFT CTRL_N /* scan left and erase */ 203 204 /* Rightward cursor motion */ 205 #define CURSOR_RIGHT CTRL_G /* right one column */ 206 #define TAB_RIGHT CTRL_I /* right one tab stop */ 207 #define SKIP_RIGHT CTRL_O /* go to end of line */ 208 #define SCAN_RIGHT CTRL_J /* scan right for char */ 209 #define G_RIGHT CTRL_R /* erase over cursor */ 210 #define G_TAB_RIGHT RS /* erase to next tab */ 211 #define KILL_RIGHT CTRL_T /* erase to end of line */ 212 #define G_SCAN_RIGHT CTRL_B /* scan right and erase */ 213 214 /* Line termination */ 215 #define T_SKIP_RIGHT CTRL_V /* skip to end and terminate */ 216 #define T_KILL_RIGHT CR /* KILL_RIGHT, SKIP_RIGHT_AND_TERM */ 217 #define FUNNY CTRL_F /* take funny return */ 218 #define CURSOR_UP CTRL_D /* move up one line */ 219 #define CURSOR_DOWN CTRL_K /* move down one line */ 220 #define CURSOR_SAME CTRL_J /* leave cursor on same line */ 221 222 /* Insertion */ 223 #define INSERT_BLANK CTRL_C /* insert one blank */ 224 #define INSERT_TAB CTRL_X /* insert blanks to next tab */ 225 #define INSERT_NEWLINE US /* insert a newline */ 226 227 /* Miscellany */ 228 #define TOGGLE_INSERT_MODE CTRL_A /* toggle insert mode flag */ 229 #define SHIFT_CASE CTRL_Z /* toggle case mapping flag */ 230 #define KILL_ALL DEL /* erase entire line */ 231 #define FIX_SCREEN GS /* clear and restore screen */ 232 233 /* Function for moving around the buffer, either style line handling: */ 234 #define NEXTLINE(k) (((k) < &Buf[Lastln]) ? (k) + 1 : Line0) 235 236 #endif 237