fixes terminal newline handling

This commit is contained in:
Niklas Kapelle 2023-11-15 17:42:22 +01:00
parent 12eb9d05de
commit e0d4844890
Signed by: niklas
GPG Key ID: 4EB651B36D841D16

View File

@ -1,5 +1,6 @@
package bin; package bin;
import lua.NativeStringTools;
import kernel.binstore.BinStore; import kernel.binstore.BinStore;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.Process;
@ -139,7 +140,6 @@ class Terminal implements Process {
} }
var commandArgs:Array<String> = args.slice(1); var commandArgs:Array<String> = args.slice(1);
var hadInput = false;
var ps = getProgByName(commandName); var ps = getProgByName(commandName);
if (ps == null) { if (ps == null) {
@ -155,17 +155,19 @@ class Terminal implements Process {
return; return;
} }
if (!hadInput) { var mfunc = NativeStringTools.gmatch(s, "(.-)(\n)");
// Add a new line, so that the input is not on the same line as the command
this.backlog.push(""); while (true) {
hadInput = true; var found = mfunc();
if (found == null) {
break;
} }
for (line in s.split("\n")) { if (found == "\n") {
if (line == "") {
this.backlog.push(""); this.backlog.push("");
} else { } else {
this.backlog[this.backlog.length - 1] += s; this.backlog.push(found);
} }
// Trim the backlog if it's too long // Trim the backlog if it's too long