mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-26 12:37:06 +08:00
Stop using fcntl
This fixes issue 16 https://github.com/ArthurSonzogni/FTXUI/issues/16 Some terminal like gnome-terminal seems not to support it correctly. It turns out it wasn't totally useful using it.
This commit is contained in:
parent
1974e9f9fc
commit
ac3db36de8
@ -26,7 +26,6 @@
|
|||||||
#else
|
#else
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Quick exit is missing in standard CLang headers
|
// Quick exit is missing in standard CLang headers
|
||||||
@ -106,7 +105,6 @@ int CheckStdinReady(int usec_timeout) {
|
|||||||
void UnixEventListener(std::atomic<bool>* quit, Sender<char> sender) {
|
void UnixEventListener(std::atomic<bool>* quit, Sender<char> sender) {
|
||||||
const int buffer_size = 100;
|
const int buffer_size = 100;
|
||||||
const int timeout_usec = 50000;
|
const int timeout_usec = 50000;
|
||||||
// short CHAR_AVAILABLE_TO_READ = POLLIN | POLLPRI;
|
|
||||||
|
|
||||||
while (!*quit) {
|
while (!*quit) {
|
||||||
if (!CheckStdinReady(timeout_usec))
|
if (!CheckStdinReady(timeout_usec))
|
||||||
@ -219,9 +217,9 @@ void ScreenInteractive::Loop(Component* component) {
|
|||||||
terminal.c_lflag &= ~ECHO; // Do not print after a key press.
|
terminal.c_lflag &= ~ECHO; // Do not print after a key press.
|
||||||
terminal.c_cc[VMIN] = 0;
|
terminal.c_cc[VMIN] = 0;
|
||||||
terminal.c_cc[VTIME] = 0;
|
terminal.c_cc[VTIME] = 0;
|
||||||
auto oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
|
//auto oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||||
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
|
//fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
|
||||||
on_exit_functions.push([=] { fcntl(STDIN_FILENO, F_GETFL, oldf); });
|
//on_exit_functions.push([=] { fcntl(STDIN_FILENO, F_GETFL, oldf); });
|
||||||
|
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &terminal);
|
tcsetattr(STDIN_FILENO, TCSANOW, &terminal);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user