mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-29 22:42:38 +01:00
Фича закрытия окон по нажатию ctrl+w
This commit is contained in:
parent
89261e847f
commit
2efca54459
@ -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",
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
1
OS.lua
1
OS.lua
@ -146,7 +146,6 @@ local function checkPassword()
|
||||
end
|
||||
|
||||
MineOSInterface.OSDraw()
|
||||
inputField:startInput()
|
||||
end
|
||||
|
||||
local function setPassword()
|
||||
|
||||
72
lib/GUI.lua
72
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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user