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