termkey_strfkey man page

termkey_strfkey — format a string representing a key event


#include <termkey.h>

size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len,
 TermKeyKey *key, TermKeyFormat format);

Link with -ltermkey.


termkey_strfkey() formats a string buffer to contain a human-readable representation of a key event. It fills the buffer in a way analogous to the snprintf(3) or strftime(3) standard library functions. This function used to be called termkey_snprint_key() but was renamed after version 0.6.

The format argument specifies the format of the output, as a bitmask of the following constants:

Print full modifier names e.g. "Shift-" instead of abbreviating to "S-".
If the only modifier is TERMKEY_MOD_CTRL on a plain letter, render it as "^X" rather than "Ctrl-X".
Use the name "Meta" or the letter "M" instead of "Alt" or "A".
If the key event is a special key instead of unmodified Unicode, wrap it in "<brackets>".
Use spaces instead of hyphens to separate the modifier name(s) from the base key name.
Use lowercase for the modifier name.
Use lowercase with spaces in for the key name instead of camelCase (for example "page down" instead of "PageDown").
If the event is a mouse event, include the position rendered as "@ (col,line)".

The following shortcuts are provided for common combinations of format bits:

Shortcut to set ALTISMETA and WRAPBRACKET, to give an output close to the format the vim editor uses.
Shortcut to set ALTISMETA, LONGMOD, LOWERMOD, SPACEMOD and LOWERSPACE, to give an output close to the format the urwid python library uses.

When formatting a TERMKEY_TYPE_UNICODE key structure, this function uses the utf8 member. If this member contains an empty string (i.e. its first character is 0) then this member will be prefilled by the function from the code.number member. This can be convenient when the key structure is being constructed programatically by user code.

Return Value

termkey_strfkey() returns the number of characters written to buffer.

See Also

termkey_new(3), termkey_getkey(3), termkey_waitkey(3), termkey_get_keyname(3), termkey_strpkey(3), termkey(7)

Referenced By

termkey(7), termkey_get_keyname(3), termkey_strpkey(3).

Explore man page connections for termkey_strfkey(3).