From 9e4eb1207e3338c5b502befc0f173f61fa12ab6f Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Tue, 23 Apr 2019 14:48:39 -0400 Subject: [PATCH] better shell launcher --- sys/apps/ShellLauncher.lua | 27 +++++++++++++++++++++++++++ sys/apps/system/launcher.lua | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 sys/apps/ShellLauncher.lua diff --git a/sys/apps/ShellLauncher.lua b/sys/apps/ShellLauncher.lua new file mode 100644 index 0000000..9407e46 --- /dev/null +++ b/sys/apps/ShellLauncher.lua @@ -0,0 +1,27 @@ +local kernel = _G.kernel +local os = _G.os +local shell = _ENV.shell + +local launcherTab = kernel.getCurrent() + +kernel.hook('kernel_focus', function(_, eventData) + local focusTab = eventData and eventData[1] + if focusTab == launcherTab.uid then + local previousTab = eventData[2] + local nextTab = launcherTab + if not previousTab then + for _, v in pairs(kernel.routines) do + if not v.hidden and v.uid > nextTab.uid then + nextTab = v + end + end + end + if nextTab == launcherTab then + shell.switchTab(shell.openTab('sys/apps/shell.lua')) + else + shell.switchTab(nextTab.uid) + end + end +end) + +while os.pullEventRaw() do end \ No newline at end of file diff --git a/sys/apps/system/launcher.lua b/sys/apps/system/launcher.lua index a2fb843..5108ad0 100644 --- a/sys/apps/system/launcher.lua +++ b/sys/apps/system/launcher.lua @@ -17,7 +17,7 @@ local tab = UI.Tab { x = 13, y = 2, width = 12, choices = { { name = 'Overview', value = 'sys/apps/Overview.lua' }, - { name = 'Shell', value = 'sys/apps/shell.lua' }, + { name = 'Shell', value = 'sys/apps/ShellLauncher.lua' }, { name = 'Custom', value = 'custom' }, }, },