diff --git a/.DS_Store b/.DS_Store index 49fad01e..f2968b86 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Applications.txt b/Applications.txt index 18ec89b2..2eb27dfd 100644 --- a/Applications.txt +++ b/Applications.txt @@ -886,7 +886,7 @@ icon="IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic", createShortcut="dock", forceDownload=true, - version=1.28, + version=1.29, resources={ { name="Localization/Russian.lang", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 0b173311..74b3b3c8 100644 Binary files a/Applications/.DS_Store and b/Applications/.DS_Store differ diff --git a/Applications/MineCodeIDE/Localization/English.lang b/Applications/MineCodeIDE/Localization/English.lang index 48c5514a..b26434ae 100755 --- a/Applications/MineCodeIDE/Localization/English.lang +++ b/Applications/MineCodeIDE/Localization/English.lang @@ -1,4 +1,5 @@ { + selectWord = "Select current word", gotoCyka = "Goto", gotoEnd = "Scroll to end", gotoStart = "Scroll to start", diff --git a/Applications/MineCodeIDE/Localization/Russian.lang b/Applications/MineCodeIDE/Localization/Russian.lang index a8d146da..3b72685d 100755 --- a/Applications/MineCodeIDE/Localization/Russian.lang +++ b/Applications/MineCodeIDE/Localization/Russian.lang @@ -1,4 +1,5 @@ { + selectWord = "Выделить текущее слово", gotoCyka = "Переход", gotoEnd = "В конец", gotoStart = "В начало", diff --git a/Applications/MineCodeIDE/MineCodeIDE.lua b/Applications/MineCodeIDE/MineCodeIDE.lua index bcf6abab..9f23bdcd 100755 --- a/Applications/MineCodeIDE/MineCodeIDE.lua +++ b/Applications/MineCodeIDE/MineCodeIDE.lua @@ -61,6 +61,7 @@ local config = { cursorColor = 0x00A8FF, cursorSymbol = "┃", cursorBlinkDelay = 0.4, + doubleClickDelay = 0.4, } local cursor = { @@ -71,12 +72,14 @@ local cursor = { blinkState = false } -local configPath = MineOSCore.paths.system .. "MineCode/Config.cfg" -local localization = MineOSCore.getCurrentApplicationLocalization() +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() local mainWindow = {} ---------------------------------------------------- Functions ---------------------------------------------------- @@ -278,6 +281,27 @@ local function gotoLine(line) end end +local function selectWord() + local shittySymbolsRegexp, from, to = "[%s%c%p]" + + for i = cursor.position.symbol, 1, -1 do + if unicode.sub(mainWindow.codeView.lines[cursor.position.line], i, i):match(shittySymbolsRegexp) then break end + from = i + end + + for i = cursor.position.symbol, unicode.len(mainWindow.codeView.lines[cursor.position.line]) do + if unicode.sub(mainWindow.codeView.lines[cursor.position.line], i, i):match(shittySymbolsRegexp) then break end + to = i + end + + if from and to then + mainWindow.codeView.selections[1] = { + from = {symbol = from, line = cursor.position.line}, + to = {symbol = to, line = cursor.position.line}, + } + end +end + local function removeTabs(text) local result = text:gsub("\t", string.rep(" ", mainWindow.codeView.indentationWidth)) return result @@ -749,6 +773,9 @@ local function createWindow() deleteLine(cursor.position.line) end menu:addSeparator() + menu:addItem(localization.selectWord, false, "^\\").onTouch = function() + selectWord() + end menu:addItem(localization.selectAll, false, "^A").onTouch = function() selectAll() end @@ -916,6 +943,10 @@ local function createWindow() menu:show() else setCursorPositionAndClearSelection(convertScreenCoordinatesToCursorPosition(eventData[3], eventData[4])) + + local newUptime = computer.uptime() + if newUptime - lastClickUptime <= config.doubleClickDelay then selectWord() end + lastClickUptime = newUptime end elseif eventData[1] == "drag" and isClickedOnCodeArea(eventData[3], eventData[4]) then if eventData[5] ~= 1 then @@ -935,8 +966,11 @@ local function createWindow() elseif eventData[1] == "key_down" then -- Ctrl or CMD if keyboard.isKeyDown(29) or keyboard.isKeyDown(219) then + -- Backslash + if eventData[4] == 43 then + selectWord() -- Slash - if eventData[4] == 53 then + elseif eventData[4] == 53 then toggleComment() -- A elseif eventData[4] == 30 then