From 414eb20cdd0548bbd11fde8aae0295b9ae8aa81c Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Mon, 20 Mar 2017 15:14:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=B0=D0=BB=D0=B3=D0=BE=D1=80=D0=B8=D1=82=D0=BC=20=D1=81=D0=BE?= =?UTF-8?q?=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=B8=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D1=87=D0=B5=D1=82=20=D1=81=20=D0=BB=D0=B8?= =?UTF-8?q?=D1=88=D0=BD=D0=B5=D0=B9=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=BE=D0=B9=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications.txt | 4 +- Applications/MineCodeIDE/MineCodeIDE.lua | 1 + lib/GUI.lua | 49 ++++++++++++++++++------ 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Applications.txt b/Applications.txt index 45d90b52..4186b643 100644 --- a/Applications.txt +++ b/Applications.txt @@ -300,7 +300,7 @@ name="lib/GUI.lua", url="IgorTimofeev/OpenComputers/master/lib/GUI.lua", type="Library", - version=1.47, + version=1.48, }, { name="lib/windows.lua", @@ -511,7 +511,7 @@ icon="IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic", createShortcut="dock", forceDownload=true, - version=1.63, + version=1.64, resources={ { name="Localization/Russian.lang", diff --git a/Applications/MineCodeIDE/MineCodeIDE.lua b/Applications/MineCodeIDE/MineCodeIDE.lua index d066cb5b..365095e1 100755 --- a/Applications/MineCodeIDE/MineCodeIDE.lua +++ b/Applications/MineCodeIDE/MineCodeIDE.lua @@ -625,6 +625,7 @@ end local function loadFile(path) newFile() + table.remove(mainWindow.codeView.lines, 1) local file = io.open(path, "r") for line in file:lines() do line = removeWindowsLineEndings(removeTabs(line)) diff --git a/lib/GUI.lua b/lib/GUI.lua index 764b7b59..6806a344 100755 --- a/lib/GUI.lua +++ b/lib/GUI.lua @@ -1604,25 +1604,47 @@ end ----------------------------------------- Color Selector object ----------------------------------------- -local function updateFileList(treeView, xOffset, path) +local function updateFileList(directoriesToShowContent, xOffset, path) + local localFileList = {} for file in fs.list(path) do local element = {} element.path = path .. file element.xOffset = xOffset element.isDirectory = fs.isDirectory(element.path) - table.insert(treeView.fileList, element) - - if treeView.directoriesToShowContent[element.path] then - updateFileList(treeView, xOffset + 2, path .. file) - end + table.insert(localFileList, element) end + + -- Sort file list alphabeitcally + table.sort(localFileList, function(a, b) return unicode.lower(a.path) < unicode.lower(b.path) end) + -- Move folders on top and recursively get their content if needed + local i, nextDirectoryIndex, nextLocalFileListIndex = 1, 1, 1 + while i <= #localFileList do + if localFileList[i].isDirectory then + table.insert(localFileList, nextDirectoryIndex, localFileList[i]) + table.remove(localFileList, i + 1) + + if directoriesToShowContent[localFileList[nextDirectoryIndex].path] then + local nextLocalFileList = updateFileList(directoriesToShowContent, xOffset + 2, localFileList[nextDirectoryIndex].path) + + nextLocalFileListIndex = nextDirectoryIndex + 1 + for j = 1, #nextLocalFileList do + table.insert(localFileList, nextLocalFileListIndex, nextLocalFileList[j]) + nextLocalFileListIndex = nextLocalFileListIndex + 1 + end + i, nextDirectoryIndex = i + #nextLocalFileList, nextDirectoryIndex + #nextLocalFileList + end + + nextDirectoryIndex = nextDirectoryIndex + 1 + end + + i = i + 1 + end + + return localFileList end local function treeViewUpdateFileList(treeView) - treeView.fileList = {} - updateFileList(treeView, 1, treeView.workPath) - table.sort(treeView.fileList, function(a, b) return unicode.lower(a.path) < unicode.lower(b.path) end) - + treeView.fileList = updateFileList(treeView.directoriesToShowContent, 1, treeView.workPath) return treeView end @@ -1856,7 +1878,12 @@ end -- buffer.start() -- buffer.clear(0x262626) --- GUI.treeView(2, 2, 50, 40, 0xFFFFFF, 0x0, 0x262626, 0x555555, 0x888888, 0xFF4444, 0x44FF44, "/MineOS/Desktop/3DTest.app/"):draw() +-- local treeView = GUI.treeView(2, 2, 50, 40, 0xFFFFFF, 0x0, 0x262626, 0x555555, 0x888888, 0xFF4444, 0x44FF44, "/MineOS/System/OS/") + +-- treeView.directoriesToShowContent["/MineOS/System/OS/Languages/"] = true +-- treeView:updateFileList() + +-- treeView:draw() -- buffer.draw(true) -- buffer.start()