aboutsummaryrefslogtreecommitdiff
path: root/include/line/mode.h
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-21 11:55:10 +0000
committer_ov4 <ov4@ov4.org>2026-09-21 11:55:10 +0000
commita025219a21254c8970e19a90bf31148d351f6579 (patch)
treec5414dd347edcd6f943cee9948b0b890078b1927 /include/line/mode.h
parent83fa0a85281118103b4f8bf82dcb25cacb42d982 (diff)
add raw input echo
Diffstat (limited to 'include/line/mode.h')
-rw-r--r--include/line/mode.h53
1 files changed, 11 insertions, 42 deletions
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 <unistd.h>
#include <termios.h>
-#include <stdlib.h>
+#include <string>
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();
}