mirror of https://github.com/shadowfacts/type.git
Handle tab press
This commit is contained in:
parent
a0ef73f313
commit
3d780753c4
11
js/type.js
11
js/type.js
|
@ -165,6 +165,9 @@ function handleKeyDown(event) {
|
||||||
} else if (event.keyCode == 13) { // enter
|
} else if (event.keyCode == 13) { // enter
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
handleEnter(event);
|
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() {
|
function moveToEndOfPreviousLine() {
|
||||||
let pos = editor.getCursor();
|
let pos = editor.getCursor();
|
||||||
if (pos.line > 0) {
|
if (pos.line > 0) {
|
||||||
|
|
Loading…
Reference in New Issue