selection update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user