From a0c5b181cdc0ed07d9e24ddc3d46893178d0ed2d Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Tue, 10 Jan 2017 07:42:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B3=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 | 6 +-- Applications/.DS_Store | Bin 77828 -> 79876 bytes .../Control2/Modules/00_LuaConsole.lua | 39 +++++++---------- lib/MineOSCore.lua | 41 ++++++++++-------- 5 files changed, 41 insertions(+), 45 deletions(-) diff --git a/.DS_Store b/.DS_Store index 28f294a746f3a0bbc5db91965975e0480e802614..4f256004b56fdd46e754103751bede640c9aa3c3 100644 GIT binary patch delta 515 zcmY+AOKeP00EX`u#66s5&P=QAT$RXlRK-L)+DvNFhFXkj6^o(OBBs5!&28sFXEa_r z<1sdx93c{-2(hC^vbFSia_)DXXA_U)%b4wFn$`pjNh0D)*=ZK zqM0!5>>y4zJ?v(HeeCA|Nse)x6Qr2rB&Wzz-~yMpOo?k~?r@iT%=462yylHA1%_8Q z_3iEV$%Nji?(0(Rl%8&F@ilt?$dC+IZc~PyZyj5e5T?RgcW|_w7`sTYhklPd$YF*U zVbo(!cwCn$(wt_NGo0l-MUQ`ls}=qYZgPv;Jm4XZc+3+Pc+LwJdC6Pe@xB~icM-EQ g8jEb)9_`X?@xF3R!>2X>D;=S44gZvKTl{0qAB7!)hX4Qo delta 609 zcmXYt&1(}u7{=$Z*6zxbPSTb%D`icJ$)O=u`~XumsTOT*i={@5qzY?xquZuQ=|-zn z=)ovPP^*Jj!HXg)h#w_XJ&IoZ1By3Kp1tWs@MC6@ISlj8^L{Xtcjqo@WOAjM8K+qG ze26uY6a9v9T845-I^;#TW_@SK!t diff --git a/Applications.txt b/Applications.txt index 2bd0e735..a9fab9a6 100644 --- a/Applications.txt +++ b/Applications.txt @@ -8,7 +8,7 @@ about="IgorTimofeev/OpenComputers/master/MineOS/About/", type="Script", forceDownload=true, - version=3.41, + version=3.42, }, { name="MineOS/Pictures/Raspberry.pic", @@ -253,7 +253,7 @@ name="lib/MineOSCore.lua", url="IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua", type="Library", - version=1.36, + version=1.37, }, { name="lib/advancedLua.lua", @@ -622,7 +622,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/Control2/Icon.pic", createShortcut="desktop", - version=1.03, + version=1.04, resources={ { name="LuaLogo.pic", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 92fbffe86ec464873609fd4d50c0e4dce358ceb3..bee85a5ee55242610b1c05cb0a01ab98cf864b84 100644 GIT binary patch delta 622 zcmZuvO=uHQ5PtJ^+wR&;c4Hf=Nvf$;#89<~G3HRxV1ftHl%S_VsbbMqi$7_s1wB*< zB2pz~kfk7051u28cEMt;=)ps&nv;c!%|)n)1`mP-!AURm;Ng2S-<$bh-n_4{q86%Z zlMn(9UmXYw=;Tym);ZY}ZMB$4CJBz*!*p2W#gI55&WPOPm3CdJ2^k&?FZggc=W5K0 z(;_F%@tG%3>s1P>-3m2m<+v6N$2x+MaGWa1(Ehr5mboyy?4_lp>k`~Fw>l=lq~cmh z!e*zU!yO4tb}|6X&Zn(#R&u<*3q~ZSdfwC-tk%dF&o-!>>14@mK<4FcX}@ZLBbdAw zz&?Kl=U;a?Za*A^4e|5>wvGkJEcUsuzkSt??S?X?re{n{J~&FL(%T?dXuMBgDES2U zJ@3&~k>S@|6qj%^+m0{n8628@ils*}?3Zc?4)3unF{1c! z?b`NQbV5P6P=`I=2b?`#c&PqQ_(k*bc57}x^LBzAa7&1BgMXZ1F@gqp)RKbc#9qB- bgL#I)F2irIYicfvuU`yK+;ysL(5U0e@<*XVXr(R@-};4zC#t*LDrvb<%b#r#*6F@Rt0uFj zm9gEFBr8fi0T~mRMiWs%-pjzy7{s(n^@&UBDd;`q@SIulO?1MBQQ%zH$vK-LgoK<- z!Chh9U&8mfDQ?|#gMrWI;6PwB#r;E-Z0DR6!P13JFGxW#W&aPa9cOvITuFvz`dV}OmHy&;*(~` z*>b1-+k|CRCc_ZG$s1!_rozx}$71l3x6|9R+tjE`xKOW8O#e&L)BFm`z=}u|10tMG X+ehLsrr=s`mfN4h@CyD*rz?K|=uy|M diff --git a/Applications/Control2/Modules/00_LuaConsole.lua b/Applications/Control2/Modules/00_LuaConsole.lua index 964cbcd9..f3d06cdb 100644 --- a/Applications/Control2/Modules/00_LuaConsole.lua +++ b/Applications/Control2/Modules/00_LuaConsole.lua @@ -18,6 +18,15 @@ function module.execute(window) error = 0xFF4940, } + window.drawingArea:deleteChildren() + local logoPanelWidth = 20 + local consolePanelWidth = window.drawingArea.width - logoPanelWidth + local luaLogoPanel = window.drawingArea:addPanel(1, 1, logoPanelWidth, window.drawingArea.height, 0xEEEEEE) + local luaLogoImage = window.drawingArea:addImage(2, 1, image.load(window.resourcesPath .. "LuaLogo.pic")) + local luaCopyrightTextBox = window.drawingArea:addTextBox(2, luaLogoImage.height + 2, luaLogoPanel.width - 2, 5, nil, 0x999999, {_G._VERSION, "(C) 1994-2016", "Lua.org, PUC-Rio", "", "GUI-based by ECS"}, 1) + luaCopyrightTextBox:setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + local consolePanel = window.drawingArea:addPanel(logoPanelWidth + 1, 1, consolePanelWidth, window.drawingArea.height, 0x1E1E1E) + local lines = { {color = 0xFFDB40, text = "Система " .. _VERSION .. " инициализирована"}, {color = colors.passive, text = "● Введите выражение и нажимте Enter для его "}, @@ -28,23 +37,13 @@ function module.execute(window) {color = colors.passive, text = " конкретной переменной"}, " " } - - window.drawingArea:deleteChildren() - local logoPanelWidth = 20 - local consolePanelWidth = window.drawingArea.width - logoPanelWidth - local luaLogoPanel = window.drawingArea:addPanel(1, 1, logoPanelWidth, window.drawingArea.height, 0xEEEEEE) - local luaLogoImage = window.drawingArea:addImage(2, 1, image.load(window.resourcesPath .. "LuaLogo.pic")) - local luaCopyrightTextBox = window.drawingArea:addTextBox(2, luaLogoImage.height + 2, luaLogoPanel.width - 2, 5, nil, 0x999999, {_G._VERSION, "(C) 1994-2016", "Lua.org, PUC-Rio", "", "GUI-based by ECS"}, 1) - luaCopyrightTextBox:setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) - local consolePanel = window.drawingArea:addPanel(logoPanelWidth + 1, 1, consolePanelWidth, window.drawingArea.height, 0x1E1E1E) local consoleTextBox = window.drawingArea:addTextBox(logoPanelWidth + 2, 1, consolePanelWidth - 2, window.drawingArea.height - 3, nil, 0xFFFFFF, lines, 1) + local consoleCommandInputTextBox = window.drawingArea:addInputTextBox(logoPanelWidth + 1, consolePanel.height - 2, consolePanel.width, 3, 0x333333, 0x777777, 0x333333, 0x444444, nil, "print(\"Hello, world!\")") consoleCommandInputTextBox.highlightLuaSyntax = true consoleCommandInputTextBox.autocompleteVariables = true - -- table.toFile("text.txt", MineOSCore, true, nil, nil, 1) - - local function addLines(lines) + local function addLines(lines, printColor) for i = 1, #lines do if #consoleTextBox.lines > luaConsoleHistoryLimit then table.remove(consoleTextBox.lines, 1) end table.insert(consoleTextBox.lines, printColor and {color = printColor, text = lines[i]} or lines[i]) @@ -53,7 +52,7 @@ function module.execute(window) end local function getStringValueOfVariable(variable) - local type, value = type(variable), "" + local type, value = type(variable) if type == "table" then value = table.serialize(variable, true, nil, nil, 1) else @@ -82,12 +81,10 @@ function module.execute(window) local oldPrint = print print = reimplementedPrint -- Пишем, че мы вообще исполняли - printColor = colors.passive - addLines({"> " .. consoleCommandInputTextBox.text}) - printColor = nil + addLines({"> " .. consoleCommandInputTextBox.text}, colors.passive) -- Ебашим поддержку = - if unicode.sub(consoleCommandInputTextBox.text, 1, 1) == "=" then consoleCommandInputTextBox.text = "return " .. unicode.sub(consoleCommandInputTextBox.text, 2, -1) end + consoleCommandInputTextBox.text = consoleCommandInputTextBox.text:gsub("^[%s+]?%=[%s+]?", "return ") local loadSuccess, loadReason = load(consoleCommandInputTextBox.text) if loadSuccess then local xpcallResult = {xpcall(loadSuccess, debug.traceback)} @@ -95,14 +92,10 @@ function module.execute(window) table.remove(xpcallResult, 1) reimplementedPrint(table.unpack(xpcallResult)) else - printColor = colors.error - reimplementedPrint(xpcallResult[2]) - printColor = nil + addLines({xpcallResult[2]}, colors.error) end else - printColor = colors.error - reimplementedPrint(loadReason) - printColor = nil + addLines({loadReason}, colors.error) end consoleCommandInputTextBox.text = nil diff --git a/lib/MineOSCore.lua b/lib/MineOSCore.lua index b0ecc1eb..e4921c48 100755 --- a/lib/MineOSCore.lua +++ b/lib/MineOSCore.lua @@ -48,7 +48,7 @@ MineOSCore.localization = {} ---------------------------------------------- Current sсript processing methods ------------------------------------------------------------------------ function MineOSCore.getCurrentScriptDirectory() - return fs.path(getCurrentScript()) + return MineOSCore.getFilePath(getCurrentScript()) end function MineOSCore.getCurrentApplicationResourcesDirectory() @@ -86,13 +86,16 @@ end ---------------------------------------------- Filesystem-related methods ------------------------------------------------------------------------ local function getFilenameAndFormat(path) - local fileName, format = string.match(path, "^(.+)(%..+)$") - return (fileName or path), (format and string.gsub(format, "%/+$", "") or nil) + local fileName, format = string.match(path, "^(.+)(%.[^%/]+)%/?$") + return (fileName or path), format end -local function getFilePathAndName(path) - local filePath, fileName = string.math(path, "^(.+%/)(.+)$") - return (filePath or "/"), (fileName or path) +function MineOSCore.getFilePath(path) + return string.match(path, "^(.+%/).") or "" +end + +function MineOSCore.getFileName(path) + return string.match(path, "%/?([^%/]+)%/?$") end function MineOSCore.getFileFormat(path) @@ -234,7 +237,7 @@ function MineOSCore.analyseIconFormat(iconObject) iconObject.launch = function() ecs.applicationHelp(iconObject.path) - MineOSCore.safeLaunch(iconObject.path .. "/" .. MineOSCore.hideFileFormat(fs.name(iconObject.path)) .. ".lua") + MineOSCore.safeLaunch(iconObject.path .. "/" .. MineOSCore.hideFileFormat(MineOSCore.getFileName(iconObject.path)) .. ".lua") end else iconObject.iconImage.image = MineOSCore.icons.folder @@ -288,7 +291,7 @@ function MineOSCore.analyseIconFormat(iconObject) elseif iconObject.format == ".pkg" or iconObject.format == ".zip" then iconObject.iconImage.image = MineOSCore.icons.archive iconObject.launch = function() - zip.unarchive(iconObject.path, (fs.path(iconObject.path) or "")) + zip.unarchive(iconObject.path, (MineOSCore.getFilePath(iconObject.path) or "")) end elseif iconObject.format == ".3dm" then iconObject.iconImage.image = MineOSCore.icons.model3D @@ -332,15 +335,15 @@ function MineOSCore.createIconObject(x, y, path, textColor, showFileFormat) iconObject.isSelected = false iconObject.iconImage = iconObject:addImage(3, 1, {width = 8, height = 4}) - iconObject.textLabel = iconObject:addLabel(1, MineOSCore.iconHeight, MineOSCore.iconWidth, 1, textColor, fs.name(iconObject.path)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + iconObject.textLabel = iconObject:addLabel(1, MineOSCore.iconHeight, MineOSCore.iconWidth, 1, textColor, MineOSCore.getFileName(iconObject.path)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) local oldDraw = iconObject.draw iconObject.draw = function(iconObject) if iconObject.isSelected then buffer.square(iconObject.x, iconObject.y, iconObject.width, iconObject.height, 0xFFFFFF, 0x000000, " ", 50) end if iconObject.showFormat then - iconObject.textLabel.text = MineOSCore.limitFileName(fs.name(iconObject.path), iconObject.textLabel.width) + iconObject.textLabel.text = MineOSCore.limitFileName(MineOSCore.getFileName(iconObject.path), iconObject.textLabel.width) else - iconObject.textLabel.text = MineOSCore.limitFileName(MineOSCore.hideFileFormat(fs.name(iconObject.path)), iconObject.textLabel.width) + iconObject.textLabel.text = MineOSCore.limitFileName(MineOSCore.hideFileFormat(MineOSCore.getFileName(iconObject.path)), iconObject.textLabel.width) end oldDraw(iconObject) if iconObject.isShortcut then buffer.set(iconObject.iconImage.x + iconObject.iconImage.width - 1, iconObject.iconImage.y + iconObject.iconImage.height - 1, 0xFFFFFF, 0x000000, "<") end @@ -453,7 +456,7 @@ end 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) .. "\"" + local programName = MineOSCore.localization.errorWhileRunningProgram .. "\"" .. MineOSCore.getFileName(path) .. "\"" local width, height = buffer.screen.width, math.floor(buffer.screen.height * 0.45) local x, y = 1, math.floor(buffer.screen.height / 2 - height / 2) local codeWidth, codeHeight = math.floor(width * 0.62), height - 3 @@ -726,7 +729,7 @@ function MineOSCore.iconRightClick(icon, eventData) elseif action == "Свойства" then MineOSCore.showPropertiesWindow(eventData[3], eventData[4], 36, 11, icon) elseif action == MineOSCore.localization.contextMenuShowContainingFolder then - computer.pushSignal("MineOSCore", "changeWorkpath", fs.path(icon.shortcutPath)) + computer.pushSignal("MineOSCore", "changeWorkpath", MineOSCore.getFilePath(icon.shortcutPath)) computer.pushSignal("MineOSCore", "updateFileList") elseif action == MineOSCore.localization.contextMenuEditInPhotoshop then MineOSCore.safeLaunch("MineOS/Applications/Photoshop.app/Photoshop.lua", "open", icon.path) @@ -743,11 +746,11 @@ function MineOSCore.iconRightClick(icon, eventData) _G.clipboardCut = true computer.pushSignal("MineOSCore", "updateFileList") elseif action == MineOSCore.localization.contextMenuDelete then - if fs.path(icon.path) == MineOSCore.paths.trash then + if MineOSCore.getFilePath(icon.path) == MineOSCore.paths.trash then fs.remove(icon.path) else - local newName = MineOSCore.paths.trash .. fs.name(icon.path) - local clearName = MineOSCore.hideFileFormat(fs.name(icon.path)) + local newName = MineOSCore.paths.trash .. MineOSCore.getFileName(icon.path) + local clearName = MineOSCore.hideFileFormat(MineOSCore.getFileName(icon.path)) local repeats = 1 while fs.exists(newName) do newName, repeats = MineOSCore.paths.trash .. clearName .. string.rep("-copy", repeats) .. icon.format, repeats + 1 @@ -759,11 +762,11 @@ function MineOSCore.iconRightClick(icon, eventData) ecs.rename(icon.path) computer.pushSignal("MineOSCore", "updateFileList") elseif action == MineOSCore.localization.contextMenuCreateShortcut then - ecs.createShortCut(fs.path(icon.path) .. "/" .. ecs.hideFileFormat(fs.name(icon.path)) .. ".lnk", icon.path) + ecs.createShortCut(MineOSCore.getFilePath(icon.path) .. "/" .. ecs.hideFileFormat(MineOSCore.getFileName(icon.path)) .. ".lnk", icon.path) computer.pushSignal("MineOSCore", "updateFileList") elseif action == MineOSCore.localization.contextMenuArchive then -- ecs.info("auto", "auto", "", "Архивация файлов...") - archive.pack(ecs.hideFileFormat(fs.name(icon.path))..".pkg", icon.path) + archive.pack(ecs.hideFileFormat(MineOSCore.getFileName(icon.path))..".pkg", icon.path) computer.pushSignal("MineOSCore", "updateFileList") elseif action == MineOSCore.localization.contextMenuSetAsWallpaper then fs.remove(MineOSCore.paths.wallpaper) @@ -775,7 +778,7 @@ function MineOSCore.iconRightClick(icon, eventData) file:close() computer.beep(1500, 0.2) elseif action == MineOSCore.localization.contextMenuCreateApplication then - ecs.newApplicationFromLuaFile(icon.path, fs.path(icon.path) or "") + ecs.newApplicationFromLuaFile(icon.path, MineOSCore.getFilePath(icon.path) or "") computer.pushSignal("MineOSCore", "updateFileList") elseif action == MineOSCore.localization.contextMenuAddToDock then table.insert(_G.OSSettings.dockShortcuts, {path = icon.path})