fixed line printing in Terminal

This commit is contained in:
Niklas Kapelle 2024-05-08 15:33:40 +02:00
parent e5b990ae61
commit 1108eab403
Signed by: niklas
GPG Key ID: 4EB651B36D841D16

View File

@ -62,6 +62,8 @@ class Terminal implements IProcess {
if (this.runningPID > 0)
return;
this.backlog.push("> " + this.input);
this.backlog.push("");
var command = this.input;
this.input = "";
this.scrollBack = 0;
@ -91,6 +93,8 @@ class Terminal implements IProcess {
var arg1 = handle.args[0];
this.backlog.push("> " + arg1);
this.backlog.push("");
EndOfLoop.endOfLoop(() -> {
this.invokeCommand(arg1);
});
@ -177,24 +181,13 @@ class Terminal implements IProcess {
return;
}
var mfunc = NativeStringTools.gmatch(s, "(.-)(\n)");
var splits = s.split("\n");
while (true) {
var found = mfunc();
if (found == null) {
break;
}
if (found == "\n") {
this.backlog.push("");
for (i => split in splits) {
if (i == 0) {
this.backlog[this.backlog.length - 1] += split;
} else {
this.backlog.push(found);
}
// Trim the backlog if it's too long
if (this.backlog.length > MAX_BACKLOG) {
this.backlog.shift();
this.backlog.push(split);
}
}