[BACK]Return to vim.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / vim

Annotation of src/usr.bin/vim/vim.h, Revision 1.2

1.2     ! downsj      1: /* $OpenBSD: vim.h,v 1.1.1.1 1996/09/07 21:40:28 downsj Exp $  */
1.1       downsj      2: /* vi:set ts=4 sw=4:
                      3:  *
                      4:  * VIM - Vi IMproved       by Bram Moolenaar
                      5:  *
                      6:  * Do ":help uganda"  in Vim to read copying and usage conditions.
                      7:  * Do ":help credits" in Vim to see a list of people who contributed.
                      8:  */
                      9:
                     10: /* ============ the header file puzzle (ca. 50-100 pieces) ========= */
                     11:
                     12: #ifdef HAVE_CONFIG_H   /* GNU autoconf (or something else) was here */
                     13: # include "config.h"
                     14: #endif
                     15:
                     16: #ifdef __EMX__         /* hand-edited config.h for OS/2 with EMX */
                     17: # include "conf_os2.h"
                     18: #endif
                     19:
                     20: /*
                     21:  * This is a bit of a wishlist.  Currently we only have the Motif and Athena
                     22:  * GUI.
                     23:  */
                     24: #if defined(USE_GUI_MOTIF) \
                     25:    || defined(USE_GUI_ATHENA) \
                     26:    || defined(USE_GUI_MAC) \
                     27:    || defined(USE_GUI_WINDOWS31) \
                     28:    || defined(USE_GUI_WIN32) \
                     29:    || defined(USE_GUI_OS2)
                     30: # ifndef USE_GUI
                     31: #  define USE_GUI
                     32: # endif
                     33: #endif
                     34:
                     35: #include "feature.h"   /* #defines for optionals and features */
                     36:
                     37: /*
                     38:  * Find out if function definitions should include argument types
                     39:  */
                     40: #ifdef AZTEC_C
                     41: # include <functions.h>
                     42: # define __ARGS(x) x
                     43: # define __PARMS(x)    x
                     44: #endif
                     45:
                     46: #ifdef SASC
                     47: # include <clib/exec_protos.h>
                     48: # define __ARGS(x) x
                     49: # define __PARMS(x)    x
                     50: #endif
                     51:
                     52: #ifdef _DCC
                     53: # include <clib/exec_protos.h>
                     54: # define __ARGS(x) x
                     55: # define __PARMS(x)    x
                     56: #endif
                     57:
                     58: #ifdef __TURBOC__
                     59: # define __ARGS(x) x
                     60: #endif
                     61:
                     62: #if defined(UNIX) || defined(__EMX__)
                     63: # include "unix.h"     /* bring lots of system header files */
                     64: #endif
                     65:
                     66: #ifdef VMS
                     67: # include "vms.h"
                     68: #endif
                     69:
                     70: #ifndef __ARGS
                     71: # if defined(__STDC__) || defined(__GNUC__) || defined(WIN32)
                     72: #  define __ARGS(x) x
                     73: # else
                     74: #  define __ARGS(x) ()
                     75: # endif
                     76: #endif
                     77:
                     78: /* __ARGS and __PARMS are the same thing. */
                     79: #ifndef __PARMS
                     80: # define __PARMS(x) __ARGS(x)
                     81: #endif
                     82:
                     83: #ifdef UNIX
                     84: # include "osdef.h"        /* bring missing declarations in */
                     85: #endif
                     86:
                     87: #ifdef __EMX__
                     88: # define   getcwd  _getcwd2
                     89: # define   chdir   _chdir2
                     90: # undef        CHECK_INODE
                     91: #endif
                     92:
                     93: #ifdef AMIGA
                     94: # include "amiga.h"
                     95: #endif
                     96:
                     97: #ifdef ARCHIE
                     98: # include "archie.h"
                     99: #endif
                    100:
                    101: #ifdef MSDOS
                    102: # include "msdos.h"
                    103: #endif
                    104:
                    105: #ifdef WIN32
                    106: # include "win32.h"
                    107: #endif
                    108:
                    109: #ifdef MINT
                    110: # include "mint.h"
                    111: #endif
                    112:
                    113: /*
1.2     ! downsj    114:  * Maximum length of a path    (for non-unix systems) Make it a bit long, to stay
        !           115:  * on the safe side.  But not too long to put on the stack.
1.1       downsj    116:  */
                    117: #ifndef MAXPATHL
