Annotation of src/usr.bin/vim/macros.h, Revision 1.1.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: /*
11: * macros.h: macro definitions for often used code
12: */
13:
14: /*
15: * pchar(lp, c) - put character 'c' at position 'lp'
16: */
17: #define pchar(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c))
18:
19: /*
20: * Position comparisons
21: */
22: #define lt(a, b) (((a).lnum != (b).lnum) \
23: ? ((a).lnum < (b).lnum) : ((a).col < (b).col))
24:
25: #define ltoreq(a, b) (((a).lnum != (b).lnum) \
26: ? ((a).lnum < (b).lnum) : ((a).col <= (b).col))
27:
28: #define equal(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
29:
30: /*
31: * lineempty() - return TRUE if the line is empty
32: */
33: #define lineempty(p) (*ml_get(p) == NUL)
34:
35: /*
36: * bufempty() - return TRUE if the current buffer is empty
37: */
38: #define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_t)1) == NUL)
39:
40: /*
41: * On some systems toupper()/tolower() only work on lower/uppercase characters
42: */
43: #ifdef BROKEN_TOUPPER
44: # define TO_UPPER(c) (islower(c) ? toupper(c) : (c))
45: # define TO_LOWER(c) (isupper(c) ? tolower(c) : (c))
46: #else
47: # define TO_UPPER toupper
48: # define TO_LOWER tolower
49: #endif
50:
51: #ifdef HAVE_LANGMAP
52: /*
53: * Adjust chars in a language according to 'langmap' option.
54: * NOTE that there is NO overhead if 'langmap' is not set; but even
55: * when set we only have to do 2 ifs and an array lookup.
56: * Don't apply 'langmap' if the character comes from the Stuff buffer.
57: * The do-while is just to ignore a ';' after the macro.
58: */
59: # define LANGMAP_ADJUST(c, condition) do { \
60: if (*p_langmap && (condition) && !KeyStuffed && (c) < 256) \
61: c = langmap_mapchar[c]; \
62: } while (0)
63: #endif
64:
65: /*
66: * isbreak() is used very often if 'linebreak' is set, use a macro to make
67: * it work fast.
68: */
69: #define isbreak(c) (breakat_flags[(char_u)(c)])