diff --git a/data/fractalheight.png b/data/fractalheight.png new file mode 100644 index 000000000..b90f8ac48 Binary files /dev/null and b/data/fractalheight.png differ diff --git a/rust/notcurses/stdout.c b/rust/notcurses/stdout.c new file mode 100644 index 000000000..9ab3ca9ce --- /dev/null +++ b/rust/notcurses/stdout.c @@ -0,0 +1,5 @@ +#include + +FILE* libc_stdout(void){ + return stdout; +} diff --git a/src/tetris/main.cpp b/src/tetris/main.cpp index 2bab37c44..ddcd70155 100644 --- a/src/tetris/main.cpp +++ b/src/tetris/main.cpp @@ -88,42 +88,4 @@ private: }; -int main(void) { - if(setlocale(LC_ALL, "") == nullptr){ - return EXIT_FAILURE; - } - srand(time(NULL)); - std::atomic_bool gameover = false; - notcurses_options ncopts{}; - ncpp::NotCurses nc(ncopts); - Tetris t{nc, gameover}; - std::thread tid(&Tetris::Ticker, &t); - ncpp::Plane* stdplane = nc.get_stdplane(); - char32_t input = 0; - ncinput ni; - while(!gameover && (input = nc.getc(true, &ni)) != (char32_t)-1){ - if(input == 'q'){ - break; - } - switch(input){ - case NCKEY_LEFT: case 'h': t.MoveLeft(); break; - case NCKEY_RIGHT: case 'l': t.MoveRight(); break; - case NCKEY_DOWN: case 'j': t.MoveDown(); break; - case 'L': if(ni.ctrl){ notcurses_refresh(nc); } break; - case 'z': t.RotateCcw(); break; - case 'x': t.RotateCw(); break; - default: - stdplane->cursor_move(0, 0); - stdplane->printf("Got unknown input U+%06x", input); - nc.render(); - break; - } - } - if(gameover || input == 'q'){ // FIXME signal it on 'q' - gameover = true; - tid.join(); - }else{ - return EXIT_FAILURE; - } - return nc.stop() ? EXIT_SUCCESS : EXIT_FAILURE; -} +#include "main.h" diff --git a/src/tetris/main.h b/src/tetris/main.h new file mode 100644 index 000000000..59a0cbc8a --- /dev/null +++ b/src/tetris/main.h @@ -0,0 +1,39 @@ +int main(void) { + if(setlocale(LC_ALL, "") == nullptr){ + return EXIT_FAILURE; + } + srand(time(NULL)); + std::atomic_bool gameover = false; + notcurses_options ncopts{}; + ncpp::NotCurses nc(ncopts); + Tetris t{nc, gameover}; + std::thread tid(&Tetris::Ticker, &t); + ncpp::Plane* stdplane = nc.get_stdplane(); + char32_t input = 0; + ncinput ni; + while(!gameover && (input = nc.getc(true, &ni)) != (char32_t)-1){ + if(input == 'q'){ + break; + } + switch(input){ + case NCKEY_LEFT: case 'h': t.MoveLeft(); break; + case NCKEY_RIGHT: case 'l': t.MoveRight(); break; + case NCKEY_DOWN: case 'j': t.MoveDown(); break; + case 'L': if(ni.ctrl){ notcurses_refresh(nc); } break; + case 'z': t.RotateCcw(); break; + case 'x': t.RotateCw(); break; + default: + stdplane->cursor_move(0, 0); + stdplane->printf("Got unknown input U+%06x", input); + nc.render(); + break; + } + } + if(gameover || input == 'q'){ // FIXME signal it on 'q' + gameover = true; + tid.join(); + }else{ + return EXIT_FAILURE; + } + return nc.stop() ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/tests/fills.cpp b/tests/fills.cpp index 32c099394..0ae946448 100644 --- a/tests/fills.cpp +++ b/tests/fills.cpp @@ -7,6 +7,9 @@ TEST_CASE("Fills") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/resize.cpp b/tests/resize.cpp index c5ff7f006..bef5da400 100644 --- a/tests/resize.cpp +++ b/tests/resize.cpp @@ -4,6 +4,9 @@ TEST_CASE("Resize") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/rotate.cpp b/tests/rotate.cpp index 55921aa12..af83bc1f0 100644 --- a/tests/rotate.cpp +++ b/tests/rotate.cpp @@ -28,6 +28,9 @@ TEST_CASE("Rotate") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true; diff --git a/tests/visual.cpp b/tests/visual.cpp index 8defcaed1..c925f6ac6 100644 --- a/tests/visual.cpp +++ b/tests/visual.cpp @@ -9,6 +9,9 @@ TEST_CASE("Multimedia") { if(getenv("TERM") == nullptr){ return; } + if(!enforce_utf8()){ + return; + } notcurses_options nopts{}; nopts.inhibit_alternate_screen = true; nopts.suppress_banner = true;