From 1ec6dd03808c10d3ac7f76428b9d9f7eb07cf932 Mon Sep 17 00:00:00 2001 From: Kuchteq Date: Sun, 31 Dec 2023 01:47:03 +0100 Subject: [PATCH] Initial oversimplified POC implementation --- doc/tofi.1.md | 4 ++++ src/input.c | 7 +++++-- src/main.c | 6 +++++- src/tofi.h | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/tofi.1.md b/doc/tofi.1.md index fe6e575..282eb05 100644 --- a/doc/tofi.1.md +++ b/doc/tofi.1.md @@ -115,6 +115,10 @@ the form **--key=value**. > An error occurred, or the user exited without making a selection. +2 + +> Alternative Success; a selection was made, but the user held down control when confirming it. Useful for building "multi-level" select prompts. + ## AUTHORS Philip Jones \<\> diff --git a/src/input.c b/src/input.c index 58154a7..13764aa 100644 --- a/src/input.c +++ b/src/input.c @@ -94,11 +94,14 @@ void input_handle_keypress(struct tofi *tofi, xkb_keycode_t keycode) || ((key == KEY_C || key == KEY_LEFTBRACE) && ctrl)) { tofi->closed = true; return; + } else if (ctrl && (key == KEY_ENTER || key == KEY_KPENTER)) { + tofi->submit = true; + tofi->submit_extra = true; + return; } else if (key == KEY_ENTER || key == KEY_KPENTER) { tofi->submit = true; return; - } - + } if (tofi->auto_accept_single && tofi->window.entry.results.count == 1) { tofi->submit = true; } diff --git a/src/main.c b/src/main.c index e91838f..ed2be5d 100644 --- a/src/main.c +++ b/src/main.c @@ -1924,5 +1924,9 @@ int main(int argc, char *argv[]) if (tofi.closed) { return EXIT_FAILURE; } - return EXIT_SUCCESS; + if(tofi.submit_extra) { + return 2; + } else { + return EXIT_SUCCESS; + } } diff --git a/src/tofi.h b/src/tofi.h index dae2c1d..e2081f2 100644 --- a/src/tofi.h +++ b/src/tofi.h @@ -54,6 +54,7 @@ struct tofi { /* State */ bool submit; + bool submit_extra; bool closed; int32_t output_width; int32_t output_height;