made WindowManager a static class

This commit is contained in:
2023-07-27 20:41:23 +02:00
parent 9deea0ee98
commit 74d0232160
5 changed files with 18 additions and 19 deletions

View File

@@ -14,12 +14,11 @@ class WindowManager {
/**
Depends on: KernelEvents, Peripheral
**/
public static var instance:WindowManager;
private var currentMainContext:WindowContext;
private final outputMap:Map<String, WindowContext> = new Map();
private static var currentMainContext:WindowContext;
private static final outputMap:Map<String, WindowContext> = new Map();
@:allow(kernel.Init)
private function new() {
private static function init() {
KernelEvents.onKey.handle(params -> {
if (currentMainContext != null) {
if (currentMainContext.eventDelegate != null){
@@ -116,24 +115,24 @@ class WindowManager {
/**
Same as createNewBufferedContext because it is the most simple context.
**/
public function createNewContext():WindowContext {
public static function createNewContext():WindowContext {
return createNewBufferedContext();
}
public function createNewBufferedContext():WindowContext {
public static function createNewBufferedContext():WindowContext {
var newContext = new WindowContext(new BufferedVirtualTermWriter());
return newContext;
}
public function createNewStatelessContext():{ctx:WindowContext, setRenderFunc:(() -> Void) -> Void, requestRender:Void->Void} {
public static function createNewStatelessContext():{ctx:WindowContext, setRenderFunc:(() -> Void) -> Void, requestRender:Void->Void} {
var writer = new StatelessVirtualTermWriter();
var newContext = new WindowContext(writer);
return {ctx: newContext, setRenderFunc: writer.setRenderFunc, requestRender: writer.requestRender};
}
public function getOutputs():ReadOnlyArray<String> {
public static function getOutputs():ReadOnlyArray<String> {
var arr = Peripheral.getAllScreens().map(screen -> return screen.getAddr());
arr.push("main");
return arr;
@@ -142,7 +141,7 @@ class WindowManager {
/**
Move context to output. If output is "main", context will be moved to main screen.
**/
public function focusContextToOutput(context:WindowContext, output:String) {
public static function focusContextToOutput(context:WindowContext, output:String) {
var target:TermWriteable;
if (output == "main") {
target = MainTerm.instance;
@@ -165,7 +164,7 @@ class WindowManager {
context.enable();
}
public function getContextByPID(pid: PID): ReadOnlyArray<WindowContext> {
public static function getContextByPID(pid: PID): ReadOnlyArray<WindowContext> {
var handle = ProcessManager.getProcess(pid);
if (handle == null) {
return [];