mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-31 11:19:11 +00:00
Update eldit.lua
This commit is contained in:
parent
e9520031d2
commit
962a1d3c0c
32
eldit.lua
32
eldit.lua
@ -185,6 +185,7 @@ prompt = function(prebuffer)
|
||||
for y = 1, eldit.size.height - 1 do -- minus one because it reserves space for the bar
|
||||
cy = y + eldit.scrollY
|
||||
-- find text
|
||||
if eldit.buffer[cy] then
|
||||
for x = 1, #eldit.buffer[cy] do
|
||||
if (not tab[eldit.buffer[cy][x]]) and eldit.buffer[cy][x] then
|
||||
textPoses[1] = x
|
||||
@ -197,6 +198,7 @@ prompt = function(prebuffer)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local isHighlighted = false
|
||||
for id,cur in pairs(eldit.cursors) do
|
||||
if cy == cur.y then
|
||||
@ -213,6 +215,7 @@ prompt = function(prebuffer)
|
||||
end
|
||||
end
|
||||
term.setCursorPos(eldit.size.x, eldit.size.y + y - 1)
|
||||
if cy <= #eldit.buffer then
|
||||
if isHighlighted then
|
||||
term.setBackgroundColor(colors.gray)
|
||||
term.setTextColor(colors.white)
|
||||
@ -221,10 +224,12 @@ prompt = function(prebuffer)
|
||||
term.setTextColor(colors.lightGray)
|
||||
end
|
||||
term.write(cy .. (" "):rep(lineNoLen - #tostring(y)))
|
||||
else
|
||||
term.write(" ")
|
||||
end
|
||||
for x = lineNoLen + 1, eldit.size.width do
|
||||
term.setCursorPos(eldit.size.x + x - 1, eldit.size.y + y - 1)
|
||||
cx = x + eldit.scrollX - lineNoLen
|
||||
cy = y + eldit.scrollY
|
||||
|
||||
if checkIfSelected(cx, cy) then
|
||||
term.setBackgroundColor(colors.blue)
|
||||
@ -243,6 +248,7 @@ prompt = function(prebuffer)
|
||||
else
|
||||
term.setTextColor(colors.white)
|
||||
end
|
||||
if textPoses[1] and textPoses[2] and eldit.buffer[cy] then
|
||||
if cx < textPoses[1] and eldit.buffer[cy][cx] then
|
||||
term.setTextColor(colors.gray)
|
||||
term.write("|")
|
||||
@ -252,6 +258,9 @@ prompt = function(prebuffer)
|
||||
else
|
||||
term.write(getChar(cx, cy) or " ")
|
||||
end
|
||||
else
|
||||
term.write(getChar(cx, cy) or " ")
|
||||
end
|
||||
end
|
||||
end
|
||||
term.setCursorPos(eldit.size.x, eldit.size.y + eldit.size.height - 1)
|
||||
@ -352,7 +361,7 @@ prompt = function(prebuffer)
|
||||
if cx < #eldit.buffer[cy] then
|
||||
xAdjList[cy] = (xAdjList[cy] or 0) + 1
|
||||
table.remove(eldit.buffer[cy], cx)
|
||||
else
|
||||
elseif cy < #eldit.buffer then
|
||||
for i = 1, #eldit.buffer[cy + 1] do
|
||||
table.insert(eldit.buffer[cy], eldit.buffer[cy + 1][i])
|
||||
end
|
||||
@ -485,6 +494,12 @@ prompt = function(prebuffer)
|
||||
cur.x = cur.x - ((xAdjusts[cur.y] or {})[cur.x] or 0) + (xAdjList[cur.y] or 0)
|
||||
for i = 1, #text do
|
||||
if isInsert then
|
||||
if cur.x == #eldit.buffer[cur.y] + 1 then
|
||||
for i = 1, #eldit.buffer[cur.y + 1] do
|
||||
table.insert(eldit.buffer[cur.y], eldit.buffer[cur.y + 1][i])
|
||||
end
|
||||
table.remove(eldit.buffer, cur.y + 1)
|
||||
end
|
||||
eldit.buffer[cur.y][cur.x + i - 1] = text:sub(i,i)
|
||||
else
|
||||
table.insert(eldit.buffer[cur.y], cur.x, text:sub(i,i))
|
||||
@ -614,6 +629,7 @@ prompt = function(prebuffer)
|
||||
doRender = true
|
||||
elseif evt[1] == "key" then
|
||||
keysDown[evt[2]] = true
|
||||
-- KEYBOARD SHORTCUTS
|
||||
if keysDown[keys.leftCtrl] or keysDown[keys.leftCtrl] then
|
||||
|
||||
if evt[2] == keys.backspace then
|
||||
@ -630,6 +646,18 @@ prompt = function(prebuffer)
|
||||
elseif evt[2] == keys.s then
|
||||
saveFile()
|
||||
|
||||
elseif evt[2] == keys.a then
|
||||
eldit.selections = {{
|
||||
{
|
||||
x = 1,
|
||||
y = 1
|
||||
},{
|
||||
x = #eldit.buffer[#eldit.buffer],
|
||||
y = #eldit.buffer
|
||||
}
|
||||
}}
|
||||
doRender = true
|
||||
|
||||
elseif evt[2] == keys.left then
|
||||
adjustCursor(-1, 0, true, "word")
|
||||
doRender, isCursorBlink = true, true
|
||||
|
Loading…
Reference in New Issue
Block a user