start using tinker
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package kernel.ui;
|
||||
|
||||
import lib.TermWriteable;
|
||||
import kernel.peripherals.Screen;
|
||||
import kernel.peripherals.Peripherals.Peripheral;
|
||||
import haxe.Exception;
|
||||
import util.Vec.Vec2;
|
||||
@@ -13,26 +12,22 @@ enum ButtonType {
|
||||
}
|
||||
|
||||
class WindowManager {
|
||||
public static final instance:WindowManager = new WindowManager();
|
||||
private function new() {}
|
||||
public static var instance:WindowManager;
|
||||
|
||||
private var currentMainContext:WindowContext;
|
||||
private final allContexts:Array<WindowContext> = new Array();
|
||||
private final outputMap:Map<String,WindowContext> = new Map();
|
||||
|
||||
public function init() {
|
||||
@:allow(kernel.Init)
|
||||
private function new() {
|
||||
KernelEvents.instance.on("key",params -> {
|
||||
var keyCode: Int = params[1];
|
||||
var isHeld: Bool = params[2];
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.key(keyCode,isHeld);
|
||||
currentMainContext.keyTrigger.trigger({keyCode: keyCode,isHeld: isHeld});
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.on("key_up",params -> {
|
||||
var keyCode: Int = params[1];
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.keyUp(keyCode);
|
||||
currentMainContext.keyUpTrigger.trigger(keyCode);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -44,7 +39,7 @@ class WindowManager {
|
||||
};
|
||||
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.click(button,clickPos);
|
||||
currentMainContext.clickTrigger.trigger({button: button,pos: clickPos});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,7 +50,7 @@ class WindowManager {
|
||||
y: (params[3]:Int) - 1,
|
||||
}
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseDrag(button,pos);
|
||||
currentMainContext.mouseDragTrigger.trigger({button: button,pos: pos});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -67,7 +62,7 @@ class WindowManager {
|
||||
}
|
||||
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseScroll(dir,pos);
|
||||
currentMainContext.mouseScrollTrigger.trigger({dir: dir,pos: pos});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -79,7 +74,7 @@ class WindowManager {
|
||||
}
|
||||
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseUp(button,pos);
|
||||
currentMainContext.mouseUpTrigger.trigger({button: button,pos: pos});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -87,7 +82,7 @@ class WindowManager {
|
||||
var text: String = params[1];
|
||||
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.paste(text);
|
||||
currentMainContext.pasteTrigger.trigger(text);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,12 +91,16 @@ class WindowManager {
|
||||
});
|
||||
}
|
||||
|
||||
private var currentMainContext:WindowContext;
|
||||
private final allContexts:Array<WindowContext> = new Array();
|
||||
private final outputMap:Map<String,WindowContext> = new Map();
|
||||
|
||||
public function createNewContext(): WindowContext {
|
||||
var newContext = new WindowContext(new VirtualTermWriter());
|
||||
|
||||
allContexts.push(newContext);
|
||||
|
||||
newContext.setTarget(MainTerm.instance);
|
||||
// newContext.setTarget(MainTerm.instance);
|
||||
newContext.enable();
|
||||
currentMainContext = newContext;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user