ComputerCraft Archive

ShellLauncher

computer operating-system kepler155c github

Description

ComputerCraft OS

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/apps/ShellLauncher.lua shelllauncher
Archive:wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-apps-shelllauncher shelllauncher
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-apps-shelllauncher ShellLauncher

Usage

Run: ShellLauncher

Tags

none

Source

View Original Source

Code Preview

local kernel = _G.kernel
local os     = _G.os
local shell  = _ENV.shell

local launcherTab = kernel.getCurrent()
launcherTab.noFocus = true

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('shell'))
		else
			shell.switchTab(nextTab.uid)
		end
	end
end)

os.pullEventRaw('kernel_halt')