1TERMKEY_STRFKEY(3) Library Functions Manual TERMKEY_STRFKEY(3)
2
3
4
6 termkey_strfkey - format a string representing a key event
7
9 #include <termkey.h>
10
11 size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len,
12 TermKeyKey *key, TermKeyFormat format);
13
14 Link with -ltermkey.
15
17 termkey_strfkey() formats a string buffer to contain a human-readable
18 representation of a key event. It fills the buffer in a way analogous
19 to the snprintf(3) or strftime(3) standard library functions. This
20 function used to be called termkey_snprint_key() but was renamed after
21 version 0.6.
22
23 The format argument specifies the format of the output, as a bitmask of
24 the following constants:
25
26 TERMKEY_FORMAT_LONGMOD
27 Print full modifier names e.g. "Shift-" instead of abbreviating
28 to "S-".
29
30 TERMKEY_FORMAT_CARETCTRL
31 If the only modifier is TERMKEY_MOD_CTRL on a plain letter, ren‐
32 der it as "^X" rather than "Ctrl-X".
33
34 TERMKEY_FORMAT_ALTISMETA
35 Use the name "Meta" or the letter "M" instead of "Alt" or "A".
36
37 TERMKEY_FORMAT_WRAPBRACKET
38 If the key event is a special key instead of unmodified Unicode,
39 wrap it in "<brackets>".
40
41 TERMKEY_FORMAT_SPACEMOD
42 Use spaces instead of hyphens to separate the modifier name(s)
43 from the base key name.
44
45 TERMKEY_FORMAT_LOWERMOD
46 Use lowercase for the modifier name.
47
48 TERMKEY_FORMAT_LOWERSPACE
49 Use lowercase with spaces in for the key name instead of camel‐
50 Case (for example "page down" instead of "PageDown").
51
52 TERMKEY_FORMAT_MOUSE_POS
53 If the event is a mouse event, include the position rendered as
54 "@ (col,line)".
55
56 The following shortcuts are provided for common combinations of format
57 bits:
58
59 TERMKEY_FORMAT_VIM
60 Shortcut to set ALTISMETA and WRAPBRACKET, to give an output
61 close to the format the vim editor uses.
62
63 TERMKEY_FORMAT_URWID
64 Shortcut to set ALTISMETA, LONGMOD, LOWERMOD, SPACEMOD and LOW‐
65 ERSPACE, to give an output close to the format the urwid python
66 library uses.
67
68 When formatting a TERMKEY_TYPE_UNICODE key structure, this function
69 uses the utf8 member. If this member contains an empty string (i.e. its
70 first character is 0) then this member will be prefilled by the func‐
71 tion from the code.number member. This can be convenient when the key
72 structure is being constructed programmatically by user code.
73
75 termkey_strfkey() returns the number of characters written to buffer.
76
78 termkey_new(3), termkey_getkey(3), termkey_waitkey(3), termkey_get_key‐
79 name(3), termkey_strpkey(3), termkey(7)
80
81
82
83 TERMKEY_STRFKEY(3)