Get rid of most block comments
They're rather difficult to maintain.
This commit is contained in:
parent
77878abe90
commit
828f03a063
|
@ -34,7 +34,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
struct pollfd fd;
|
||||
fd.fd = STDIN_FILENO; /* the file descriptor we passed to termo_new() */
|
||||
fd.fd = STDIN_FILENO; // the file descriptor we passed to termo_new()
|
||||
fd.events = POLLIN;
|
||||
|
||||
termo_result_t ret;
|
||||
|
|
54
driver-csi.c
54
driver-csi.c
|
@ -19,9 +19,9 @@ typedef termo_result_t (*csi_handler_fn)
|
|||
(termo_t *tk, termo_key_t *key, int cmd, long *arg, int args);
|
||||
static csi_handler_fn csi_handlers[64];
|
||||
|
||||
/*
|
||||
* Handler for CSI/SS3 cmd keys
|
||||
*/
|
||||
//
|
||||
// Handler for CSI/SS3 cmd keys
|
||||
//
|
||||
|
||||
static struct keyinfo csi_ss3s[64];
|
||||
|
||||
|
@ -67,9 +67,9 @@ register_csi_ss3 (termo_type_t type, termo_sym_t sym, unsigned char cmd)
|
|||
register_csi_ss3_full (type, sym, 0, 0, cmd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for SS3 keys with kpad alternate representations
|
||||
*/
|
||||
//
|
||||
// Handler for SS3 keys with kpad alternate representations
|
||||
//
|
||||
|
||||
static void
|
||||
register_ss3kpalt (termo_type_t type, termo_sym_t sym,
|
||||
|
@ -86,11 +86,11 @@ register_ss3kpalt (termo_type_t type, termo_sym_t sym,
|
|||
ss3_kpalts[cmd - 0x40] = kpalt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for CSI number ~ function keys
|
||||
*/
|
||||
//
|
||||
// Handler for CSI number ~ function keys
|
||||
//
|
||||
|
||||
/* This value must be increased if more CSI function keys are added */
|
||||
// This value must be increased if more CSI function keys are added
|
||||
static struct keyinfo csifuncs[35];
|
||||
#define NCSIFUNCS ((long) (sizeof csifuncs / sizeof csifuncs[0]))
|
||||
|
||||
|
@ -146,9 +146,9 @@ register_csifunc (termo_type_t type, termo_sym_t sym, int number)
|
|||
csi_handlers['~' - 0x40] = &handle_csifunc;
|
||||
}
|
||||
|
||||
/*
|
||||
* URxvt seems to emit this instead of ~ when holding Ctrl
|
||||
*/
|
||||
//
|
||||
// URxvt seems to emit this instead of ~ when holding Ctrl
|
||||
//
|
||||
|
||||
static termo_result_t
|
||||
handle_csi_caret (termo_t *tk,
|
||||
|
@ -168,9 +168,9 @@ handle_csi_caret (termo_t *tk,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for CSI u extended Unicode keys
|
||||
*/
|
||||
//
|
||||
// Handler for CSI u extended Unicode keys
|
||||
//
|
||||
|
||||
static termo_result_t
|
||||
handle_csi_u (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
|
||||
|
@ -195,10 +195,10 @@ handle_csi_u (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for CSI M / CSI m mouse events in SGR and rxvt encodings
|
||||
* Note: This does not handle X10 encoding
|
||||
*/
|
||||
//
|
||||
// Handler for CSI M / CSI m mouse events in SGR and rxvt encodings
|
||||
// Note: This does not handle X10 encoding
|
||||
//
|
||||
|
||||
static termo_result_t
|
||||
handle_csi_m (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
|
||||
|
@ -302,10 +302,10 @@ termo_interpret_mouse (termo_t *tk, const termo_key_t *key,
|
|||
return TERMO_RES_KEY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for CSI ? R position reports
|
||||
* A plain CSI R with no arguments is probably actually <F3>
|
||||
*/
|
||||
//
|
||||
// Handler for CSI ? R position reports
|
||||
// A plain CSI R with no arguments is probably actually <F3>
|
||||
//
|
||||
|
||||
static termo_result_t
|
||||
handle_csi_R (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
|
||||
|
@ -338,9 +338,9 @@ termo_interpret_position (termo_t *tk,
|
|||
return TERMO_RES_KEY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for CSI $y mode status reports
|
||||
*/
|
||||
//
|
||||
// Handler for CSI $y mode status reports
|
||||
//
|
||||
|
||||
static termo_result_t
|
||||
handle_csi_y (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
|
||||
|
|
26
driver-ti.c
26
driver-ti.c
|
@ -16,11 +16,10 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* To be efficient at lookups, we store the byte sequence => keyinfo mapping
|
||||
* in a trie. This avoids a slow linear search through a flat list of
|
||||
* sequences. Because it is likely most nodes will be very sparse, we optimise
|
||||
* vector to store an extent map after the database is loaded.
|
||||
*/
|
||||
// To be efficient at lookups, we store the byte sequence => keyinfo mapping
|
||||
// in a trie. This avoids a slow linear search through a flat list of
|
||||
// sequences. Because it is likely most nodes will be very sparse, we optimise
|
||||
// vector to store an extent map after the database is loaded.
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -46,8 +45,8 @@ trie_node_key_t;
|
|||
typedef struct trie_node_array
|
||||
{
|
||||
trie_nodetype_t type;
|
||||
unsigned char min, max; /* INCLUSIVE endpoints of the extent range */
|
||||
trie_node_t *arr[]; /* dynamic size at allocation time */
|
||||
unsigned char min, max; // INCLUSIVE endpoints of the extent range
|
||||
trie_node_t *arr[]; // dynamic size at allocation time
|
||||
}
|
||||
trie_node_array_t;
|
||||
|
||||
|
@ -190,8 +189,8 @@ load_terminfo (termo_ti_t *ti, const char *term)
|
|||
const char *name = unibi_name_str (i);
|
||||
const char *value = unibi_get_str (unibi, i);
|
||||
#else
|
||||
/* Have to cast away the const. But it's OK - we know terminfo won't
|
||||
* really modify term */
|
||||
// Have to cast away the const. But it's OK - we know terminfo won't
|
||||
// really modify term
|
||||
int err;
|
||||
if (setupterm ((char *) term, 1, &err) != OK)
|
||||
return false;
|
||||
|
@ -262,10 +261,9 @@ load_terminfo (termo_ti_t *ti, const char *term)
|
|||
}
|
||||
}
|
||||
|
||||
/* Take copies of these terminfo strings, in case we build multiple termo
|
||||
* instances for multiple different termtypes, and it's different by the
|
||||
* time we want to use it
|
||||
*/
|
||||
// Take copies of these terminfo strings, in case we build multiple termo
|
||||
// instances for multiple different termtypes, and it's different by the
|
||||
// time we want to use it
|
||||
#ifdef HAVE_UNIBILIUM
|
||||
const char *keypad_xmit = unibi_get_str (unibi, unibi_pkey_xmit);
|
||||
#endif
|
||||
|
@ -452,7 +450,7 @@ static struct func
|
|||
}
|
||||
funcs[] =
|
||||
{
|
||||
/* THIS LIST MUST REMAIN SORTED! */
|
||||
// THIS LIST MUST REMAIN SORTED!
|
||||
{ "backspace", TERMO_TYPE_KEYSYM, TERMO_SYM_BACKSPACE, 0 },
|
||||
{ "begin", TERMO_TYPE_KEYSYM, TERMO_SYM_BEGIN, 0 },
|
||||
{ "beg", TERMO_TYPE_KEYSYM, TERMO_SYM_BEGIN, 0 },
|
||||
|
|
76
termo.c
76
termo.c
|
@ -119,7 +119,7 @@ keynames[] =
|
|||
#define CHARAT(i) (tk->buffer[tk->buffstart + (i)])
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Some internal deubgging functions */
|
||||
// Some internal deubgging functions
|
||||
|
||||
static void
|
||||
print_buffer (termo_t *tk)
|
||||
|
@ -208,9 +208,8 @@ res2str (termo_result_t res)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Similar to snprintf(str, size, "%s", src) except it turns CamelCase into
|
||||
* space separated values
|
||||
*/
|
||||
// Similar to snprintf(str, size, "%s", src) except it turns CamelCase into
|
||||
// space separated values
|
||||
static int
|
||||
snprint_cameltospaces (char *str, size_t size, const char *src)
|
||||
{
|
||||
|
@ -230,8 +229,8 @@ snprint_cameltospaces (char *str, size_t size, const char *src)
|
|||
}
|
||||
str[l] = 0;
|
||||
|
||||
/* For consistency with snprintf, return the number of bytes that would have
|
||||
* been written, excluding '\0' */
|
||||
// For consistency with snprintf, return the number of bytes that would
|
||||
// have been written, excluding '\0'
|
||||
for (; *src; src++)
|
||||
{
|
||||
if (isupper (*src) && prev_lower)
|
||||
|
@ -242,11 +241,10 @@ snprint_cameltospaces (char *str, size_t size, const char *src)
|
|||
return l;
|
||||
}
|
||||
|
||||
/* Similar to strcmp(str, strcamel, n) except that:
|
||||
* it compares CamelCase in strcamel with space separated values in str;
|
||||
* it takes char**s and updates them
|
||||
* n counts bytes of strcamel, not str
|
||||
*/
|
||||
// Similar to strcmp(str, strcamel, n) except that:
|
||||
// it compares CamelCase in strcamel with space separated values in str;
|
||||
// it takes char**s and updates them
|
||||
// n counts bytes of strcamel, not str
|
||||
static int
|
||||
strpncmp_camel (const char **strp, const char **strcamelp, size_t n)
|
||||
{
|
||||
|
@ -285,7 +283,7 @@ termo_alloc (void)
|
|||
if (!tk)
|
||||
return NULL;
|
||||
|
||||
/* Default all the object fields but don't allocate anything */
|
||||
// Default all the object fields but don't allocate anything
|
||||
|
||||
tk->fd = -1;
|
||||
tk->flags = 0;
|
||||
|
@ -294,12 +292,12 @@ termo_alloc (void)
|
|||
tk->buffer = NULL;
|
||||
tk->buffstart = 0;
|
||||
tk->buffcount = 0;
|
||||
tk->buffsize = 256; /* bytes */
|
||||
tk->buffsize = 256; // bytes
|
||||
tk->hightide = 0;
|
||||
|
||||
tk->restore_termios_valid = false;
|
||||
|
||||
tk->waittime = 50; /* msec */
|
||||
tk->waittime = 50; // msec
|
||||
|
||||
tk->is_closed = false;
|
||||
tk->is_started = false;
|
||||
|
@ -497,14 +495,14 @@ termo_start (termo_t *tk)
|
|||
termios.c_cc[VTIME] = 0;
|
||||
|
||||
if (tk->flags & TERMO_FLAG_CTRLC)
|
||||
/* want no signal keys at all, so just disable ISIG */
|
||||
// want no signal keys at all, so just disable ISIG
|
||||
termios.c_lflag &= ~ISIG;
|
||||
else
|
||||
{
|
||||
/* Disable ^\ == VQUIT and ^D == VSUSP but leave ^C as SIGINT */
|
||||
// Disable ^\ == VQUIT and ^D == VSUSP but leave ^C as SIGINT
|
||||
termios.c_cc[VQUIT] = _POSIX_VDISABLE;
|
||||
termios.c_cc[VSUSP] = _POSIX_VDISABLE;
|
||||
/* Some OSes have ^Y == VDSUSP */
|
||||
// Some OSes have ^Y == VDSUSP
|
||||
#ifdef VDSUSP
|
||||
termios.c_cc[VDSUSP] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
@ -626,8 +624,8 @@ termo_set_buffer_size (termo_t *tk, size_t size)
|
|||
size_t
|
||||
termo_get_buffer_remaining (termo_t *tk)
|
||||
{
|
||||
/* Return the total number of free bytes in the buffer,
|
||||
* because that's what is available to the user. */
|
||||
// Return the total number of free bytes in the buffer,
|
||||
// because that's what is available to the user.
|
||||
return tk->buffsize - tk->buffcount;
|
||||
}
|
||||
|
||||
|
@ -667,7 +665,7 @@ fill_multibyte (termo_t *tk, termo_key_t *key)
|
|||
return;
|
||||
}
|
||||
|
||||
// Append a null character, as it wasn't port of the input
|
||||
// Append a null character, as it wasn't part of the input
|
||||
key->multibyte[output] = 0;
|
||||
}
|
||||
|
||||
|
@ -732,12 +730,11 @@ emit_codepoint (termo_t *tk, uint32_t codepoint, termo_key_t *key)
|
|||
if (!key->code.sym)
|
||||
{
|
||||
key->type = TERMO_TYPE_KEY;
|
||||
/* Generically modified Unicode ought not report the SHIFT state,
|
||||
* or else we get into complications trying to report Shift-; vs :
|
||||
* and so on... In order to be able to represent Ctrl-Shift-A as
|
||||
* CTRL modified unicode A, we need to call Ctrl-A simply 'a',
|
||||
* lowercase
|
||||
*/
|
||||
// Generically modified Unicode ought not report the SHIFT state,
|
||||
// or else we get into complications trying to report Shift-; vs :
|
||||
// and so on... In order to be able to represent Ctrl-Shift-A as
|
||||
// CTRL modified unicode A, we need to call Ctrl-A simply 'a',
|
||||
// lowercase
|
||||
if (codepoint + 0x40 >= 'A' && codepoint + 0x40 <= 'Z')
|
||||
// It's a letter - use lowercase instead
|
||||
key->code.codepoint = codepoint + 0x60;
|
||||
|
@ -848,7 +845,7 @@ peekkey (termo_t *tk, termo_key_t *key, int force, size_t *nbytep)
|
|||
tk->buffstart -= halfsize;
|
||||
}
|
||||
|
||||
/* fallthrough */
|
||||
// Fallthrough
|
||||
}
|
||||
case TERMO_RES_EOF:
|
||||
case TERMO_RES_ERROR:
|
||||
|
@ -936,11 +933,10 @@ peekkey_simple (termo_t *tk, termo_key_t *key, int force, size_t *nbytep)
|
|||
|
||||
if (res == TERMO_RES_AGAIN && force)
|
||||
{
|
||||
/* There weren't enough bytes for a complete character but
|
||||
* caller demands an answer. About the best thing we can do here
|
||||
* is eat as many bytes as we have, and emit a MULTIBYTE_INVALID.
|
||||
* If the remaining bytes arrive later, they'll be invalid too.
|
||||
*/
|
||||
// There weren't enough bytes for a complete character but
|
||||
// caller demands an answer. About the best thing we can do here
|
||||
// is eat as many bytes as we have, and emit a MULTIBYTE_INVALID.
|
||||
// If the remaining bytes arrive later, they'll be invalid too.
|
||||
codepoint = MULTIBYTE_INVALID;
|
||||
*nbytep = tk->buffcount;
|
||||
res = TERMO_RES_KEY;
|
||||
|
@ -1094,9 +1090,9 @@ termo_getkey (termo_t *tk, termo_key_t *key)
|
|||
eat_bytes (tk, nbytes);
|
||||
|
||||
if (ret == TERMO_RES_AGAIN)
|
||||
/* Call peekkey() again in force mode to obtain whatever it can */
|
||||
// Call peekkey() again in force mode to obtain whatever it can
|
||||
(void) peekkey (tk, key, 1, &nbytes);
|
||||
/* Don't eat it yet though */
|
||||
// Don't eat it yet though
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1173,7 +1169,7 @@ retry:
|
|||
}
|
||||
}
|
||||
|
||||
/* UNREACHABLE */
|
||||
// UNREACHABLE
|
||||
}
|
||||
|
||||
termo_result_t
|
||||
|
@ -1191,7 +1187,7 @@ termo_advisereadable (termo_t *tk)
|
|||
tk->buffstart = 0;
|
||||
}
|
||||
|
||||
/* Not expecting it ever to be greater but doesn't hurt to handle that */
|
||||
// Not expecting it ever to be greater but doesn't hurt to handle that
|
||||
if (tk->buffcount >= tk->buffsize)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
|
@ -1229,7 +1225,7 @@ termo_push_bytes (termo_t *tk, const char *bytes, size_t len)
|
|||
tk->buffstart = 0;
|
||||
}
|
||||
|
||||
/* Not expecting it ever to be greater but doesn't hurt to handle that */
|
||||
// Not expecting it ever to be greater but doesn't hurt to handle that
|
||||
if (tk->buffcount >= tk->buffsize)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
|
@ -1286,8 +1282,8 @@ static const char *
|
|||
termo_lookup_keyname_format (termo_t *tk,
|
||||
const char *str, termo_sym_t *sym, termo_format_t format)
|
||||
{
|
||||
/* We store an array, so we can't do better than a linear search. Doesn't
|
||||
* matter because user won't be calling this too often */
|
||||
// We store an array, so we can't do better than a linear search. Doesn't
|
||||
// matter because user won't be calling this too often
|
||||
|
||||
for (*sym = 0; *sym < tk->nkeynames; (*sym)++)
|
||||
{
|
||||
|
@ -1598,7 +1594,7 @@ int
|
|||
termo_keycmp (termo_t *tk,
|
||||
const termo_key_t *key1p, const termo_key_t *key2p)
|
||||
{
|
||||
/* Copy the key structs since we'll be modifying them */
|
||||
// Copy the key structs since we'll be modifying them
|
||||
termo_key_t key1 = *key1p, key2 = *key2p;
|
||||
|
||||
termo_canonicalise (tk, &key1);
|
||||
|
|
64
termo.h
64
termo.h
|
@ -16,17 +16,17 @@ enum termo_sym
|
|||
TERMO_SYM_UNKNOWN = -1,
|
||||
TERMO_SYM_NONE = 0,
|
||||
|
||||
/* Special names in C0 */
|
||||
// Special names in C0
|
||||
TERMO_SYM_BACKSPACE,
|
||||
TERMO_SYM_TAB,
|
||||
TERMO_SYM_ENTER,
|
||||
TERMO_SYM_ESCAPE,
|
||||
|
||||
/* Special names in G0 */
|
||||
// Special names in G0
|
||||
TERMO_SYM_SPACE,
|
||||
TERMO_SYM_DEL,
|
||||
|
||||
/* Special keys */
|
||||
// Special keys
|
||||
TERMO_SYM_UP,
|
||||
TERMO_SYM_DOWN,
|
||||
TERMO_SYM_LEFT,
|
||||
|
@ -41,7 +41,7 @@ enum termo_sym
|
|||
TERMO_SYM_HOME,
|
||||
TERMO_SYM_END,
|
||||
|
||||
/* Special keys from terminfo */
|
||||
// Special keys from terminfo
|
||||
TERMO_SYM_CANCEL,
|
||||
TERMO_SYM_CLEAR,
|
||||
TERMO_SYM_CLOSE,
|
||||
|
@ -65,7 +65,7 @@ enum termo_sym
|
|||
TERMO_SYM_SUSPEND,
|
||||
TERMO_SYM_UNDO,
|
||||
|
||||
/* Numeric keypad special keys */
|
||||
// Numeric keypad special keys
|
||||
TERMO_SYM_KP0,
|
||||
TERMO_SYM_KP1,
|
||||
TERMO_SYM_KP2,
|
||||
|
@ -97,7 +97,7 @@ enum termo_type
|
|||
TERMO_TYPE_MOUSE,
|
||||
TERMO_TYPE_POSITION,
|
||||
TERMO_TYPE_MODEREPORT,
|
||||
/* add other recognised types here */
|
||||
// add other recognised types here
|
||||
|
||||
TERMO_TYPE_UNKNOWN_CSI = -1
|
||||
};
|
||||
|
@ -134,22 +134,22 @@ struct termo_key
|
|||
termo_type_t type;
|
||||
union
|
||||
{
|
||||
uint32_t codepoint; /* TERMO_TYPE_KEY */
|
||||
int number; /* TERMO_TYPE_FUNCTION */
|
||||
termo_sym_t sym; /* TERMO_TYPE_KEYSYM */
|
||||
uint32_t codepoint; // TERMO_TYPE_KEY
|
||||
int number; // TERMO_TYPE_FUNCTION
|
||||
termo_sym_t sym; // TERMO_TYPE_KEYSYM
|
||||
|
||||
/* TERMO_TYPE_MODEREPORT */
|
||||
/* opaque, see termo_interpret_modereport() */
|
||||
// TERMO_TYPE_MODEREPORT
|
||||
// opaque, see termo_interpret_modereport()
|
||||
struct { char initial; int mode, value; } mode;
|
||||
|
||||
/* TERMO_TYPE_MOUSE */
|
||||
/* opaque, see termo_interpret_mouse() */
|
||||
// TERMO_TYPE_MOUSE
|
||||
// opaque, see termo_interpret_mouse()
|
||||
struct { uint16_t x, y, info; } mouse;
|
||||
} code;
|
||||
|
||||
int modifiers;
|
||||
|
||||
/* The raw multibyte sequence for the key */
|
||||
// The raw multibyte sequence for the key
|
||||
char multibyte[MB_LEN_MAX + 1];
|
||||
};
|
||||
|
||||
|
@ -157,26 +157,26 @@ typedef struct termo termo_t;
|
|||
|
||||
enum
|
||||
{
|
||||
/* Do not interpret C0//DEL codes if possible */
|
||||
// Do not interpret C0//DEL codes if possible
|
||||
TERMO_FLAG_NOINTERPRET = 1 << 0,
|
||||
/* Convert KP codes to regular keypresses */
|
||||
// Convert KP codes to regular keypresses
|
||||
TERMO_FLAG_CONVERTKP = 1 << 1,
|
||||
/* Don't try to decode the input characters */
|
||||
// Don't try to decode the input characters
|
||||
TERMO_FLAG_RAW = 1 << 2,
|
||||
/* Do not make initial termios calls on construction */
|
||||
// Do not make initial termios calls on construction
|
||||
TERMO_FLAG_NOTERMIOS = 1 << 4,
|
||||
/* Sets TERMO_CANON_SPACESYMBOL */
|
||||
// Sets TERMO_CANON_SPACESYMBOL
|
||||
TERMO_FLAG_SPACESYMBOL = 1 << 5,
|
||||
/* Allow Ctrl-C to be read as normal, disabling SIGINT */
|
||||
// Allow Ctrl-C to be read as normal, disabling SIGINT
|
||||
TERMO_FLAG_CTRLC = 1 << 6,
|
||||
/* Return ERROR on signal (EINTR) rather than retry */
|
||||
// Return ERROR on signal (EINTR) rather than retry
|
||||
TERMO_FLAG_EINTR = 1 << 7
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TERMO_CANON_SPACESYMBOL = 1 << 0, /* Space is symbolic rather than Unicode */
|
||||
TERMO_CANON_DELBS = 1 << 1 /* Del is converted to Backspace */
|
||||
TERMO_CANON_SPACESYMBOL = 1 << 0, // Space is symbolic rather than Unicode
|
||||
TERMO_CANON_DELBS = 1 << 1 // Del is converted to Backspace
|
||||
};
|
||||
|
||||
void termo_check_version (int major, int minor);
|
||||
|
@ -238,25 +238,25 @@ termo_result_t termo_interpret_csi (termo_t *tk,
|
|||
typedef enum termo_format termo_format_t;
|
||||
enum termo_format
|
||||
{
|
||||
/* Shift-... instead of S-... */
|
||||
// Shift-... instead of S-...
|
||||
TERMO_FORMAT_LONGMOD = 1 << 0,
|
||||
/* ^X instead of C-X */
|
||||
// ^X instead of C-X
|
||||
TERMO_FORMAT_CARETCTRL = 1 << 1,
|
||||
/* Meta- or M- instead of Alt- or A- */
|
||||
// Meta- or M- instead of Alt- or A-
|
||||
TERMO_FORMAT_ALTISMETA = 1 << 2,
|
||||
/* Wrap special keys in brackets like <Escape> */
|
||||
// Wrap special keys in brackets like <Escape>
|
||||
TERMO_FORMAT_WRAPBRACKET = 1 << 3,
|
||||
/* M Foo instead of M-Foo */
|
||||
// M Foo instead of M-Foo
|
||||
TERMO_FORMAT_SPACEMOD = 1 << 4,
|
||||
/* meta or m instead of Meta or M */
|
||||
// meta or m instead of Meta or M
|
||||
TERMO_FORMAT_LOWERMOD = 1 << 5,
|
||||
/* page down instead of PageDown */
|
||||
// page down instead of PageDown
|
||||
TERMO_FORMAT_LOWERSPACE = 1 << 6,
|
||||
/* Include mouse position if relevant; @ col,line */
|
||||
// Include mouse position if relevant; @ col,line
|
||||
TERMO_FORMAT_MOUSE_POS = 1 << 8
|
||||
};
|
||||
|
||||
/* Some useful combinations */
|
||||
// Some useful combinations
|
||||
|
||||
#define TERMO_FORMAT_VIM (termo_format_t) \
|
||||
(TERMO_FORMAT_ALTISMETA | TERMO_FORMAT_WRAPBRACKET)
|
||||
|
|
|
@ -18,8 +18,8 @@ main (int argc, char *argv[])
|
|||
is_int (key.type, TERMO_TYPE_KEY, "key.type low ASCII");
|
||||
is_int (key.code.codepoint, 'a', "key.code.codepoint low ASCII");
|
||||
|
||||
/* 2-byte UTF-8 range is U+0080 to U+07FF (0xDF 0xBF) */
|
||||
/* However, we'd best avoid the C1 range, so we'll start at U+00A0 (0xC2 0xA0) */
|
||||
// 2-byte UTF-8 range is U+0080 to U+07FF (0xDF 0xBF)
|
||||
// However, we'd best avoid the C1 range, so we'll start at U+00A0 (0xC2 0xA0)
|
||||
|
||||
termo_push_bytes (tk, "\xC2\xA0", 2);
|
||||
|
||||
|
@ -35,7 +35,7 @@ main (int argc, char *argv[])
|
|||
is_int (key.type, TERMO_TYPE_KEY, "key.type UTF-8 2 high");
|
||||
is_int (key.code.codepoint, 0x07FF, "key.code.codepoint UTF-8 2 high");
|
||||
|
||||
/* 3-byte UTF-8 range is U+0800 (0xE0 0xA0 0x80) to U+FFFD (0xEF 0xBF 0xBD) */
|
||||
// 3-byte UTF-8 range is U+0800 (0xE0 0xA0 0x80) to U+FFFD (0xEF 0xBF 0xBD)
|
||||
|
||||
termo_push_bytes (tk, "\xE0\xA0\x80", 3);
|
||||
|
||||
|
@ -51,7 +51,7 @@ main (int argc, char *argv[])
|
|||
is_int (key.type, TERMO_TYPE_KEY, "key.type UTF-8 3 high");
|
||||
is_int (key.code.codepoint, 0xFFFD, "key.code.codepoint UTF-8 3 high");
|
||||
|
||||
/* 4-byte UTF-8 range is U+10000 (0xF0 0x90 0x80 0x80) to U+10FFFF (0xF4 0x8F 0xBF 0xBF) */
|
||||
// 4-byte UTF-8 range is U+10000 (0xF0 0x90 0x80 0x80) to U+10FFFF (0xF4 0x8F 0xBF 0xBF)
|
||||
|
||||
termo_push_bytes (tk, "\xF0\x90\x80\x80", 4);
|
||||
|
||||
|
@ -68,9 +68,9 @@ main (int argc, char *argv[])
|
|||
is_int (key.code.codepoint, 0x10FFFF, "key.code.codepoint UTF-8 4 high");
|
||||
|
||||
#if 0
|
||||
/* XXX: With the move to iconv, this has changed significantly. */
|
||||
// XXX: With the move to iconv, this has changed significantly.
|
||||
|
||||
/* Invalid continuations */
|
||||
// Invalid continuations
|
||||
|
||||
termo_push_bytes (tk, "\xC2!", 2);
|
||||
|
||||
|
@ -139,7 +139,7 @@ main (int argc, char *argv[])
|
|||
"key.code.codepoint UTF-8 4 invalid after");
|
||||
#endif
|
||||
|
||||
/* Partials */
|
||||
// Partials
|
||||
|
||||
termo_push_bytes (tk, "\xC2", 1);
|
||||
is_int (termo_getkey (tk, &key), TERMO_RES_AGAIN,
|
||||
|
|
|
@ -12,11 +12,10 @@ main (int argc, char *argv[])
|
|||
|
||||
plan_tests (21);
|
||||
|
||||
/* We'll need a real filehandle we can write/read.
|
||||
* pipe () can make us one */
|
||||
// We'll need a real filehandle we can write/read. pipe() can make us one
|
||||
pipe (fd);
|
||||
|
||||
/* Sanitise this just in case */
|
||||
// Sanitise this just in case
|
||||
putenv ("TERM=vt100");
|
||||
|
||||
tk = termo_new (fd[0], NULL, TERMO_FLAG_NOTERMIOS);
|
||||
|
|
|
@ -118,8 +118,8 @@ main (int argc, char *argv[])
|
|||
is_int (len, 7, "length for sym/PageUp/0 lowerspace");
|
||||
is_str (buffer, "page up", "buffer for sym/PageUp/0 lowerspace");
|
||||
|
||||
/* If size of buffer is too small,
|
||||
* strfkey should return something consistent */
|
||||
// If size of buffer is too small,
|
||||
// strfkey should return something consistent
|
||||
len = termo_strfkey (tk, buffer, 4, &key, 0);
|
||||
is_int (len, 6, "length for sym/PageUp/0");
|
||||
is_str (buffer, "Pag", "buffer of len 4 for sym/PageUp/0");
|
||||
|
|
|
@ -24,7 +24,7 @@ int main (int argc, char *argv[])
|
|||
is_int (line, 15, "line for position report");
|
||||
is_int (col, 7, "column for position report");
|
||||
|
||||
/* A plain CSI R is likely to be <F3> though. This is tricky :/ */
|
||||
// A plain CSI R is likely to be <F3> though. This is tricky :/
|
||||
termo_push_bytes (tk, "\e[R", 3);
|
||||
|
||||
is_int (termo_getkey (tk, &key), TERMO_RES_KEY,
|
||||
|
|
Loading…
Reference in New Issue