1 /*
2     This file is part of GNU APL, a free implementation of the
3     ISO/IEC Standard 13751, "Programming Language APL, Extended"
4 
5     Copyright (C) 2008-2015  Dr. Jürgen Sauermann
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __UNICODE_HH_DEFINED__
22 #define __UNICODE_HH_DEFINED__
23 
24 #ifndef __COMMON_HH_DEFINED__
25 # error This file shall NOT be #included directly, but by #including Common.hh
26 #endif
27 
28 #include "../config.h"
29 
30 /// One Unicode character
31 enum Unicode
32 {
33 #define char_def(n, u, t, f, p) UNI_ ## n = u,
34 #define char_df1(n, u, t, f, p) UNI_ ## n = u,
35 #include "Avec.def"
36 
37    Unicode_0       = 0,            ///< End of unicode string
38    Invalid_Unicode = 0x55AA55AA,   ///< An invalid Unicode.
39 
40    // cursor control characters for line editing
41    //
42    UNI_EOF         = -1,
43    UNI_CursorUp    = -2,
44    UNI_CursorDown  = -3,
45    UNI_CursorRight = -4,
46    UNI_CursorLeft  = -5,
47    UNI_CursorEnd   = -6,
48    UNI_CursorHome  = -7,
49    UNI_InsertMode  = -8,
50 
51    /// internal pad characters - will be removed before printout
52 #ifdef VISIBLE_MARKERS_WANTED
53    UNI_iPAD_U2    = UNI_PAD_U2,
54    UNI_iPAD_U3    = UNI_PAD_U3,
55    UNI_iPAD_U1    = UNI_PAD_U1,
56 
57    UNI_iPAD_U0    = UNI_PAD_U0,
58    UNI_iPAD_U4    = UNI_PAD_U4,
59    UNI_iPAD_U5    = UNI_PAD_U5,
60    UNI_iPAD_U6    = UNI_PAD_U6,
61    UNI_iPAD_U7    = UNI_PAD_U7,
62    UNI_iPAD_U8    = UNI_PAD_U8,
63    UNI_iPAD_U9    = UNI_PAD_U9,
64 
65    UNI_iPAD_L0    = UNI_PAD_L0,
66    UNI_iPAD_L1    = UNI_PAD_L1,
67    UNI_iPAD_L2    = UNI_PAD_L2,
68    UNI_iPAD_L3    = UNI_PAD_L3,
69    UNI_iPAD_L4    = UNI_PAD_L4,
70    UNI_iPAD_L5    = UNI_PAD_L5,
71    UNI_iPAD_L9    = UNI_PAD_L9,
72 #else
73    UNI_iPAD_U2    = 0xEEEE,
74    UNI_iPAD_U3    = 0xEEEF,
75    UNI_iPAD_U1    = 0xEEF0,
76 
77    UNI_iPAD_U0    = 0xEEF1,
78    UNI_iPAD_U4    = 0xEEF2,
79    UNI_iPAD_U5    = 0xEEF3,
80    UNI_iPAD_U6    = 0xEEF4,
81    UNI_iPAD_U7    = 0xEEF5,
82    UNI_iPAD_U8    = 0xEEF6,
83    UNI_iPAD_U9    = 0xEEF7,
84 
85    UNI_iPAD_L0    = 0xEEF8,
86    UNI_iPAD_L1    = 0xEEF9,
87    UNI_iPAD_L2    = 0xEEFA,
88    UNI_iPAD_L3    = 0xEEFB,
89    UNI_iPAD_L4    = 0xEEFC,
90    UNI_iPAD_L5    = 0xEEFD,
91    UNI_iPAD_L9    = 0xEEFE,
92 #endif
93 };
94 
95 /// value 0-15 of hex digit, or -1 if uni not in "023456789ABCDEFabcdef"
96 extern int nibble(Unicode uni);
97 
98 /// value 0-63 of base64 digit, or -1 if uni not base64 (RFC 4648)
99 extern int sixbit(Unicode uni);
100 
101 inline void
Hswap(Unicode & u1,Unicode & u2)102 Hswap(Unicode & u1, Unicode & u2)
103 { const Unicode tmp = u1;   u1 = u2;   u2 = tmp; }
104 
105 #endif // __UNICODE_HH_DEFINED__
106