1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-23 19:57:39 +00:00

format and installer branches

This commit is contained in:
kepler155c@gmail.com
2018-01-24 17:39:38 -05:00
parent 1eea0d7cd8
commit 5a32fe208e
80 changed files with 10742 additions and 10156 deletions

View File

@@ -10,17 +10,17 @@ local textutils = _G.textutils
local data
kernel.hook('clipboard_copy', function(_, args)
data = args[1]
data = args[1]
end)
keyboard.addHotkey('control-shift-paste', function(_, args)
if type(data) == 'table' then
local s, m = pcall(textutils.serialize, data)
data = (s and m) or Util.tostring(data)
end
-- replace the event paste data with our internal data
args[1] = Util.tostring(data or '')
if data then
os.queueEvent('paste', data)
keyboard.addHotkey('shift-paste', function()
if type(data) == 'table' then
local s, m = pcall(textutils.serialize, data)
data = (s and m) or Util.tostring(data)
end
-- replace the event paste data with our internal data
-- args[1] = Util.tostring(data or '')
if data then
os.queueEvent('paste', data)
end
end)

View File

@@ -2,42 +2,42 @@ local modem = _G.device.wireless_modem
local turtle = _G.turtle
if turtle and modem then
local s, m = turtle.run(function()
local s, m = turtle.run(function()
_G.requireInjector()
_G.requireInjector(_ENV)
local Config = require('config')
local config = {
destructive = false,
}
Config.load('gps', config)
local Config = require('config')
local config = {
destructive = false,
}
Config.load('gps', config)
if config.home then
if config.home then
local s = turtle.enableGPS(2)
if not s then
s = turtle.enableGPS(2)
end
if not s and config.destructive then
turtle.setPolicy('turtleSafe')
s = turtle.enableGPS(2)
end
local s = turtle.enableGPS(2)
if not s then
s = turtle.enableGPS(2)
end
if not s and config.destructive then
turtle.setPolicy('turtleSafe')
s = turtle.enableGPS(2)
end
if not s then
error('Unable to get GPS position')
end
if not s then
error('Unable to get GPS position')
end
if config.destructive then
turtle.setPolicy('turtleSafe')
end
if config.destructive then
turtle.setPolicy('turtleSafe')
end
if not turtle.pathfind(config.home) then
error('Failed to return home')
end
end
end)
if not turtle.pathfind(config.home) then
error('Failed to return home')
end
end
end)
if not s and m then
error(m)
end
if not s and m then
error(m)
end
end

View File

@@ -1,14 +1,19 @@
if _G.device.wireless_modem then
_G.requireInjector()
local Config = require('config')
_G.requireInjector(_ENV)
local Config = require('config')
local config = { }
Config.load('gps', config)
local kernel = _G.kernel
if config.host and type(config.host) == 'table' then
_ENV._APP_TITLE = 'GPS Daemon'
os.run(_ENV, '/rom/programs/gps', 'host', config.host.x, config.host.y, config.host.z)
print('GPS daemon stopped')
end
local config = { }
Config.load('gps', config)
if config.host and type(config.host) == 'table' then
kernel.run({
title = 'GPS Daemon',
hidden = true,
path = '/rom/programs/gps',
args = { 'host', config.host.x, config.host.y, config.host.z },
})
end
end

View File

@@ -1,4 +1,4 @@
_G.requireInjector()
_G.requireInjector(_ENV)
local Util = require('util')
@@ -8,50 +8,50 @@ local multishell = _ENV.multishell
-- overview
keyboard.addHotkey('control-o', function()
for _,tab in pairs(multishell.getTabs()) do
if tab.isOverview then
multishell.setFocus(tab.tabId)
end
end
for _,tab in pairs(multishell.getTabs()) do
if tab.isOverview then
multishell.setFocus(tab.uid)
end
end
end)
-- restart tab
keyboard.addHotkey('control-backspace', function()
local uid = multishell.getFocus()
local tab = kernel.find(uid)
if not tab.isOverview then
multishell.terminate(uid)
tab = Util.shallowCopy(tab)
tab.isDead = false
tab.focused = true
multishell.openTab(tab)
end
local uid = multishell.getFocus()
local tab = kernel.find(uid)
if not tab.isOverview then
multishell.terminate(uid)
tab = Util.shallowCopy(tab)
tab.isDead = false
tab.focused = true
multishell.openTab(tab)
end
end)
-- next tab
keyboard.addHotkey('control-tab', function()
local tabs = multishell.getTabs()
local visibleTabs = { }
local currentTabId = multishell.getFocus()
local tabs = multishell.getTabs()
local visibleTabs = { }
local currentTabId = multishell.getFocus()
local function compareTab(a, b)
return a.uid < b.uid
end
for _,tab in Util.spairs(tabs, compareTab) do
if not tab.hidden then
table.insert(visibleTabs, tab)
end
end
local function compareTab(a, b)
return a.uid < b.uid
end
for _,tab in Util.spairs(tabs, compareTab) do
if not tab.hidden then
table.insert(visibleTabs, tab)
end
end
for k,tab in ipairs(visibleTabs) do
if tab.uid == currentTabId then
if k < #visibleTabs then
multishell.setFocus(visibleTabs[k + 1].uid)
return
end
end
end
if #visibleTabs > 0 then
multishell.setFocus(visibleTabs[1].uid)
end
for k,tab in ipairs(visibleTabs) do
if tab.uid == currentTabId then
if k < #visibleTabs then
multishell.setFocus(visibleTabs[k + 1].uid)
return
end
end
end
if #visibleTabs > 0 then
multishell.setFocus(visibleTabs[1].uid)
end
end)

View File

@@ -1,7 +1,7 @@
_G.requireInjector(_ENV)
--[[
Adds a task and the control-d hotkey to view the kernel log.
Adds a task and the control-d hotkey to view the kernel log.
--]]
local kernel = _G.kernel
@@ -10,42 +10,46 @@ local multishell = _ENV.multishell
local os = _G.os
local term = _G.term
local routine = kernel.getCurrent()
if multishell then
multishell.setTitle(multishell.getCurrent(), 'System Log')
multishell.hideTab(routine.uid)
local function systemLog()
local routine = kernel.getCurrent()
local w, h = kernel.window.getSize()
kernel.window.reposition(1, 2, w, h - 1)
routine.terminal = kernel.window
routine.window = kernel.window
term.redirect(kernel.window)
kernel.hook('mouse_scroll', function(_, eventData)
local dir, y = eventData[1], eventData[3]
if y > 1 then
local currentTab = kernel.getFocused()
if currentTab.terminal.scrollUp and not currentTab.terminal.noAutoScroll then
if dir == -1 then
currentTab.terminal.scrollUp()
else
currentTab.terminal.scrollDown()
end
end
end
end)
keyboard.addHotkey('control-d', function()
local current = kernel.getFocused()
if current.uid ~= routine.uid then
kernel.raise(routine.uid)
elseif kernel.routines[2] then
kernel.raise(kernel.routines[2].uid)
end
end)
os.pullEventRaw('terminate')
keyboard.removeHotkey('control-d')
end
local w, h = kernel.window.getSize()
kernel.window.reposition(1, 2, w, h - 1)
routine.terminal = kernel.window
routine.window = kernel.window
term.redirect(kernel.window)
kernel.hook('mouse_scroll', function(_, eventData)
local dir, y = eventData[1], eventData[3]
if y > 1 then
local currentTab = kernel.getFocused()
if currentTab.terminal.scrollUp and not currentTab.terminal.noAutoScroll then
if dir == -1 then
currentTab.terminal.scrollUp()
else
currentTab.terminal.scrollDown()
end
end
end
end)
keyboard.addHotkey('control-d', function()
local current = kernel.getFocused()
if current.uid ~= routine.uid then
kernel.raise(routine.uid)
elseif kernel.routines[2] then
kernel.raise(kernel.routines[2].uid)
end
end)
os.pullEventRaw('terminate')
keyboard.removeHotkey('control-d')
multishell.openTab({
title = 'System Log',
fn = systemLog,
hidden = true,
})