From ec63a65ba3dd803e07f9a541b7dcaaacbb8576c7 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 22 May 2023 22:26:00 +0200 Subject: [PATCH] use new Terminal Process in Terminal --- src/lib/HomeContext.hx | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/lib/HomeContext.hx b/src/lib/HomeContext.hx index d9876a7..4faeed7 100644 --- a/src/lib/HomeContext.hx +++ b/src/lib/HomeContext.hx @@ -1,5 +1,6 @@ package lib; +import kernel.ps.Process; import kernel.ps.ProcessManager; import bin.KernelLog; import lib.ui.elements.UIElement; @@ -89,26 +90,8 @@ class HomeContext { focusContext(contextId); } - private function addTerminal(){ - var newContext = WindowManager.instance.createNewBufferedContext(); - - // Create new terminal - var term = new Terminal(); - term.invoke(newContext); - - var contextID = addContextNextWorkspace(newContext); - if (contextID == -1) { - return; - } - focusContext(contextID); - } - - - private function addLog(){ - var pid = ProcessManager.run(new KernelLog(),{ - - }); - + private function spawnPs(ps: Process) { + var pid = ProcessManager.run(ps, {}); var lastContextID = -1; for ( ctx in WindowManager.instance.getContextByPID(pid)){ @@ -118,7 +101,7 @@ class HomeContext { if (lastContextID == -1) { return; } - focusContext(lastContextID); + focusContext(lastContextID); } private function render() { @@ -132,8 +115,8 @@ class HomeContext { 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})); + 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})); renderer.setChildren(children);