select output on home context
This commit is contained in:
parent
788c839937
commit
2937de86d6
@ -1,5 +1,7 @@
|
||||
package lib;
|
||||
|
||||
import kernel.peripherals.Screen;
|
||||
import kernel.peripherals.Peripherals.Peripheral;
|
||||
import kernel.ps.Process;
|
||||
import kernel.ps.ProcessManager;
|
||||
import bin.KernelLog;
|
||||
@ -23,6 +25,9 @@ class HomeContext {
|
||||
private var currentWorkspace:Int = -1;
|
||||
private var requestRender: Void->Void;
|
||||
private var renderer:RootElement;
|
||||
|
||||
private var selectedOutput:String = "main";
|
||||
private var selectedOutputIndex:Int = -1;
|
||||
|
||||
public function new() {}
|
||||
|
||||
@ -71,7 +76,7 @@ class HomeContext {
|
||||
|
||||
private function focusContext(id:Int) {
|
||||
if (workspaces.exists(id)) {
|
||||
WindowManager.instance.focusContextToOutput(workspaces[id], "main");
|
||||
WindowManager.instance.focusContextToOutput(workspaces[id], selectedOutput);
|
||||
currentWorkspace = id;
|
||||
}
|
||||
}
|
||||
@ -101,7 +106,28 @@ class HomeContext {
|
||||
if (lastContextID == -1) {
|
||||
return;
|
||||
}
|
||||
focusContext(lastContextID);
|
||||
focusContext(lastContextID);
|
||||
|
||||
if (selectedOutputIndex != -1) {
|
||||
requestRender();
|
||||
}
|
||||
}
|
||||
|
||||
private function cycleOutput() {
|
||||
var screenAddr = Peripheral.instance.findAddrByType(Screen.TYPE_NAME);
|
||||
|
||||
if (selectedOutputIndex == -1) {
|
||||
selectedOutputIndex = 0;
|
||||
selectedOutput = screenAddr[selectedOutputIndex];
|
||||
} else if (selectedOutputIndex >= screenAddr.length - 1) {
|
||||
selectedOutputIndex = -1;
|
||||
selectedOutput = "main";
|
||||
} else {
|
||||
selectedOutputIndex++;
|
||||
selectedOutput = screenAddr[selectedOutputIndex];
|
||||
}
|
||||
|
||||
requestRender();
|
||||
}
|
||||
|
||||
private function render() {
|
||||
@ -118,6 +144,7 @@ class HomeContext {
|
||||
children.push(new TextElement('Add Terminal', {onClick: this.spawnPs.bind(new Terminal())}));
|
||||
children.push(new TextElement('Add Log', {onClick: this.spawnPs.bind(new KernelLog())}));
|
||||
children.push(new TextElement('Exit', {onClick: KernelEvents.instance.shutdown}));
|
||||
children.push(new TextElement('Output :${selectedOutput}', {onClick: this.cycleOutput}));
|
||||
|
||||
renderer.setChildren(children);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user