mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
demo: properly center wave on front page #50
This commit is contained in:
parent
02a3b25ae0
commit
f1e7b4a8e5
@ -1,3 +1,4 @@
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
@ -150,11 +151,15 @@ int main(int argc, char** argv){
|
||||
if(ncplane_putstr(ncp, str) != (int)strlen(str)){
|
||||
goto err;
|
||||
}
|
||||
const char bstr[] = "▏▁ ▂ ▃ ▄ ▅ ▆ ▇ █ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁▕";
|
||||
if(ncplane_cursor_move_yx(ncp, rows / 2 - 5, (cols - strlen(bstr) + 4) / 2)){
|
||||
const wchar_t wstr[] = L"▏▁ ▂ ▃ ▄ ▅ ▆ ▇ █ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁▕";
|
||||
char mbstr[128];
|
||||
if(wcstombs(mbstr, wstr, sizeof(mbstr)) <= 0){
|
||||
goto err;
|
||||
}
|
||||
if(ncplane_putstr(ncp, bstr) != (int)strlen(bstr)){
|
||||
if(ncplane_cursor_move_yx(ncp, rows / 2 - 5, (cols - wcslen(wstr) + 4) / 2)){
|
||||
goto err;
|
||||
}
|
||||
if(ncplane_putstr(ncp, mbstr) != (int)strlen(mbstr)){
|
||||
goto err;
|
||||
}
|
||||
if(notcurses_render(nc)){
|
||||
|
@ -65,7 +65,6 @@ int unicodeblocks_demo(struct notcurses* nc){
|
||||
return -1;
|
||||
}
|
||||
ncplane_fg_rgb8(n, 0xad, 0xd8, 0xe6);
|
||||
ncplane_bg_rgb8(n, 0, 0, 0);
|
||||
if(ncplane_printf(n, "Unicode points %04x–%04x", blockstart, blockstart + BLOCKSIZE) <= 0){
|
||||
return -1;
|
||||
}
|
||||
@ -87,6 +86,7 @@ int unicodeblocks_demo(struct notcurses* nc){
|
||||
memset(&ps, 0, sizeof(ps));
|
||||
wchar_t w = blockstart + chunk * CHUNKSIZE + z;
|
||||
char utf8arr[MB_CUR_MAX + 1];
|
||||
// FIXME we can print wide ones here, just add an extra line
|
||||
if(wcwidth(w) == 1 && iswprint(w)){
|
||||
int bwc = wcrtomb(utf8arr, w, &ps);
|
||||
if(bwc < 0){
|
||||
|
Loading…
Reference in New Issue
Block a user