BIG FORMATING COMMIT
This commit is contained in:
@@ -15,18 +15,18 @@ class Terminal implements Process {
|
||||
private var handle:ProcessHandle;
|
||||
|
||||
private var ctx:WindowContext;
|
||||
private var requestRender: () -> Void;
|
||||
|
||||
private var requestRender:() -> Void;
|
||||
|
||||
private var input:String = "";
|
||||
private var backlog:Array<String> = [];
|
||||
private var history:Array<String> = [];
|
||||
private var historyIndex:Int = 0;
|
||||
|
||||
private var runningPID:PID = -1;
|
||||
private var runningPID:PID = -1;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function run(handle: ProcessHandle): Void {
|
||||
public function run(handle:ProcessHandle):Void {
|
||||
this.handle = handle;
|
||||
|
||||
var statelessContext = handle.createStatelessWindowContext();
|
||||
@@ -38,7 +38,8 @@ class Terminal implements Process {
|
||||
|
||||
// Add input event handlers
|
||||
handle.addCallbackLink(this.ctx.onChar.handle(char -> {
|
||||
if (this.runningPID > 0) return;
|
||||
if (this.runningPID > 0)
|
||||
return;
|
||||
this.input += char;
|
||||
this.requestRender();
|
||||
}));
|
||||
@@ -47,11 +48,13 @@ class Terminal implements Process {
|
||||
handle.addCallbackLink(this.ctx.onKey.handle(e -> {
|
||||
switch (e.keyCode) {
|
||||
case 259: // Backspace
|
||||
if (this.runningPID > 0) return;
|
||||
if (this.runningPID > 0)
|
||||
return;
|
||||
this.input = this.input.substr(0, this.input.length - 1);
|
||||
this.requestRender();
|
||||
case 257: // Enter
|
||||
if (this.runningPID > 0) return;
|
||||
if (this.runningPID > 0)
|
||||
return;
|
||||
this.backlog.push("> " + this.input);
|
||||
var command = this.input;
|
||||
this.input = "";
|
||||
@@ -145,7 +148,7 @@ class Terminal implements Process {
|
||||
return;
|
||||
}
|
||||
|
||||
this.runningPID = ProcessManager.run(ps,{
|
||||
this.runningPID = ProcessManager.run(ps, {
|
||||
args: commandArgs,
|
||||
onWrite: (s:String) -> {
|
||||
if (s == "") {
|
||||
@@ -159,7 +162,7 @@ class Terminal implements Process {
|
||||
}
|
||||
|
||||
for (line in s.split("\n")) {
|
||||
if (line == ""){
|
||||
if (line == "") {
|
||||
this.backlog.push("");
|
||||
} else {
|
||||
this.backlog[this.backlog.length - 1] += s;
|
||||
@@ -170,7 +173,7 @@ class Terminal implements Process {
|
||||
this.backlog.shift();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.requestRender();
|
||||
},
|
||||
onExit: (success:Bool) -> {
|
||||
@@ -205,7 +208,7 @@ class Terminal implements Process {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Type.createInstance(bin.c,[]);
|
||||
return Type.createInstance(bin.c, []);
|
||||
}
|
||||
|
||||
private function moveCursorToInput() {
|
||||
|
||||
Reference in New Issue
Block a user