Merge branch 'vim'
[vim_extended.git] / src / ascii.h
blobb920d41afd92b6d3d821ba93310f8430aa6669ea
1 /* vi:set ts=8 sts=4 sw=4:
3 * VIM - Vi IMproved by Bram Moolenaar
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 */
9 /*
10 * Definitions of various common control characters.
11 * For EBCDIC we have to use different values.
14 #ifndef EBCDIC
16 /* IF_EB(ASCII_constant, EBCDIC_constant) */
17 #define IF_EB(a, b) a
19 #define CharOrd(x) ((x) < 'a' ? (x) - 'A' : (x) - 'a')
20 #define CharOrdLow(x) ((x) - 'a')
21 #define CharOrdUp(x) ((x) - 'A')
22 #define ROT13(c, a) (((((c) - (a)) + 13) % 26) + (a))
24 #define NUL '\000'
25 #define BELL '\007'
26 #define BS '\010'
27 #define TAB '\011'
28 #define NL '\012'
29 #define NL_STR (char_u *)"\012"
30 #define FF '\014'
31 #define CAR '\015' /* CR is used by Mac OS X */
32 #define ESC '\033'
33 #define ESC_STR (char_u *)"\033"
34 #define ESC_STR_nc "\033"
35 #define DEL 0x7f
36 #define DEL_STR (char_u *)"\177"
37 #define CSI 0x9b /* Control Sequence Introducer */
38 #define CSI_STR "\233"
39 #define DCS 0x90 /* Device Control String */
40 #define STERM 0x9c /* String Terminator */
42 #define POUND 0xA3
44 #define Ctrl_chr(x) (TOUPPER_ASC(x) ^ 0x40) /* '?' -> DEL, '@' -> ^@, etc. */
45 #define Meta(x) ((x) | 0x80)
47 #define CTRL_F_STR "\006"
48 #define CTRL_H_STR "\010"
49 #define CTRL_V_STR "\026"
51 #define Ctrl_AT 0 /* @ */
52 #define Ctrl_A 1
53 #define Ctrl_B 2
54 #define Ctrl_C 3
55 #define Ctrl_D 4
56 #define Ctrl_E 5
57 #define Ctrl_F 6
58 #define Ctrl_G 7
59 #define Ctrl_H 8
60 #define Ctrl_I 9
61 #define Ctrl_J 10
62 #define Ctrl_K 11
63 #define Ctrl_L 12
64 #define Ctrl_M 13
65 #define Ctrl_N 14
66 #define Ctrl_O 15
67 #define Ctrl_P 16
68 #define Ctrl_Q 17
69 #define Ctrl_R 18
70 #define Ctrl_S 19
71 #define Ctrl_T 20
72 #define Ctrl_U 21
73 #define Ctrl_V 22
74 #define Ctrl_W 23
75 #define Ctrl_X 24
76 #define Ctrl_Y 25
77 #define Ctrl_Z 26
78 /* CTRL- [ Left Square Bracket == ESC*/
79 #define Ctrl_BSL 28 /* \ BackSLash */
80 #define Ctrl_RSB 29 /* ] Right Square Bracket */
81 #define Ctrl_HAT 30 /* ^ */
82 #define Ctrl__ 31
84 #else
86 /* EBCDIC */
88 /* IF_EB(ASCII_constant, EBCDIC_constant) */
89 #define IF_EB(a, b) b
92 * Finding the position in the alphabet is not straightforward in EBCDIC.
93 * There are gaps in the code table.
94 * 'a' + 1 == 'b', but: 'i' + 7 == 'j' and 'r' + 8 == 's'
96 #define CharOrd__(c) ((c) < ('j' - 'a') ? (c) : ((c) < ('s' - 'a') ? (c) - 7 : (c) - 7 - 8))
97 #define CharOrdLow(x) (CharOrd__((x) - 'a'))
98 #define CharOrdUp(x) (CharOrd__((x) - 'A'))
99 #define CharOrd(x) (isupper(x) ? CharOrdUp(x) : CharOrdLow(x))
101 #define EBCDIC_CHAR_ADD_(x) ((x) < 0?'a':(x)>25?'z':"abcdefghijklmnopqrstuvwxyz"[x])
102 #define EBCDIC_CHAR_ADD(c,s) (isupper(c) ? toupper(EBCDIC_CHAR_ADD_(CharOrdUp(c)+(s))) : EBCDIC_CHAR_ADD_(CharOrdLow(c)+(s)))
104 #define R13_(c) ("abcdefghijklmnopqrstuvwxyz"[((c) + 13) % 26])
105 #define ROT13(c, a) (isupper(c) ? toupper(R13_(CharOrdUp(c))) : R13_(CharOrdLow(c)))
107 #define NUL '\000'
108 #define BELL '\x2f'
109 #define BS '\x16'
110 #define TAB '\x05'
111 #define NL '\x15'
112 #define NL_STR (char_u *)"\x15"
113 #define FF '\x0C'
114 #define CAR '\x0D'
115 #define ESC '\x27'
116 #define ESC_STR (char_u *)"\x27"
117 #define ESC_STR_nc "\x27"
118 #define DEL 0x07
119 #define DEL_STR (char_u *)"\007"
120 /* TODO: EBCDIC Code page dependent (here 1047) */
121 #define CSI 0x9b /* Control Sequence Introducer */
122 #define CSI_STR "\233"
123 #define DCS 0x90 /* Device Control String */
124 #define STERM 0x9c /* String Terminator */
126 #define POUND '£'
128 #define CTRL_F_STR "\056"
129 #define CTRL_H_STR "\026"
130 #define CTRL_V_STR "\062"
132 #define Ctrl_AT 0x00 /* @ */
133 #define Ctrl_A 0x01
134 #define Ctrl_B 0x02
135 #define Ctrl_C 0x03
136 #define Ctrl_D 0x37
137 #define Ctrl_E 0x2D
138 #define Ctrl_F 0x2E
139 #define Ctrl_G 0x2F
140 #define Ctrl_H 0x16
141 #define Ctrl_I 0x05
142 #define Ctrl_J 0x15
143 #define Ctrl_K 0x0B
144 #define Ctrl_L 0x0C
145 #define Ctrl_M 0x0D
146 #define Ctrl_N 0x0E
147 #define Ctrl_O 0x0F
148 #define Ctrl_P 0x10
149 #define Ctrl_Q 0x11
150 #define Ctrl_R 0x12
151 #define Ctrl_S 0x13
152 #define Ctrl_T 0x3C
153 #define Ctrl_U 0x3D
154 #define Ctrl_V 0x32
155 #define Ctrl_W 0x26
156 #define Ctrl_X 0x18
157 #define Ctrl_Y 0x19
158 #define Ctrl_Z 0x3F
159 /* CTRL- [ Left Square Bracket == ESC*/
160 #define Ctrl_RSB 0x1D /* ] Right Square Bracket */
161 #define Ctrl_BSL 0x1C /* \ BackSLash */
162 #define Ctrl_HAT 0x1E /* ^ */
163 #define Ctrl__ 0x1F
165 #define Ctrl_chr(x) (CtrlTable[(x)])
166 extern char CtrlTable[];
168 #define CtrlChar(x) ((x < ' ') ? CtrlCharTable[(x)] : 0)
169 extern char CtrlCharTable[];
171 #define MetaChar(x) ((x < ' ') ? MetaCharTable[(x)] : 0)
172 extern char MetaCharTable[];
174 #endif /* defined EBCDIC */
177 * Character that separates dir names in a path.
178 * For MS-DOS, WIN32 and OS/2 we use a backslash. A slash mostly works
179 * fine, but there are places where it doesn't (e.g. in a command name).
180 * For Acorn we use a dot.
182 #ifdef BACKSLASH_IN_FILENAME
183 # define PATHSEP psepc
184 # define PATHSEPSTR pseps
185 #else
186 # ifdef RISCOS
187 # define PATHSEP '.'
188 # define PATHSEPSTR "."
189 # else
190 # define PATHSEP '/'
191 # define PATHSEPSTR "/"
192 # endif
193 #endif