From b6db9c7c1b8e2cef958b892b067aa565f4c5e403 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Sat, 18 Oct 2025 01:17:11 -0400 Subject: allow free result --- args.c | 6 +++++- input_field.c | 6 +++++- state.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/args.c b/args.c index 5fe2f89..5fbc381 100644 --- a/args.c +++ b/args.c @@ -8,16 +8,20 @@ void parse_args(client_state* state, int argc, char* argv[]) { static struct option long_opts[] = { {"lines", required_argument, 0, 'l'}, + {"allow-free-result", required_argument, 0, 'a'}, {0, 0, 0, 0} }; int opt; int long_index = 0; - while ((opt = getopt_long(argc, argv, "l:", long_opts, &long_index)) != -1) { + while ((opt = getopt_long(argc, argv, "l:a", long_opts, &long_index)) != -1) { switch (opt) { case 'l': state->lines = atoi(optarg); break; + case 'a': + state->allow_free_result = true; + break; default: fprintf(stderr, "Usage: NOT WHAT YOU TYPED\n"); break; diff --git a/input_field.c b/input_field.c index 14aca1b..46f0791 100644 --- a/input_field.c +++ b/input_field.c @@ -105,7 +105,11 @@ bool type_key(client_state* state, xkb_keysym_t keysym) { void submit_line(client_state* state) { if (state->selected_filtered_item == -1) { - printf("%.*s\n", (int)array_size(state->input_buffer), state->input_buffer); + if (state->allow_free_result) { + printf("%.*s\n", (int)array_size(state->input_buffer), state->input_buffer); + } else { + return; + } } else { printf("%s\n", state->items[state->filtered_items[state->selected_filtered_item]].text); } diff --git a/state.h b/state.h index b2cadd0..877c70a 100644 --- a/state.h +++ b/state.h @@ -94,6 +94,7 @@ typedef struct { // arguments int lines; + bool allow_free_result; // state char* input_buffer; -- cgit v1.2.3