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