format
This commit is contained in:
@@ -4,102 +4,98 @@ import lib.TermWriteable;
|
||||
import kernel.peripherals.Peripherals.Peripheral;
|
||||
|
||||
class WindowManager {
|
||||
public static var instance:WindowManager;
|
||||
public static var instance:WindowManager;
|
||||
|
||||
@:allow(kernel.Init)
|
||||
private function new() {
|
||||
@:allow(kernel.Init)
|
||||
private function new() {
|
||||
KernelEvents.instance.onKey.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.keyTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onKey.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.keyTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onKeyUp.handle(keyCode -> {
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.keyUpTrigger.trigger(keyCode);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onKeyUp.handle(keyCode -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.keyUpTrigger.trigger(keyCode);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseClick.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.clickTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseDrag.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseDragTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseClick.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.clickTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseScroll.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseScrollTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseDrag.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.mouseDragTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMouseUp.handle(params ->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.mouseUpTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseScroll.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.mouseScrollTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onPaste.handle(text->{
|
||||
if (currentMainContext != null){
|
||||
currentMainContext.pasteTrigger.trigger(text);
|
||||
}
|
||||
});
|
||||
KernelEvents.instance.onMouseUp.handle(params -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.mouseUpTrigger.trigger(params);
|
||||
}
|
||||
});
|
||||
|
||||
KernelEvents.instance.onMonitorTouch.handle(params ->{
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
KernelEvents.instance.onPaste.handle(text -> {
|
||||
if (currentMainContext != null) {
|
||||
currentMainContext.pasteTrigger.trigger(text);
|
||||
}
|
||||
});
|
||||
|
||||
private var currentMainContext:WindowContext;
|
||||
private final allContexts:Array<WindowContext> = new Array();
|
||||
private final outputMap:Map<String,WindowContext> = new Map();
|
||||
KernelEvents.instance.onMonitorTouch.handle(params -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
public function createNewContext(): WindowContext {
|
||||
var newContext = new WindowContext(new VirtualTermWriter());
|
||||
private var currentMainContext:WindowContext;
|
||||
private final allContexts:Array<WindowContext> = new Array();
|
||||
private final outputMap:Map<String, WindowContext> = new Map();
|
||||
|
||||
allContexts.push(newContext);
|
||||
public function createNewContext():WindowContext {
|
||||
var newContext = new WindowContext(new VirtualTermWriter());
|
||||
|
||||
// newContext.setTarget(MainTerm.instance);
|
||||
newContext.enable();
|
||||
currentMainContext = newContext;
|
||||
allContexts.push(newContext);
|
||||
|
||||
return newContext;
|
||||
}
|
||||
// newContext.setTarget(MainTerm.instance);
|
||||
newContext.enable();
|
||||
currentMainContext = newContext;
|
||||
|
||||
return newContext;
|
||||
}
|
||||
|
||||
public function getOutputs(): Array<String> {
|
||||
var arr = Peripheral.instance.getScreens().map(screen -> return screen.getAddr());
|
||||
arr.push("main");
|
||||
return arr;
|
||||
}
|
||||
public function getOutputs():Array<String> {
|
||||
var arr = Peripheral.instance.getScreens().map(screen -> return screen.getAddr());
|
||||
arr.push("main");
|
||||
return arr;
|
||||
}
|
||||
|
||||
public function focusContextToOutput(context: WindowContext,output: String) {
|
||||
var target: TermWriteable;
|
||||
if (output == "main"){
|
||||
target = MainTerm.instance;
|
||||
}else{
|
||||
target = Peripheral.instance.getScreen(output);
|
||||
public function focusContextToOutput(context:WindowContext, output:String) {
|
||||
var target:TermWriteable;
|
||||
if (output == "main") {
|
||||
target = MainTerm.instance;
|
||||
} else {
|
||||
target = Peripheral.instance.getScreen(output);
|
||||
|
||||
if (target == null){
|
||||
// output target not found
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
// output target not found
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (outputMap.exists(output)){
|
||||
outputMap[output].disable();
|
||||
}
|
||||
if (outputMap.exists(output)) {
|
||||
outputMap[output].disable();
|
||||
}
|
||||
|
||||
|
||||
outputMap[output] = context;
|
||||
context.setTarget(target);
|
||||
context.enable();
|
||||
}
|
||||
outputMap[output] = context;
|
||||
context.setTarget(target);
|
||||
context.enable();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user