From 963ffb33811ee1dc16198b10472d79aa3df0676b Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Mon, 9 Jan 2017 17:33:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D1=8F=D1=83-=D0=BC=D1=8F=D1=83-=D0=BC?= =?UTF-8?q?=D1=8F=D1=83!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 18436 -> 18436 bytes Applications.txt | 10 +-- Applications/.DS_Store | Bin 77828 -> 77828 bytes Applications/Control2/Control2.lua | 9 +-- .../Control2/Modules/00_LuaConsole.lua | 1 + .../SmartHouse/Modules/command_block/Main.lua | 2 + .../SmartHouse/Modules/homePC/Main.lua | 2 + Applications/SmartHouse/Modules/mfsu/Main.lua | 2 + .../SmartHouse/Modules/motion_sensor/Main.lua | 2 + .../SmartHouse/Modules/reactor/Main.lua | 2 + .../SmartHouse/Modules/redstone/Main.lua | 2 + .../SmartHouse/Modules/screen/Main.lua | 2 + MineOS/OS.lua | 4 +- lib/MineOSCore.lua | 61 +++++++++++------- lib/advancedLua.lua | 12 ++-- 15 files changed, 69 insertions(+), 42 deletions(-) diff --git a/.DS_Store b/.DS_Store index 350867984e897e9225ea55f18391905e5452fb04..167c8c3c555faadb759df99b9ac33df82dbcf0ec 100644 GIT binary patch delta 709 zcmZvYOH30{6o%(7VCT}SodP0^EjBH*MGKS=i8K(3NFP*u#40FiY?*-!wuRbCL|s;; zE|laNi1CR=W1yE(~ueBU`YJ&W`#9(M|;W?h0> zN~>r!d)HLM%r)z5SrUqeV{%q67%FJ3xRD6U{9!4ak_RRvWmJ)+e1$DFRF36aEMh$o z!h9&HoGuR8X(JJmBy?Pf7n(&UZRQ1u?2m>cax_0Lw$e6U2$I1m`9xBgh!>LWbQ^Dg zlMIba#A0$hl`Ocn*o=Z$EB5gG!PP~2BuSRoF1KhUqIUe+xvuuSDRn{wFnHM#$x7FtgX$P$5L4;_&*FX08`w%ar8LOVS0 z!iWBxc>o76h(j38xkqze1>=a~B&Ki*(>Q~4&VKLw>!D1{1d|2hH<(nUsvT&V4eOuQHRp&C5|2aZ!aXU3?!r7-O M*1Mrus8v9Gk1biiVfM^V}W;Z5*?iUBp18MIIep$GyRHfY3! zf;UD?jETmmiHe#D;*#jbxW>y3T=YWttxdRGW|*{s|`3^0@s;} zPs)5O-RSjkT<1VMDehzaOTyPN`Z{l2lXVmZgyBOzz%q%m(v= z`NjNZHkmEv4_M?OA6D4lLJ9UEfGX4=f+%Xyio-aHW9Y1-&SMytFo`K###P+J zJZ^*FKAz(x7V!%2@E#w?tf@pgQlvKhn>&T@TesP!SR_IK(!22Q#G4%+MW$Z=qgr2psMvgx(cj; zbw?6w3_WDQ(%4;sGMcXeO*CB_+HnG1=td7s*oO<~#{d$zh;dA4DQ9pE*D;G5H02%K z#RBf(5gy|Sp5htaK*18;Vi_x1?oi%mqVq3Wf~A$BBUo8=MRZJ6R0KpvS+JZ$^}EPd zzem}bzr`v!jxQj^`VJ-N>dPQbzCdSg;7ByHj@ZqW%6^XzmdL!Qnr7UQz1q#VX#&an zAOq{$x;;|LUeWK;haNb1IS 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 6537b3e11038d958a5c6191fecdf36c58e8df3a4..b683a76f7a157b24341f2d5f6ab9a43d199c212f 100644 GIT binary patch delta 56 ucmZp9z|!)7Wy388c4Jc=1w%u#%?}+`o547fA3At!zFoeNA61}Ta|HlOw-oFE delta 56 ucmZp9z|!)7Wy388b_+ut1tSCV%?}+`o547fA3At!zFoeNA61}Ta|HlPauo6a 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