Make GRAPHIC select the text plane
Some checks failed
akbasic CI Build / cmake_build (push) Failing after 3m22s
akbasic CI Build / sanitizers (push) Failing after 4m43s
akbasic CI Build / coverage (push) Failing after 3m43s
akbasic CI Build / akgl_build (push) Failing after 4m48s
akbasic CI Build / mutation_test (push) Failing after 3m31s

Co-authored-by: Andrew Kesterson <andrew@aklabs.net>
This commit is contained in:
2026-08-03 08:08:34 -04:00
parent c5d13f00f6
commit 3342f2b569
13 changed files with 345 additions and 79 deletions

View File

@@ -47,6 +47,9 @@ static akerr_ErrorContext AKERR_NOIGNORE *broken_clear(akbasic_TextSink *self)
static int MOVETOS = 0;
static int WINDOWS = 0;
static int WINDOW_ARGS[4] = { 0, 0, 0, 0 };
static int GRAPHICS = 0;
static int GRAPHIC_MODE = 0;
static int GRAPHIC_SPLIT = 0;
static akerr_ErrorContext AKERR_NOIGNORE *counting_moveto(akbasic_TextSink *self, int col, int row)
{
@@ -70,6 +73,17 @@ static akerr_ErrorContext AKERR_NOIGNORE *counting_window(akbasic_TextSink *self
SUCCEED_RETURN(errctx);
}
static akerr_ErrorContext AKERR_NOIGNORE *counting_graphic(akbasic_TextSink *self, int mode, int split)
{
PREPARE_ERROR(errctx);
(void)self;
GRAPHICS += 1;
GRAPHIC_MODE = mode;
GRAPHIC_SPLIT = split;
SUCCEED_RETURN(errctx);
}
int main(void)
{
akbasic_TextSink primary;
@@ -163,11 +177,15 @@ int main(void)
gridded.clear = broken_clear;
gridded.moveto = counting_moveto;
gridded.window = counting_window;
gridded.grid = NULL;
gridded.graphic = counting_graphic;
MOVETOS = 0;
WINDOWS = 0;
GRAPHICS = 0;
TEST_REQUIRE_OK(akbasic_sink_init_tee(&tee, &teestate, &primary, &gridded, NULL));
TEST_REQUIRE(tee.moveto != NULL, "a tee with a gridded half must offer moveto");
TEST_REQUIRE(tee.window != NULL, "a tee with a gridded half must offer window");
TEST_REQUIRE(tee.graphic != NULL, "a tee with a graphical half must offer graphic");
TEST_REQUIRE_OK(tee.moveto(&tee, 3, 4));
TEST_REQUIRE_OK(tee.window(&tee, 0, 20, 39, 24));
TEST_REQUIRE_INT(MOVETOS, 1);
@@ -176,6 +194,10 @@ int main(void)
TEST_REQUIRE_INT(WINDOW_ARGS[1], 20);
TEST_REQUIRE_INT(WINDOW_ARGS[2], 39);
TEST_REQUIRE_INT(WINDOW_ARGS[3], 24);
TEST_REQUIRE_OK(tee.graphic(&tee, 2, 19));
TEST_REQUIRE_INT(GRAPHICS, 1);
TEST_REQUIRE_INT(GRAPHIC_MODE, 2);
TEST_REQUIRE_INT(GRAPHIC_SPLIT, 19);
/* The gridded half being first is wired the same way round. */
WINDOWS = 0;
@@ -193,6 +215,10 @@ int main(void)
broken.writeln = broken_write;
broken.readline = NULL;
broken.clear = broken_clear;
broken.moveto = NULL;
broken.window = NULL;
broken.grid = NULL;
broken.graphic = NULL;
TEST_REQUIRE_OK(akbasic_sink_init_tee(&tee, &teestate, &primary, &broken, NULL));
TEST_REQUIRE_STATUS(tee.write(&tee, "X"), AKERR_IO);
TEST_REQUIRE_STATUS(tee.writeln(&tee, "X"), AKERR_IO);