mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-11 23:34:04 +09:00
edit.js: hit return to add a new line in the middle of the text
This commit is contained in:
@@ -243,7 +243,10 @@ function appendText(code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function appendLine() {
|
function appendLine() {
|
||||||
textbuffer.push("");
|
//textbuffer.push("");
|
||||||
|
let s1 = textbuffer[cursorRow].substring(0, cursorCol);
|
||||||
|
let s2 = textbuffer[cursorRow].substring(cursorCol);
|
||||||
|
textbuffer.splice(cursorRow, 1, s1, s2);
|
||||||
|
|
||||||
// reset horizontal scroll before going to the next line
|
// reset horizontal scroll before going to the next line
|
||||||
scrollHor = 0;
|
scrollHor = 0;
|
||||||
@@ -256,8 +259,9 @@ function appendLine() {
|
|||||||
if (cursorRow >= windowHeight - scrollPeek) {
|
if (cursorRow >= windowHeight - scrollPeek) {
|
||||||
scroll += 1;
|
scroll += 1;
|
||||||
drawLineNumbers();
|
drawLineNumbers();
|
||||||
drawTextbuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawTextbuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextCol() {
|
function nextCol() {
|
||||||
@@ -332,10 +336,13 @@ while (!exit) {
|
|||||||
nextCol(); drawLnCol(); gotoText();
|
nextCol(); drawLnCol(); gotoText();
|
||||||
}
|
}
|
||||||
else if (key == con.KEY_HOME) {
|
else if (key == con.KEY_HOME) {
|
||||||
cursorCol = 0; scrollHor = 0; drawTextLine(cursorRow - scroll); drawLnCol(); gotoText();
|
cursorCol = 0; scrollHor = 0;
|
||||||
|
drawTextLine(cursorRow - scroll); drawLnCol(); gotoText();
|
||||||
}
|
}
|
||||||
else if (key == con.KEY_END) {
|
else if (key == con.KEY_END) {
|
||||||
cursorCol = textbuffer[cursorRow].length; scrollHor = textbuffer[cursorRow].length - paintWidth + 2; drawTextLine(cursorRow - scroll); drawLnCol(); gotoText();
|
cursorCol = textbuffer[cursorRow].length;
|
||||||
|
scrollHor = textbuffer[cursorRow].length - paintWidth + 2;
|
||||||
|
drawTextLine(cursorRow - scroll); drawLnCol(); gotoText();
|
||||||
}
|
}
|
||||||
else if (key >= 32 && key < 128) { // printables (excludes \n)
|
else if (key >= 32 && key < 128) { // printables (excludes \n)
|
||||||
appendText(key);
|
appendText(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user