|
|
1.1 ! root 1: /* vi.h */ ! 2: ! 3: /* Author: ! 4: * Steve Kirkendall ! 5: * 14407 SW Teal Blvd. #C ! 6: * Beaverton, OR 97005 ! 7: * [email protected] ! 8: */ ! 9: ! 10: #define VERSION "ELVIS 1.6, by Steve Kirkendall (27 April 1992)" ! 11: #define COPYING "This version of ELVIS is freely redistributable." ! 12: ! 13: #include <errno.h> ! 14: extern int errno; ! 15: #if TOS ! 16: # ifndef __GNUC__ ! 17: # define ENOENT (-AEFILNF) ! 18: # endif ! 19: #endif ! 20: ! 21: #if TOS || VMS ! 22: # include <types.h> ! 23: # define O_RDONLY 0 ! 24: # define O_WRONLY 1 ! 25: # define O_RDWR 2 ! 26: # ifdef __GNUC__ ! 27: # define S_IJDIR S_IFDIR ! 28: # endif ! 29: #else ! 30: # if OSK ! 31: # include <modes.h> ! 32: # define O_RDONLY S_IREAD ! 33: # define O_WRONLY S_IWRITE ! 34: # define O_RDWR (S_IREAD | S_IWRITE) ! 35: # define ENOENT E_PNNF ! 36: # define sprintf Sprintf ! 37: # else ! 38: # if !AMIGA ! 39: # include <sys/types.h> ! 40: # endif ! 41: # include <fcntl.h> ! 42: # endif ! 43: #endif ! 44: ! 45: #ifndef O_BINARY ! 46: # define O_BINARY 0 ! 47: #endif ! 48: ! 49: #include "curses.h" ! 50: ! 51: #include <signal.h> ! 52: #ifdef __STDC__ ! 53: # include <stdio.h> /* for [v]sprintf prototype */ ! 54: # include <string.h> /* for str* prototypes */ ! 55: # include <stdlib.h> /* for atoi, system, malloc, free */ ! 56: # include <stdarg.h> /* for vararg definitions */ ! 57: # if ANY_UNIX ! 58: # include <unistd.h> /* for read, write, ... prototypes */ ! 59: # include <sys/wait.h> /* for wait prototype */ ! 60: # endif ! 61: #endif ! 62: ! 63: /*------------------------------------------------------------------------*/ ! 64: /* Miscellaneous constants. */ ! 65: ! 66: #define INFINITY 2000000001L /* a very large integer */ ! 67: #define LONGKEY 10 /* longest possible raw :map key */ ! 68: #ifndef MAXRCLEN ! 69: # define MAXRCLEN 1000 /* longest possible :@ command */ ! 70: #endif ! 71: ! 72: /*------------------------------------------------------------------------*/ ! 73: /* These describe how temporary files are divided into blocks */ ! 74: ! 75: #define MAXBLKS (BLKSIZE / sizeof(unsigned short)) ! 76: typedef union ! 77: { ! 78: char c[BLKSIZE]; /* for text blocks */ ! 79: unsigned short n[MAXBLKS]; /* for the header block */ ! 80: } ! 81: BLK; ! 82: ! 83: /*------------------------------------------------------------------------*/ ! 84: /* These are used manipulate BLK buffers. */ ! 85: ! 86: extern BLK hdr; /* buffer for the header block */ ! 87: extern BLK *blkget P_((int)); /* given index into hdr.c[], reads block */ ! 88: extern BLK *blkadd P_((int)); /* inserts a new block into hdr.c[] */ ! 89: ! 90: /*------------------------------------------------------------------------*/ ! 91: /* These are used to keep track of various flags */ ! 92: extern struct _viflags ! 93: { ! 94: short file; /* file flags */ ! 95: } ! 96: viflags; ! 97: ! 98: /* file flags */ ! 99: #define NEWFILE 0x0001 /* the file was just created */ ! 100: #define READONLY 0x0002 /* the file is read-only */ ! 101: #define HADNUL 0x0004 /* the file contained NUL characters */ ! 102: #define MODIFIED 0x0008 /* the file has been modified, but not saved */ ! 103: #define NOFILE 0x0010 /* no name is known for the current text */ ! 104: #define ADDEDNL 0x0020 /* newlines were added to the file */ ! 105: #define HADBS 0x0040 /* backspace chars were lost from the file */ ! 106: #define UNDOABLE 0x0080 /* file has been modified */ ! 107: #define NOTEDITED 0x0100 /* the :file command has been used */ ! 108: ! 109: /* macros used to set/clear/test flags */ ! 110: #define setflag(x,y) viflags.x |= y ! 111: #define clrflag(x,y) viflags.x &= ~y ! 112: #define tstflag(x,y) (viflags.x & y) ! 113: #define initflags() viflags.file = 0; ! 114: ! 115: /* The options */ ! 116: extern char o_autoindent[1]; ! 117: extern char o_autoprint[1]; ! 118: extern char o_autotab[1]; ! 119: extern char o_autowrite[1]; ! 120: extern char o_columns[3]; ! 121: extern char o_directory[30]; ! 122: extern char o_edcompatible[1]; ! 123: extern char o_equalprg[80]; ! 124: extern char o_errorbells[1]; ! 125: extern char o_exrefresh[1]; ! 126: extern char o_ignorecase[1]; ! 127: extern char o_keytime[3]; ! 128: extern char o_keywordprg[80]; ! 129: extern char o_lines[3]; ! 130: extern char o_list[1]; ! 131: extern char o_number[1]; ! 132: extern char o_readonly[1]; ! 133: extern char o_remap[1]; ! 134: extern char o_report[3]; ! 135: extern char o_scroll[3]; ! 136: extern char o_shell[60]; ! 137: extern char o_shiftwidth[3]; ! 138: extern char o_sidescroll[3]; ! 139: extern char o_sync[1]; ! 140: extern char o_tabstop[3]; ! 141: extern char o_term[30]; ! 142: extern char o_flash[1]; ! 143: extern char o_warn[1]; ! 144: extern char o_wrapscan[1]; ! 145: ! 146: #ifndef CRUNCH ! 147: extern char o_beautify[1]; ! 148: extern char o_exrc[1]; ! 149: extern char o_mesg[1]; ! 150: extern char o_more[1]; ! 151: extern char o_nearscroll[3]; ! 152: extern char o_novice[1]; ! 153: extern char o_prompt[1]; ! 154: extern char o_taglength[3]; ! 155: extern char o_terse[1]; ! 156: extern char o_window[3]; ! 157: extern char o_wrapmargin[3]; ! 158: extern char o_writeany[1]; ! 159: #endif ! 160: ! 161: #ifndef NO_ERRLIST ! 162: extern char o_cc[30]; ! 163: extern char o_make[30]; ! 164: #endif ! 165: ! 166: #ifndef NO_CHARATTR ! 167: extern char o_charattr[1]; ! 168: #endif ! 169: ! 170: #ifndef NO_DIGRAPH ! 171: extern char o_digraph[1]; ! 172: extern char o_flipcase[80]; ! 173: #endif ! 174: ! 175: #ifndef NO_SENTENCE ! 176: extern char o_hideformat[1]; ! 177: #endif ! 178: ! 179: #ifndef NO_EXTENSIONS ! 180: extern char o_inputmode[1]; ! 181: extern char o_ruler[1]; ! 182: #endif ! 183: ! 184: #ifndef NO_MAGIC ! 185: extern char o_magic[1]; ! 186: #endif ! 187: ! 188: #ifndef NO_MODELINES ! 189: extern char o_modelines[1]; ! 190: #endif ! 191: ! 192: #ifndef NO_SENTENCE ! 193: extern char o_paragraphs[30]; ! 194: extern char o_sections[30]; ! 195: #endif ! 196: ! 197: #if MSDOS ! 198: extern char o_pcbios[1]; ! 199: #endif ! 200: ! 201: #ifndef NO_SHOWMATCH ! 202: extern char o_showmatch[1]; ! 203: #endif ! 204: ! 205: #ifndef NO_SHOWMODE ! 206: extern char o_smd[1]; ! 207: #endif ! 208: ! 209: /*------------------------------------------------------------------------*/ ! 210: /* These help support the single-line multi-change "undo" -- shift-U */ ! 211: ! 212: extern char U_text[BLKSIZE]; ! 213: extern long U_line; ! 214: ! 215: /*------------------------------------------------------------------------*/ ! 216: /* These are used to refer to places in the text */ ! 217: ! 218: typedef long MARK; ! 219: #define markline(x) (long)((x) / BLKSIZE) ! 220: #define markidx(x) (int)((x) & (BLKSIZE - 1)) ! 221: #define MARK_UNSET ((MARK)0) ! 222: #define MARK_FIRST ((MARK)BLKSIZE) ! 223: #define MARK_LAST ((MARK)(nlines * BLKSIZE)) ! 224: #define MARK_EOF ((MARK)((nlines + 1) * BLKSIZE)) ! 225: #define MARK_AT_LINE(x) ((MARK)(x) * BLKSIZE) ! 226: ! 227: #define NMARKS 29 ! 228: extern MARK mark[NMARKS]; /* marks a-z, plus mark ' and two temps */ ! 229: extern MARK cursor; /* mark where line is */ ! 230: ! 231: /*------------------------------------------------------------------------*/ ! 232: /* These are used to keep track of the current & previous files. */ ! 233: ! 234: extern long origtime; /* modification date&time of the current file */ ! 235: extern char origname[256]; /* name of the current file */ ! 236: extern char prevorig[256]; /* name of the preceding file */ ! 237: extern long prevline; /* line number from preceding file */ ! 238: ! 239: /*------------------------------------------------------------------------*/ ! 240: /* misc housekeeping variables & functions */ ! 241: ! 242: extern int tmpfd; /* fd used to access the tmp file */ ! 243: extern int tmpnum; /* counter used to generate unique filenames */ ! 244: extern long lnum[MAXBLKS]; /* last line# of each block */ ! 245: extern long nlines; /* number of lines in the file */ ! 246: extern char args[BLKSIZE]; /* file names given on the command line */ ! 247: extern int argno; /* the current element of args[] */ ! 248: extern int nargs; /* number of filenames in args */ ! 249: extern long changes; /* counts changes, to prohibit short-cuts */ ! 250: extern int significant; /* boolean: was a *REAL* change made? */ ! 251: extern int exitcode; /* 0=not updated, 1=overwritten, else error */ ! 252: extern BLK tmpblk; /* a block used to accumulate changes */ ! 253: extern long topline; /* file line number of top line */ ! 254: extern int leftcol; /* column number of left col */ ! 255: #define botline (topline + LINES - 2) ! 256: #define rightcol (leftcol + COLS - (*o_number ? 9 : 1)) ! 257: extern int physcol; /* physical column number that cursor is on */ ! 258: extern int physrow; /* physical row number that cursor is on */ ! 259: extern int exwrote; /* used to detect verbose ex commands */ ! 260: extern int doingdot; /* boolean: are we doing the "." command? */ ! 261: extern int doingglobal; /* boolean: are doing a ":g" command? */ ! 262: extern long rptlines; /* number of lines affected by a command */ ! 263: extern char *rptlabel; /* description of how lines were affected */ ! 264: extern char *fetchline P_((long)); /* read a given line from tmp file */ ! 265: extern char *parseptrn P_((REG char *)); /* isolate a regexp in a line */ ! 266: extern MARK paste P_((MARK, int, int)); /* paste from cut buffer to a given point */ ! 267: extern char *wildcard P_((char *)); /* expand wildcards in filenames */ ! 268: extern MARK input P_((MARK, MARK, int, int)); /* inserts characters from keyboard */ ! 269: extern char *linespec P_((REG char *, MARK *)); /* finds the end of a /regexp/ string */ ! 270: #define ctrl(ch) ((ch)&037) ! 271: #ifndef NO_RECYCLE ! 272: extern long allocate P_((void)); /* allocate a free block of the tmp file */ ! 273: #endif ! 274: extern int trapint P_((int)); /* trap handler for SIGINT */ ! 275: extern int deathtrap P_((int)); /* trap handler for deadly signals */ ! 276: extern void blkdirty P_((BLK *)); /* marks a block as being "dirty" */ ! 277: extern void blksync P_((void)); /* forces all "dirty" blocks to disk */ ! 278: extern void blkinit P_((void)); /* resets the block cache to "empty" state */ ! 279: extern void beep P_((void)); /* rings the terminal's bell */ ! 280: extern void exrefresh P_((void)); /* writes text to the screen */ ! 281: #ifdef __STDC__ ! 282: extern void msg (char *, ...); /* writes a printf-style message to the screen */ ! 283: #else ! 284: extern void msg (); /* writes a printf-style message to the screen */ ! 285: #endif ! 286: extern void endmsgs P_((void)); /* if "manymsgs" is set, then scroll up 1 line */ ! 287: extern void garbage P_((void)); /* reclaims any garbage blocks */ ! 288: extern void redraw P_((MARK, int)); /* updates the screen after a change */ ! 289: extern void resume_curses P_((int)); /* puts the terminal in "cbreak" mode */ ! 290: extern void beforedo P_((int)); /* saves current revision before a new change */ ! 291: extern void afterdo P_((void)); /* marks end of a beforedo() change */ ! 292: extern void abortdo P_((void)); /* like "afterdo()" followed by "undo()" */ ! 293: extern int undo P_((void)); /* restores file to previous undo() */ ! 294: extern void dumpkey P_((int, int)); /* lists key mappings to the screen */ ! 295: extern void mapkey P_((char *, char *, int, char *)); /* defines a new key mapping */ ! 296: extern void redrawrange P_((long, long, long)); /* records clues from modify.c */ ! 297: extern void cut P_((MARK, MARK)); /* saves text in a cut buffer */ ! 298: extern void delete P_((MARK, MARK)); /* deletes text */ ! 299: extern void add P_((MARK, char *)); /* adds text */ ! 300: extern void change P_((MARK, MARK, char *));/* deletes text, and then adds other text */ ! 301: extern void cutswitch P_((void)); /* updates cut buffers when we switch files */ ! 302: extern void do_digraph P_((int, char [])); /* defines or lists digraphs */ ! 303: extern void exstring P_((char *, int, int));/* execute a string as EX commands */ ! 304: extern void dumpopts P_((int)); /* display current option settings on the screen */ ! 305: extern void setopts P_((char *)); /* assign new values to options */ ! 306: extern void saveopts P_((int)); /* save current option values to a given fd */ ! 307: extern void savedigs P_((int)); /* save current non-standard digraphs to fd */ ! 308: extern void savecolor P_((int)); /* save current color settings (if any) to fd */ ! 309: extern void cutname P_((int)); /* select cut buffer for next cut/paste */ ! 310: extern void initopts P_((void)); /* initialize options */ ! 311: extern void cutend P_((void)); /* free all cut buffers & delete temp files */ ! 312: extern int storename P_((char *)); /* stamp temp file with pathname of text file */ ! 313: extern int tmpstart P_((char *)); /* load a text file into edit buffer */ ! 314: extern int tmpsave P_((char *, int)); /* write edit buffer out to text file */ ! 315: extern int tmpend P_((int)); /* call tmpsave(), and then tmpabort */ ! 316: extern int tmpabort P_((int)); /* abandon the current edit buffer */ ! 317: extern void savemaps P_((int, int)); /* write current :map or :ab commands to fd */ ! 318: extern int ansicolor P_((int, int)); /* emit ANSI color command to terminal */ ! 319: extern int filter P_((MARK, MARK, char *, int)); /* I/O though another program */ ! 320: extern int getkey P_((int)); /* return a keystroke, interpretting maps */ ! 321: extern int vgets P_((int, char *, int)); /* read a single line from keyboard */ ! 322: extern int doexrc P_((char *)); /* execute a string as a sequence of EX commands */ ! 323: extern int cb2str P_((int, char *, unsigned));/* return a string containing cut buffer's contents */ ! 324: extern int ansiquit P_((void)); /* neutralize previous ansicolor() call */ ! 325: extern int ttyread P_((char *, int, int)); /* read from keyboard with optional timeout */ ! 326: extern int tgetent P_((char *, char *)); /* start termcap */ ! 327: extern int tgetnum P_((char *)); /* get a termcap number */ ! 328: extern int tgetflag P_((char *)); /* get a termcap boolean */ ! 329: extern int getsize P_((int)); /* determine how big the screen is */ ! 330: extern int endcolor P_((void)); /* used during color output */ ! 331: extern int getabkey P_((int, char *, int));/* like getkey(), but also does abbreviations */ ! 332: extern int idx2col P_((MARK, REG char *, int)); /* returns column# of a given MARK */ ! 333: extern int cutneeds P_((BLK *)); /* returns bitmap of blocks needed to hold cutbuffer text */ ! 334: extern void execmap P_((int, char *, int)); /* replaces "raw" keys with "mapped" keys */ ! 335: #ifndef CRUNCH ! 336: extern int wset; /* boolean: has the "window" size been set? */ ! 337: #endif ! 338: ! 339: /*------------------------------------------------------------------------*/ ! 340: /* macros that are used as control structures */ ! 341: ! 342: #define BeforeAfter(before, after) for((before),bavar=1;bavar;(after),bavar=0) ! 343: #define ChangeText BeforeAfter(beforedo(FALSE),afterdo()) ! 344: ! 345: extern int bavar; /* used only in BeforeAfter macros */ ! 346: ! 347: /*------------------------------------------------------------------------*/ ! 348: /* These are the movement commands. Each accepts a mark for the starting */ ! 349: /* location & number and returns a mark for the destination. */ ! 350: ! 351: extern MARK m_updnto P_((MARK, long, int)); /* k j G */ ! 352: extern MARK m_right P_((MARK, long, int, int)); /* h */ ! 353: extern MARK m_left P_((MARK, long)); /* l */ ! 354: extern MARK m_tocol P_((MARK, long, int)); /* | */ ! 355: extern MARK m_front P_((MARK, long)); /* ^ */ ! 356: extern MARK m_rear P_((MARK, long)); /* $ */ ! 357: extern MARK m_fword P_((MARK, long, int, int)); /* w */ ! 358: extern MARK m_bword P_((MARK, long, int)); /* b */ ! 359: extern MARK m_eword P_((MARK, long, int)); /* e */ ! 360: extern MARK m_paragraph P_((MARK, long, int)); /* { } [[ ]] */ ! 361: extern MARK m_match P_((MARK, long)); /* % */ ! 362: #ifndef NO_SENTENCE ! 363: extern MARK m_sentence P_((MARK, long, int)); /* ( ) */ ! 364: #endif ! 365: extern MARK m_tomark P_((MARK, long, int)); /* 'm */ ! 366: #ifndef NO_EXTENSIONS ! 367: extern MARK m_wsrch P_((char *, MARK, int)); /* ^A */ ! 368: #endif ! 369: extern MARK m_nsrch P_((MARK)); /* n */ ! 370: extern MARK m_Nsrch P_((MARK)); /* N */ ! 371: extern MARK m_fsrch P_((MARK, char *)); /* /regexp */ ! 372: extern MARK m_bsrch P_((MARK, char *)); /* ?regexp */ ! 373: #ifndef NO_CHARSEARCH ! 374: extern MARK m__ch P_((MARK, long, int)); /* ; , */ ! 375: extern MARK m_fch P_((MARK, long, int)); /* f */ ! 376: extern MARK m_tch P_((MARK, long, int)); /* t */ ! 377: extern MARK m_Fch P_((MARK, long, int)); /* F */ ! 378: extern MARK m_Tch P_((MARK, long, int)); /* T */ ! 379: #endif ! 380: extern MARK m_row P_((MARK, long, int)); /* H L M */ ! 381: extern MARK m_z P_((MARK, long, int)); /* z */ ! 382: extern MARK m_scroll P_((MARK, long, int)); /* ^B ^F ^E ^Y ^U ^D */ ! 383: ! 384: /* Some stuff that is used by movement functions... */ ! 385: ! 386: extern MARK adjmove P_((MARK, REG MARK, int)); /* a helper fn, used by move fns */ ! 387: ! 388: /* This macro is used to set the default value of cnt */ ! 389: #define DEFAULT(val) if (cnt < 1) cnt = (val) ! 390: ! 391: /* These are used to minimize calls to fetchline() */ ! 392: extern int plen; /* length of the line */ ! 393: extern long pline; /* line number that len refers to */ ! 394: extern long pchgs; /* "changes" level that len refers to */ ! 395: extern char *ptext; /* text of previous line, if valid */ ! 396: extern void pfetch P_((long)); ! 397: extern char digraph P_((int, int)); ! 398: ! 399: /* This is used to build a MARK that corresponds to a specific point in the ! 400: * line that was most recently pfetch'ed. ! 401: */ ! 402: #define buildmark(text) (MARK)(BLKSIZE * pline + (int)((text) - ptext)) ! 403: ! 404: ! 405: /*------------------------------------------------------------------------*/ ! 406: /* These are used to handle EX commands. */ ! 407: ! 408: #define CMD_NULL 0 /* NOT A VALID COMMAND */ ! 409: #define CMD_ABBR 1 /* "define an abbreviation" */ ! 410: #define CMD_ARGS 2 /* "show me the args" */ ! 411: #define CMD_APPEND 3 /* "insert lines after this line" */ ! 412: #define CMD_AT 4 /* "execute a cut buffer's contents via EX" */ ! 413: #define CMD_BANG 5 /* "run a single shell command" */ ! 414: #define CMD_CC 6 /* "run `cc` and then do CMD_ERRLIST" */ ! 415: #define CMD_CD 7 /* "change directories" */ ! 416: #define CMD_CHANGE 8 /* "change some lines" */ ! 417: #define CMD_COLOR 9 /* "change the default colors" */ ! 418: #define CMD_COPY 10 /* "copy the selected text to a given place" */ ! 419: #define CMD_DELETE 11 /* "delete the selected text" */ ! 420: #define CMD_DIGRAPH 12 /* "add a digraph, or display them all" */ ! 421: #define CMD_EDIT 13 /* "switch to a different file" */ ! 422: #define CMD_EQUAL 14 /* "display a line number" */ ! 423: #define CMD_ERRLIST 15 /* "locate the next error in a list" */ ! 424: #define CMD_FILE 16 /* "show the file's status" */ ! 425: #define CMD_GLOBAL 17 /* "globally search & do a command" */ ! 426: #define CMD_INSERT 18 /* "insert lines before the current line" */ ! 427: #define CMD_JOIN 19 /* "join the selected line & the one after" */ ! 428: #define CMD_LIST 20 /* "print lines, making control chars visible" */ ! 429: #define CMD_MAKE 21 /* "run `make` and then do CMD_ERRLIST" */ ! 430: #define CMD_MAP 22 /* "adjust the keyboard map" */ ! 431: #define CMD_MARK 23 /* "mark this line" */ ! 432: #define CMD_MKEXRC 24 /* "make a .exrc file" */ ! 433: #define CMD_MOVE 25 /* "move the selected text to a given place" */ ! 434: #define CMD_NEXT 26 /* "switch to next file in args" */ ! 435: #define CMD_NUMBER 27 /* "print lines from the file w/ line numbers" */ ! 436: #define CMD_PRESERVE 28 /* "act as though vi crashed" */ ! 437: #define CMD_PREVIOUS 29 /* "switch to the previous file in args" */ ! 438: #define CMD_PRINT 30 /* "print the selected text" */ ! 439: #define CMD_PUT 31 /* "insert any cut lines before this line" */ ! 440: #define CMD_QUIT 32 /* "quit without writing the file" */ ! 441: #define CMD_READ 33 /* "append the given file after this line */ ! 442: #define CMD_RECOVER 34 /* "recover file after vi crashes" - USE -r FLAG */ ! 443: #define CMD_REWIND 35 /* "rewind to first file" */ ! 444: #define CMD_SET 36 /* "set a variable's value" */ ! 445: #define CMD_SHELL 37 /* "run some lines through a command" */ ! 446: #define CMD_SHIFTL 38 /* "shift lines left" */ ! 447: #define CMD_SHIFTR 39 /* "shift lines right" */ ! 448: #define CMD_SOURCE 40 /* "interpret a file's contents as ex commands" */ ! 449: #define CMD_STOP 41 /* same as CMD_SUSPEND */ ! 450: #define CMD_SUBAGAIN 42 /* "repeat the previous substitution" */ ! 451: #define CMD_SUBSTITUTE 43 /* "substitute text in this line" */ ! 452: #define CMD_SUSPEND 44 /* "suspend the vi session" */ ! 453: #define CMD_TR 45 /* "transliterate chars in the selected lines" */ ! 454: #define CMD_TAG 46 /* "go to a particular tag" */ ! 455: #define CMD_UNABBR 47 /* "remove an abbreviation definition" */ ! 456: #define CMD_UNDO 48 /* "undo the previous command" */ ! 457: #define CMD_UNMAP 49 /* "remove a key sequence map */ ! 458: #define CMD_VERSION 50 /* "describe which version this is" */ ! 459: #define CMD_VGLOBAL 51 /* "apply a cmd to lines NOT containing an RE" */ ! 460: #define CMD_VISUAL 52 /* "go into visual mode" */ ! 461: #define CMD_WQUIT 53 /* "write this file out (any case) & quit" */ ! 462: #define CMD_WRITE 54 /* "write the selected(?) text to a given file" */ ! 463: #define CMD_XIT 55 /* "write this file out (if modified) & quit" */ ! 464: #define CMD_YANK 56 /* "copy the selected text into the cut buffer" */ ! 465: #ifdef DEBUG ! 466: # define CMD_DEBUG 57 /* access to internal data structures */ ! 467: # define CMD_VALIDATE 58 /* check for internal consistency */ ! 468: #endif ! 469: typedef int CMD; ! 470: ! 471: extern void ex P_((void)); ! 472: extern void vi P_((void)); ! 473: extern void doexcmd P_((char *)); ! 474: ! 475: extern void cmd_append P_((MARK, MARK, CMD, int, char *)); ! 476: extern void cmd_args P_((MARK, MARK, CMD, int, char *)); ! 477: #ifndef NO_AT ! 478: extern void cmd_at P_((MARK, MARK, CMD, int, char *)); ! 479: #endif ! 480: extern void cmd_cd P_((MARK, MARK, CMD, int, char *)); ! 481: #ifndef NO_COLOR ! 482: extern void cmd_color P_((MARK, MARK, CMD, int, char *)); ! 483: #endif ! 484: extern void cmd_delete P_((MARK, MARK, CMD, int, char *)); ! 485: #ifndef NO_DIGRAPH ! 486: extern void cmd_digraph P_((MARK, MARK, CMD, int, char *)); ! 487: #endif ! 488: extern void cmd_edit P_((MARK, MARK, CMD, int, char *)); ! 489: #ifndef NO_ERRLIST ! 490: extern void cmd_errlist P_((MARK, MARK, CMD, int, char *)); ! 491: #endif ! 492: extern void cmd_file P_((MARK, MARK, CMD, int, char *)); ! 493: extern void cmd_global P_((MARK, MARK, CMD, int, char *)); ! 494: extern void cmd_join P_((MARK, MARK, CMD, int, char *)); ! 495: extern void cmd_mark P_((MARK, MARK, CMD, int, char *)); ! 496: #ifndef NO_ERRLIST ! 497: extern void cmd_make P_((MARK, MARK, CMD, int, char *)); ! 498: #endif ! 499: extern void cmd_map P_((MARK, MARK, CMD, int, char *)); ! 500: #ifndef NO_MKEXRC ! 501: extern void cmd_mkexrc P_((MARK, MARK, CMD, int, char *)); ! 502: #endif ! 503: extern void cmd_next P_((MARK, MARK, CMD, int, char *)); ! 504: extern void cmd_print P_((MARK, MARK, CMD, int, char *)); ! 505: extern void cmd_put P_((MARK, MARK, CMD, int, char *)); ! 506: extern void cmd_read P_((MARK, MARK, CMD, int, char *)); ! 507: extern void cmd_set P_((MARK, MARK, CMD, int, char *)); ! 508: extern void cmd_shell P_((MARK, MARK, CMD, int, char *)); ! 509: extern void cmd_shift P_((MARK, MARK, CMD, int, char *)); ! 510: extern void cmd_source P_((MARK, MARK, CMD, int, char *)); ! 511: extern void cmd_substitute P_((MARK, MARK, CMD, int, char *)); ! 512: extern void cmd_tag P_((MARK, MARK, CMD, int, char *)); ! 513: extern void cmd_undo P_((MARK, MARK, CMD, int, char *)); ! 514: extern void cmd_version P_((MARK, MARK, CMD, int, char *)); ! 515: extern void cmd_write P_((MARK, MARK, CMD, int, char *)); ! 516: extern void cmd_xit P_((MARK, MARK, CMD, int, char *)); ! 517: extern void cmd_move P_((MARK, MARK, CMD, int, char *)); ! 518: #ifdef DEBUG ! 519: extern void cmd_debug P_((MARK, MARK, CMD, int, char *)); ! 520: extern void cmd_validate P_((MARK, MARK, CMD, int, char *)); ! 521: #endif ! 522: #ifdef SIGTSTP ! 523: extern void cmd_suspend P_((MARK, MARK, CMD, int, char *)); ! 524: #endif ! 525: ! 526: /*----------------------------------------------------------------------*/ ! 527: /* These are used to handle VI commands */ ! 528: ! 529: extern MARK v_1ex P_((MARK, char *)); /* : */ ! 530: extern MARK v_mark P_((MARK, long, int)); /* m */ ! 531: extern MARK v_quit P_((void)); /* Q */ ! 532: extern MARK v_redraw P_((void)); /* ^L ^R */ ! 533: extern MARK v_ulcase P_((MARK, long)); /* ~ */ ! 534: extern MARK v_undo P_((MARK)); /* u */ ! 535: extern MARK v_xchar P_((MARK, long, int)); /* x X */ ! 536: extern MARK v_replace P_((MARK, long, int));/* r */ ! 537: extern MARK v_overtype P_((MARK)); /* R */ ! 538: extern MARK v_selcut P_((MARK, long, int)); /* " */ ! 539: extern MARK v_paste P_((MARK, long, int)); /* p P */ ! 540: extern MARK v_yank P_((MARK, MARK)); /* y Y */ ! 541: extern MARK v_delete P_((MARK, MARK)); /* d D */ ! 542: extern MARK v_join P_((MARK, long)); /* J */ ! 543: extern MARK v_insert P_((MARK, long, int)); /* a A i I o O */ ! 544: extern MARK v_change P_((MARK, MARK)); /* c C */ ! 545: extern MARK v_subst P_((MARK, long)); /* s */ ! 546: extern MARK v_lshift P_((MARK, MARK)); /* < */ ! 547: extern MARK v_rshift P_((MARK, MARK)); /* > */ ! 548: extern MARK v_reformat P_((MARK, MARK)); /* = */ ! 549: extern MARK v_filter P_((MARK, MARK)); /* ! */ ! 550: extern MARK v_status P_((void)); /* ^G */ ! 551: extern MARK v_switch P_((void)); /* ^^ */ ! 552: extern MARK v_tag P_((char *, MARK, long)); /* ^] */ ! 553: extern MARK v_xit P_((MARK, long, int)); /* ZZ */ ! 554: extern MARK v_undoline P_((MARK)); /* U */ ! 555: extern MARK v_again P_((MARK, MARK)); /* & */ ! 556: #ifndef NO_EXTENSIONS ! 557: extern MARK v_keyword P_((char *, MARK, long)); /* K */ ! 558: extern MARK v_increment P_((char *, MARK, long)); /* * */ ! 559: #endif ! 560: #ifndef NO_ERRLIST ! 561: extern MARK v_errlist P_((MARK)); /* * */ ! 562: #endif ! 563: #ifndef NO_AT ! 564: extern MARK v_at P_((MARK, long, int)); /* @ */ ! 565: #endif ! 566: #ifdef SIGTSTP ! 567: extern MARK v_suspend P_((void)); /* ^Z */ ! 568: #endif ! 569: #ifndef NO_POPUP ! 570: extern MARK v_popup P_((MARK, MARK)); /* \ */ ! 571: #endif ! 572: ! 573: /*----------------------------------------------------------------------*/ ! 574: /* These flags describe the quirks of the individual visual commands */ ! 575: #define NO_FLAGS 0x00 ! 576: #define MVMT 0x01 /* this is a movement command */ ! 577: #define PTMV 0x02 /* this can be *part* of a movement command */ ! 578: #define FRNT 0x04 /* after move, go to front of line */ ! 579: #define INCL 0x08 /* include last char when used with c/d/y */ ! 580: #define LNMD 0x10 /* use line mode of c/d/y */ ! 581: #define NCOL 0x20 /* this command can't change the column# */ ! 582: #define NREL 0x40 /* this is "non-relative" -- set the '' mark */ ! 583: #define SDOT 0x80 /* set the "dot" variables, for the "." cmd */ ! 584: #define FINL 0x100 /* final testing, more strict! */ ! 585: #define NWRP 0x200 /* no line-wrap (used for 'w' and 'W') */ ! 586: #ifndef NO_VISIBLE ! 587: # define VIZ 0x400 /* commands which can be used with 'v' */ ! 588: #else ! 589: # define VIZ 0 ! 590: #endif ! 591: ! 592: /* This variable is zeroed before a command executes, and later ORed with the ! 593: * command's flags after the command has been executed. It is used to force ! 594: * certain flags to be TRUE for *some* invocations of a particular command. ! 595: * For example, "/regexp/+offset" forces the LNMD flag, and sometimes a "p" ! 596: * or "P" command will force FRNT. ! 597: */ ! 598: extern int force_flags; ! 599: ! 600: /*----------------------------------------------------------------------*/ ! 601: /* These describe what mode we're in */ ! 602: ! 603: #define MODE_EX 1 /* executing ex commands */ ! 604: #define MODE_VI 2 /* executing vi commands */ ! 605: #define MODE_COLON 3 /* executing an ex command from vi mode */ ! 606: #define MODE_QUIT 4 ! 607: extern int mode; ! 608: ! 609: #define WHEN_VICMD 1 /* getkey: we're reading a VI command */ ! 610: #define WHEN_VIINP 2 /* getkey: we're in VI's INPUT mode */ ! 611: #define WHEN_VIREP 4 /* getkey: we're in VI's REPLACE mode */ ! 612: #define WHEN_EX 8 /* getkey: we're in EX mode */ ! 613: #define WHEN_MSG 16 /* getkey: we're at a "more" prompt */ ! 614: #define WHEN_POPUP 32 /* getkey: we're in the pop-up menu */ ! 615: #define WHEN_REP1 64 /* getkey: we're getting a single char for 'r' */ ! 616: #define WHEN_CUT 128 /* getkey: we're getting a cut buffer name */ ! 617: #define WHEN_MARK 256 /* getkey: we're getting a mark name */ ! 618: #define WHEN_CHAR 512 /* getkey: we're getting a destination for f/F/t/T */ ! 619: #define WHEN_INMV 4096 /* in input mode, interpret the key in VICMD mode */ ! 620: #define WHEN_FREE 8192 /* free the keymap after doing it once */ ! 621: #define WHENMASK (WHEN_VICMD|WHEN_VIINP|WHEN_VIREP|WHEN_REP1|WHEN_CUT|WHEN_MARK|WHEN_CHAR) ! 622: ! 623: #ifndef NO_VISIBLE ! 624: extern MARK V_from; ! 625: extern int V_linemd; ! 626: extern MARK v_start P_((MARK m, long cnt, int cmd)); ! 627: #endif ! 628: ! 629: #ifdef DEBUG ! 630: # define malloc(size) dbmalloc(size, __FILE__, __LINE__) ! 631: # define free(ptr) dbfree(ptr, __FILE__, __LINE__) ! 632: # define checkmem() dbcheckmem(__FILE__, __LINE__) ! 633: extern char *dbmalloc P_((int, char *, int)); ! 634: #else ! 635: # define checkmem() ! 636: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.