term.c
资源名称:vim53src.zip [点击查看]
上传用户:gddssl
上传日期:2007-01-06
资源大小:1003k
文件大小:95k
源码类别:
编辑器/阅读器
开发平台:
DOS
- /* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
- /*
- *
- * term.c: functions for controlling the terminal
- *
- * primitive termcap support for Amiga, MSDOS, and Win32 included
- *
- * NOTE: padding and variable substitution is not performed,
- * when compiling without HAVE_TGETENT, we use tputs() and tgoto() dummies.
- */
- /*
- * Some systems have a prototype for tgetstr() with (char *) instead of
- * (char **). This define removes that prototype. We include our own prototype
- * below.
- */
- #define tgetstr tgetstr_defined_wrong
- #include "vim.h"
- #ifdef HAVE_TGETENT
- # ifdef HAVE_TERMIOS_H
- # include <termios.h> /* seems to be required for some Linux */
- # endif
- # ifdef HAVE_TERMCAP_H
- # include <termcap.h>
- # endif
- /*
- * A few linux systems define outfuntype in termcap.h to be used as the third
- * argument for tputs().
- */
- # ifdef VMS
- # define TPUTSFUNCAST
- # else
- # ifdef HAVE_OUTFUNTYPE
- # define TPUTSFUNCAST (outfuntype)
- # else
- # define TPUTSFUNCAST (int (*)())
- # endif
- # endif
- #endif
- #undef tgetstr
- /*
- * Here are the builtin termcap entries. They are not stored as complete
- * Tcarr structures, as such a structure is too big.
- *
- * The entries are compact, therefore they normally are included even when
- * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries
- * can be accessed with "builtin_amiga", "builtin_ansi", "builtin_debug", etc.
- *
- * Each termcap is a list of builtin_term structures. It always starts with
- * KS_NAME, which separates the entries. See parse_builtin_tcap() for all
- * details.
- * bt_entry is either a KS_xxx code (< 0x100), or a K_xxx code.
- */
- struct builtin_term
- {
- int bt_entry;
- char *bt_string;
- };
- /* start of keys that are not directly used by Vim but can be mapped */
- #define BT_EXTRA_KEYS 0x101
- static struct builtin_term *find_builtin_term __ARGS((char_u *name));
- static void parse_builtin_tcap __ARGS((char_u *s));
- static void term_color __ARGS((char_u *s, int n));
- static void gather_termleader __ARGS((void));
- static int get_bytes_from_buf __ARGS((char_u *, char_u *, int));
- static int term_is_builtin __ARGS((char_u *));
- #ifdef HAVE_TGETENT
- static char_u *tgetent_error __ARGS((char_u *, char_u *));
- /*
- * Here is our own prototype for tgetstr(), any prototypes from the include
- * files have been disabled by the define at the start of this file.
- */
- char *tgetstr __ARGS((char *, char **));
- /*
- * Don't declare these variables if termcap.h contains them.
- * Autoconf checks if these variables should be declared extern (not all
- * systems have them).
- * Some versions define ospeed to be speed_t, but that is incompatible with
- * BSD, where ospeed is short and speed_t is long.
- */
- # ifndef HAVE_OSPEED
- # ifdef OSPEED_EXTERN
- extern short ospeed;
- # else
- short ospeed;
- # endif
- # endif
- # ifndef HAVE_UP_BC_PC
- # ifdef UP_BC_PC_EXTERN
- extern char *UP, *BC, PC;
- # else
- char *UP, *BC, PC;
- # endif
- # endif
- # define TGETSTR(s, p) (char_u *)tgetstr((s), (char **)(p))
- # define TGETENT(b, t) tgetent((char *)(b), (char *)(t))
- #endif /* HAVE_TGETENT */
- struct builtin_term builtin_termcaps[] =
- {
- #if defined(USE_GUI)
- /*
- * Motif/Athena pseudo term-cap.
- */
- {(int)KS_NAME, "gui"},
- {(int)KS_CE, "