fixes terminal newline handling
This commit is contained in:
parent
12eb9d05de
commit
e0d4844890
@ -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("");
|
|
||||||
hadInput = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (line in s.split("\n")) {
|
while (true) {
|
||||||
if (line == "") {
|
var found = mfunc();
|
||||||
|
|
||||||
|
if (found == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found == "\n") {
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user