From a025219a21254c8970e19a90bf31148d351f6579 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Mon, 21 Sep 2026 11:55:10 +0000 Subject: add raw input echo --- include/line/mode.h | 53 +++++++++++------------------------------------------ 1 file changed, 11 insertions(+), 42 deletions(-) (limited to 'include/line') diff --git a/include/line/mode.h b/include/line/mode.h index 8811e66..2baad81 100644 --- a/include/line/mode.h +++ b/include/line/mode.h @@ -1,59 +1,28 @@ #pragma once -#include #include -#include +#include using namespace std; // TODO: remove namespace ov4 { -inline termios attr; - -void disable_raw() -{ - tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr); -} - -void enable_raw() +struct T_position { - termios attr_raw; - tcgetattr(STDIN_FILENO, &attr); - tcgetattr(STDIN_FILENO, &attr_raw); - - // LOCAL + int row; + int col; +}; - // disable - // echo - // canonical - // signal - // disable post-input processing, aka control-V - attr_raw.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN); - - // INPUT - - // disable - // software flow control, aka control-S/Q - // \n and \r conversion - attr_raw.c_iflag &= ~(IXON | ICRNL); - - // OUTPUT +inline termios attr; - // disable - // post-output processing - attr_raw.c_oflag &= ~(OPOST); +void disable_raw(); +void enable_raw(); - // misc - attr_raw.c_iflag &= ~(BRKINT | INPCK | ISTRIP); - attr_raw.c_cflag |= ~(CS8); +void clear_below(); - atexit(disable_raw); +std::string readline(); - // TCSAFLUSH - // the change shall occur after all output written to fildes is transmitted - // and all input so far received but not read shall be discarded before the change is made - tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr_raw); -} +T_position get_cursor_position(); } -- cgit v1.3.1-4-g156e