78ed81a3 |
1 | /* chardefs.h -- Character definitions for readline. */ |
2 | #ifndef _CHARDEFS_ |
3 | |
4 | #ifndef savestring |
5 | #define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x)) |
6 | #endif |
7 | |
8 | #ifndef whitespace |
9 | #define whitespace(c) (((c) == ' ') || ((c) == '\t')) |
10 | #endif |
11 | |
12 | #ifdef CTRL |
13 | #undef CTRL |
14 | #endif |
15 | |
16 | /* Some character stuff. */ |
17 | #define control_character_threshold 0x020 /* smaller than this is control */ |
18 | #define meta_character_threshold 0x07f /* larger than this is Meta. */ |
19 | #define control_character_bit 0x40 /* 0x000000, must be off. */ |
20 | #define meta_character_bit 0x080 /* x0000000, must be on. */ |
21 | |
22 | #define CTRL(c) ((c) & (~control_character_bit)) |
23 | #define META(c) ((c) | meta_character_bit) |
24 | |
25 | #define UNMETA(c) ((c) & (~meta_character_bit)) |
26 | #define UNCTRL(c) to_upper(((c)|control_character_bit)) |
27 | |
28 | #define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) |
29 | #define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) |
30 | |
31 | #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c)) |
32 | |
33 | #ifndef to_upper |
34 | #define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c)) |
35 | #define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c)) |
36 | #endif |
37 | |
38 | #define CTRL_P(c) ((c) < control_character_threshold) |
39 | #define META_P(c) ((c) > meta_character_threshold) |
40 | |
41 | #define NEWLINE '\n' |
42 | #define RETURN CTRL('M') |
43 | #define RUBOUT 0x07f |
44 | #define TAB '\t' |
45 | #define ABORT_CHAR CTRL('G') |
46 | #define PAGE CTRL('L') |
47 | #define SPACE 0x020 |
48 | #define ESC CTRL('[') |
49 | |
50 | #endif /* _CHARDEFS_ */ |