diff --git a/.DS_Store b/.DS_Store index 35086798..167c8c3c 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Applications.txt b/Applications.txt index bfef6ba4..8d4094fc 100644 --- a/Applications.txt +++ b/Applications.txt @@ -8,7 +8,7 @@ about="IgorTimofeev/OpenComputers/master/MineOS/About/", type="Script", forceDownload=true, - version=3.38, + version=3.39, }, { name="MineOS/Pictures/Raspberry.pic", @@ -247,14 +247,14 @@ name="lib/MineOSCore.lua", url="IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua", type="Library", - version=1.33, + version=1.34, }, { name="lib/advancedLua.lua", url="IgorTimofeev/OpenComputers/master/lib/advancedLua.lua", type="Library", preLoadFile=true, - version=1.05, + version=1.06, }, { name="MineOS/System/OS/EFI.lua", @@ -524,7 +524,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Icon.pic", createShortcut="desktop", - version=1.27, + version=1.28, resources={ { name="Modules/command_block/Icon.pic", @@ -616,7 +616,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/Control2/Icon.pic", createShortcut="desktop", - version=1.01, + version=1.02, resources={ { name="LuaLogo.pic", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 6537b3e1..b683a76f 100644 Binary files a/Applications/.DS_Store and b/Applications/.DS_Store differ diff --git a/Applications/Control2/Control2.lua b/Applications/Control2/Control2.lua index 78767128..aaf38f00 100755 --- a/Applications/Control2/Control2.lua +++ b/Applications/Control2/Control2.lua @@ -32,13 +32,14 @@ local function createWindow() window = windows.empty("auto", "auto", math.floor(buffer.screen.width * 0.8), math.floor(buffer.screen.height * 0.7), 78, 24) window:addPanel(1, 1, window.width, window.height, 0xEEEEEE).disabled = true window.tabBar = window:addTabBar(1, 1, window.width, 3, 1, 0xDDDDDD, 0x262626, 0xCCCCCC, 0x262626, "Интерпретатор Lua", "События", "Память", "Диски", "BIOS") - window:addWindowActionButtons(2, 1, false) - window.drawingArea = window:addContainer(1, 4, window.width, window.height - 3, 0xEEEEEE) - window.tabBar.onTabSwitched = function(object, eventData) end - + window:addWindowActionButtons(2, 1, false).close.onTouch = function() + window:close() + end + window.drawingArea = window:addContainer(1, 4, window.width, window.height - 3, 0xEEEEEE) + window.resourcesPath = MineOSCore.getCurrentApplicationResourcesDirectory() window.modules = {} for file in fs.list(window.resourcesPath .. "Modules/") do diff --git a/Applications/Control2/Modules/00_LuaConsole.lua b/Applications/Control2/Modules/00_LuaConsole.lua index 396e4860..73f41e8f 100644 --- a/Applications/Control2/Modules/00_LuaConsole.lua +++ b/Applications/Control2/Modules/00_LuaConsole.lua @@ -1,5 +1,6 @@ local args = {...} +local buffer = require("doubleBuffering") local GUI = require("GUI") local image = require("image") local unicode = require("unicode") diff --git a/Applications/SmartHouse/Modules/command_block/Main.lua b/Applications/SmartHouse/Modules/command_block/Main.lua index 6cbba50b..ea2a9b28 100755 --- a/Applications/SmartHouse/Modules/command_block/Main.lua +++ b/Applications/SmartHouse/Modules/command_block/Main.lua @@ -1,4 +1,6 @@ +local GUI = require("GUI") + local module = { allowSignalConnections = true, updateWhenModuleDetailsIsHidden = false, diff --git a/Applications/SmartHouse/Modules/homePC/Main.lua b/Applications/SmartHouse/Modules/homePC/Main.lua index 30ff3f0e..a2f51fd9 100755 --- a/Applications/SmartHouse/Modules/homePC/Main.lua +++ b/Applications/SmartHouse/Modules/homePC/Main.lua @@ -1,4 +1,6 @@ +local GUI = require("GUI") + local module = { allowSignalConnections = false, updateWhenModuleDetailsIsHidden = false, diff --git a/Applications/SmartHouse/Modules/mfsu/Main.lua b/Applications/SmartHouse/Modules/mfsu/Main.lua index 1bf3700b..57d7fe5f 100755 --- a/Applications/SmartHouse/Modules/mfsu/Main.lua +++ b/Applications/SmartHouse/Modules/mfsu/Main.lua @@ -1,4 +1,6 @@ +local GUI = require("GUI") + local module = { allowSignalConnections = false, updateWhenModuleDetailsIsHidden = false, diff --git a/Applications/SmartHouse/Modules/motion_sensor/Main.lua b/Applications/SmartHouse/Modules/motion_sensor/Main.lua index 8602ee5d..d517bf57 100755 --- a/Applications/SmartHouse/Modules/motion_sensor/Main.lua +++ b/Applications/SmartHouse/Modules/motion_sensor/Main.lua @@ -1,4 +1,6 @@ +local GUI = require("GUI") + local module = { allowSignalConnections = false, updateWhenModuleDetailsIsHidden = true, diff --git a/Applications/SmartHouse/Modules/reactor/Main.lua b/Applications/SmartHouse/Modules/reactor/Main.lua index ac4a3ce8..9f2d7405 100755 --- a/Applications/SmartHouse/Modules/reactor/Main.lua +++ b/Applications/SmartHouse/Modules/reactor/Main.lua @@ -1,4 +1,6 @@ +local GUI = require("GUI") + local module = { allowSignalConnections = false, updateWhenModuleDetailsIsHidden = false, diff --git a/Applications/SmartHouse/Modules/redstone/Main.lua b/Applications/SmartHouse/Modules/redstone/Main.lua index 80f51f14..b6112dd2 100755 --- a/Applications/SmartHouse/Modules/redstone/Main.lua +++ b/Applications/SmartHouse/Modules/redstone/Main.lua @@ -1,3 +1,5 @@ + +local GUI = require("GUI") local sides = require("sides") local module = { diff --git a/Applications/SmartHouse/Modules/screen/Main.lua b/Applications/SmartHouse/Modules/screen/Main.lua index a09a8d93..d14a0ae4 100755 --- a/Applications/SmartHouse/Modules/screen/Main.lua +++ b/Applications/SmartHouse/Modules/screen/Main.lua @@ -1,4 +1,6 @@ +local GUI = require("GUI") + local module = { allowSignalConnections = false, updateWhenModuleDetailsIsHidden = false, diff --git a/MineOS/OS.lua b/MineOS/OS.lua index 3cd30857..70e9f5d3 100755 --- a/MineOS/OS.lua +++ b/MineOS/OS.lua @@ -1,7 +1,5 @@ -package.loaded.MineOSCore, _G.MineOSCore = nil, nil -package.loaded.GUI, _G.GUI = nil, nil -package.loaded.windows, _G.windows = nil, nil +-- package.loaded.MineOSCore, package.loaded.GUI, package.loaded.windows = nil, nil, nil ---------------------------------------------- Копирайт, епта ------------------------------------------------------------------------ diff --git a/lib/MineOSCore.lua b/lib/MineOSCore.lua index 3c28f57c..07936e2a 100755 --- a/lib/MineOSCore.lua +++ b/lib/MineOSCore.lua @@ -449,7 +449,7 @@ function MineOSCore.parseErrorMessage(error, indentationWidth) return parsedError end -local function drawErrorWindow(path, programVersion, errorLine, reason, showSendToDeveloperButton) +local function drawErrorWindow(path, programVersion, errorLine, reason) local drawLimit = buffer.getDrawLimit(); buffer.resetDrawLimit() local colors = { topBar = 0x383838, title = 0xFFFFFF } local programName = MineOSCore.localization.errorWhileRunningProgram .. "\"" .. fs.name(path) .. "\"" @@ -557,48 +557,61 @@ end function MineOSCore.safeLaunch(path, ...) local args = {...} - local oldResolutionWidth, oldResolutionHeight = component.gpu.getResolution() - local finalSuccess, finalReason = true, true - local loadSuccess, loadReason = loadfile(string.canonicalPath("/" .. path)) + local oldResolutionWidth, oldResolutionHeight = buffer.screen.width, buffer.screen.height + local finalSuccess, finalPath, finalLine, finalTraceback = true if fs.exists(path) then + local loadSuccess, loadReason = loadfile(string.canonicalPath("/" .. path)) + if loadSuccess then - local function launcher() + local function launchMethod() loadSuccess(table.unpack(args)) end - - local runSuccess, runReason = xpcall(launcher, debug.traceback) - if not runSuccess then - if type(runReason) == "string" then - if not string.find(runReason, "interrupted", 1, 15) then - finalSuccess, finalReason = false, runReason + + local function tracebackMethod(xpcallTraceback) + local traceback, info, firstMatch = xpcallTraceback .. "\n" .. debug.traceback() + for runLevel = 0, math.huge do + info = debug.getinfo(runLevel) + if info then + if (info.what == "main" or info.what == "Lua") and info.source ~= "=machine" then + if firstMatch then + return { + path = info.source:sub(2, -1), + line = info.currentline, + traceback = traceback + } + else + firstMatch = true + end + end + else + error("Failed to get debug info for runlevel " .. runLevel) end end end + + local runSuccess, runReason = xpcall(launchMethod, tracebackMethod) + if not runSuccess and not string.find(runReason.traceback, "interrupted", 1, 15) then + finalSuccess, finalPath, finalLine, finalTraceback = false, runReason.path, runReason.line, runReason.traceback + end else - finalSuccess, finalReason = false, loadReason + finalSuccess, finalPath, finalTraceback = false, path, loadReason + local match = string.match(loadReason, ":(%d+)%:") + finalLine = tonumber(match) + if not match or not finalLine then error("Дебажь говно! " .. tostring(loadReason)) end end else - finalSuccess, finalReason = false, unicode.sub(debug.traceback(), 19, -1) + GUI.error("Failed to safely launch file that doesn't exists: \"" .. path .. "\"", {title = {color = 0xFFDB40, text = "Warning"}}) end if not finalSuccess then - finalReason = string.canonicalPath("/" .. finalReason) - local match = string.match(finalReason, "%/[^%:]+%:%d+%:") - if match then - local errorLine = tonumber(unicode.sub(string.match(match, "%:%d+%:"), 2, -2)) - local errorPath = unicode.sub(string.match(match, "%/[^%:]+%:"), 1, -2) - - drawErrorWindow(errorPath, programVersion, errorLine, finalReason, applicationExists) - else - GUI.error("Unknown error in lib/MineOSCore.lua due program execution: possible reason is \"" .. tostring(finalReason) .. "\"") - end + drawErrorWindow(finalPath, "1.0", finalLine, finalTraceback) end component.gpu.setResolution(oldResolutionWidth, oldResolutionHeight) buffer.start() - return finalSuccess, finalReason + return finalSuccess, finalPath, finalLine, finalTraceback end ----------------------------------------------------------------------------------------------------------------------------------- diff --git a/lib/advancedLua.lua b/lib/advancedLua.lua index 5d75dc76..5357fedb 100755 --- a/lib/advancedLua.lua +++ b/lib/advancedLua.lua @@ -17,16 +17,16 @@ local bit32 = require("bit32") -------------------------------------------------- System extensions -------------------------------------------------- function _G.getCurrentScript() - local runLevel, info = 0 - while true do + local info + for runLevel = 0, math.huge do info = debug.getinfo(runLevel) if info then - if info.what == "main" and filesystem.exists(info.short_src) then return info.short_src end + if info.what == "main" then + return info.source:sub(2, -1) + end else - error("Failed to get running script: current runLevel is " .. runLevel) + error("Failed to get debug info for runlevel " .. runLevel) end - - runLevel = runLevel + 1 end end