From 2efca54459e7bf7947b1cfd6bae8ae0c41fd7ae2 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Tue, 17 Oct 2017 20:21:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D1=87=D0=B0=20=D0=B7=D0=B0=D0=BA?= =?UTF-8?q?=D1=80=D1=8B=D1=82=D0=B8=D1=8F=20=D0=BE=D0=BA=D0=BE=D0=BD=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=BD=D0=B0=D0=B6=D0=B0=D1=82=D0=B8=D1=8E=20ctr?= =?UTF-8?q?l+w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications.cfg | 15 +++---- Applications/Braille/Main.lua | 2 +- Applications/Control/Modules/1.lua | 6 +-- OS.lua | 1 - lib/GUI.lua | 72 +++++++++++++++++------------- lib/MineOSInterface.lua | 14 +++--- lib/advancedLua.lua | 6 ++- lib/palette.lua | 7 +-- 8 files changed, 64 insertions(+), 59 deletions(-) diff --git a/Applications.cfg b/Applications.cfg index a2d1a6a0..b30a774a 100644 --- a/Applications.cfg +++ b/Applications.cfg @@ -4,7 +4,7 @@ url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/OS.lua", type="Script", forceDownload=true, - version=3.95, + version=3.96, }, { path="/MineOS/Pictures/MoonTouch.pic", @@ -235,7 +235,7 @@ path="/lib/MineOSInterface.lua", url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSInterface.lua", type="Library", - version=1.07, + version=1.08, }, { path="/lib/MineOSPaths.lua", @@ -249,7 +249,7 @@ url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/advancedLua.lua", type="Library", preloadFile=true, - version=1.26, + version=1.27, }, { path="/lib/web.lua", @@ -302,7 +302,7 @@ url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua", type="Library", preloadFile=true, - version=1.87, + version=1.89, }, { path="/lib/rayEngine.lua", @@ -332,14 +332,13 @@ path="/lib/syntax.lua", url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/syntax.lua", type="Library", - preloadFile=true, version=1.17, }, { path="/lib/palette.lua", url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/palette.lua", type="Library", - version=1.17, + version=1.18, }, { path="/lib/doubleBuffering.lua", @@ -560,7 +559,7 @@ type="Application", icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Braille/Icon.pic", createShortcut=true, - version=1.04, + version=1.05, }, { path="/MineOS/Applications/GeoScan2", @@ -896,7 +895,7 @@ type="Application", icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Control/Icon.pic", forceDownload=true, - version=5.05, + version=5.06, resources={ { path="/Localization/Russian.lang", diff --git a/Applications/Braille/Main.lua b/Applications/Braille/Main.lua index ed2d3737..ea7a5e65 100644 --- a/Applications/Braille/Main.lua +++ b/Applications/Braille/Main.lua @@ -11,7 +11,7 @@ local MineOSInterface = require("MineOSInterface") --------------------------------------------------------------------------------------------------------- local mainContainer, window = MineOSInterface.addWindow(GUI.window(nil, nil, 32, 19)) -local panel = window:addChild(GUI.panel(1, 1, 1, 3, 0x2D2D2D, 0.2)) +local panel = window:addChild(GUI.panel(1, 1, 1, 3, 0x2D2D2D)) local layout = window:addChild(GUI.layout(1, 2, 1, 1, 1, 1)) layout:setCellDirection(1, 1, GUI.directions.horizontal) diff --git a/Applications/Control/Modules/1.lua b/Applications/Control/Modules/1.lua index 2979f686..5c50de58 100644 --- a/Applications/Control/Modules/1.lua +++ b/Applications/Control/Modules/1.lua @@ -49,6 +49,8 @@ module.onTouch = function() -- local abc = " "; for i = 1, 30 do abc = abc .. "p " end; print(abc) end + input.historyEnabled = true + input.autoComplete.colors.default.background = 0x4B4B4B input.autoComplete.colors.default.text = 0xC3C3C3 input.autoComplete.colors.default.textMatch = 0xFFFFFF @@ -154,7 +156,7 @@ module.onTouch = function() add("> " .. input.text, 0xAAAAAA) - if unicode.sub(input.text, 1, 1) == "=" then + if input.text:match("^%=") then input.text = "return " .. unicode.sub(input.text, 2, -1) end @@ -173,8 +175,6 @@ module.onTouch = function() print = oldPrint input.text = "" - input.textCutFrom = 1 - input:setCursorPosition(1) end end diff --git a/OS.lua b/OS.lua index d771a3b8..94f20c6f 100755 --- a/OS.lua +++ b/OS.lua @@ -146,7 +146,6 @@ local function checkPassword() end MineOSInterface.OSDraw() - inputField:startInput() end local function setPassword() diff --git a/lib/GUI.lua b/lib/GUI.lua index eef6efa2..c13ea068 100755 --- a/lib/GUI.lua +++ b/lib/GUI.lua @@ -10,7 +10,6 @@ local event = require("event") local color = require("color") local image = require("image") local buffer = require("doubleBuffering") -local syntax = require("syntax") ----------------------------------------- Constants ----------------------------------------- @@ -924,7 +923,7 @@ end ----------------------------------------- CodeView object ----------------------------------------- local function codeViewDraw(codeView) - -- local toLine = codeView.fromLine + codeView.height - (codeView.scrollBars.horizontal.hidden and 1 or 2) + local syntax = require("syntax") local toLine = codeView.fromLine + codeView.height - 1 -- Line numbers bar and code area @@ -1251,31 +1250,38 @@ local function windowCheck(container, x, y) end local function windowEventHandler(mainContainer, object, eventData) - if eventData ~= mainContainer.focusedWindowEventData then - mainContainer.focusedWindowEventData = eventData + if eventData[1] == "touch" then + object.lastTouchPosition = object.lastTouchPosition or {} + object.lastTouchPosition.x, object.lastTouchPosition.y = eventData[3], eventData[4] + + if object ~= object.parent.children[#object.parent.children] then + object:moveToFront() + mainContainer:draw() + buffer.draw() + end + elseif eventData[1] == "drag" and object.lastTouchPosition and not windowCheck(object, eventData[3], eventData[4]) then + local xOffset, yOffset = eventData[3] - object.lastTouchPosition.x, eventData[4] - object.lastTouchPosition.y + object.lastTouchPosition.x, object.lastTouchPosition.y = eventData[3], eventData[4] - if eventData[1] == "touch" then - mainContainer.focusedWindow = object - object.lastTouchPosition = object.lastTouchPosition or {} - object.lastTouchPosition.x, object.lastTouchPosition.y = eventData[3], eventData[4] - - if object ~= object.parent.children[#object.parent.children] then - object:moveToFront() - mainContainer:draw() - buffer.draw() + if xOffset ~= 0 or yOffset ~= 0 then + object.localPosition.x, object.localPosition.y = object.localPosition.x + xOffset, object.localPosition.y + yOffset + mainContainer:draw() + buffer.draw() + end + elseif eventData[1] == "drop" then + object.lastTouchPosition = nil + elseif eventData[1] == "key_down" then + -- Ctrl or CMD + if keyboard.isKeyDown(29) or keyboard.isKeyDown(219) then + -- W + if eventData[4] == 17 then + if object == object.parent.children[#object.parent.children] and not eventData.windowHandled then + eventData.windowHandled = true + object:close() + mainContainer:draw() + buffer.draw() + end end - elseif eventData[1] == "drag" and object == mainContainer.focusedWindow and object.lastTouchPosition and not windowCheck(object, eventData[3], eventData[4]) then - local xOffset, yOffset = eventData[3] - object.lastTouchPosition.x, eventData[4] - object.lastTouchPosition.y - object.lastTouchPosition.x, object.lastTouchPosition.y = eventData[3], eventData[4] - - if xOffset ~= 0 or yOffset ~= 0 then - object.localPosition.x, object.localPosition.y = object.localPosition.x + xOffset, object.localPosition.y + yOffset - mainContainer:draw() - buffer.draw() - end - elseif eventData[1] == "drop" then - mainContainer.focusedWindow = nil - object.lastTouchPosition = nil end end end @@ -1284,7 +1290,6 @@ function GUI.window(x, y, width, height) local window = GUI.container(x, y, width, height) window.eventHandler = windowEventHandler - window.allowDragMovement = true window.draw = windowDraw return window @@ -3104,6 +3109,7 @@ end local function inputEventHandler(mainContainer, input, mainEventData) if mainEventData[1] == "touch" then + local textOnStart = input.text input.focused = true if input.historyEnabled then @@ -3262,6 +3268,13 @@ local function inputEventHandler(mainContainer, input, mainEventData) if input.autoCompleteEnabled then input.autoComplete:clear() end + + if input.validator then + if not input.validator(input.text) then + input.text = textOnStart + input:setCursorPosition(unicode.len(input.text) + 1) + end + end GUI.callMethod(input.onInputFinished, mainContainer, input, mainEventData, input.text) @@ -3416,21 +3429,20 @@ local function autoCompleteMatch(object, variants, text) object:clear() if text then - object.matchText = text - object.matchTextLength = unicode.len(text) for i = 1, #variants do if variants[i] ~= text and variants[i]:match("^" .. text) then table.insert(object.items, variants[i]) end end else - object.matchText = "" - object.matchTextLength = 0 for i = 1, #variants do table.insert(object.items, variants[i]) end end + object.matchText = text or "" + object.matchTextLength = unicode.len(object.matchText) + table.sort(object.items, function(a, b) return unicode.lower(a) < unicode.lower(b) end) object.itemCount = #object.items diff --git a/lib/MineOSInterface.lua b/lib/MineOSInterface.lua index acb841af..9acc141b 100755 --- a/lib/MineOSInterface.lua +++ b/lib/MineOSInterface.lua @@ -331,7 +331,7 @@ end local function iconFieldUpdateFileList(iconField) -- GUI.error(debug.traceback()) - iconField.fileList = fs.sortedList(iconField.workpath, MineOSCore.properties.sortingMethod or "type", MineOSCore.properties.showHiddenFiles) + iconField.fileList = fs.sortedList(iconField.workpath, MineOSCore.properties.sortingMethod or "type", MineOSCore.properties.showHiddenFiles, iconField.filenameMatcher, false) iconField:update() -- Грузим инфу об иконочках @@ -342,12 +342,10 @@ local function iconFieldUpdateFileList(iconField) local configList, notConfigList = {}, {} for i = iconField.fromFile, iconField.fromFile + iconField.iconCount.total - 1 do if iconField.fileList[i] then - if not iconField.filenameMatcher or string.unicodeFind(unicode.lower(iconField.fileList[i]), unicode.lower(iconField.filenameMatcher)) then - if iconField.iconConfigEnabled and iconField.iconConfig[iconField.fileList[i]] then - table.insert(configList, iconField.fileList[i]) - else - table.insert(notConfigList, iconField.fileList[i]) - end + if iconField.iconConfigEnabled and iconField.iconConfig[iconField.fileList[i]] then + table.insert(configList, iconField.fileList[i]) + else + table.insert(notConfigList, iconField.fileList[i]) end else break @@ -1014,7 +1012,6 @@ function MineOSInterface.rename(parentWindow, path) parentWindow:draw() buffer.draw() - container.inputField:startInput() end function MineOSInterface.editShortcut(parentWindow, path) @@ -1036,7 +1033,6 @@ function MineOSInterface.editShortcut(parentWindow, path) parentWindow:draw() buffer.draw() - container.inputField:startInput() end function MineOSInterface.launchWithArguments(parentWindow, path) diff --git a/lib/advancedLua.lua b/lib/advancedLua.lua index c763e07e..64cd005b 100755 --- a/lib/advancedLua.lua +++ b/lib/advancedLua.lua @@ -170,7 +170,7 @@ function filesystem.isFileHidden(path) return false end -function filesystem.sortedList(path, sortingMethod, showHiddenFiles) +function filesystem.sortedList(path, sortingMethod, showHiddenFiles, filenameMatcher, filenameMatcherCaseSensitive) if not filesystem.exists(path) then error("Failed to get file list: directory \"" .. tostring(path) .. "\" doesn't exists") end @@ -180,7 +180,9 @@ function filesystem.sortedList(path, sortingMethod, showHiddenFiles) local fileList, sortedFileList = {}, {} for file in filesystem.list(path) do - table.insert(fileList, file) + if not filenameMatcher or string.unicodeFind(filenameMatcherCaseSensitive and file or unicode.lower(file), filenameMatcherCaseSensitive and filenameMatcher or unicode.lower(filenameMatcher)) then + table.insert(fileList, file) + end end if #fileList > 0 then diff --git a/lib/palette.lua b/lib/palette.lua index 2c94cf7c..4c9af989 100755 --- a/lib/palette.lua +++ b/lib/palette.lua @@ -1,19 +1,16 @@ -local advancedLua = require("advancedLua") +require("advancedLua") local component = require("component") local fs = require("filesystem") local color = require("color") local image = require("image") local buffer = require("doubleBuffering") local GUI = require("GUI") -local MineOSPaths = require("MineOSPaths") -------------------------------------------------------------------------------------------------------------- local palette = {} -local pathToFavouritesConfig, favourites = MineOSPaths.applicationData .. "Palette/Favourites.cfg" - --------------------------------------------------------------------------------------------------------------- +local pathToFavouritesConfig, favourites = fs.path(getCurrentScript()) .. ".palette.cfg" local function saveFavourites() table.toFile(pathToFavouritesConfig, favourites)