1
0
mirror of https://github.com/shadowfacts/type.git synced 2025-02-05 10:11:24 +00:00

Handle tab press

This commit is contained in:
Shadowfacts 2016-10-02 17:14:01 -04:00
parent a0ef73f313
commit 3d780753c4
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5

View File

@ -165,6 +165,9 @@ function handleKeyDown(event) {
} else if (event.keyCode == 13) { // enter
event.preventDefault();
handleEnter(event);
} else if (event.keyCode == 9) { // tab
event.preventDefault();
handleTab(event);
}
}
}
@ -225,6 +228,14 @@ function handleEnter(event) {
}
}
function handleTab(event) {
let pos = editor.getCursor();
let line = editor.doc.getLine(pos.line);
if (line.charCodeAt(pos.ch) == 9) {
setCursor({ line: pos.line, ch: pos.ch + 1 });
}
}
function moveToEndOfPreviousLine() {
let pos = editor.getCursor();
if (pos.line > 0) {