mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00

buffer.h: buflist_getfile() flags buflist_new() flags buf_freeall() flags do_buffer() flags charset.h: chartab[] flags edit.h: in_cinkeys() flags change_indent() flags beginline() flags insertchar() flags nv_mousescroll() flags eval.c AUTOLOAD_CHAR eval.h: enum for vimvars[] ex_cmds.h: do_ecmd read_viminfo flags ex_cmds2.h: check_changed() flags do_source() flags ex_cmds_defs.h: BAD_* flags ex_docmd.h: VALID_PATH VALID_HEAD EXMODE_* do_cmdline() flags added include ex_getln.c *_ESC_CHARS definitions ex_getln.h: history table flags - used by add_to_history() fileio.h: readfile() flags event_T definition getchar.h: ins_typebuf() flags KEYLEN_* globals.h: NO_SCREEN NO_BUFFERS SEA_* defines current_SID flags hlf_T enum HL_FLAGS do_profiling() flags schar_T sattr_T indent.h: set_indent() flags macros.h: BINARY_FILE_IO flags mbyte.h: MB_BYTE2LEN* ENC_* memfile.h: mf_sync() flags misc1.h: open_line() flags message.h: do_dialog() flags vim_dialogyesno() flags DLG_BUTTON_* normal.h: find_ident_under_cursor() flags ops.h: do_put() flags operator ID's option.h: buf_copy_options() flags OPT_* flags os_unix.h: mch_nodetype() flags quickfix.h: skip_vimgrep_pat() flags regexp.h: vim_regcomp() flags values for reg_do_extmatch search.h: do_search() flags search_regcomp() flags findmatchlimit() flags syntax.h: HL_* flags HL_FOLD is used in buffer_defs.h but nvim compiles just fine with the defines in syntax.h tag.h: do_tag() flags find_tags() flags term.h: TBUFSZ flags MOUSE flags ui.h: jump_to_mouse() flags window.h: file_name_in_line() flags win_split() flags MIN_LINES MIN_COLUMNS Remove VimClipboard which should have been removed with PR #921.
162 lines
5.7 KiB
C
162 lines
5.7 KiB
C
#ifndef NVIM_MACROS_H
|
|
#define NVIM_MACROS_H
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
|
|
/*
|
|
* macros.h: macro definitions for often used code
|
|
*/
|
|
|
|
/*
|
|
* Position comparisons
|
|
*/
|
|
# define lt(a, b) (((a).lnum != (b).lnum) \
|
|
? (a).lnum < (b).lnum \
|
|
: (a).col != (b).col \
|
|
? (a).col < (b).col \
|
|
: (a).coladd < (b).coladd)
|
|
# define ltp(a, b) (((a)->lnum != (b)->lnum) \
|
|
? (a)->lnum < (b)->lnum \
|
|
: (a)->col != (b)->col \
|
|
? (a)->col < (b)->col \
|
|
: (a)->coladd < (b)->coladd)
|
|
# define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && \
|
|
((a).coladd == (b).coladd))
|
|
# define clearpos(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0; }
|
|
|
|
#define ltoreq(a, b) (lt(a, b) || equalpos(a, b))
|
|
|
|
/*
|
|
* lineempty() - return TRUE if the line is empty
|
|
*/
|
|
#define lineempty(p) (*ml_get(p) == NUL)
|
|
|
|
/*
|
|
* bufempty() - return TRUE if the current buffer is empty
|
|
*/
|
|
#define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == \
|
|
NUL)
|
|
|
|
/*
|
|
* toupper() and tolower() that use the current locale.
|
|
* Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
|
|
* range 0 - 255. toupper()/tolower() on some systems can't handle others.
|
|
* Note: It is often better to use vim_tolower() and vim_toupper(), because many
|
|
* toupper() and tolower() implementations only work for ASCII.
|
|
*/
|
|
#define TOUPPER_LOC toupper
|
|
#define TOLOWER_LOC tolower
|
|
|
|
/* toupper() and tolower() for ASCII only and ignore the current locale. */
|
|
# define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
|
|
# define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
|
|
|
|
/* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
|
|
* non-zero for superscript 1. Also avoids that isdigit() crashes for numbers
|
|
* below 0 and above 255. */
|
|
#define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10)
|
|
|
|
/* Like isalpha() but reject non-ASCII characters. Can't be used with a
|
|
* special key (negative value). */
|
|
# define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26)
|
|
# define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26)
|
|
# define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
|
|
# define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || VIM_ISDIGIT(c))
|
|
|
|
/* macro version of chartab().
|
|
* Only works with values 0-255!
|
|
* Doesn't work for UTF-8 mode with chars >= 0x80. */
|
|
#define CHARSIZE(c) (chartab[c] & CT_CELL_MASK)
|
|
|
|
/*
|
|
* Adjust chars in a language according to 'langmap' option.
|
|
* NOTE that there is no noticeable overhead if 'langmap' is not set.
|
|
* When set the overhead for characters < 256 is small.
|
|
* Don't apply 'langmap' if the character comes from the Stuff buffer.
|
|
* The do-while is just to ignore a ';' after the macro.
|
|
*/
|
|
# define LANGMAP_ADJUST(c, condition) \
|
|
do { \
|
|
if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0) \
|
|
{ \
|
|
if ((c) < 256) \
|
|
c = langmap_mapchar[c]; \
|
|
else \
|
|
c = langmap_adjust_mb(c); \
|
|
} \
|
|
} while (0)
|
|
|
|
/*
|
|
* vim_isbreak() is used very often if 'linebreak' is set, use a macro to make
|
|
* it work fast.
|
|
*/
|
|
#define vim_isbreak(c) (breakat_flags[(char_u)(c)])
|
|
|
|
#ifdef BINARY_FILE_IO
|
|
# define WRITEBIN "wb" /* no CR-LF translation */
|
|
# define READBIN "rb"
|
|
# define APPENDBIN "ab"
|
|
#else
|
|
# define WRITEBIN "w"
|
|
# define READBIN "r"
|
|
# define APPENDBIN "a"
|
|
#endif
|
|
|
|
# define mch_fopen(n, p) fopen((n), (p))
|
|
# define mch_open(n, m, p) open((n), (m), (p))
|
|
|
|
/* mch_open_rw(): invoke mch_open() with third argument for user R/W. */
|
|
#if defined(UNIX) /* open in rw------- mode */
|
|
# define mch_open_rw(n, f) mch_open((n), (f), (mode_t)0600)
|
|
#else
|
|
# define mch_open_rw(n, f) mch_open((n), (f), 0)
|
|
#endif
|
|
|
|
#ifdef STARTUPTIME
|
|
# define TIME_MSG(s) { if (time_fd != NULL) time_msg(s, NULL); }
|
|
#else
|
|
# define TIME_MSG(s)
|
|
#endif
|
|
|
|
# define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
|
|
|
|
# define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))
|
|
|
|
/* Whether to draw the vertical bar on the right side of the cell. */
|
|
# define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
|
|
|
|
/*
|
|
* mb_ptr_adv(): advance a pointer to the next character, taking care of
|
|
* multi-byte characters if needed.
|
|
* mb_ptr_back(): backup a pointer to the previous character, taking care of
|
|
* multi-byte characters if needed.
|
|
* MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
|
|
* PTR2CHAR(): get character from pointer.
|
|
*/
|
|
/* Get the length of the character p points to */
|
|
# define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1)
|
|
/* Advance multi-byte pointer, skip over composing chars. */
|
|
# define mb_ptr_adv(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1
|
|
/* Advance multi-byte pointer, do not skip over composing chars. */
|
|
# define mb_cptr_adv(p) p += \
|
|
enc_utf8 ? utf_ptr2len(p) : has_mbyte ? (*mb_ptr2len)(p) : 1
|
|
/* Backup multi-byte pointer. Only use with "p" > "s" ! */
|
|
# define mb_ptr_back(s, p) p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
|
|
/* get length of multi-byte char, not including composing chars */
|
|
# define mb_cptr2len(p) (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
|
|
|
|
# define MB_COPY_CHAR(f, \
|
|
t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
|
|
# define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
|
|
# define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
|
|
# define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
|
|
|
|
# define RESET_BINDING(wp) (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE
|
|
|
|
#endif // NVIM_MACROS_H
|