aboutsummaryrefslogtreecommitdiff
path: root/src/line/cursor.cc
diff options
context:
space:
mode:
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;
+}
+
}