Add mouse support

This commit is contained in:
2025-12-13 15:08:31 +00:00
parent e83cc6cf02
commit d9ebf83588
7 changed files with 357 additions and 346 deletions

View File

@@ -163,6 +163,14 @@ void scroll_down(Editor *editor, uint32_t number) {
free(line);
line_index++;
}
if (q_size > 0) {
uint32_t idx;
if (q_size < max_visual_lines)
idx = (q_head + q_size - 1) % max_visual_lines;
else
idx = q_head;
editor->scroll = scroll_queue[idx];
}
free(it);
free(scroll_queue);
}
@@ -216,13 +224,6 @@ void ensure_cursor(Editor *editor) {
Coord current = {line_index, offset};
last_visible = current;
visual_rows++;
if (line_index == editor->cursor.row) {
if (editor->cursor.col >= offset) {
free(line);
free(it);
return;
}
}
if (visual_rows >= editor->size.row)
break;
uint32_t col = 0;
@@ -238,6 +239,14 @@ void ensure_cursor(Editor *editor) {
left -= g;
col += w;
}
if (line_index == editor->cursor.row) {
if (editor->cursor.col >= offset &&
editor->cursor.col < offset + advance) {
free(line);
free(it);
return;
}
}
if (advance == 0)
break;
offset += advance;