Skip to content

Commit

Permalink
included delete key in editor, fixes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
tmhglnd committed Feb 19, 2021
1 parent 07cf633 commit 09f080c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 17 additions & 5 deletions mercury_ide/external/th.gl.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function keyPress(k){
// Backspace Win = 8, Mac = 127
// Delete Win = 127, Mac = 127
else if (k == keys["backspace"]){ backSpace(); }
else if (k == keys["delete"]){ deleteChar(); }
// arrow keys Platform-independent
else if (k == keys["tab"]){ addTab(); }
else if (k == keys["up"] || k == keys["down"]){
Expand Down Expand Up @@ -298,7 +299,7 @@ function addChar(k){
}

// backspace a character
function backSpace(k){
function backSpace(){
// decrement character index
curChar = Math.max(-1, (curChar-=1));

Expand All @@ -314,6 +315,18 @@ function backSpace(k){
}
}

// delete a character (oposite of backspace)
function deleteChar(){
if (curChar < textBuf[curLine].length){
textBuf[curLine] = textBuf[curLine].removeCharAt(curChar);
} else {
if (curLine < textBuf.length-1){
gotoLine(1);
removeLine();
}
}
}

// ===========
// Deprecated

Expand Down Expand Up @@ -643,13 +656,12 @@ function fillText(mat){
function set(){
var text = arrayfromargs(arguments);
totalLines = Math.min(EDITOR_LINES, text.length);
text = text.slice(0, totalLines);

text = text.slice(0, totalLines);
// empty buffer
textBuf = [];
textBuf = Array.isArray(text)? text : [text];;
textBuf = Array.isArray(text)? text : [text];

curLine = textBuf.length - 1;
curLine = textBuf.length-1;
jumpTo(2);
jumpTo(1);
draw();
Expand Down
4 changes: 2 additions & 2 deletions mercury_ide/patchers/_mercury_main.maxpat
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 416.333333333333371, 1146.0, 73.0, 22.0 ],
"patching_rect" : [ 390.0, 1185.0, 73.0, 22.0 ],
"text" : "s storePrefs"
}

Expand Down Expand Up @@ -61408,7 +61408,7 @@
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 50.0, 194.0, 80.0, 22.0 ],
"patching_rect" : [ 50.0, 195.0, 80.0, 22.0 ],
"text" : "prepend read"
}

Expand Down

0 comments on commit 09f080c

Please sign in to comment.