1.2     ! downsj    118: # ifdef MAXPATHLEN
        !           119: #  define MAXPATHL MAXPATHLEN
        !           120: # else
        !           121: #  define MAXPATHL 256
        !           122: # endif
1.1       downsj    123: #endif
                    124:
                    125: /*
                    126:  * Shorthand for unsigned variables. Many systems, but not all, have u_char
                    127:  * already defined, so we use char_u to avoid trouble.
                    128:  */
                    129: typedef unsigned char  char_u;
                    130: typedef unsigned short short_u;
                    131: typedef unsigned int   int_u;
                    132: typedef unsigned long  long_u;
                    133:
                    134: #ifndef UNIX               /* For Unix this is included in unix.h */
                    135: #include <stdio.h>
                    136: #include <ctype.h>
                    137: #endif
                    138:
                    139: #if defined(HAVE_STRING_H)
                    140: # include <string.h>
                    141: #else
                    142: # ifdef HAVE_STRINGS_H
                    143: #  include <strings.h>
                    144: # endif
                    145: #endif
                    146:
                    147: #include "ascii.h"
                    148: #include "keymap.h"
                    149: #include "term.h"
                    150: #include "macros.h"
                    151:
                    152: #ifdef LATTICE
                    153: # include <sys/types.h>
                    154: # include <sys/stat.h>
                    155: #endif
                    156: #ifdef _DCC
                    157: # include <sys/stat.h>
                    158: #endif
                    159: #if defined MSDOS  ||  defined WIN32
                    160: # include <sys\stat.h>
                    161: #endif
                    162:
                    163: /* allow other (non-unix) systems to configure themselves now */
                    164: #ifndef UNIX
                    165: # ifdef HAVE_STAT_H
                    166: #  include <stat.h>
                    167: # endif
                    168: # ifdef HAVE_STDLIB_H
                    169: #  include <stdlib.h>
                    170: # endif
                    171: #endif /* NON-UNIX */
                    172:
                    173: /* ================ end of the header file puzzle =============== */
                    174:
                    175: /*
                    176:  * flags for updateScreen()
                    177:  * The higher the value, the higher the priority
                    178:  */
                    179: #define VALID                  10  /* buffer not changed */
                    180: #define INVERTED               20  /* redisplay inverted part */
                    181: #define VALID_TO_CURSCHAR      30  /* buffer at/below cursor changed */
                    182: #define NOT_VALID              40  /* buffer changed */
                    183: #define CURSUPD                    50  /* buffer changed, update cursor first */
                    184: #define CLEAR                  60  /* screen messed up, clear it */
                    185:
                    186: /*
                    187:  * Attributes for NextScreen.
                    188:  */
                    189: #define CHAR_NORMAL        0
                    190: #define CHAR_INVERT        1
                    191: #define CHAR_UNDERL        2
                    192: #define CHAR_BOLD      3
                    193: #define CHAR_STDOUT        4
                    194: #define CHAR_ITALIC        5
                    195:
                    196: /*
                    197:  * values for State
                    198:  *
                    199:  * The lowest four bits are used to distinguish normal/visual/cmdline/
                    200:  * insert+replace mode. This is used for mapping. If none of these bits are
                    201:  * set, no mapping is done.
                    202:  * The upper four bits are used to distinguish between other states.
                    203:  */
                    204: #define NORMAL                 0x01
                    205: #define VISUAL                 0x02
                    206: #define CMDLINE                0x04
                    207: #define INSERT                 0x08
                    208: #define NORMAL_BUSY                0x11    /* busy interpreting a command */
                    209: #define REPLACE                0x28    /* replace mode */
                    210: #define HITRETURN              0x61    /* waiting for a return */
                    211: #define ASKMORE                    0x70    /* Asking if you want --more-- */
                    212: #define SETWSIZE               0x80    /* window size has changed */
                    213: #define ABBREV                 0x90    /* abbreviation instead of mapping */
                    214: #define EXTERNCMD              0xa0    /* executing an external command */
                    215:
                    216: /* directions */
                    217: #define FORWARD                1
                    218: #define BACKWARD               (-1)
                    219: #define BOTH_DIRECTIONS            2
                    220:
                    221: /* return values for functions */
                    222: #define OK                     1
                    223: #define FAIL                   0
                    224:
                    225: /*
                    226:  * values for command line completion
                    227:  */
                    228: #define CONTEXT_UNKNOWN            (-2)
                    229: #define EXPAND_UNSUCCESSFUL        (-1)
                    230: #define EXPAND_NOTHING         0
                    231: #define EXPAND_COMMANDS            1
                    232: #define EXPAND_FILES           2
                    233: #define EXPAND_DIRECTORIES     3
                    234: #define EXPAND_SETTINGS            4
                    235: #define EXPAND_BOOL_SETTINGS   5
                    236: #define EXPAND_TAGS                6
                    237: #define EXPAND_OLD_SETTING     7
                    238: #define EXPAND_HELP                8
                    239: #define EXPAND_BUFFERS         9
                    240: #define EXPAND_EVENTS          10
                    241: #define EXPAND_MENUS           11
                    242:
                    243: /* Values for nextwild() and ExpandOne().  See ExpandOne() for meaning. */
                    244: #define WILD_FREE              1
                    245: #define WILD_EXPAND_FREE       2
                    246: #define WILD_EXPAND_KEEP       3
                    247: #define WILD_NEXT              4
                    248: #define WILD_PREV              5
                    249: #define WILD_ALL               6
                    250: #define WILD_LONGEST           7
                    251:
                    252: #define WILD_LIST_NOTFOUND     1
                    253: #define WILD_HOME_REPLACE      2
                    254:
                    255: /* Values for the find_pattern_in_path() function args 'type' and 'action': */
                    256: #define FIND_ANY       1
                    257: #define FIND_DEFINE        2
                    258: #define CHECK_PATH     3
                    259:
                    260: #define ACTION_SHOW        1
                    261: #define ACTION_GOTO        2
                    262: #define ACTION_SPLIT   3
                    263: #define ACTION_SHOW_ALL    4
                    264: #ifdef INSERT_EXPAND
                    265: # define ACTION_EXPAND 5
                    266: #endif
                    267:
                    268: /* Values for 'options' argument in do_search() and searchit() */
                    269: #define SEARCH_REV   0x01  /* go in reverse of previous dir. */
                    270: #define SEARCH_ECHO      0x02  /* echo the search command and handle options */
                    271: #define SEARCH_MSG   0x0c  /* give messages (yes, it's not 0x04) */
                    272: #define SEARCH_NFMSG  0x08 /* give all messages except not found */
                    273: #define SEARCH_OPT   0x10  /* interpret optional flags */
                    274: #define SEARCH_HIS   0x20  /* put search pattern in history */
                    275: #define SEARCH_END   0x40  /* put cursor at end of match */
                    276: #define SEARCH_NOOF      0x80  /* don't add offset to position */
                    277: #define SEARCH_START 0x100 /* start search without col offset */
                    278: #define SEARCH_MARK  0x200 /* set previous context mark */
                    279: #define SEARCH_KEEP  0x400 /* keep previous search pattern */
                    280:
                    281: /* Values for find_ident_under_cursor() */
                    282: #define FIND_IDENT 1       /* find identifier (word) */
                    283: #define FIND_STRING    2       /* find any string (WORD) */
                    284:
                    285: /* Values for get_file_name_in_path() */
                    286: #define FNAME_MESS 1       /* give error message */
                    287: #define FNAME_EXP  2       /* expand to path */
                    288: #define FNAME_HYP  4       /* check for hypertext link */
                    289:
                    290: /* Values for buflist_getfile() */
                    291: #define GETF_SETMARK   0x01    /* set pcmark before jumping */
                    292: #define GETF_ALT       0x02    /* jumping to alternate file (not buf num) */
                    293:
                    294: /* Values for in_indentkeys() */
                    295: #define KEY_OPEN_FORW  0x101
                    296: #define KEY_OPEN_BACK  0x102
                    297:
                    298: /* Values for call_shell() second argument */
                    299: #define SHELL_FILTER       1       /* filtering text */
                    300: #define SHELL_EXPAND       2       /* expanding wildcards */
                    301: #define SHELL_COOKED       4       /* set term to cooked mode */
                    302:
                    303: /* Values for change_indent() */
                    304: #define INDENT_SET         1       /* set indent */
                    305: #define INDENT_INC         2       /* increase indent */
                    306: #define INDENT_DEC         3       /* decrease indent */
                    307:
                    308: /* Values for flags argument for findmatchlimit() */
                    309: #define FM_BACKWARD            0x01    /* search backwards */
                    310: #define FM_FORWARD         0x02    /* search forwards */
                    311: #define FM_BLOCKSTOP       0x04    /* stop at start/end of block */
                    312: #define FM_SKIPCOMM            0x08    /* skip comments */
                    313:
                    314: /* Values for action argument for do_buffer() */
                    315: #define DOBUF_GOTO     0       /* go to specified buffer */
                    316: #define DOBUF_SPLIT        1       /* split window and go to specified buffer */
                    317: #define DOBUF_UNLOAD   2       /* unload specified buffer(s) */
                    318: #define DOBUF_DEL      3       /* delete specified buffer(s) */
                    319:
                    320: /* Values for start argument for do_buffer() */
                    321: #define DOBUF_CURRENT  0       /* "count" buffer from current buffer */
                    322: #define DOBUF_FIRST        1       /* "count" buffer from first buffer */
                    323: #define DOBUF_LAST     2       /* "count" buffer from last buffer */
                    324: #define DOBUF_MOD      3       /* "count" mod. buffer from current buffer */
                    325:
                    326: /* Values for sub_cmd and which_pat argument for myregcomp() */
                    327: /* Also used for which_pat argument for searchit() */
                    328: #define RE_SEARCH  0           /* save/use pat in/from search_pattern */
                    329: #define RE_SUBST   1           /* save/use pat in/from subst_pattern */
                    330: #define RE_BOTH        2           /* save pat in both patterns */
                    331: #define RE_LAST        2           /* use last used pattern if "pat" is NULL */
                    332:
                    333: /* Return values for fullpathcmp() */
                    334: #define FPC_SAME   1           /* both exist and are the same file. */
                    335: #define FPC_DIFF   2           /* both exist and are different files. */
                    336: #define FPC_NOTX   3           /* both don't exist. */
                    337: #define FPC_DIFFX  4           /* one of them doesn't exist. */
