From a4a6c2363d016cf91fc81583627d0e58d350b1aa Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Mon, 16 Jan 2017 23:35:22 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D1=83=D0=B0=D1=84=D1=83=D0=B0?= 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 79876 -> 79876 bytes Applications/MineCodeIDE/MineCodeIDE.lua | 114 ++++++++++++----------- lib/palette.lua | 2 +- lib/windows.lua | 8 +- 6 files changed, 69 insertions(+), 61 deletions(-) diff --git a/.DS_Store b/.DS_Store index 2778f7d2d26509c4129681c482e02a56edaf8789..bdefa5348c1c3d8b00a20533103fd14d205d9262 100644 GIT binary patch delta 602 zcmZ{gO-NKx7>3W2qIdMb+-bD*DyC!2m=0=Mf-Z6lsWB6>w2YKc?;RT*ooLL;q88cj zBD6!4(85A0kTSVgEu+6>E1@<);Vx(uZ33&SGqmfh&UxR%_dV}BG0DUv&q{PPy}2OG zEBB~IeIebOBc=KlEcY$BTuW}Wf;^Q43qV1FK(3e1_~u zM8_??H)Z()Qg#eQM@&7D8dDLJMrW+I&x+}$OIw>TsD$NK0Yd`qMCYk5~7J+w6dQA9HfID`mu;GzzNPU&N;3&lO=c*0ZW zdC6+5@>iyOVyFGU{%g!$TgjQ2m pA1tn^tyl9K!gj6ilC)=vI3$y-tc2&dGbVqN;&J3+&{srf(k1zlL delta 831 zcmZvZOH30{6o&6#3cVMGaEnTyHh=|#kP4L|V3AnB09ueu5d|f-&R_R^uMeDlA#n>>L|qxp_jqqhn`BkzM>g(b!8wngw#9$*6#(%`r%M9f@DsGf0OpjUXxfQAIL}YiF_ts$XD_M6byL~Py!b!PzevV z!H4Z=MLPoM!5;J>h=Ul$A%t)QF&u-6I8Ngn&SMrApy3*>;|6ZxKAzwyp5YZ<<1OA} z#hh(HW`{09w8h%|hE+YzA_|d7SWzcpVI>+S#4`7Pf1KUBx(f_{ZfUb?MzwdFixd4i zOKH+z!)>Wz-6g>#R5CkKj1wbvRynJw?i{z6vfEjk_JwDes=-@iJlj-t&}omj)l^#q z9dLm095eJg+ta)`HH)j9g`JFY{LOY@tuNt0BmC$@7k2CHda)M+7{riHZ$u|2V-yOG zV*-;nfm4{$2~K0iAb1IvaRpa#8+WjPyI8~$9^w&}@fgqX0xy3t{fB5EL)Lh#gkU8p zuDh3e@k~)NuY3j6>uGeC*L&)pClFbEVBmYncs3iN~2sy-i#7l7^;aop0Lu Mhg_Jn`M=wK0?%T<6#xJL diff --git a/Applications.txt b/Applications.txt index ca90c6d0..f8f42111 100644 --- a/Applications.txt +++ b/Applications.txt @@ -306,7 +306,7 @@ name="lib/windows.lua", url="IgorTimofeev/OpenComputers/master/lib/windows.lua", type="Library", - version=1.15, + version=1.16, }, { name="lib/rayEngine.lua", @@ -366,7 +366,7 @@ name="lib/palette.lua", url="IgorTimofeev/OpenComputers/master/lib/palette.lua", type="Library", - version=1.08, + version=1.09, }, { name="lib/doubleBuffering.lua", @@ -886,7 +886,7 @@ icon="IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic", createShortcut="dock", forceDownload=true, - version=1.30, + version=1.31, resources={ { name="Localization/Russian.lang", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 35983d6d3e44ee4fac308382338c7640333804a0..b8c7ac7fc7330fe3fe1c718df1348e062276dbe4 100644 GIT binary patch delta 26 icmZqqz|!)8Wy6x~>_%pmItoU{lLh~HZvL`epaB4v3=1p( delta 27 jcmZqqz|!)8Wy6x~9L5G_ItoSxMw1^pcx?W%U7!H~pdbrp diff --git a/Applications/MineCodeIDE/MineCodeIDE.lua b/Applications/MineCodeIDE/MineCodeIDE.lua index 9d8cc2ec..793f6418 100755 --- a/Applications/MineCodeIDE/MineCodeIDE.lua +++ b/Applications/MineCodeIDE/MineCodeIDE.lua @@ -28,34 +28,37 @@ local keyboard = require("keyboard") local args = {...} -local config = { - colorScheme = { - topToolBar = 0xDDDDDD, - bottomToolBar = { +local colors = { + topToolBar = 0xDDDDDD, + bottomToolBar = { + background = 0x3C3C3C, + buttons = 0x2D2D2D, + buttonsText = 0xFFFFFF, + }, + topMenu = { + backgroundColor = 0xEEEEEE, + textColor = 0x444444, + backgroundPressedColor = 0x3366CC, + textPressedColor = 0xFFFFFF, + }, + title = { + default = { + sides = 0x555555, background = 0x3C3C3C, - buttons = 0x2D2D2D, - buttonsText = 0xFFFFFF, + text = 0xEEEEEE }, - topMenu = { - backgroundColor = 0xEEEEEE, - textColor = 0x444444, - backgroundPressedColor = 0x3366CC, - textPressedColor = 0xFFFFFF, - }, - title = { - default = { - background = 0x3C3C3C, - text = 0xEEEEEE - }, - warning = { - background = 0x880000, - text = 0xEEEEEE, - } - }, - leftTreeView = { - background = 0xCCCCCC, + warning = { + sides = 0xCC4940, + background = 0x880000, + text = 0xEEEEEE, } }, + leftTreeView = { + background = 0xCCCCCC, + } +} + +local config = { syntaxColorScheme = syntax.colorScheme, scrollSpeed = 8, cursorColor = 0x00A8FF, @@ -76,7 +79,6 @@ local resourcesPath = MineOSCore.getCurrentApplicationResourcesDirectory() local configPath = resourcesPath .. "Config.cfg" local localization = MineOSCore.getLocalization(resourcesPath .. "Localization/") local findStartFrom -local workPath local clipboard local lastErrorLine local lastClickUptime = computer.uptime() @@ -150,15 +152,16 @@ local function showErrorMessage(text) mainWindow.errorMessage.backgroundPanel.height = mainWindow.errorMessage.height mainWindow.errorMessage.errorTextBox.height = mainWindow.errorMessage.height - 2 - mainWindow.titleTextBox.colors.background, mainWindow.titleTextBox.colors.text = config.colorScheme.title.warning.background, config.colorScheme.title.warning.text + mainWindow.titleTextBox.colors.background, mainWindow.titleTextBox.colors.text = colors.title.warning.background, colors.title.warning.text + mainWindow.titleTextBox.colors.sides = colors.title.warning.sides for i = 1, 3 do component.computer.beep(1500, 0.08) end mainWindow.errorMessage.isHidden = false end local function hideErrorMessage() - mainWindow.titleTextBox.colors.background = config.colorScheme.title.default.background - mainWindow.titleTextBox.colors.text = config.colorScheme.title.default.text + mainWindow.titleTextBox.colors.background, mainWindow.titleTextBox.colors.text = colors.title.default.background, colors.title.default.text + mainWindow.titleTextBox.colors.sides = colors.title.default.sides mainWindow.errorMessage.isHidden = true end @@ -316,8 +319,7 @@ local function loadFile(path) mainWindow.codeView.maximumLineLength = math.max(mainWindow.codeView.maximumLineLength, unicode.len(line)) end file:close() - workPath = path - mainWindow.leftTreeView.currentFile = workPath + mainWindow.leftTreeView.currentFile = path if #mainWindow.codeView.lines == 0 then table.insert(mainWindow.codeView.lines, "") end setCursorPositionAndClearSelection(1, 1) end @@ -333,8 +335,7 @@ end local function newFile() mainWindow.codeView.lines = {""} - mainWindow.leftTreeView.currentFile = "" - workPath = nil + mainWindow.leftTreeView.currentFile = nil setCursorPositionAndClearSelection(1, 1) end @@ -363,13 +364,13 @@ local function saveAs() ) if data[2] == "OK" then saveFile(data[1]) - workPath = data[1] - mainWindow.leftTreeView.workPath = workPath + mainWindow.leftTreeView.currentFile = data[1] + mainWindow.leftTreeView:updateFileList() end end local function save() - saveFile(workPath) + saveFile(mainWindow.leftTreeView.currentFile) end local function run() @@ -625,8 +626,8 @@ local function indentOrUnindent(isIndent) end local function updateTitle() - mainWindow.titleTextBox.lines[1] = string.limit(localization.file .. ": " .. (workPath or localization.none), mainWindow.titleTextBox.width - 2) - mainWindow.titleTextBox.lines[2] = string.limit(localization.cursor .. cursor.position.line .. localization.line .. cursor.position.symbol .. localization.symbol, mainWindow.titleTextBox.width - 2) + mainWindow.titleTextBox.lines[1] = string.limit(localization.file .. ": " .. (mainWindow.leftTreeView.currentFile or localization.none), mainWindow.titleTextBox.width - 4) + mainWindow.titleTextBox.lines[2] = string.limit(localization.cursor .. cursor.position.line .. localization.line .. cursor.position.symbol .. localization.symbol, mainWindow.titleTextBox.width - 4) if mainWindow.codeView.selections[1] then local countOfSelectedLines = mainWindow.codeView.selections[1].to.line - mainWindow.codeView.selections[1].from.line + 1 local countOfSelectedSymbols @@ -639,9 +640,9 @@ local function updateTitle() end countOfSelectedSymbols = countOfSelectedSymbols + unicode.len(unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].to.line], 1, mainWindow.codeView.selections[1].to.symbol)) end - mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. countOfSelectedLines .. localization.lines .. countOfSelectedSymbols .. localization.symbols, mainWindow.titleTextBox.width - 2) + mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. countOfSelectedLines .. localization.lines .. countOfSelectedSymbols .. localization.symbols, mainWindow.titleTextBox.width - 4) else - mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. localization.none, mainWindow.titleTextBox.width - 2) + mainWindow.titleTextBox.lines[3] = string.limit(localization.selection .. localization.none, mainWindow.titleTextBox.width - 4) end end @@ -715,7 +716,7 @@ local function createWindow() mainWindow.codeView.scrollBars.horizontal.onTouch = function() mainWindow.codeView.fromSymbol = mainWindow.codeView.scrollBars.horizontal.value end - mainWindow.topMenu = mainWindow:addMenu(1, 1, 1, config.colorScheme.topMenu.backgroundColor, config.colorScheme.topMenu.textColor, config.colorScheme.topMenu.backgroundPressedColor, config.colorScheme.topMenu.textPressedColor) + mainWindow.topMenu = mainWindow:addMenu(1, 1, 1, colors.topMenu.backgroundColor, colors.topMenu.textColor, colors.topMenu.backgroundPressedColor, colors.topMenu.textPressedColor) local item1 = mainWindow.topMenu:addItem("MineCode", 0x0) item1.onTouch = function() @@ -739,7 +740,7 @@ local function createWindow() open() end menu:addSeparator() - menu:addItem(localization.save, not workPath, "^S").onTouch = function() + menu:addItem(localization.save, not mainWindow.leftTreeView.currentFile, "^S").onTouch = function() save() end menu:addItem(localization.saveAs, false, "^⇧S").onTouch = function() @@ -859,15 +860,22 @@ local function createWindow() end mainWindow.topToolBar = mainWindow:addContainer(1, 2, 1, 3) - mainWindow.topToolBar.backgroundPanel = mainWindow.topToolBar:addPanel(1, 1, 1, 3, config.colorScheme.topToolBar) + mainWindow.topToolBar.backgroundPanel = mainWindow.topToolBar:addPanel(1, 1, 1, 3, colors.topToolBar) mainWindow.titleTextBox = mainWindow.topToolBar:addTextBox(1, 1, 1, 3, 0x0, 0x0, {}, 1):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) - + mainWindow.titleTextBox.colors.sides = colors.title.default.sides + local titleTextBoxOldDraw = mainWindow.titleTextBox.draw + mainWindow.titleTextBox.draw = function(titleTextBox) + titleTextBoxOldDraw(titleTextBox) + buffer.square(titleTextBox.x, titleTextBox.y, 1, titleTextBox.height, mainWindow.titleTextBox.colors.sides, titleTextBox.colors.text, " ") + buffer.square(titleTextBox.x + titleTextBox.width - 1, titleTextBox.y, 1, titleTextBox.height, mainWindow.titleTextBox.colors.sides, titleTextBox.colors.text, " ") + end + mainWindow.runButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0x4B4B4B, 0xEEEEEE, 0xCCCCCC, 0x444444, "▷") mainWindow.runButton.onTouch = function() run() end - mainWindow.toggleSyntaxHighlightingButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x5A5A5A, 0xEEEEEE, "*") + mainWindow.toggleSyntaxHighlightingButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x696969, 0xEEEEEE, "*") mainWindow.toggleSyntaxHighlightingButton.switchMode, mainWindow.toggleSyntaxHighlightingButton.pressed = true, true mainWindow.toggleSyntaxHighlightingButton.onTouch = function() mainWindow.codeView.highlightLuaSyntax = not mainWindow.codeView.highlightLuaSyntax @@ -880,14 +888,14 @@ local function createWindow() calculateSizes() end - mainWindow.toggleBottomToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x5A5A5A, 0xEEEEEE, "⇩") + mainWindow.toggleBottomToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x696969, 0xEEEEEE, "⇩") mainWindow.toggleBottomToolBarButton.switchMode, mainWindow.toggleBottomToolBarButton.pressed = true, false mainWindow.toggleBottomToolBarButton.onTouch = function() mainWindow.bottomToolBar.isHidden = not mainWindow.toggleBottomToolBarButton.pressed calculateSizes() end - mainWindow.toggleTopToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x696969, 0xEEEEEE, "⇧") + mainWindow.toggleTopToolBarButton = mainWindow.topToolBar:addAdaptiveButton(1, 1, 3, 1, 0xCCCCCC, 0x444444, 0x878787, 0xEEEEEE, "⇧") mainWindow.toggleTopToolBarButton.switchMode, mainWindow.toggleTopToolBarButton.pressed = true, true mainWindow.toggleTopToolBarButton.onTouch = function() mainWindow.topToolBar.isHidden = not mainWindow.toggleTopToolBarButton.pressed @@ -910,7 +918,7 @@ local function createWindow() end mainWindow.bottomToolBar.isHidden = true - mainWindow.leftTreeView = mainWindow:addTreeView(1, 1, 1, 1, config.colorScheme.leftTreeView.background, 0x3C3C3C, 0x3C3C3C, 0xEEEEEE, 0x888888, 0x444444, 0x00DBFF, "/") + mainWindow.leftTreeView = mainWindow:addTreeView(1, 1, 1, 1, colors.leftTreeView.background, 0x3C3C3C, 0x3C3C3C, 0xEEEEEE, 0x888888, 0x444444, 0x00DBFF, "/") mainWindow.leftTreeView.onFileSelected = function(path) loadFile(path) end @@ -997,7 +1005,7 @@ local function createWindow() -- S elseif eventData[4] == 31 then -- Shift - if workPath and not keyboard.isKeyDown(42) then + if mainWindow.leftTreeView.currentFile and not keyboard.isKeyDown(42) then save() else saveAs() @@ -1101,15 +1109,11 @@ buffer.start() loadConfig() createWindow() calculateSizes() +updateTitle() mainWindow:draw() -if args[1] == "open" then - if fs.exists(args[2]) then - loadFile(args[2]) - else - newFile() - workPath = args[2] - end +if args[1] == "open" and fs.exists(args[2] or "") then + loadFile(args[2]) else newFile() end diff --git a/lib/palette.lua b/lib/palette.lua index 3fba3fd6..80d8ce17 100755 --- a/lib/palette.lua +++ b/lib/palette.lua @@ -269,7 +269,7 @@ function palette.show(x, y, startColor) buffer.start() loadFavourites() switchColorFromHex(startColor or 0x00B6FF) - createWindow(x, y) + createWindow(x or "auto", y or "auto") createCrestsCoordinates() refreshRainbows() diff --git a/lib/windows.lua b/lib/windows.lua index ad27bc30..24a2b613 100755 --- a/lib/windows.lua +++ b/lib/windows.lua @@ -254,7 +254,11 @@ end function windows.handleEvents(window, pullTime) while true do window:handleEventData({event.pull(pullTime)}) - if window.dataToReturn then return table.unpack(window.dataToReturn) end + if window.dataToReturn then + local data = window.dataToReturn + window = nil + return table.unpack(data) + end end end @@ -320,7 +324,7 @@ function windows.tabbed(x, y, width, height, minimumWidth, minimumHeight, ...) window:addPanel(1, 1, window.width, window.height, 0xEEEEEE).disabled = true window:addTabBar(1, 1, window.width, 3, 1, 0xDDDDDD, 0x262626, 0xCCCCCC, 0x262626, ...) window:addWindowActionButtons(2, 1, false) - + return window end