From 674e7f8843e72f3beab5d70d72bb8ba6f1e9916c Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 17:28:49 +0300 Subject: [PATCH 1/8] Add files via upload --- Libraries/Clipboard.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Libraries/Clipboard.lua diff --git a/Libraries/Clipboard.lua b/Libraries/Clipboard.lua new file mode 100644 index 00000000..13c85767 --- /dev/null +++ b/Libraries/Clipboard.lua @@ -0,0 +1,17 @@ +local Clipboard = { + maxHistory = 2, + history = {} +} + +function Clipboard.copy(content) + table.insert(Clipboard.history,1,content) + while #Clipboard.history > Clipboard.maxHistory do + table.remove(Clipboard.history, Clipboard.maxHistory + 1) + end +end + +function Clipboard.paste() + return Clipboard.history[1] +end + +return Clipboard \ No newline at end of file From 91a97273d842fd1001fda9e09b773654ed38d39b Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 17:29:34 +0300 Subject: [PATCH 2/8] Update Main.lua --- Applications/MineCode IDE.app/Main.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Applications/MineCode IDE.app/Main.lua b/Applications/MineCode IDE.app/Main.lua index 76f02855..b582e1f7 100755 --- a/Applications/MineCode IDE.app/Main.lua +++ b/Applications/MineCode IDE.app/Main.lua @@ -77,7 +77,7 @@ local currentScriptDirectory = filesystem.path(system.getCurrentScript()) local configPath = paths.user.applicationData .. "MineCode IDE/Config9.cfg" local localization = system.getLocalization(currentScriptDirectory .. "Localizations/") local findStartFrom -local clipboard +local clipboard = require('Clipboard') local breakpointLines local lastErrorLine local autocompleteDatabase @@ -970,17 +970,17 @@ local function deleteSelectedData() clearSelection() end end - +print(clipboard) local function copy() if codeView.selections[1] then if codeView.selections[1].to.line == codeView.selections[1].from.line then - clipboard = { unicode.sub(lines[codeView.selections[1].from.line], codeView.selections[1].from.symbol, codeView.selections[1].to.symbol) } + clipboard.copy({ unicode.sub(lines[codeView.selections[1].from.line], codeView.selections[1].from.symbol, codeView.selections[1].to.symbol) }) else - clipboard = { unicode.sub(lines[codeView.selections[1].from.line], codeView.selections[1].from.symbol, -1) } + clipboard.copy({ unicode.sub(lines[codeView.selections[1].from.line], codeView.selections[1].from.symbol, -1) }) for line = codeView.selections[1].from.line + 1, codeView.selections[1].to.line - 1 do - table.insert(clipboard, lines[line]) + table.insert(clipboard.history[1], lines[line]) end - table.insert(clipboard, unicode.sub(lines[codeView.selections[1].to.line], 1, codeView.selections[1].to.symbol)) + table.insert(clipboard.history[1], unicode.sub(lines[codeView.selections[1].to.line], 1, codeView.selections[1].to.symbol)) end end end @@ -1320,8 +1320,8 @@ local function createEditOrRightClickMenu(menu) copy() end - menu:addItem("⇲", localization.paste, not clipboard, "^V").onTouch = function() - paste(clipboard) + menu:addItem("⇲", localization.paste, not clipboard.history[1], "^V").onTouch = function() + paste(clipboard.history[1]) end menu:addSeparator() @@ -1453,8 +1453,8 @@ codeView.eventHandler = function(workspace, object, e1, e2, e3, e4, e5) copy() end -- V - elseif e4 == 47 and clipboard then - paste(clipboard) + elseif e4 == 47 and clipboard.paste() then + paste(clipboard.paste()) -- X elseif e4 == 45 then if codeView.selections[1] then From 501304daf2ba5e025af324ece4822be723f13c26 Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 17:30:43 +0300 Subject: [PATCH 3/8] =?UTF-8?q?=D0=95=D0=B1=D1=83=D1=87=D0=B8=D0=B9=20prin?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/MineCode IDE.app/Main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/MineCode IDE.app/Main.lua b/Applications/MineCode IDE.app/Main.lua index b582e1f7..b217064c 100755 --- a/Applications/MineCode IDE.app/Main.lua +++ b/Applications/MineCode IDE.app/Main.lua @@ -970,7 +970,7 @@ local function deleteSelectedData() clearSelection() end end -print(clipboard) + local function copy() if codeView.selections[1] then if codeView.selections[1].to.line == codeView.selections[1].from.line then From 2e5344f4b5502edd6590b9aa244431e17064749b Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 17:59:57 +0300 Subject: [PATCH 4/8] Update Main.lua --- Applications/MineCode IDE.app/Main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/MineCode IDE.app/Main.lua b/Applications/MineCode IDE.app/Main.lua index b217064c..22332be0 100755 --- a/Applications/MineCode IDE.app/Main.lua +++ b/Applications/MineCode IDE.app/Main.lua @@ -1321,7 +1321,7 @@ local function createEditOrRightClickMenu(menu) end menu:addItem("⇲", localization.paste, not clipboard.history[1], "^V").onTouch = function() - paste(clipboard.history[1]) + paste(clipboard.paste()) end menu:addSeparator() From bc8d1e54c2e6eac069c7e752e17b72ffe9ac60b9 Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 18:00:45 +0300 Subject: [PATCH 5/8] Update GUI.lua --- Libraries/GUI.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 809797ce..d0c4c5c3 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -7,6 +7,7 @@ local screen = require("Screen") local paths = require("Paths") local text = require("Text") local number = require("Number") +local clipboard = require("Clipboard") ----------------------------------------------------------------------------------------- @@ -3061,7 +3062,11 @@ local function inputEventHandler(workspace, input, e1, e2, e3, e4, e5, e6, ...) -- End elseif e4 == 207 then input:setCursorPosition(unicode.len(input.text) + 1) - + + -- V + elseif e4 == 47 and type(clipboard.paste()) ~= "table" then + input.text = input.text .. tostring(clipboard.paste()) + input:setCursorPosition(unicode.len(input.text)+1) else local char = unicode.char(e3) From 8d34ce7b4bb05db76869f5e0e24759503131cf8b Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 18:07:34 +0300 Subject: [PATCH 6/8] Update GUI.lua --- Libraries/GUI.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index d0c4c5c3..42fae9f4 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -3064,7 +3064,7 @@ local function inputEventHandler(workspace, input, e1, e2, e3, e4, e5, e6, ...) input:setCursorPosition(unicode.len(input.text) + 1) -- V - elseif e4 == 47 and type(clipboard.paste()) ~= "table" then + elseif e4 == 47 and type(clipboard.paste()) ~= "table" and clipboard.paste() ~= nil then input.text = input.text .. tostring(clipboard.paste()) input:setCursorPosition(unicode.len(input.text)+1) else From b8727e8de3d0cc562347ba6a739d2f36685a80a2 Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 18:07:58 +0300 Subject: [PATCH 7/8] =?UTF-8?q?clear=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BA=D0=BE=D1=80=D0=BE=D1=87=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Libraries/Clipboard.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Libraries/Clipboard.lua b/Libraries/Clipboard.lua index 13c85767..cc890144 100644 --- a/Libraries/Clipboard.lua +++ b/Libraries/Clipboard.lua @@ -14,4 +14,9 @@ function Clipboard.paste() return Clipboard.history[1] end -return Clipboard \ No newline at end of file +function Clipboard.clear() + Clipboard.history = {} + return true +end + +return Clipboard From c37a692a778cfb355739cafc4bab6ce38de97974 Mon Sep 17 00:00:00 2001 From: Oleshe <125771937+0leshe@users.noreply.github.com> Date: Sun, 25 May 2025 22:12:31 +0300 Subject: [PATCH 8/8] =?UTF-8?q?=D0=9D=D0=B5=20=D1=82=D0=B0=D0=BA=20=D0=B2?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D1=8F=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Libraries/GUI.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 42fae9f4..753a655b 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -3064,9 +3064,11 @@ local function inputEventHandler(workspace, input, e1, e2, e3, e4, e5, e6, ...) input:setCursorPosition(unicode.len(input.text) + 1) -- V - elseif e4 == 47 and type(clipboard.paste()) ~= "table" and clipboard.paste() ~= nil then - input.text = input.text .. tostring(clipboard.paste()) - input:setCursorPosition(unicode.len(input.text)+1) + elseif e4 == 47 and type(clipboard.paste()) ~= "table" and clipboard.paste() ~= nil then + local startPos = input.cursorPosition + local toPaste = tostring(clipboard.paste()) + input.text = unicode.sub(input.text, 1,startPos) .. toPaste .. unicode.sub(input.text, startPos, unicode.len(input.text)) + input:setCursorPosition(startPos + unicode.len(toPaste)+1) else local char = unicode.char(e3)