Commit | Line | Data |
---|---|---|
bd5635a1 RP |
1 | /* chardefs.h -- Character definitions for readline. */ |
2 | #ifndef _CHARDEFS_ | |
5e98bbab PB |
3 | #define _CHARDEFS_ |
4 | ||
5 | #include <ctype.h> | |
6 | ||
bd5635a1 | 7 | #ifndef savestring |
f550cec5 PB |
8 | #define savestring(X) _rl_savestring(X) |
9 | extern char * _rl_savestring (); | |
bd5635a1 RP |
10 | #endif |
11 | ||
12 | #ifndef whitespace | |
13 | #define whitespace(c) (((c) == ' ') || ((c) == '\t')) | |
14 | #endif | |
15 | ||
16 | #ifdef CTRL | |
17 | #undef CTRL | |
18 | #endif | |
19 | ||
20 | /* Some character stuff. */ | |
5e98bbab PB |
21 | #define control_character_threshold 0x020 /* Smaller than this is control. */ |
22 | #define meta_character_threshold 0x07f /* Larger than this is Meta. */ | |
bd5635a1 RP |
23 | #define control_character_bit 0x40 /* 0x000000, must be off. */ |
24 | #define meta_character_bit 0x080 /* x0000000, must be on. */ | |
5e98bbab | 25 | #define largest_char 255 /* Largest character value. */ |
bd5635a1 | 26 | |
5e98bbab | 27 | #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) |
bd5635a1 RP |
28 | #define CTRL(c) ((c) & (~control_character_bit)) |
29 | #define META(c) ((c) | meta_character_bit) | |
30 | ||
31 | #define UNMETA(c) ((c) & (~meta_character_bit)) | |
32 | #define UNCTRL(c) to_upper(((c)|control_character_bit)) | |
33 | ||
34 | #define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) | |
35 | #define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) | |
36 | ||
37 | #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c)) | |
38 | ||
39 | #ifndef to_upper | |
40 | #define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c)) | |
41 | #define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c)) | |
42 | #endif | |
43 | ||
44 | #define CTRL_P(c) ((c) < control_character_threshold) | |
45 | #define META_P(c) ((c) > meta_character_threshold) | |
46 | ||
5e98bbab | 47 | #ifndef NEWLINE |
bd5635a1 | 48 | #define NEWLINE '\n' |
5e98bbab PB |
49 | #endif |
50 | ||
51 | #ifndef RETURN | |
bd5635a1 | 52 | #define RETURN CTRL('M') |
5e98bbab PB |
53 | #endif |
54 | ||
55 | #ifndef RUBOUT | |
bd5635a1 | 56 | #define RUBOUT 0x07f |
5e98bbab PB |
57 | #endif |
58 | ||
59 | #ifndef TAB | |
bd5635a1 | 60 | #define TAB '\t' |
5e98bbab PB |
61 | #endif |
62 | ||
63 | #ifdef ABORT_CHAR | |
64 | #undef ABORT_CHAR | |
65 | #endif | |
bd5635a1 | 66 | #define ABORT_CHAR CTRL('G') |
5e98bbab PB |
67 | |
68 | #ifdef PAGE | |
69 | #undef PAGE | |
70 | #endif | |
bd5635a1 | 71 | #define PAGE CTRL('L') |
5e98bbab PB |
72 | |
73 | #ifdef SPACE | |
74 | #undef SPACE | |
75 | #endif | |
bd5635a1 | 76 | #define SPACE 0x020 |
5e98bbab PB |
77 | |
78 | #ifdef ESC | |
79 | #undef ESC | |
80 | #endif | |
81 | ||
bd5635a1 RP |
82 | #define ESC CTRL('[') |
83 | ||
84 | #endif /* _CHARDEFS_ */ |