C-Menu
0.2.9
A User Interface Toolkit
Toggle main menu visibility
Loading...
Searching...
No Matches
mkcc.c
Go to the documentation of this file.
1
/** mkcc
2
@brief Create a cchar_t with the specified color pair index and attributes
3
@ingroup color_management
4
@param cp Color pair index
5
@param attr Attributes to apply to the cchar_t
6
@param s Multibyte string to convert to wide character (only the first
7
character is used)
8
@return cchar_t with the specified color pair index and a space character
9
as the wide character */
10
11
cchar_t
mkcc
(
short
cp, attr_t attr,
const
char
*s) {
12
mbstate_t mbstate;
13
memset(&mbstate, 0,
sizeof
(mbstate));
14
size_t len;
15
size_t n;
16
cchar_t cc = {0};
17
wchar_t wstr[2] = {L'\0', L'\0'};
18
len = strlen(s);
19
if
(len > 0) {
20
n = mbrtowc(wstr, s, MB_CUR_MAX, &mbstate);
21
if
(n <= 0) {
22
wstr[0] = L'?';
23
wstr[1] = L'\0';
24
}
else
{
25
wstr[1] = L'\0';
26
}
27
}
else
{
28
wstr[0] = L' ';
29
wstr[1] = L'\0';
30
}
31
ui_setcchar(&cc, wstr, attr, cp,
nullptr
);
32
return
cc;
33
}
34
// #endif
mkcc
cchar_t mkcc(short cp, attr_t attr, const char *s)
Create a cchar_t with the specified color pair index and attributes.
Definition
mkcc.c:11
ui
mkcc.c
Generated by
1.17.0