From abc81cf5d82d7414942bb4a3c6f456f0ede31276 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Thu, 19 Jan 2017 04:05:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B7=D0=B0=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D1=8E=D1=89=D0=B8=D1=85=D1=81=D1=8F=20=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 18436 -> 18436 bytes Applications.txt | 2 +- Applications/.DS_Store | Bin 79876 -> 79876 bytes Applications/MineCodeIDE/MineCodeIDE.lua | 99 ++++++++++++++++------- 4 files changed, 73 insertions(+), 28 deletions(-) diff --git a/.DS_Store b/.DS_Store index 351a8546c3466e929713f484880d733b4b50cf25..c74537a35f4ff0eede4e36d9ddbbb02350ce7c12 100644 GIT binary patch delta 41 qcmZpfz}PZ@al;ld4r5Cb9R(vxqsa#q9XJ0K+rtGH*?dsZSq%UixD5vY delta 31 lcmZpfz}PZ@al;m|$$u?9H~$se!v$hYc2SYsEUolX6#(Ei4QBuV diff --git a/Applications.txt b/Applications.txt index ead0768e..a74c41d4 100644 --- a/Applications.txt +++ b/Applications.txt @@ -517,7 +517,7 @@ icon="IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic", createShortcut="dock", forceDownload=true, - version=1.35, + version=1.36, resources={ { name="Localization/Russian.lang", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 94c8c45b2e936c565d4b4edca90c3a9358f2685d..fc651f80324d14a83fd14e7559801e09ac70bbe3 100644 GIT binary patch delta 31 ncmZqqz|!)8Wkc0=4r5Cb9R(vxqsgI99VcJeCcgRBcC7{g(1i_? delta 22 ecmZqqz|!)8Wkc2W$-YlLCtuknzWLU6tp)&zc?<#o diff --git a/Applications/MineCodeIDE/MineCodeIDE.lua b/Applications/MineCodeIDE/MineCodeIDE.lua index c7f63fea..dec835fb 100755 --- a/Applications/MineCodeIDE/MineCodeIDE.lua +++ b/Applications/MineCodeIDE/MineCodeIDE.lua @@ -29,6 +29,32 @@ local palette = require("palette") local args = {...} +local about = { + "MineCode IDE", + "Copyright © 2015-2017 ECS Inc.", + " ", + "Developers:", + " ", + "Timofeev Igor, vk.com/id7799889", + "Trifonov Gleb, vk.com/id88323331", + " ", + "Testers:", + " ", + "Semyonov Semyon, vk.com/id92656626", + "Shestakov Timofey, vk.com/id113499693", +} + +local config = { + syntaxColorScheme = syntax.colorScheme, + scrollSpeed = 8, + cursorColor = 0x00A8FF, + cursorSymbol = "┃", + cursorBlinkDelay = 0.5, + doubleClickDelay = 0.4, + screenScale = 1, + enableAutoBrackets = true +} + local colors = { topToolBar = 0xDDDDDD, bottomToolBar = { @@ -59,14 +85,10 @@ local colors = { } } -local config = { - syntaxColorScheme = syntax.colorScheme, - scrollSpeed = 8, - cursorColor = 0x00A8FF, - cursorSymbol = "┃", - cursorBlinkDelay = 0.4, - doubleClickDelay = 0.4, - screenScale = 1, +local possibleBrackets = { + ["{"] = "}", + ["["] = "]", + ["("] = ")", } local cursor = { @@ -272,14 +294,6 @@ local function setCursorPositionToEnd() setCursorPositionAndClearSelection(unicode.len(mainWindow.codeView.lines[#mainWindow.codeView.lines]) + 1, #mainWindow.codeView.lines) end -local function pageUp() - scroll(1, mainWindow.codeView.height - 2) -end - -local function pageDown() - scroll(-1, mainWindow.codeView.height - 2) -end - local function scroll(direction, speed) if direction == 1 then if mainWindow.codeView.fromLine > speed then @@ -296,6 +310,14 @@ local function scroll(direction, speed) end end +local function pageUp() + scroll(1, mainWindow.codeView.height - 2) +end + +local function pageDown() + scroll(-1, mainWindow.codeView.height - 2) +end + local function gotoLine(line) mainWindow.codeView.fromLine = math.floor(line - mainWindow.codeView.height / 2) + 1 if mainWindow.codeView.fromLine < 1 then @@ -331,11 +353,16 @@ local function removeTabs(text) return result end +local function removeWindowsLineEndings(text) + local result = text:gsub("\r\n", "\n") + return result +end + local function loadFile(path) mainWindow.codeView.fromLine, mainWindow.codeView.fromSymbol, mainWindow.codeView.lines, mainWindow.codeView.maximumLineLength = 1, 1, {}, 0 local file = io.open(path, "r") for line in file:lines() do - line = removeTabs(line) + line = removeWindowsLineEndings(removeTabs(line)) table.insert(mainWindow.codeView.lines, line) mainWindow.codeView.maximumLineLength = math.max(mainWindow.codeView.maximumLineLength, unicode.len(line)) end @@ -498,6 +525,16 @@ local function paste(pasteLines) end end +local function pasteAutoBrackets(firstSymbol, secondSymbol) + local nextSymbol = unicode.sub(mainWindow.codeView.lines[cursor.position.line], cursor.position.symbol, cursor.position.symbol) + if config.enableAutoBrackets and (nextSymbol:match("[%s%{%}%[%]%(%)]") or nextSymbol == "") then + paste({firstSymbol .. secondSymbol}) + setCursorPosition(cursor.position.symbol - 1, cursor.position.line) + else + paste({firstSymbol}) + end +end + local function delete() if mainWindow.codeView.selections[1] then deleteSelectedData() @@ -750,8 +787,10 @@ local function createWindow() local item1 = mainWindow.topMenu:addItem("MineCode", 0x0) item1.onTouch = function() local menu = GUI.contextMenu(item1.x, item1.y + 1) - menu:addItem(localization.about, true).onTouch = function() - + menu:addItem(localization.about).onTouch = function() + mainWindow.settingsContainer.isHidden = false + local y = math.floor(mainWindow.settingsContainer.height / 2 - #about / 2) + mainWindow.settingsContainer:addTextBox(1, y, mainWindow.settingsContainer.width, #about, nil, 0xEEEEEE, about, 1):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) end menu:addItem(localization.quit, false, "^W").onTouch = function() mainWindow:close() @@ -970,12 +1009,10 @@ local function createWindow() mainWindow.settingsContainer.backgroundPanel.onTouch = hideSettingsContainer mainWindow.settingsContainer.isHidden = true - mainWindow.onAnyEvent = function(eventData) - cursor.blinkState = not cursor.blinkState - local oldCursorState = cursor.blinkState - cursor.blinkState = true - + mainWindow.onAnyEvent = function(eventData) if eventData[1] == "touch" and isClickedOnCodeArea(eventData[3], eventData[4]) then + cursor.blinkState = true + if eventData[5] == 1 then local menu = GUI.contextMenu(eventData[3], eventData[4]) menu:addItem(localization.cut, not mainWindow.codeView.selections[1], "^X").onTouch = function() @@ -1000,6 +1037,8 @@ local function createWindow() lastClickUptime = newUptime end elseif eventData[1] == "drag" and isClickedOnCodeArea(eventData[3], eventData[4]) then + cursor.blinkState = true + if eventData[5] ~= 1 then mainWindow.codeView.selections[1] = mainWindow.codeView.selections[1] or {from = {}, to = {}} mainWindow.codeView.selections[1].from.symbol, mainWindow.codeView.selections[1].from.line = cursor.position.symbol, cursor.position.line @@ -1015,6 +1054,8 @@ local function createWindow() end end elseif eventData[1] == "key_down" then + cursor.blinkState = true + -- Ctrl or CMD if keyboard.isKeyDown(29) or keyboard.isKeyDown(219) then -- Backslash @@ -1112,9 +1153,13 @@ local function createWindow() elseif eventData[4] == 211 then delete() else - if not keyboard.isControl(eventData[3]) then + local char = unicode.char(eventData[3]) + if possibleBrackets[char] then + pasteAutoBrackets(char, possibleBrackets[char]) + cursor.blinkState = false + elseif not keyboard.isControl(eventData[3]) then deleteSelectedData() - paste({unicode.char(eventData[3])}) + paste({char}) end end elseif eventData[1] == "clipboard" then @@ -1130,7 +1175,7 @@ local function createWindow() scroll(eventData[5], config.scrollSpeed) end elseif not eventData[1] then - cursor.blinkState = oldCursorState + cursor.blinkState = not cursor.blinkState end updateTitle()