1432
|
1 /* chardefs.h -- Character definitions for readline. */ |
|
2 |
|
3 /* Copyright (C) 1994 Free Software Foundation, Inc. |
|
4 |
|
5 This file is part of the GNU Readline Library, a library for |
|
6 reading lines of text with interactive input and history editing. |
|
7 |
|
8 The GNU Readline Library is free software; you can redistribute it |
|
9 and/or modify it under the terms of the GNU General Public License |
|
10 as published by the Free Software Foundation; either version 1, or |
|
11 (at your option) any later version. |
|
12 |
|
13 The GNU Readline Library is distributed in the hope that it will be |
|
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
|
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 The GNU General Public License is often shipped with GNU software, and |
|
19 is generally kept in a file called COPYING or LICENSE. If you do not |
|
20 have a copy of the license, write to the Free Software Foundation, |
|
21 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
22 |
|
23 #ifndef _CHARDEFS_H |
|
24 #define _CHARDEFS_H |
|
25 |
1464
|
26 #ifdef __cplusplus |
|
27 extern "C" { |
|
28 #endif |
|
29 |
1432
|
30 #include <ctype.h> |
|
31 |
|
32 #if defined (HAVE_STRING_H) |
|
33 # include <string.h> |
|
34 #else |
|
35 # include <strings.h> |
|
36 #endif /* HAVE_STRING_H */ |
|
37 |
|
38 #ifndef whitespace |
|
39 #define whitespace(c) (((c) == ' ') || ((c) == '\t')) |
|
40 #endif |
|
41 |
|
42 #ifdef CTRL |
|
43 #undef CTRL |
|
44 #endif |
|
45 |
|
46 /* Some character stuff. */ |
|
47 #define control_character_threshold 0x020 /* Smaller than this is control. */ |
|
48 #define control_character_mask 0x1f /* 0x20 - 1 */ |
|
49 #define meta_character_threshold 0x07f /* Larger than this is Meta. */ |
|
50 #define control_character_bit 0x40 /* 0x000000, must be off. */ |
|
51 #define meta_character_bit 0x080 /* x0000000, must be on. */ |
|
52 #define largest_char 255 /* Largest character value. */ |
|
53 |
|
54 #define CTRL_CHAR(c) ((c) < control_character_threshold) |
|
55 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) |
|
56 |
|
57 #define CTRL(c) ((c) & control_character_mask) |
|
58 #define META(c) ((c) | meta_character_bit) |
|
59 |
|
60 #define UNMETA(c) ((c) & (~meta_character_bit)) |
|
61 #define UNCTRL(c) to_upper(((c)|control_character_bit)) |
|
62 |
|
63 /* Old versions |
|
64 #define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) |
|
65 #define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) |
|
66 #define digit_p(c) ((c) >= '0' && (c) <= '9') |
|
67 */ |
|
68 |
|
69 #define lowercase_p(c) (islower(c)) |
|
70 #define uppercase_p(c) (isupper(c)) |
|
71 #define digit_p(x) (isdigit (x)) |
|
72 |
|
73 #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c)) |
|
74 |
|
75 /* Old versions |
|
76 # define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c)) |
|
77 # define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c)) |
|
78 */ |
|
79 |
|
80 #ifndef to_upper |
|
81 # define to_upper(c) (islower(c) ? toupper(c) : (c)) |
|
82 # define to_lower(c) (isupper(c) ? tolower(c) : (c)) |
|
83 #endif |
|
84 |
|
85 #ifndef digit_value |
|
86 #define digit_value(x) ((x) - '0') |
|
87 #endif |
|
88 |
|
89 #ifndef NEWLINE |
|
90 #define NEWLINE '\n' |
|
91 #endif |
|
92 |
|
93 #ifndef RETURN |
|
94 #define RETURN CTRL('M') |
|
95 #endif |
|
96 |
|
97 #ifndef RUBOUT |
|
98 #define RUBOUT 0x7f |
|
99 #endif |
|
100 |
|
101 #ifndef TAB |
|
102 #define TAB '\t' |
|
103 #endif |
|
104 |
|
105 #ifdef ABORT_CHAR |
|
106 #undef ABORT_CHAR |
|
107 #endif |
|
108 #define ABORT_CHAR CTRL('G') |
|
109 |
|
110 #ifdef PAGE |
|
111 #undef PAGE |
|
112 #endif |
|
113 #define PAGE CTRL('L') |
|
114 |
|
115 #ifdef SPACE |
|
116 #undef SPACE |
|
117 #endif |
|
118 #define SPACE ' ' /* XXX - was 0x20 */ |
|
119 |
|
120 #ifdef ESC |
|
121 #undef ESC |
|
122 #endif |
|
123 |
|
124 #define ESC CTRL('[') |
|
125 |
1464
|
126 #ifdef __cplusplus |
|
127 } |
|
128 #endif |
|
129 |
1432
|
130 #endif /* _CHARDEFS_H */ |