aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2025-10-18 01:17:11 -0400
committerJack Jamison <jackqjamison@gmail.com>2025-10-18 01:17:11 -0400
commitb6db9c7c1b8e2cef958b892b067aa565f4c5e403 (patch)
tree33b627bb0d2f0ae67812c74941f0649ad52fdf53
parent87338246fbf60e044f8aaba53032661c1796e0f9 (diff)
allow free result
-rw-r--r--args.c6
-rw-r--r--input_field.c6
-rw-r--r--state.h1
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;