From 03329cae6a69b7b6ceda57e3649284117af0ca6e Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 10 May 2024 11:04:55 +0000 Subject: [PATCH] Process editor(1) input immediately. --- editor/input.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/editor/input.c b/editor/input.c index 5b141e93..ca64bc8b 100644 --- a/editor/input.c +++ b/editor/input.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, 2016 Jonas 'Sortie' Termansen. + * Copyright (c) 2013, 2014, 2016, 2024 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -257,8 +258,8 @@ void editor_input_begin(struct editor_input* editor_input) } } -void editor_input_process(struct editor_input* editor_input, - struct editor* editor) +void editor_input_process_byte(struct editor_input* editor_input, + struct editor* editor) { unsigned char uc; ssize_t amount_read = read(0, &uc, sizeof(uc)); @@ -352,6 +353,14 @@ void editor_input_process(struct editor_input* editor_input, } } +void editor_input_process(struct editor_input* editor_input, + struct editor* editor) +{ + struct pollfd pfd = { .fd = 0, .events = POLLIN }; + do editor_input_process_byte(editor_input, editor); + while ( poll(&pfd, 1, 0) == 1 ); +} + void editor_input_end(struct editor_input* editor_input) { if ( getenv("TERM") && strcmp(getenv("TERM"), "sortix") != 0 )