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