The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
ZXChars.h
Go to the documentation of this file.
1
2/* **************************************************************************/
24#ifndef ZXCHARS
25#define ZXCHARS
26
27#include <string>
29
30namespace zxeco
31{
32
33/*****************************************************************************
34*
35* Constants
36*
37******************************************************************************/
38
43constexpr uint8_t CHRSPC = 32;
44constexpr uint8_t CHRCOMMA = 6;
45constexpr uint8_t CHREDIT = 7;
46constexpr uint8_t CHRLEFT = 8;
47constexpr uint8_t CHRRIGHT = 9;
48constexpr uint8_t CHRDOWN = 10;
49constexpr uint8_t CHRUP = 11;
50constexpr uint8_t CHRDELETE = 12;
51constexpr uint8_t CHRENTER = 13;
52constexpr uint8_t CHRNUM = 14;
53constexpr uint8_t CHRINK = 16;
54constexpr uint8_t CHRPAPER = 17;
55constexpr uint8_t CHRFLASH = 18;
56constexpr uint8_t CHRBRIGHT = 19;
57constexpr uint8_t CHRINVERSE = 20;
58constexpr uint8_t CHROVER = 21;
59constexpr uint8_t CHRAT = 22;
60constexpr uint8_t CHRTAB = 23;
61constexpr uint8_t CHRFIRST = CHRSPC;
62constexpr uint8_t CHRQUOTE = 34;
63constexpr uint8_t CHR0 = 0x30;
64constexpr uint8_t CHRa = 0x61;
65constexpr uint8_t CHRz = 0x7a;
66constexpr uint8_t CHRA = 0x41;
67constexpr uint8_t CHRZ = 0x5a;
68constexpr uint8_t CHRINVALID = 63;
69constexpr uint8_t CHRLAST = 0x7F;
70constexpr uint8_t CHRCOPYRIGHT = 0x7F;
71constexpr uint8_t CHRPOUND = 0x60;
72constexpr uint8_t CHRFIRSTGB = 0x80;
73constexpr uint8_t CHRLASTGB = 0x8f;
74constexpr uint8_t CHRFIRSTUDG = 0x90;
75constexpr uint8_t CHRLASTUDG = 0xa4;
76constexpr uint8_t CHRFIRSTTOKEN = 0xa5;
79constexpr char ISCHRCTRL(uint8_t c) noexcept
80 { return( ((c==CHRCOMMA)||(c==CHRENTER)||(c==CHRDELETE)||
81 (c==CHRLEFT)||(c==CHRRIGHT)||(c==CHRDOWN)||(c==CHRUP)) ? 0:
82 ( ((c==CHRINK)||(c==CHRPAPER)||(c==CHRFLASH)||(c==CHRBRIGHT)||
83 (c==CHRINVERSE)||(c==CHROVER)) ? 1:
84 ( ((c==CHRTAB) || (c==CHRAT)) ? 2 : -1 )
85 )
86 ); }
88
92char ISCHRCTRLALL(uint8_t c) noexcept;
94
96constexpr bool ISPRINTCHR(uint8_t c) noexcept
97 { return( (c >= CHRFIRST) ); }
99
102constexpr bool ISGRAPHICBLOCK(uint8_t c) noexcept
103 { return((c >= CHRFIRSTGB) && (c <= CHRLASTGB)); }
105
106constexpr bool ISUDG(uint8_t c) noexcept
107 { return((c >= CHRFIRSTUDG) && (c <= CHRLASTUDG)); }
109
110constexpr bool ISTOKEN(uint8_t c) noexcept
111 { return(c >= CHRFIRSTTOKEN); }
113
114
115
116/*****************************************************************************
117*
118* Function: zxString
119*
120******************************************************************************/
123inline std::string zxString(uint8_t cc)
124 { return(std::string(1,cc)); }
127inline std::string zxString(uint8_t cc, uint8_t arg1)
128 { return(std::string(1,cc) + static_cast<char>(arg1)); }
131inline std::string zxString(uint8_t cc, uint8_t arg1, uint8_t arg2)
132 { return(std::string(1,cc) + static_cast<char>(arg1) +
133 static_cast<char>(arg2)); }
134
135
136/*****************************************************************************
137*
138* Function: ctrlString
139*
140******************************************************************************/
141
142const std::string & ctrlString(uint8_t c);
144
147/*****************************************************************************
148*
149* Function: nonCtrlString
150*
151******************************************************************************/
152
153std::string nonCtrlString(const std::string & txt, char who = 'A');
155
163} // end namespace zxeco
164
165#endif
166 // ZXChars
168
const std::string & ctrlString(uint8_t c)
Return a string representing the control code C.
std::string zxString(uint8_t cc)
Return a string composed of the ZX control code CC (no arguments).
Definition: ZXChars.h:121
std::string nonCtrlString(const std::string &txt, char who='A')
Return a version of TXT without control codes.
The main namespace of the library, that spans across all the zx modules.
Definition: ZXChars.h:31
constexpr uint8_t CHRDELETE
delete (control code)
Definition: ZXChars.h:50
constexpr uint8_t CHRLAST
Last of the printable chars.
Definition: ZXChars.h:69
constexpr uint8_t CHRz
last lower alpha
Definition: ZXChars.h:65
constexpr uint8_t CHRLASTGB
last graphic-block char
Definition: ZXChars.h:73
constexpr uint8_t CHRTAB
tab (control code; 2 args, 2nd is ignored)
Definition: ZXChars.h:60
constexpr uint8_t CHRPOUND
Pounds.
Definition: ZXChars.h:71
constexpr uint8_t CHRAT
at (control code; 2 args)
Definition: ZXChars.h:59
constexpr bool ISGRAPHICBLOCK(uint8_t c) noexcept
Return TRUE if C is a graphic block character. *‍/.
Definition: ZXChars.h:100
constexpr uint8_t CHRZ
last upper alpha
Definition: ZXChars.h:67
constexpr char ISCHRCTRL(uint8_t c) noexcept
Whether C is a control code with results if printed.
Definition: ZXChars.h:79
constexpr uint8_t CHREDIT
edit (control code)
Definition: ZXChars.h:45
constexpr uint8_t CHRDOWN
down (control code)
Definition: ZXChars.h:48
constexpr uint8_t CHRFIRSTGB
first graphic-block char
Definition: ZXChars.h:72
constexpr uint8_t CHRNUM
Preffix of numeric value.
Definition: ZXChars.h:52
constexpr uint8_t CHRRIGHT
right (control code)
Definition: ZXChars.h:47
constexpr uint8_t CHRCOPYRIGHT
Copyright.
Definition: ZXChars.h:70
constexpr uint8_t CHRFIRST
first printable char
Definition: ZXChars.h:61
constexpr uint8_t CHRCOMMA
comma (control code)
Definition: ZXChars.h:44
constexpr uint8_t CHRa
first lower alpha
Definition: ZXChars.h:64
constexpr uint8_t CHR0
first digit
Definition: ZXChars.h:63
constexpr uint8_t CHRLASTUDG
last UDG char
Definition: ZXChars.h:75
constexpr uint8_t CHRPAPER
paper (control code; 1 arg)
Definition: ZXChars.h:54
constexpr uint8_t CHRA
first upper alpha
Definition: ZXChars.h:66
constexpr bool ISPRINTCHR(uint8_t c) noexcept
Whether C is a printable char.
Definition: ZXChars.h:95
constexpr uint8_t CHROVER
over (control code; 1 arg)
Definition: ZXChars.h:58
constexpr bool ISTOKEN(uint8_t c) noexcept
Return TRUE if C is a token. *‍/.
Definition: ZXChars.h:108
constexpr uint8_t CHRENTER
enter (control code)
Definition: ZXChars.h:51
constexpr uint8_t CHRINVERSE
inverse (control code; 1 arg)
Definition: ZXChars.h:57
constexpr uint8_t CHRFLASH
flash (control code; 1 arg)
Definition: ZXChars.h:55
constexpr uint8_t CHRSPC
space
Definition: ZXChars.h:43
constexpr uint8_t CHRINVALID
invalid mark char
Definition: ZXChars.h:68
constexpr uint8_t CHRINK
ink (control code; 1 arg)
Definition: ZXChars.h:53
char ISCHRCTRLALL(uint8_t c) noexcept
The same as ISCHRCTRL but including those that do not affect printing.
constexpr uint8_t CHRUP
up (control code)
Definition: ZXChars.h:49
constexpr uint8_t CHRFIRSTUDG
first UDG char
Definition: ZXChars.h:74
constexpr uint8_t CHRFIRSTTOKEN
first token char
Definition: ZXChars.h:76
constexpr uint8_t CHRBRIGHT
bright (control code; 1 arg)
Definition: ZXChars.h:56
constexpr bool ISUDG(uint8_t c) noexcept
Return TRUE if C is a UDG. *‍/.
Definition: ZXChars.h:104
constexpr uint8_t CHRQUOTE
double quote char
Definition: ZXChars.h:62
constexpr uint8_t CHRLEFT
left (control code)
Definition: ZXChars.h:46