Edit.luaa v1.2.0 - Added support for the Tab key and removed Ocelot card calls I had accidentally left in.

This commit is contained in:
TheWahlolly
2025-07-01 19:43:37 +03:00
parent 02e9494da6
commit b7a7f01c3f
2 changed files with 18 additions and 3 deletions
+17 -2
View File
@@ -10,7 +10,8 @@ local cursorWhite = true
local changesMade = false
local renderBuffer = gpu.allocateBuffer()
local scrollSpeed = 5
local ocelot = component.ocelot
local tab = " "
--local ocelot = component.ocelot
local function rawset(x, y, text)
termlib.cursorPosX = x
@@ -54,7 +55,7 @@ end
local function render()
gpu.setActiveBuffer(renderBuffer)
clear()
ocelot.log(tostring(scrollPosY))
--ocelot.log(tostring(scrollPosY))
local realCursorX = math.min(cursorPosX, unicode.wlen(tmpdata[cursorPosY + scrollPosY - 1]) - scrollPosX + 2)
if realCursorX < 1 then
scrollPosX = scrollPosX + realCursorX - 1
@@ -212,6 +213,20 @@ local function processEvent(args)
end
end
end
if key == "tab" then
changesMade = true
cursorRenderFlag = true
cursorWhite = true
tmpdata[cursorPosY + scrollPosY - 1] = tmpdata[cursorPosY + scrollPosY - 1]:sub(1, cursorPosX + scrollPosX - 2) .. tab .. tmpdata[cursorPosY + scrollPosY - 1]:sub(cursorPosX + scrollPosX - 1)
cursorPosX = cursorPosX + unicode.wlen(tab)
if cursorPosX > width then
scrollPosX = scrollPosX + cursorPosX - width
cursorPosX = width
renderFlag = true
else
rawset(1, cursorPosY, tmpdata[cursorPosY + scrollPosY - 1]:sub(scrollPosX))
end
end
if args[3] >= 32 and args[3] <= 126 then
changesMade = true
cursorRenderFlag = true