added UIApp and renamed CLIBase
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
package bin;
|
||||
|
||||
import lib.ui.UIApp;
|
||||
import lib.cli.TermHandle;
|
||||
import lib.cli.CLIBase;
|
||||
import lib.cli.CLIApp;
|
||||
import lib.Color;
|
||||
import kernel.ui.WindowContext;
|
||||
import kernel.ui.WindowManager;
|
||||
|
||||
class Terminal {
|
||||
using tink.CoreApi;
|
||||
|
||||
class Terminal extends UIApp {
|
||||
private var context:WindowContext;
|
||||
private var input:String = "";
|
||||
private var backlog:Array<String> = [];
|
||||
private var exitTrigger: Bool -> Void;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function execute() {
|
||||
this.context = WindowManager.instance.createNewContext();
|
||||
public function invoke(context: WindowContext): Future<Bool> {
|
||||
this.context = context;
|
||||
|
||||
this.context.onChar.handle(char -> {
|
||||
this.input += char;
|
||||
@@ -37,6 +41,11 @@ class Terminal {
|
||||
|
||||
WindowManager.instance.focusContextToOutput(context, "main");
|
||||
this.redrawInput();
|
||||
|
||||
return new Future<Bool>(cb -> {
|
||||
this.exitTrigger = cb;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private function redrawBacklog() {
|
||||
@@ -105,7 +114,7 @@ class Terminal {
|
||||
}
|
||||
});
|
||||
|
||||
var prog:CLIBase = getProgByName(commandName);
|
||||
var prog:CLIApp = getProgByName(commandName);
|
||||
|
||||
if (prog == null) {
|
||||
this.backlog.push("Command not found: " + commandName);
|
||||
@@ -135,7 +144,7 @@ class Terminal {
|
||||
this.redrawBacklog();
|
||||
}
|
||||
|
||||
private function getProgByName(name:String):CLIBase {
|
||||
private function getProgByName(name:String):CLIApp {
|
||||
switch (name) {
|
||||
case "hello":
|
||||
return new HelloWorld();
|
||||
|
||||
Reference in New Issue
Block a user