improved home context
This commit is contained in:
parent
4ae6fb4bc7
commit
793639c69d
@ -1,5 +1,6 @@
|
|||||||
package lib;
|
package lib;
|
||||||
|
|
||||||
|
import bin.KernelLog;
|
||||||
import lib.ui.elements.UIElement;
|
import lib.ui.elements.UIElement;
|
||||||
import lib.ui.elements.TextElement;
|
import lib.ui.elements.TextElement;
|
||||||
import lib.ui.elements.RootElement;
|
import lib.ui.elements.RootElement;
|
||||||
@ -80,32 +81,56 @@ class HomeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function handleSelectContext(contextId:Int) {
|
private function handleSelectContext(contextId:Int) {
|
||||||
if (workspaces[contextId] != null) {
|
if (workspaces[contextId] == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
focusContext(contextId);
|
focusContext(contextId);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
private function addTerminal(){
|
||||||
var newContext = WindowManager.instance.createNewBufferedContext();
|
var newContext = WindowManager.instance.createNewBufferedContext();
|
||||||
|
|
||||||
// Create new terminal
|
// Create new terminal
|
||||||
var term = new Terminal();
|
var term = new Terminal();
|
||||||
term.invoke(newContext);
|
term.invoke(newContext);
|
||||||
|
|
||||||
addContextToWorkspace(newContext, contextId);
|
var contextID = addContextNextWorkspace(newContext);
|
||||||
focusContext(contextId);
|
if (contextID == -1) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
focusContext(contextID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function addLog(){
|
||||||
|
var newContext = WindowManager.instance.createNewBufferedContext();
|
||||||
|
|
||||||
|
// Create new terminal
|
||||||
|
var term = new KernelLog();
|
||||||
|
term.invoke(newContext);
|
||||||
|
|
||||||
|
var contextID = addContextNextWorkspace(newContext);
|
||||||
|
if (contextID == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
focusContext(contextID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function render() {
|
private function render() {
|
||||||
ctx.clear();
|
ctx.clear();
|
||||||
ctx.setCursorBlink(false);
|
ctx.setCursorBlink(false);
|
||||||
|
|
||||||
var list = [
|
var workspaceIDs:Array<Int> = [for (k=>v in workspaces) k];
|
||||||
for (i in 0...MAX_CONTEXT) workspaces.exists(i) ? 'Switch to context ${i}' : 'Create new Terminal on context ${i}'
|
workspaceIDs.sort((a, b) -> a - b);
|
||||||
];
|
|
||||||
|
|
||||||
var children:Array<UIElement> = [
|
var children:Array<UIElement> = [
|
||||||
for (i => line in list) new TextElement(line, {onClick: this.handleSelectContext.bind(i)})
|
for (i in workspaceIDs) new TextElement('Switch to ${i + 1}', {onClick: this.handleSelectContext.bind(i)})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
children.push(new TextElement('Add Terminal', {onClick: this.addTerminal}));
|
||||||
|
children.push(new TextElement('Add Log', {onClick: this.addLog}));
|
||||||
|
|
||||||
renderer.setChildren(children);
|
renderer.setChildren(children);
|
||||||
|
|
||||||
renderer.render().renderToContext(ctx);
|
renderer.render().renderToContext(ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user