diff options
author | Mattias Andrée <m@maandree.se> | 2025-02-16 12:45:12 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-02-16 12:45:12 +0100 |
commit | 31605225524215ca7f0c06662b469d16bbe2bba7 (patch) | |
tree | 6ea2fcf2d075a400bfca824786f3de311e2b75a6 /interactive-test.c | |
parent | update year in license file (diff) | |
download | libterminput-31605225524215ca7f0c06662b469d16bbe2bba7.tar.gz libterminput-31605225524215ca7f0c06662b469d16bbe2bba7.tar.bz2 libterminput-31605225524215ca7f0c06662b469d16bbe2bba7.tar.xz |
interactive-test: add TEST_LIBTERMINPUT_PRINT_STATE
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'interactive-test.c')
-rw-r--r-- | interactive-test.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/interactive-test.c b/interactive-test.c index 5e07685..d982ec5 100644 --- a/interactive-test.c +++ b/interactive-test.c @@ -14,7 +14,7 @@ main(void) struct libterminput_state ctx; union libterminput_input input; struct termios stty, saved_stty; - int r; + int r, print_state; memset(&ctx, 0, sizeof(ctx)); @@ -47,6 +47,8 @@ main(void) libterminput_set_flags(&ctx, LIBTERMINPUT_AWAITING_CURSOR_POSITION); } + print_state = !!getenv("TEST_LIBTERMINPUT_PRINT_STATE"); + if (tcgetattr(STDERR_FILENO, &stty)) { perror("tcgetattr STDERR_FILENO"); return 1; @@ -184,16 +186,16 @@ main(void) } else { printf("other\n"); } -#if 0 - printf("(state):\n" - "\tinited=%i, mods=%#x, flags=%#x, bracketed_paste=%i, mouse_tracking=%i, meta=%i,\n" - "\tn=%i, stored_head=%zu, stored_tail=%zu, paused=%i, npartial=%i, partial=\"%.*s\",\n" - "\tkey=\"%s\", stored=\"%.*s\"\n", - (int)ctx.inited, (unsigned)ctx.mods, (unsigned)ctx.flags, (int)ctx.bracketed_paste, - (int)ctx.mouse_tracking, (int)ctx.meta, (int)ctx.n, ctx.stored_head, ctx.stored_tail, - (int)ctx.paused, (int)ctx.npartial, (int)ctx.npartial, ctx.partial, ctx.key, - (int)(ctx.stored_tail - ctx.stored_head), &ctx.stored[ctx.stored_head]); -#endif + if (print_state) { + printf("(state):\n" + "\tinited=%i, mods=%#x, flags=%#x, bracketed_paste=%i, mouse_tracking=%i, meta=%i,\n" + "\tn=%i, stored_head=%zu, stored_tail=%zu, paused=%i, npartial=%i, partial=\"%.*s\",\n" + "\tkey=\"%s\", stored=\"%.*s\"\n", + (int)ctx.inited, (unsigned)ctx.mods, (unsigned)ctx.flags, (int)ctx.bracketed_paste, + (int)ctx.mouse_tracking, (int)ctx.meta, (int)ctx.n, ctx.stored_head, ctx.stored_tail, + (int)ctx.paused, (int)ctx.npartial, (int)ctx.npartial, ctx.partial, ctx.key, + (int)(ctx.stored_tail - ctx.stored_head), &ctx.stored[ctx.stored_head]); + } } if (r < 0) |