delete key
This commit is contained in:
parent
2e8923e2e7
commit
99655e663c
15
editmode.ts
15
editmode.ts
@ -50,9 +50,7 @@ const codeTabState = {
|
||||
const lines = this.code.split("\n");
|
||||
const {focusX, focusY, anchorX, anchorY} = this;
|
||||
const newLines = lines.map((line, i) => {
|
||||
console.log(i, Math.min(focusY, anchorY), Math.max(focusY, anchorY));
|
||||
if (i >= Math.min(focusY, anchorY) && i <= Math.max(focusY, anchorY)) {
|
||||
console.log(indentString+line);
|
||||
return indentString+line;
|
||||
} else {
|
||||
return line;
|
||||
@ -86,6 +84,16 @@ const codeTabState = {
|
||||
this.insertText("");
|
||||
}
|
||||
},
|
||||
delete() {
|
||||
const {code, focus} = this;
|
||||
if (this.isCollapsed()) {
|
||||
if (focus < code.length) {
|
||||
this.code = code.slice(0, focus) + code.slice(1+focus);
|
||||
}
|
||||
} else {
|
||||
this.insertText("");
|
||||
}
|
||||
},
|
||||
get code() {
|
||||
return getSheet(0);
|
||||
},
|
||||
@ -164,6 +172,9 @@ const update = () => {
|
||||
if (keyPressed(K.BACKSPACE)) {
|
||||
codeTabState.backspace();
|
||||
}
|
||||
if (keyPressed(K.DELETE)) {
|
||||
codeTabState.delete();
|
||||
}
|
||||
if (keyPressed(K.ARROW_RIGHT)) {
|
||||
if (shiftKeyDown()) {
|
||||
codeTabState.setFocus(focus+1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user