1.2     ! downsj    338:
        !           339: /* flags for do_ecmd() */
        !           340: #define ECMD_HIDE      1       /* don't free the current buffer */
        !           341: #define ECMD_SET_HELP  2       /* set b_help flag of (new) buffer before
        !           342:                                   opening file */
        !           343: #define ECMD_OLDBUF        4       /* use existing buffer if it exists */
        !           344: #define ECMD_FORCEIT   8       /* ! used in Ex command */
1.1       downsj    345:
                    346: /*
                    347:  * Events for autocommands.
                    348:  */
                    349: enum auto_events
                    350: {
                    351:    EVENT_BUFENTER = 0,     /* after entering a buffer */
                    352:    EVENT_BUFLEAVE,         /* before leaving a buffer */
                    353:    EVENT_BUFNEWFILE,       /* when creating a buffer for a new file */
                    354:    EVENT_BUFREADPOST,      /* after reading a buffer */
                    355:    EVENT_BUFREADPRE,       /* before reading a buffer */
                    356:    EVENT_BUFWRITEPOST,     /* after writing a buffer */
                    357:    EVENT_BUFWRITEPRE,      /* before writing a buffer */
                    358:    EVENT_FILEAPPENDPOST,   /* after appending to a file */
                    359:    EVENT_FILEAPPENDPRE,    /* before appending to a file */
                    360:    EVENT_FILEREADPOST,     /* after reading a file */
                    361:    EVENT_FILEREADPRE,      /* before reading a file */
                    362:    EVENT_FILEWRITEPOST,    /* after writing a file */
                    363:    EVENT_FILEWRITEPRE,     /* before writing a file */
                    364:    EVENT_FILTERREADPOST,   /* after reading from a filter */
                    365:    EVENT_FILTERREADPRE,    /* before reading from a filter */
                    366:    EVENT_FILTERWRITEPOST,  /* after writing to a filter */
                    367:    EVENT_FILTERWRITEPRE,   /* before writing to a filter */
                    368:    EVENT_VIMLEAVE,         /* before exiting Vim */
                    369:    EVENT_WINENTER,         /* after entering a window */
                    370:    EVENT_WINLEAVE,         /* before leaving a window */
                    371:    NUM_EVENTS              /* MUST be the last one */
                    372: };
                    373:
                    374: /*
                    375:  * Boolean constants
                    376:  */
                    377: #ifndef TRUE
                    378: # define FALSE 0           /* note: this is an int, not a long! */
                    379: # define TRUE  1
                    380: #endif
                    381:
                    382: #define MAYBE  2           /* for beginline() and the 'sol' option */
                    383:
                    384: /* May be returned by add_new_completion(): */
                    385: #define RET_ERROR              (-1)
                    386:
                    387: /*
                    388:  * jump_to_mouse() returns one of these values, possibly with
                    389:  * CURSOR_MOVED added
                    390:  */
                    391: #define IN_UNKNOWN     1
                    392: #define IN_BUFFER      2
                    393: #define IN_STATUS_LINE 3           /* Or in command line */
                    394: #define CURSOR_MOVED   0x100
                    395:
                    396: /* flags for jump_to_mouse() */
                    397: #define MOUSE_FOCUS        0x1     /* if used, need to stay in this window */
                    398: #define MOUSE_MAY_VIS  0x2     /* if used, may set visual mode */
                    399: #define MOUSE_DID_MOVE 0x4     /* if used, only act when mouse has moved */
                    400: #define MOUSE_SETPOS   0x8     /* if used, only set current mouse position */
                    401:
                    402: /*
                    403:  * Minimum screen size
                    404:  */
                    405: #define MIN_COLUMNS        12      /* minimal columns for screen */
                    406: #define MIN_ROWS       1       /* minimal rows for one window */
                    407: #define STATUS_HEIGHT  1       /* height of a status line under a window */
                    408:
                    409: /*
                    410:  * Buffer sizes
                    411:  */
                    412: #ifndef CMDBUFFSIZE
                    413: # define CMDBUFFSIZE   256     /* size of the command processing buffer */
                    414: #endif
                    415:
                    416: #define LSIZE      512         /* max. size of a line in the tags file */
                    417:
                    418: #define IOSIZE    (1024+1)     /* file i/o and sprintf buffer size */
                    419: #define MSG_BUF_LEN    80          /* length of buffer for small messages */
                    420:
                    421: #define    TERMBUFSIZE 1024
                    422:
                    423: #if defined(AMIGA) || defined(__linux__)
                    424: # define TBUFSZ 2048           /* buffer size for termcap entry */
                    425: #else
                    426: # define TBUFSZ 1024           /* buffer size for termcap entry */
                    427: #endif
                    428:
                    429: /*
                    430:  * Maximum length of key sequence to be mapped.
                    431:  * Must be able to hold an Amiga resize report.
                    432:  */
                    433: #define MAXMAPLEN  50
                    434:
                    435: #ifdef BINARY_FILE_IO
                    436: # define WRITEBIN  "wb"        /* no CR-LF translation */
                    437: # define READBIN   "rb"
                    438: # define APPENDBIN "ab"
                    439: #else
                    440: # define WRITEBIN  "w"
                    441: # define READBIN   "r"
                    442: # define APPENDBIN "a"
                    443: #endif
                    444:
                    445: /*
                    446:  * EMX doesn't have a global way of making open() use binary I/O.
                    447:  * Use O_BINARY for all open() calls.
                    448:  */
                    449: #ifdef __EMX__
                    450: # define O_EXTRA   O_BINARY
                    451: #else
                    452: # define O_EXTRA   0
                    453: #endif
                    454:
                    455: #define CHANGED        set_Changed()
                    456: #define UNCHANGED(buf) unset_Changed(buf)
                    457:
                    458: /*
                    459:  * defines to avoid typecasts from (char_u *) to (char *) and back
                    460:  * (vim_strchr() and vim_strrchr() are now in alloc.c)
                    461:  */
                    462: #define STRLEN(s)          strlen((char *)(s))
                    463: #define STRCPY(d, s)       strcpy((char *)(d), (char *)(s))
                    464: #define STRNCPY(d, s, n)   strncpy((char *)(d), (char *)(s), (size_t)(n))
                    465: #define STRCMP(d, s)       strcmp((char *)(d), (char *)(s))
                    466: #define STRNCMP(d, s, n)   strncmp((char *)(d), (char *)(s), (size_t)(n))
                    467: #define STRCAT(d, s)       strcat((char *)(d), (char *)(s))
                    468: #define STRNCAT(d, s, n)   strncat((char *)(d), (char *)(s), (size_t)(n))
                    469:
                    470: #define MSG(s)             msg((char_u *)(s))
                    471: #define EMSG(s)                emsg((char_u *)(s))
                    472: #define EMSG2(s, p)            emsg2((char_u *)(s), (char_u *)(p))
                    473: #define EMSGN(s, n)            emsgn((char_u *)(s), (long)(n))
                    474: #define OUTSTR(s)          outstr((char_u *)(s))
                    475: #define OUTSTRN(s)         outstrn((char_u *)(s))
                    476: #define MSG_OUTSTR(s)      msg_outstr((char_u *)(s))
                    477:
                    478: typedef long       linenr_t;       /* line number type */
                    479: typedef unsigned   colnr_t;        /* column number type */
                    480:
                    481: #define MAXLNUM (0x7fffffff)       /* maximum (invalid) line number */
                    482:
                    483: #if SIZEOF_INT >= 4
                    484: # define MAXCOL    (0x7fffffff)        /* maximum column number, 31 bits */
                    485: #else
                    486: # define MAXCOL    (0x7fff)            /* maximum column number, 15 bits */
                    487: #endif
                    488:
                    489: #define SHOWCMD_COLS 10                /* columns needed by shown command */
                    490:
                    491: /*
                    492:  * Include a prototype for vim_memmove(), it may not be in alloc.pro.
                    493:  */
                    494: #ifdef VIM_MEMMOVE
                    495: void vim_memmove __ARGS((void *, void *, size_t));
                    496: #else
                    497: # ifndef vim_memmove
                    498: #  define vim_memmove(to, from, len) memmove(to, from, len)
                    499: # endif
                    500: #endif
                    501:
                    502: /*
                    503:  * For the Amiga we use a version of getenv that does local variables under 2.0
                    504:  * For Win32 and MSDOS we also check $HOME when $VIM is used.
                    505:  */
                    506: #if !defined(AMIGA) && !defined(WIN32) && !defined(MSDOS) && !defined(VMS)
                    507: # define vim_getenv(x) (char_u *)getenv((char *)x)
                    508: #endif
                    509:
                    510: /*
                    511:  * fnamecmp() is used to compare filenames.
                    512:  * On some systems case in a filename does not matter, on others it does.
                    513:  * (this does not account for maximum name lengths and things like "../dir",
                    514:  * thus it is not 100% accurate!)
                    515:  */
                    516: #ifdef CASE_INSENSITIVE_FILENAME
                    517: # define fnamecmp(x, y) stricmp((char *)(x), (char *)(y))
                    518: # define fnamencmp(x, y, n) strnicmp((char *)(x), (char *)(y), (size_t)(n))
                    519: #else
                    520: # define fnamecmp(x, y) strcmp((char *)(x), (char *)(y))
                    521: # define fnamencmp(x, y, n) strncmp((char *)(x), (char *)(y), (size_t)(n))
                    522: #endif
                    523:
                    524: #ifdef HAVE_MEMSET
                    525: # define vim_memset(ptr, c, size)  memset((ptr), (c), (size))
                    526: #else
                    527: void *vim_memset __ARGS((void *, int, size_t));
                    528: #endif
                    529:
                    530: /* for MS-DOS and Win32: use chdir() that also changes the default drive */
                    531: #ifdef USE_VIM_CHDIR
                    532: int vim_chdir __ARGS((char *));
                    533: #else
                    534: # define vim_chdir chdir
                    535: #endif
                    536:
                    537: /*
                    538:  * vim_iswhite() is used for "^" and the like. It differs from isspace()
                    539:  * because it doesn't include <CR> and <LF> and the like.
                    540:  */
                    541: #define vim_iswhite(x) ((x) == ' ' || (x) == '\t')
                    542:
                    543: /* Note that gui.h is included by structs.h */
                    544:
                    545: #include "structs.h"       /* file that defines many structures */