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;
|
||||
@ -24,6 +26,9 @@ class HomeContext {
|
||||
private var requestRender: Void->Void;
|
||||
private var renderer:RootElement;
|
||||
|
||||
private var selectedOutput:String = "main";
|
||||
private var selectedOutputIndex:Int = -1;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function run() {
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -102,6 +107,27 @@ class HomeContext {
|
||||
return;
|
||||
}
|
||||
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