Process editor(1) input immediately.

This commit is contained in:
Jonas 'Sortie' Termansen 2024-05-10 11:04:55 +00:00
parent ca9ec73726
commit 51e483b537
1 changed files with 12 additions and 3 deletions

View File

@ -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 <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
@ -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 )