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 lines = this.code.split("\n");
|
||||||
const {focusX, focusY, anchorX, anchorY} = this;
|
const {focusX, focusY, anchorX, anchorY} = this;
|
||||||
const newLines = lines.map((line, i) => {
|
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)) {
|
if (i >= Math.min(focusY, anchorY) && i <= Math.max(focusY, anchorY)) {
|
||||||
console.log(indentString+line);
|
|
||||||
return indentString+line;
|
return indentString+line;
|
||||||
} else {
|
} else {
|
||||||
return line;
|
return line;
|
||||||
@ -86,6 +84,16 @@ const codeTabState = {
|
|||||||
this.insertText("");
|
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() {
|
get code() {
|
||||||
return getSheet(0);
|
return getSheet(0);
|
||||||
},
|
},
|
||||||
@ -164,6 +172,9 @@ const update = () => {
|
|||||||
if (keyPressed(K.BACKSPACE)) {
|
if (keyPressed(K.BACKSPACE)) {
|
||||||
codeTabState.backspace();
|
codeTabState.backspace();
|
||||||
}
|
}
|
||||||
|
if (keyPressed(K.DELETE)) {
|
||||||
|
codeTabState.delete();
|
||||||
|
}
|
||||||
if (keyPressed(K.ARROW_RIGHT)) {
|
if (keyPressed(K.ARROW_RIGHT)) {
|
||||||
if (shiftKeyDown()) {
|
if (shiftKeyDown()) {
|
||||||
codeTabState.setFocus(focus+1);
|
codeTabState.setFocus(focus+1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user