Reputation: 35
I am writing a terminal program for the Raspberry Pi using ncurses. I want to add a shadow around a box. I want to use mvaddch()
to print extended characters such as char 233 (upper half box character). What would be the syntax for the mvaddch()
command? Or is there another way to accomplish this?
Upvotes: 1
Views: 896
Reputation: 54465
You're probably referring to something like code page 866. ncurses will assume your terminal shows characters consistent with the locale encoding, which probably is UTF-8. So (unless you want to convert the characters in your program) the way to go is using Unicode values.
The Unicode organization has tables which you can use to lookup a particular code, e.g., ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP866.TXT. For your example, the relevant row is
0xdf 0x2580 #UPPER HALF BLOCK
(because 0xdf is 223). You would use the Unicode 0x2580
in a call to the function mvaddwstr, e.g.
wchar_t mydata[] = { 0x2580, 0 };
mvaddwstr(0,0, mydata);
(the similarly-named wadd_wch
uses a data structure which is more complicated).
You would have to link with the ncursesw library, and of course initialize your program's locale using setlocale
as mentioned in the ncurses manual page.
Upvotes: 1