selection update

This commit is contained in:
2026-06-30 21:31:35 +02:00
parent 594c4c674d
commit c4300b0416
10 changed files with 402 additions and 91 deletions
+25
View File
@@ -0,0 +1,25 @@
export function moveUp(buffer, cursor) {
if (cursor.line > 0) cursor.line--;
cursor.col = Math.min(cursor.col, buffer[cursor.line].length);
}
export function moveDown(buffer, cursor) {
if (cursor.line < buffer.length - 1) cursor.line++;
cursor.col = Math.min(cursor.col, buffer[cursor.line].length);
}
export function moveLeft(buffer, cursor) {
if (cursor.col > 0) cursor.col--;
else if (cursor.line > 0) {
cursor.line--;
cursor.col = buffer[cursor.line].length;
}
}
export function moveRight(buffer, cursor) {
if (cursor.col < buffer[cursor.line].length) cursor.col++;
else if (cursor.line < buffer.length - 1) {
cursor.line++;
cursor.col = 0;
}
}