diff --git a/.DS_Store b/.DS_Store index 28f294a7..4f256004 100644 Binary files a/.DS_Store and b/.DS_Store differ 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 92fbffe8..bee85a5e 100644 Binary files a/Applications/.DS_Store and b/Applications/.DS_Store differ 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})