aboutsummaryrefslogtreecommitdiff
path: root/termkey_strfkey.3
blob: 77679522ba7bc4adf548597d9741a9edd62dbe02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
.TH TERMKEY_STRFKEY 3
.SH NAME
termkey_strfkey \- format a string representing a key event
.SH SYNOPSIS
.nf
.B #include <termkey.h>
.sp
.BI "size_t termkey_strfkey(TermKey *" tk ", char *" buffer ", size_t " len ",
.BI "            TermKeyKey *" key ", TermKeyFormat " format );
.fi
.sp
Link with \fI-ltermkey\fP.
.SH DESCRIPTION
\fBtermkey_strfkey\fP() formats a string buffer to contain a human-readable representation of a key event. It fills the \fIbuffer\fP in a way analogous to the \fBsnprintf\fP(3) or \fBstrftime\fP(3) standard library functions. This function used to be called \fBtermkey_snprint_key\fP() but was renamed after version 0.6.
.PP
The \fIformat\fP argument specifies the format of the output, as a bitmask of the following constants:
.TP
.B TERMKEY_FORMAT_LONGMOD
Print full modifier names e.g. "Shift-" instead of abbreviating to "S-".
.TP
.B TERMKEY_FORMAT_CARETCTRL
If the only modifier is \fBTERMKEY_MOD_CTRL\fP on a plain letter, render it as "^X" rather than "Ctrl-X".
.TP
.B TERMKEY_FORMAT_ALTISMETA
Use the name "Meta" or the letter "M" instead of "Alt" or "A".
.TP
.B TERMKEY_FORMAT_WRAPBRACKET
If the key event is a special key instead of unmodified Unicode, wrap it in "<brackets>".
.TP
.B TERMKEY_FORMAT_MOUSE_POS
If the event is a mouse event, include the position rendered as "@ (col,line)".
.PP
The following shortcuts are provided for common combinations of format bits:
.TP
.B TERMKEY_FORMAT_VIM
Shortcut to set \fBALTISMETA\fP and \fBWRAPBRACKET\fP, to give an output close to the format the \fIvim\fP editor uses.
.PP
When formatting a \fBTERMKEY_TYPE_UNICODE\fP key structure, this function uses the \fIutf8\fP 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 \fIcode.number\fP member. This can be convenient when the key structure is being constructed programatically by user code.
.SH "RETURN VALUE"
\fBtermkey_strfkey\fP() returns the number of characters written to \fIbuffer\fP.
.SH "SEE ALSO"
.BR termkey_new (3),
.BR termkey_getkey (3),
.BR termkey_waitkey (3),
.BR termkey_get_keyname (3),
.BR termkey_strpkey (3)