blob: e824822b30add54350df6f3baebbcde140efb622 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001/* vi:set ts=8 sts=4 sw=4:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
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 */
8
9/*
10 * Definitions of various common control characters.
11 * For EBCDIC we have to use different values.
12 */
13
14#ifndef EBCDIC
15
16/* IF_EB(ASCII_constant, EBCDIC_constant) */
17#define IF_EB(a, b) a
18
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))
23
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 */
41
42#define POUND 0xA3
43
44#define Ctrl_chr(x) (TOUPPER_ASC(x) ^ 0x40) /* '?' -> DEL, '@' -> ^@, etc. */
45#define Meta(x) ((x) | 0x80)
46
47#define CTRL_F_STR "\006"
48#define CTRL_H_STR "\010"
49#define CTRL_V_STR "\026"
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
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
Bram Moolenaar7fae6362005-06-30 22:06:41 +000078 /* CTRL- [ Left Square Bracket == ESC*/
Bram Moolenaar071d4272004-06-13 20:20:40 +000079#define Ctrl_BSL 28 /* \ BackSLash */
80#define Ctrl_RSB 29 /* ] Right Square Bracket */
81#define Ctrl_HAT 30 /* ^ */
82#define Ctrl__ 31
83
84#else
85
86/* EBCDIC */
87
88/* IF_EB(ASCII_constant, EBCDIC_constant) */
89#define IF_EB(a, b) b
90
91/*
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'
95 */
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))
100
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)))
103
104#define R13_(c) ("abcdefghijklmnopqrstuvwxyz"[((c) + 13) % 26])
105#define ROT13(c, a) (isupper(c) ? toupper(R13_(CharOrdUp(c))) : R13_(CharOrdLow(c)))
106
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 */
125
Bram Moolenaard3184b52011-09-02 14:18:20 +0200126#define POUND '\xA3'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127
128#define CTRL_F_STR "\056"
129#define CTRL_H_STR "\026"
130#define CTRL_V_STR "\062"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131
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
Bram Moolenaar7fae6362005-06-30 22:06:41 +0000159 /* CTRL- [ Left Square Bracket == ESC*/
Bram Moolenaar071d4272004-06-13 20:20:40 +0000160#define Ctrl_RSB 0x1D /* ] Right Square Bracket */
161#define Ctrl_BSL 0x1C /* \ BackSLash */
162#define Ctrl_HAT 0x1E /* ^ */
163#define Ctrl__ 0x1F
164
165#define Ctrl_chr(x) (CtrlTable[(x)])
166extern char CtrlTable[];
167
168#define CtrlChar(x) ((x < ' ') ? CtrlCharTable[(x)] : 0)
169extern char CtrlCharTable[];
170
171#define MetaChar(x) ((x < ' ') ? MetaCharTable[(x)] : 0)
172extern char MetaCharTable[];
173
174#endif /* defined EBCDIC */
175
176/*
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).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000180 * For Acorn we use a dot.
181 */
182#ifdef BACKSLASH_IN_FILENAME
183# define PATHSEP psepc
184# define PATHSEPSTR pseps
185#else
Bram Moolenaare60acc12011-05-10 16:41:25 +0200186# define PATHSEP '/'
187# define PATHSEPSTR "/"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000188#endif