1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-06-11 23:24:05 +00:00

Added cut, improved multicursor paste

This commit is contained in:
LDDestroier 2019-03-20 11:49:59 -04:00 committed by GitHub
parent 4dafde4dd3
commit 78f7159e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -329,8 +329,7 @@ prompt = function(prebuffer, precy, _eldit)
term.write(barmsg) term.write(barmsg)
else else
for id,cur in pairs(eldit.cursors) do for id,cur in pairs(eldit.cursors) do
--term.write("(" .. cur.x .. "," .. cur.y .. ") ") term.write("(" .. cur.x .. "," .. cur.y .. ") ")
term.write(#eldit.selections)
end end
end end
end end
@ -734,22 +733,26 @@ prompt = function(prebuffer, precy, _eldit)
elseif evt[1] == "paste" then elseif evt[1] == "paste" then
if keysDown[keys.leftShift] then if keysDown[keys.leftShift] then
local cb = eldit.clipboards[eldit.selectedClipboard] local cb = eldit.clipboards[eldit.selectedClipboard]
local cbb = {}
if cb then if cb then
deleteSelections() deleteSelections()
sortCursors() sortCursors()
for i = 1, #cb do for i = 1, math.max(#cb, #eldit.cursors) do
cbb[i] = cb[(i % #cb) + 1]
end
for i = 1, #cbb do
if eldit.cursors[i] then if eldit.cursors[i] then
for y = 1, #cb[i] do for y = 1, #cbb[i] do
placeText(table.concat(cb[i][y]), {eldit.cursors[i]}) placeText(table.concat(cbb[i][y]), {eldit.cursors[i]})
if y < #cb[i] then if y < #cbb[i] then
makeNewLine({eldit.cursors[i]}) makeNewLine({eldit.cursors[i]})
end end
end end
else else
makeNewLine({eldit.cursors[#eldit.cursors]}) makeNewLine({eldit.cursors[#eldit.cursors]})
for y = 1, #cb[i] do for y = 1, #cbb[i] do
placeText(table.concat(cb[i][y]), {eldit.cursors[#eldit.cursors]}) placeText(table.concat(cbb[i][y]), {eldit.cursors[#eldit.cursors]})
if y < #cb[i] then if y < #cbb[i] then
makeNewLine({eldit.cursors[#eldit.cursors]}) makeNewLine({eldit.cursors[#eldit.cursors]})
end end
end end
@ -757,7 +760,7 @@ prompt = function(prebuffer, precy, _eldit)
end end
barmsg = "Pasted from clipboard " .. eldit.selectedClipboard .. "." barmsg = "Pasted from clipboard " .. eldit.selectedClipboard .. "."
else else
barmsg = "Clipboard is empty." barmsg = "Clipboard " .. eldit.selectedClipboard .. " is empty."
end end
barlife = defaultBarLife barlife = defaultBarLife
else else
@ -770,7 +773,11 @@ prompt = function(prebuffer, precy, _eldit)
if keysDown[keys.leftCtrl] or keysDown[keys.rightCtrl] then if keysDown[keys.leftCtrl] or keysDown[keys.rightCtrl] then
if keysDown[keys.leftShift] or keysDown[keys.rightShift] then if keysDown[keys.leftShift] or keysDown[keys.rightShift] then
if evt[2] == keys.c then if evt[2] == keys.c or evt[2] == keys.x then
if #eldit.selections == 0 then
barmsg = "No selections have been made."
barlife = defaultBarLife
else
eldit.clipboards[eldit.selectedClipboard] = {} eldit.clipboards[eldit.selectedClipboard] = {}
local cb = eldit.clipboards[eldit.selectedClipboard] local cb = eldit.clipboards[eldit.selectedClipboard]
sortSelections() sortSelections()
@ -786,9 +793,16 @@ prompt = function(prebuffer, precy, _eldit)
end end
end end
end end
if evt[2] == keys.x then
deleteSelections()
barmsg = "Cut to clipboard " .. eldit.selectedClipboard .. "."
barlife = defaultBarLife
else
barmsg = "Copied to clipboard " .. eldit.selectedClipboard .. "." barmsg = "Copied to clipboard " .. eldit.selectedClipboard .. "."
barlife = defaultBarLife barlife = defaultBarLife
end end
end
end
-- In-editor pasting is done with the "paste" event! -- In-editor pasting is done with the "paste" event!
else else
if numToKey[evt[2]] then -- if that's a number then if numToKey[evt[2]] then -- if that's a number then