diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-08 15:08:00 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-08 15:08:00 +0000 |
| commit | 0e9bbb3d8922405585304b220cbbf8b28cfa7978 (patch) | |
| tree | c465a83f5f524f66ea86ab9faf912f16299af3c7 | |
| parent | 6864b943fb91debe90b88e2e8a3a063fa89cbdce (diff) | |
fix get_terminal_pos_cursor
| -rw-r--r-- | src/line/cursor.cc | 4 | ||||
| -rw-r--r-- | src/line/getter.cc | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/line/cursor.cc b/src/line/cursor.cc index b44054e..4b51d04 100644 --- a/src/line/cursor.cc +++ b/src/line/cursor.cc @@ -123,7 +123,7 @@ void move_cursor(T_cursor_movement_direction d) { case T_cursor_movement_direction::LEFT: // if cursor is not at left margin - if (prompt_pos < get_terminal_pos_cursor()) + if (prompt_pos+1 < get_terminal_pos_cursor()) { buffer_index_cursor--; print("\x1b[D"); fflush(stdout); // move cursor to the left @@ -144,7 +144,7 @@ void move_cursor(T_cursor_movement_direction d) { // already at the end of buffer if (buffer_index_cursor == line_buffer.size()) break; - + buffer_index_cursor++; print("\x1b[C"); fflush(stdout); // move cursor to the right } diff --git a/src/line/getter.cc b/src/line/getter.cc index 73b0c03..f396ce1 100644 --- a/src/line/getter.cc +++ b/src/line/getter.cc @@ -18,7 +18,7 @@ namespace ov4 int get_terminal_pos_cursor() { - return prompt_pos + buffer_index_cursor; + return prompt_pos + (buffer_index_cursor - get_buffer_index_display_begin()) + 1; } int get_buffer_index_display_begin() |
