00001 /* ELLE - Copyright 1982, 1984 by Ken Harrenstien, SRI International 00002 * This software is quasi-public; it may be used freely with 00003 * like software, but may NOT be sold or made part of licensed 00004 * products without permission of the author. 00005 */ 00006 /* 00007 * ELLE.H Global ELLE definitions 00008 */ 00009 00010 #ifndef EXT 00011 #define EXT extern /* Default assumes these are referencing decls */ 00012 #endif 00013 00014 /* Make identifiers unique in 1st 6 chars as per ANSI rule for externals */ 00015 #define tvc_cin tvccin 00016 #define tvc_cdn tvccdn 00017 #define tvc_lin tvclin 00018 #define tvc_ldn tvcldn 00019 #define ev_fno1 evfno1 00020 #define ev_fno2 evfno2 00021 #define ev_fnn1 evfnn1 00022 #define ev_fnn2 evfnn2 00023 00024 #define ask_sall asksal /* eebuff.c */ 00025 #define ask_save asksav 00026 #define buf_tmod buftmo 00027 #define buf_tmat buftma 00028 #define e_gobob egobob /* eeedit.c */ 00029 #define e_gobol egobol 00030 #define e_goeob egoeob 00031 #define e_goeol egoeol 00032 #define fill_prefix filpfx /* eefill.c */ 00033 #define fill_plen filpln 00034 #define fill_cur_line filcln 00035 #define kill_ptr kilptr /* eef3.c */ 00036 #define kill_push kilpsh 00037 #define ed_insert edinst /* eefed.c */ 00038 #define ed_insn edinsn 00039 #define ed_deln eddeln 00040 #define ed_delete eddele 00041 #define f_fillreg ffilrg /* eejust.c */ 00042 #define f_fillpara ffilpa 00043 00044 #include "eesite.h" /* Insert site-dependent flags and parameters */ 00045 #include "sb.h" /* Insert SB package definitions */ 00046 #include "eeprof.h" /* Insert user profile definition. This is a 00047 * separate file so ELLEC can use it too. */ 00048 #include "eefidx.h" /* Insert desired function defs */ 00049 00050 /* ELLE Compile-time parameter defaults */ 00051 00052 #ifndef KILL_LEN 00053 #define KILL_LEN 8 /* Size of kill ring */ 00054 #endif 00055 #ifndef MAXHT 00056 #define MAXHT 72 /* Height (# lines) of largest screen we'll suport */ 00057 #endif 00058 #ifndef MAXLINE 00059 #define MAXLINE 132 /* Width (# chars) of largest screen we'll support */ 00060 #endif 00061 #ifndef FNAMELEN 00062 #define FNAMELEN 14 /* Sys-dep: Max size of last filename component */ 00063 #endif /* Check FNAMSIZ if you change this. */ 00064 #ifndef FNAMSIZ 00065 #define FNAMSIZ 100 /* Sys-dep: Max size of complete filename */ 00066 #endif /* This must be at least as large as FNAMELEN! */ 00067 #ifndef ISRCHLIM 00068 #define ISRCHLIM 50 /* Max # of chars to allow I-search on */ 00069 #endif 00070 #ifndef TOBFSIZ 00071 #define TOBFSIZ 80 /* Size of TTY output buffer */ 00072 #endif 00073 #ifndef TIBFSIZ 00074 #define TIBFSIZ 50 /* Size of TTY input buffer */ 00075 #endif 00076 #ifndef ECHOLINES 00077 #define ECHOLINES 1 /* # of lines for echo area (below mode line) */ 00078 #endif 00079 #ifndef MAXARGFILES 00080 #define MAXARGFILES 2 /* # of filename args OK at startup */ 00081 #endif 00082 00083 /* ELLE initialized variables. 00084 * Initial values are defined in EEVINI.C, but the vars must be 00085 * declared here as well so that references from all modules will 00086 * compile correctly. 00087 */ 00088 00089 extern char *ev_verstr; /* String: Editor name and version # */ 00090 extern int ev_filmod; /* Default file creation mode */ 00091 extern char *ev_fno1,*ev_fno2; /* Pre, postfix for "old" filenames */ 00092 extern char *ev_fnn1,*ev_fnn2; /* Pre, postfix for "new" filenames */ 00093 extern int ev_fcolumn; /* Fill Column variable */ 00094 #if FX_INDCOMM 00095 extern int ev_ccolumn; /* Comment Column variable */ 00096 #endif 00097 extern int ev_nwpct, ev_mvpct; /* New window selection percentages */ 00098 #if FX_SOWIND 00099 extern int ev_modwso; /* Initial mode window standout flag */ 00100 #endif 00101 #if FX_2MODEWINDS 00102 extern int ev_2modws; /* Initial setting of 2-mode-window flag */ 00103 #endif 00104 extern char *ev_markshow; /* String to show when Set Mark done */ 00105 extern char *ev_helpfile; /* Location of ELLE help file */ 00106 extern char *ev_profile; /* Filename of ELLE binary user profile */ 00107 extern struct profile def_prof; /* ELLE default user profile */ 00108 00109 /* Global variables */ 00110 00111 EXT chroff cur_dot; /* Current dot */ 00112 EXT chroff mark_dot; /* Dot for mark */ 00113 EXT int mark_p; /* flag indicating whether mark exists */ 00114 EXT int this_cmd, last_cmd; /* Command type */ 00115 EXT int unrchf; /* Stuffed character back for readcommand */ 00116 EXT int exp; /* Numeric argument for commands */ 00117 EXT int exp_p; /* Flag meaning an arg was given */ 00118 EXT int pgoal; /* Permanent goal column */ 00119 EXT int goal; 00120 EXT char *srch_str; /* Last search string specified (0 = none) */ 00121 EXT int srch_len; /* Length of srch_str string */ 00122 EXT int ask_len; /* Length of last string returned by "ask" */ 00123 EXT char *homedir; /* User's home directory */ 00124 EXT int kill_ptr; /* Index into kill ring */ 00125 extern SBSTR *kill_ring[]; /* Kill ring table (allocated in eevini) */ 00126 00127 /* Editor Command types */ 00128 00129 #define KILLCMD 1 /* Kill command, for kill merging */ 00130 #define ARGCMD 2 /* Argument-setter, for main loop */ 00131 #define YANKCMD 3 /* Yank command, for yankpop */ 00132 #define LINECMD 4 /* Next or previous line goal hacking */ 00133 #if IMAGEN 00134 #define INSCMD 5 /* Simple char-insert command, for autowrap */ 00135 #endif /*IMAGEN*/ 00136 00137 /* Misc char definitions */ 00138 #define CTRL(ch) (037&ch) 00139 #define BELL ('\007') /* Will become \a in ANSI */ 00140 #define BS ('\b') 00141 #define TAB ('\t') 00142 #define LF ('\n') 00143 #define FF ('\f') 00144 #define CR ('\r') 00145 #define ESC ('\033') 00146 #define SP (' ') 00147 #define DEL ('\177') 00148 00149 #define CB_META (0200) /* Meta bit in command char */ 00150 #define CB_EXT (0400) /* Extend bit in command char */ 00151 #define METIZER ESC 00152 #define EXTIZER CTRL('X') 00153 00154 /* Terminal parameters - set at runtime startup */ 00155 00156 EXT char *tv_stype; /* Terminal type string specified by user/system */ 00157 EXT int scr_ht; /* # lines of main screen area */ 00158 EXT int scr_wid; /* # columns of screen */ 00159 EXT int scr_wd0; /* scr_wid - 1 (for 0-origin stuff) */ 00160 EXT int trm_ospeed; /* Output speed index */ 00161 EXT int tvc_pos; /* Cost for absolute move (# of output chars) */ 00162 EXT int tvc_bs; /* Cost for backspace */ 00163 EXT int tvc_ci, tvc_cin; /* Char ins cost per call, cost per column */ 00164 EXT int tvc_cd, tvc_cdn; /* Char del " " " " " " */ 00165 EXT int tvc_li, tvc_lin; /* Line ins cost per call, cost per line */ 00166 EXT int tvc_ld, tvc_ldn; /* Line del " " " " " " */ 00167 00168 EXT int trm_flags; /* Terminal capabilities - bit flags */ 00169 /* Maybe change to word vars someday (faster) */ 00170 #define TF_IDLIN 01 /* Has I/D line */ 00171 #define TF_IDCHR 02 /* Has I/D char */ 00172 #define TF_SO 04 /* Has usable standout mode */ 00173 #define TF_CLEOL 010 /* Has clear-to-eol */ 00174 #define TF_METAKEY 020 /* Has meta key */ 00175 #define TF_DIRVID 040 /* Has direct-video type interface */ 00176 00177 00178 /* Redisplay definitions */ 00179 00180 EXT int curs_lin; /* Line # of current cursor (0 origin) */ 00181 EXT int curs_col; /* Column # of current cursor (0 origin) */ 00182 00183 EXT int rd_type; /* Global var: holds redisplay "hints" */ 00184 #define redp(n) rd_type |= (n) 00185 00186 #define RD_SCREEN 01 /* Clear everything and redisplay */ 00187 #define RD_WINDS 02 /* Check all windows for changes (b/emod) */ 00188 #define RD_MODE 04 /* Mode line has changed, update it. */ 00189 #define RD_WINRES 0400 /* Assume all of window was changed (clear b/emod) */ 00190 #define RD_MOVE 010 /* Cursor has moved */ 00191 #define RD_UPDWIN 020 /* Window fixed, must update modified screen lines */ 00192 /*#define RD_ICHR 0 *//* Hint: Char insert done */ 00193 /*#define RD_DCHR 0 *//* Hint: Char del done */ 00194 #define RD_ILIN 0100 /* Hint: Line insert done */ 00195 #define RD_DLIN 0200 /* Hint: Line del done */ 00196 00197 /* #define RD_MOVWIN 02000 *//* Window should be re-positioned */ 00198 #define RD_FIXWIN 02000 /* Window needs fixing (call fix_wind) */ 00199 #define RD_TMOD 04000 /* Text changed in this window, check it. */ 00200 #define RD_WINCLR 010000 /* Clear window with CLEOLs (not yet) */ 00201 #define RD_CHKALL 020000 /* Check all windows for redisplay flags */ 00202 #if IMAGEN 00203 #define RD_REDO 040000 /* Just re-do the entire window, don't think */ 00204 #endif /*IMAGEN*/ 00205 00206 /* Flags with global effects, only seen in rd_type */ 00207 #define RDS_GLOBALS (RD_SCREEN|RD_MODE|RD_WINDS|RD_CHKALL) 00208 /* Flags which are allowed per-window (in w_redp) */ 00209 #define RDS_WINFLGS (~RDS_GLOBALS) 00210 /* Flags which force FIX_WIND() to do something */ 00211 #define RDS_DOFIX (RD_WINRES|RD_TMOD|RD_FIXWIN|RD_MOVE) 00212 00213 #define CI_CLINE '!' /* Char indicator for continued line */ 00214 #define CI_CNTRL '^' /* Char indicator for control chars */ 00215 #define CI_META '~' /* Char indicator for meta-bit (8th) set */ 00216 #define CI_TOP '|' /* Char indicator for top-bit (9th) set */ 00217 #define MAXCHAR (8+3) /* Longest char representation (TAB) + slop */ 00218 00219 /* Definitions for screen structures */ 00220 00221 struct scr_line { 00222 chroff sl_boff; /* Ptr to start of line's text in buffer */ 00223 int sl_len; /* # buffer chars in line (incl NL) */ 00224 char *sl_line; /* Ptr to screen image of line */ 00225 int sl_col; /* # chars in image == # columns used */ 00226 char sl_flg; /* Flags - set if this line modified */ 00227 char sl_cont; /* If line being continued on next, this */ 00228 /* contains 1 plus # extra chars (if any) */ 00229 /* stored at end of this line which shd be */ 00230 /* put at beg of next line. */ 00231 char *sl_nlin; /* New screen image line if modified flag set */ 00232 int sl_ncol; 00233 }; 00234 /* sl_flg definitions */ 00235 #define SL_MOD 01 /* New line exists, must update to it */ 00236 #define SL_EOL 02 /* Buffer line ends with EOL */ 00237 #define SL_CSO 04 /* Current screen line is in standout mode */ 00238 #define SL_NSO 010 /* New screen line is in standout mode */ 00239 #if IMAGEN 00240 #define SL_REDO 0100 /* Line should be redone completely */ 00241 #endif /*IMAGEN*/ 00242 00243 extern struct scr_line *scr[]; /* Screen line ptrs (allocated in e_vinit) */ 00244 00245 00246 /* Buffer stuff */ 00247 00248 struct buffer 00249 { SBBUF b_sb; /* MUST be 1st thing! */ 00250 struct buffer *b_next; /* ptr to next in chain */ 00251 char *b_name; /* text name */ 00252 char *b_fn; /* filename */ 00253 chroff b_dot; /* point (dot) */ 00254 int b_flags; /* misc. bits */ 00255 struct majmode *b_mode; /* Mode of buffer */ 00256 #if IMAGEN 00257 long b_mtime; /* Last file modification time */ 00258 #endif /*IMAGEN*/ 00259 }; 00260 /* b_flags definitions */ 00261 #define B_MODIFIED 01 /* Buffer is modified */ 00262 #define B_EOLCRLF 0200 /* On = CRLF mode, off = LF mode */ 00263 #if IMAGEN 00264 #define B_PERMANENT 002 /* buffer cannot be killed */ 00265 #define B_CMODE 004 /* "C" mode (HACK HACK) */ 00266 #define B_BACKEDUP 010 /* Buffer has been backed up once */ 00267 #define B_TEXTMODE 020 /* Text mode (auto-wrap, basically) */ 00268 #define B_QUERYREP 040 /* Query-replace mode (qualifier) */ 00269 #endif /*IMAGEN*/ 00270 00271 /* Handy macro to check EOL mode */ 00272 #define eolcrlf(buf) (((struct buffer *)buf)->b_flags&B_EOLCRLF) 00273 00274 /* Buffer pointers */ 00275 00276 EXT struct buffer 00277 *buf_head, /* head of list of all buffers */ 00278 *cur_buf, /* buffer we are editing now */ 00279 *last_buf, /* buffer we were editing before */ 00280 *lines_buf; /* buffer for sep_win */ 00281 00282 /* Window stuff */ 00283 00284 struct window 00285 { struct window *w_next; /* ptr to next in chain */ 00286 int w_flags; /* Window flags */ 00287 int w_pos; /* index of top line */ 00288 int w_ht; /* number of lines */ 00289 struct buffer *w_buf; /* buffer in this window */ 00290 int w_pct; /* % of buffer window is at */ 00291 int w_redp; /* Redisplay hints */ 00292 chroff w_topldot; /* line currently at top of window */ 00293 chroff w_dot; /* Saved dot while not cur_win */ 00294 chroff w_bmod; /* Lower bound of modified text */ 00295 chroff w_emod; /* Upper bound of modified text */ 00296 /* (offset from end of buffer!) */ 00297 chroff w_oldz; /* Buffer len as of last update */ 00298 }; 00299 00300 /* Window flags */ 00301 #define W_STANDOUT 01 /* Use terminal's standout mode for window */ 00302 #define W_MODE 02 /* This is a mode window */ 00303 00304 /* Window pointers */ 00305 00306 EXT struct window 00307 *win_head, /* head of list of all windows */ 00308 *cur_win, /* window we are now in */ 00309 *user_win, /* current user window */ 00310 *oth_win, /* "other" user window */ 00311 *mode_win, /* window for mode line */ 00312 *ask_win, /* window for ask (echo) area */ 00313 *sep_win; /* window for separation dashes */ 00314 00315 /* Major Mode stuff. Each buffer has its own major mode. 00316 * Only one major mode may be in effect at any time. 00317 */ 00318 struct majmode { 00319 char *mjm_name; /* Simple for now */ 00320 }; 00321 EXT struct majmode *fun_mode; /* Fundamental mode - the default */ 00322 EXT struct majmode *cur_mode; /* Current major mode */ 00323 00324 /* Minor modes are currently implemented by means of flag variables 00325 * which have global effects (regardless of buffer or major mode). 00326 * Each variable has the name "x_mode" where x is the name of the minor 00327 * mode. These are declared in the modules containing their support code. 00328 * In the future this may be generalized along the lines of major modes. 00329 */ 00330 00331 00332 /* Miscellaneous debug stuff */ 00333 00334 EXT int dbgval; /* Set nonzero to do verify stuff */ 00335 EXT int dbg_isw; /* Set to enable interrupts if possible */ 00336 #if IMAGEN 00337 EXT int dbg_redp; /* Set to debug redisplay algorithms */ 00338 #endif /*IMAGEN*/ 00339 extern int errno; 00340 00341 /* V7 routines for setexit/reset emulation */ 00342 00343 #if !(V6) 00344 #include <setjmp.h> 00345 EXT jmp_buf env_main; 00346 #define setexit(a) setjmp(env_main) 00347 #define reset(a) longjmp(env_main,a) 00348 #endif /*-V6*/ 00349 00350 /* Declare functions returning CHROFF values (offsets into a buffer) */ 00351 00352 extern chroff e_dot(),e_nldot(),e_pldot(),e_boldot(),e_eoldot(), 00353 e_alldot(),ex_boldot(),ex_alldot(), 00354 ex_blen(),e_blen(),ex_dot(),e_wdot(); 00355 00356 extern SBSTR *e_copyn(); 00357 00358 /* Some other commonly needed declarations */ 00359 00360 extern char *memalloc(), *ask(), *dottoa(), *strdup(); 00361 #if !(V6) 00362 extern char *getenv(); 00363 #endif /*-V6*/ 00364 #include "eeproto.h" /* function prototypes */
1.4.6