Interpret space as Unicode by default, add a flag to make it symbolic instead
This commit is contained in:
parent
ba0c32e8d8
commit
a71f68dd57
2
demo.c
2
demo.c
|
@ -30,7 +30,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
tk = termkey_new(0, 0);
|
||||
tk = termkey_new(0, TERMKEY_FLAG_SPACESYMBOL);
|
||||
|
||||
if(!tk) {
|
||||
fprintf(stderr, "Cannot allocate termkey instance\n");
|
||||
|
|
|
@ -447,7 +447,7 @@ static void emit_codepoint(TermKey *tk, long codepoint, TermKeyKey *key)
|
|||
key->type = TERMKEY_TYPE_KEYSYM;
|
||||
}
|
||||
}
|
||||
else if(codepoint == 0x20 && !(tk->flags & TERMKEY_FLAG_NOINTERPRET)) {
|
||||
else if(codepoint == 0x20 && (tk->flags & TERMKEY_FLAG_SPACESYMBOL)) {
|
||||
// ASCII space
|
||||
key->type = TERMKEY_TYPE_KEYSYM;
|
||||
key->code.sym = TERMKEY_SYM_SPACE;
|
||||
|
|
|
@ -133,11 +133,12 @@ typedef struct {
|
|||
typedef struct _TermKey TermKey;
|
||||
|
||||
enum {
|
||||
TERMKEY_FLAG_NOINTERPRET = 1 << 0, // Do not interpret C0//G1 codes if possible
|
||||
TERMKEY_FLAG_NOINTERPRET = 1 << 0, // Do not interpret C0//DEL codes if possible
|
||||
TERMKEY_FLAG_CONVERTKP = 1 << 1, // Convert KP codes to regular keypresses
|
||||
TERMKEY_FLAG_RAW = 1 << 2, // Input is raw bytes, not UTF-8
|
||||
TERMKEY_FLAG_UTF8 = 1 << 3, // Input is definitely UTF-8
|
||||
TERMKEY_FLAG_NOTERMIOS = 1 << 4, // Do not make initial termios calls on construction
|
||||
TERMKEY_FLAG_SPACESYMBOL = 1 << 5, // Space is symbolic rather than Unicode
|
||||
};
|
||||
|
||||
void termkey_check_version(int major, int minor);
|
||||
|
|
|
@ -38,6 +38,9 @@ Ignore locale settings; force UTF-8 recombining on. This flag overrides \fBTERMK
|
|||
Even if the terminal file descriptor \fIfd\fP represents a
|
||||
.SM TTY
|
||||
device, do not call the \fBtcsetattr\fP() \fBtermios\fP function on it to set it to canonical input mode.
|
||||
.TP
|
||||
.B TERMKEY_FLAG_SPACESYMBOL
|
||||
Report space as being a symbolic key rather than a Unicode codepoint.
|
||||
.PP
|
||||
When the constructor is invoked, it attempts to detect if the current locale is UTF-8 aware or not, and sets either the \fBTERMKEY_FLAG_UTF8\fP or \fBTERMKEY_FLAG_RAW\fP flag. One of these two bits will always be in effect. The current flags in effect can be obtained by \fBtermkey_get_flags\fP().
|
||||
.SH VERSION CHECK MACRO
|
||||
|
|
Loading…
Reference in New Issue