From a48c1e89e286b7e4b1786f7014e9df96bca8d86c Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Sun, 15 Jan 2017 00:34:31 +0300 Subject: [PATCH] aaefaef --- .DS_Store | Bin 18436 -> 18436 bytes Applications.txt | 6 +-- Applications/.DS_Store | Bin 79876 -> 79876 bytes Applications/MineCodeIDE/MineCodeIDE.lua | 60 +++++++++++++++++------ lib/ECSAPI.lua | 4 +- 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/.DS_Store b/.DS_Store index 6f8a319ccd0a3d52f27c400d5d7ff5f248069219..431198288197709511aec270c53b6df919598e46 100644 GIT binary patch delta 501 zcmX|-OHUI~7>4IbOq>&s=_ypCBMVb1VyuEt2{sVHMdhlSDhO&U%s>WvQCb^s%X+CR zl4CR`8gJ2PTnJX;Wu^WC7r1fdnzfqfMu(|!`+o16=gC)IpuE6hkD@{Ms_Hr!k`4Ov zuEzL;Ydg83JL5X@BFKtJ<8cTrKR9-DZ%O z7@y8(vz}9-#@gA^6tcorziA#@6X~~Y$2Ob$2K8#NXZox0%~&;l7(b0)#&6>fCV~w} z!bE5$N;~^V&_gc=7-ob+945sHPI8Jgvz*~91&Une3RkIc1I=CTai0ggzf7!hXOLG_p67xQa`6ltu28@?>{mkqyF2Jp7>3WIR!?B0lh)eih=fE;7A>{n1x%|=wP>{s7Ofg-6=TkcrcIO5M5|Tk zCW;Z1>OrjFMiDQFH$v5oAiD7fbnD8U;7&J!mzk5yVwi8<@Af|BdCK#=?vXURJ7v{P zZS0&|^7)n;rN5~yV2Lq1RdNyqJDbTmwp=u8%KCt1jcR4jw4-j@G`)gQ*b*bf?5rbG z^~6Y2h>?kG-j>CB)AkNw9m%CmJ2`3lYGqxUg>~$_GhNIU@^a9ZsQqr+F05p_FgfYu zOGQ5&_2gK$Wu4Tchf>AT!6_%N*7{PP->cR-uC+ef)=QZi;-}p2{+{$#$ee7nCVGePa5l)cCA;TG_xWFuzxXcx9a*Nxz+~+wj zc*!f?^NG)Hr75{8II#afqv&^ggMY537(bsUKXgL0X|X?kIM zM^MP+9yF~g9zogQ;nAT2A>;}Vpblf*N?oZq)oOd=s+H*>&}x5FwZimi>xMq=!kT@f zoorS9_A;Q{4Uym|Nk$n{4l|r(oC$KAV}^^K%Q9EFMuqFjItoUnlLh~HZvL`epaB4uy9*}( diff --git a/Applications/MineCodeIDE/MineCodeIDE.lua b/Applications/MineCodeIDE/MineCodeIDE.lua index bc0321e9..19a498c0 100755 --- a/Applications/MineCodeIDE/MineCodeIDE.lua +++ b/Applications/MineCodeIDE/MineCodeIDE.lua @@ -168,10 +168,30 @@ local function moveCursor(symbolOffset, lineOffset) setCursorPositionAndClearSelection(newSymbol, newLine) end -local function setCursorPositionToEOF() +local function setCursorPositionToHome() + setCursorPositionAndClearSelection(1, 1) +end + +local function setCursorPositionToEnd() setCursorPositionAndClearSelection(unicode.len(mainWindow.codeView.lines[#mainWindow.codeView.lines]) + 1, #mainWindow.codeView.lines) end +local function scroll(direction, speed) + if direction == 1 then + if mainWindow.codeView.fromLine > speed then + mainWindow.codeView.fromLine = mainWindow.codeView.fromLine - speed + else + mainWindow.codeView.fromLine = 1 + end + else + if mainWindow.codeView.fromLine < #mainWindow.codeView.lines - speed then + mainWindow.codeView.fromLine = mainWindow.codeView.fromLine + speed + else + mainWindow.codeView.fromLine = #mainWindow.codeView.lines + end + end +end + local function gotoLine(line) mainWindow.codeView.fromLine = math.floor(line - mainWindow.codeView.height / 2) + 1 if mainWindow.codeView.fromLine < 1 then @@ -183,11 +203,15 @@ end ---------------------------------------------------- File processing methods ---------------------------------------------------- +local function removeTabs(text) + return text:gsub("\t", string.rep(" ", mainWindow.codeView.indentationWidth)) +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 = line:gsub("\t", string.rep(" ", mainWindow.codeView.indentationWidth)) + line = removeTabs(line) table.insert(mainWindow.codeView.lines, line) mainWindow.codeView.maximumLineLength = math.max(mainWindow.codeView.maximumLineLength, unicode.len(line)) end @@ -214,7 +238,7 @@ local function newFile() "" } workPath = nil - setCursorPositionToEOF() + setCursorPositionAndClearSelection(1, 1) end local function open() @@ -714,6 +738,18 @@ local function createWindow() -- F5 elseif eventData[4] == 63 then run() + -- Home + elseif eventData[4] == 199 then + setCursorPositionToHome() + -- End + elseif eventData[4] == 207 then + setCursorPositionToEnd() + -- Page Up + elseif eventData[4] == 201 then + scroll(1, mainWindow.codeView.height - 2) + -- Page Down + elseif eventData[4] == 209 then + scroll(-1, mainWindow.codeView.height - 2) else if not keyboard.isControl(eventData[3]) then deleteSelectedData() @@ -721,22 +757,14 @@ local function createWindow() end end elseif eventData[1] == "clipboard" then + local lines = {} + for line in data:gmatch("(.+)\n") do + table.insert(lines, removeTabs(line)) + end paste({eventData[3]}) elseif eventData[1] == "scroll" then if mainWindow.codeView:isClicked(eventData[3], eventData[4]) then - if eventData[5] == 1 then - if mainWindow.codeView.fromLine > config.scrollSpeed then - mainWindow.codeView.fromLine = mainWindow.codeView.fromLine - config.scrollSpeed - else - mainWindow.codeView.fromLine = 1 - end - else - if mainWindow.codeView.fromLine < #mainWindow.codeView.lines - config.scrollSpeed then - mainWindow.codeView.fromLine = mainWindow.codeView.fromLine + config.scrollSpeed - else - mainWindow.codeView.fromLine = #mainWindow.codeView.lines - end - end + scroll(eventData[5], config.scrollSpeed) end elseif not eventData[1] then cursor.blinkState = oldCursorState diff --git a/lib/ECSAPI.lua b/lib/ECSAPI.lua index 189a29dd..208174d4 100755 --- a/lib/ECSAPI.lua +++ b/lib/ECSAPI.lua @@ -1178,8 +1178,8 @@ function ecs.newFile(path) local inputs = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x262626, "Новый файл"}, {"EmptyLine"}, {"Input", 0x262626, 0x880000, ""}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}}) if ecs.checkName(inputs[1], path) then - ecs.prepareToExit() - ecs.editFile(path .. inputs[1]) + local MineOSCore = require("MineOSCore") + MineOSCore.safeLaunch(MineOSCore.paths.applications .. "/MineCode IDE.app/MineCode IDE.lua", "open", path) end end