made WindowManager a static class
This commit is contained in:
@@ -27,7 +27,7 @@ class Init {
|
||||
Log.init();
|
||||
KernelEvents.init();
|
||||
|
||||
WindowManager.instance = new WindowManager();
|
||||
WindowManager.init();
|
||||
MainTerm.instance = new MainTerm();
|
||||
|
||||
BinStore.instance = new BinStore();
|
||||
|
||||
@@ -63,13 +63,13 @@ class ProcessHandle {
|
||||
}
|
||||
|
||||
public function createBufferdWindowContext(): WindowContext {
|
||||
var ctx = WindowManager.instance.createNewContext();
|
||||
var ctx = WindowManager.createNewContext();
|
||||
this.windowContexts.push(ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public function createStatelessWindowContext(): {ctx:WindowContext, setRenderFunc: (() -> Void) -> Void, requestRender:() -> Void} {
|
||||
var ctx = WindowManager.instance.createNewStatelessContext();
|
||||
var ctx = WindowManager.createNewStatelessContext();
|
||||
this.windowContexts.push(ctx.ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -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 [];
|
||||
|
||||
Reference in New Issue
Block a user