Add selection + clipboard support (cut/copy/paste)

This commit is contained in:
2025-12-13 17:50:44 +00:00
parent a59111162c
commit 5153770ee9
7 changed files with 167 additions and 22 deletions

View File

@@ -184,9 +184,7 @@ void scroll_down(Editor *editor, uint32_t number) {
void ensure_cursor(Editor *editor) {
std::shared_lock knot_lock(editor->knot_mtx);
if (editor->cursor.row < editor->scroll.row ||
(editor->cursor.row == editor->scroll.row &&
editor->cursor.col < editor->scroll.col)) {
if (editor->cursor < editor->scroll) {
editor->cursor = editor->scroll;
return;
}
@@ -275,9 +273,7 @@ void ensure_scroll(Editor *editor) {
uint32_t numlen =
2 + static_cast<int>(std::log10(editor->root->line_count + 1));
uint32_t render_width = editor->size.col - numlen;
if (editor->cursor.row < editor->scroll.row ||
(editor->cursor.row == editor->scroll.row &&
editor->cursor.col < editor->scroll.col)) {
if (editor->cursor < editor->scroll) {
LineIterator *it = begin_l_iter(editor->root, editor->cursor.row);
if (!it)
return;