aboutsummaryrefslogtreecommitdiff
path: root/src/line/mode.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-12 06:56:18 +0000
committer_ov4 <ov4@ov4.org>2026-10-12 06:56:18 +0000
commit7ae4c2d4b67ce40a5434b5195e14085cadf6e22f (patch)
tree9ffa85f08350aa591d48d3afce7af1d923fc491d /src/line/mode.cc
parent70ff2908167db12ddfb319e5e3dcfcf50ecb886d (diff)
seperate file for line editor
Diffstat (limited to 'src/line/mode.cc')
-rw-r--r--src/line/mode.cc78
1 files changed, 0 insertions, 78 deletions
diff --git a/src/line/mode.cc b/src/line/mode.cc
index 6f59ace..06f1727 100644
--- a/src/line/mode.cc
+++ b/src/line/mode.cc
@@ -63,84 +63,6 @@ void enable_raw()
tcsetattr(STDIN_FILENO, TCSAFLUSH, &attr_raw);
}
-void clear_below()
-{
- print("\x1b[0J");
-}
-
-string readline()
-{
- update_window_size();
- history_vec.push_back("");
- history_index = get_last_index();
- reset_editor();
-
- T_position pos = get_cursor_position();
- prompt_pos = pos.col;
- char c;
- while (read(STDIN_FILENO, &c, 1) == 1)
- {
- if (iscntrl(c))
- {
- //print("control: {}\r\n", static_cast<unsigned char>(c));
- //fflush(stdout);
- if (c == 0x0A || c == 0x0D) // \n OR \r
- {
- //print("line: {}\r\n", line_buffer);
- if (line_buffer.empty())
- {
- history_index--;
- history_vec.pop_back();
- }
- else
- {
- history_vec[get_last_index()] = line_buffer;
- }
- return line_buffer;
- }
-
- else if (c == 0x03) // control C
- {
- history_index--;
- history_vec.pop_back();
- return "";
- }
-
- // ESC sequence
- else if (c == '\x1b')
- {
- char seq[10];
- // eat [
- if (read(STDIN_FILENO, seq + 0, 1) != 1)
- continue;
-
- if (read(STDIN_FILENO, seq + 1, 1) != 1)
- continue;
-
- move_cursor(seq[1]);
- }
- }
-
- // normal char
- else
- {
- cursor_input_char(c);
- print_override(line_buffer);
- }
- }
-
- if (line_buffer.empty())
- {
- history_index--;
- history_vec.pop_back();
- }
- else
- {
- history_vec[get_last_index()] = line_buffer;
- }
- return line_buffer;
-}
-
void editor_exit(int code)
{
disable_raw();