aboutsummaryrefslogtreecommitdiff
path: root/src/line/cursor.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-22 03:22:34 +0000
committer_ov4 <ov4@ov4.org>2026-09-22 03:22:34 +0000
commit6d7ff828389456a1e73b313afe2b732eb50a207c (patch)
treed981e5ee825446701b5e5c98441bc04b5a37b5b0 /src/line/cursor.cc
parenta1740da4d2e52c0999c36e82523234fb4f88885a (diff)
add cursor insert
Diffstat (limited to 'src/line/cursor.cc')
-rw-r--r--src/line/cursor.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/line/cursor.cc b/src/line/cursor.cc
index ce01466..9ff8bbc 100644
--- a/src/line/cursor.cc
+++ b/src/line/cursor.cc
@@ -47,12 +47,13 @@ T_position get_cursor_position()
void print_override(const std::string &s)
{
+ print("\x1b[s"); fflush(stdout);
print("\r");
fflush(stdout);
print("{}", s);
fflush(stdout);
- cursor_col = s.size()+1;
- line_end_pos = cursor_col;
+ //line_end_pos = s.size()+1;
+ print("\x1b[u"); fflush(stdout);
}
void move_cursor(char c)
@@ -90,4 +91,22 @@ void move_cursor(char c)
}
}
+void cursor_input(char c, std::string &buffer)
+{
+ if (c != '\b')
+ {
+ buffer.insert(cursor_col-1, 1, c);
+ print("\x1b[C"); fflush(stdout);
+ cursor_col++;
+ line_end_pos = buffer.size()+1;
+ return;
+ }
+
+ // BACKSPACE
+ buffer.erase(cursor_col-1, 1);
+ print("\x1b[D"); fflush(stdout);
+ cursor_col--;
+ line_end_pos = buffer.size()+1;
+}
+
}