diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 02:45:56 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 02:54:09 +0100 |
commit | 2789e5da50987b908a4aa5758a17c86570d94d63 (patch) | |
tree | a60f11f3b82ff3d7ff0a07bf576f851f68165266 /src/sciteco.h | |
parent | 4aa51b925f5364511173c74277b78d2984e37218 (diff) | |
download | sciteco-2789e5da50987b908a4aa5758a17c86570d94d63.tar.gz |
cleaned up usage of the escape control character: introduced CTL_KEY_ESC and CTL_KEY_ESC_STR
* the reason for the CTL_KEY() macro is to get the control character
resulting from a CTRL+Key press -- at least this is how SciTECO
presents these key presses.
It is also a macro and may be resolved to a constant expression,
so it can be used in switch-case statements.
Sometimes it is clearer to use standard C escape sequences (like '\t').
* CTL_KEY('[') for escape is hard to read, so I always used '\x1B' which
is even more cryptic.
Diffstat (limited to 'src/sciteco.h')
-rw-r--r-- | src/sciteco.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/sciteco.h b/src/sciteco.h index 53131dc..c4395c1 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -49,15 +49,28 @@ namespace Flags { extern sig_atomic_t sigint_occurred; -/* - * for sentinels: NULL might not be defined as a +/** + * For sentinels: NULL might not be defined as a * pointer type (LLVM/CLang) */ #define NIL ((void *)0) +/** true if C is a control character */ #define IS_CTL(C) ((C) < ' ') +/** ASCII character to echo control character C */ #define CTL_ECHO(C) ((C) | 0x40) +/** + * Control character of ASCII C, i.e. + * control character corresponding to CTRL+<C> keypress. + */ #define CTL_KEY(C) ((C) & ~0x40) +/** + * Control character of the escape key. + * Equivalent to CTL_KEY('[') + */ +#define CTL_KEY_ESC 27 +/** String containing the escape character */ +#define CTL_KEY_ESC_STR "\x1B" #define SUCCESS (-1) #define FAILURE (0) |