bedit: Fixed addition of weird DC3 character when saving
This commit is contained in:
+86
-86
@@ -188,99 +188,99 @@ while true do
|
|||||||
if keyboard.keys[eventArgs[4]] == "s" then
|
if keyboard.keys[eventArgs[4]] == "s" then
|
||||||
save()
|
save()
|
||||||
end
|
end
|
||||||
end
|
else
|
||||||
|
if keyboard.keys[eventArgs[4]] == "up" and cursorY > 1 then
|
||||||
if keyboard.keys[eventArgs[4]] == "up" and cursorY > 1 then
|
if cursorY - scrollY <= 1 then
|
||||||
if cursorY - scrollY <= 1 then
|
renderBufferFlag = true
|
||||||
renderBufferFlag = true
|
scrollY = scrollY - 1
|
||||||
scrollY = scrollY - 1
|
else
|
||||||
else
|
if not previousCursorX and not previousCursorY then
|
||||||
if not previousCursorX and not previousCursorY then
|
previousCursorX = cursorX
|
||||||
previousCursorX = cursorX
|
previousCursorY = cursorY
|
||||||
previousCursorY = cursorY
|
end
|
||||||
|
end
|
||||||
|
cursorY = cursorY - 1
|
||||||
|
-- The cursor absolute position still has to be moved, even if on-screen it won't move
|
||||||
|
if cursorX > string.len(lines[cursorY]) + 1 then -- cursor snapping, +1 to be 1 char in front of end of line
|
||||||
|
cursorX = string.len(lines[cursorY]) + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cursorY = cursorY - 1
|
if keyboard.keys[eventArgs[4]] == "down" then
|
||||||
-- The cursor absolute position still has to be moved, even if on-screen it won't move
|
if cursorY - scrollY >= resY - 1 then
|
||||||
if cursorX > string.len(lines[cursorY]) + 1 then -- cursor snapping, +1 to be 1 char in front of end of line
|
renderBufferFlag = true
|
||||||
cursorX = string.len(lines[cursorY]) + 1
|
scrollY = scrollY + 1
|
||||||
end
|
else
|
||||||
end
|
if not previousCursorX and not previousCursorY then
|
||||||
if keyboard.keys[eventArgs[4]] == "down" then
|
previousCursorX = cursorX
|
||||||
if cursorY - scrollY >= resY - 1 then
|
previousCursorY = cursorY
|
||||||
renderBufferFlag = true
|
end
|
||||||
scrollY = scrollY + 1
|
end
|
||||||
else
|
cursorY = cursorY + 1
|
||||||
if not previousCursorX and not previousCursorY then
|
if cursorX > string.len(lines[cursorY]) + 1 then
|
||||||
previousCursorX = cursorX
|
cursorX = string.len(lines[cursorY]) + 1
|
||||||
previousCursorY = cursorY
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cursorY = cursorY + 1
|
if keyboard.keys[eventArgs[4]] == "left" and cursorX > 1 then
|
||||||
if cursorX > string.len(lines[cursorY]) + 1 then
|
if cursorX - scrollX <= 1 then
|
||||||
cursorX = string.len(lines[cursorY]) + 1
|
renderBufferFlag = true
|
||||||
end
|
scrollX = scrollX - 1
|
||||||
end
|
else
|
||||||
if keyboard.keys[eventArgs[4]] == "left" and cursorX > 1 then
|
if not previousCursorX and not previousCursorY then
|
||||||
if cursorX - scrollX <= 1 then
|
previousCursorX = cursorX
|
||||||
renderBufferFlag = true
|
previousCursorY = cursorY
|
||||||
scrollX = scrollX - 1
|
end
|
||||||
else
|
|
||||||
if not previousCursorX and not previousCursorY then
|
|
||||||
previousCursorX = cursorX
|
|
||||||
previousCursorY = cursorY
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
cursorX = cursorX - 1
|
|
||||||
end
|
|
||||||
if keyboard.keys[eventArgs[4]] == "right" and cursorX < string.len(lines[cursorY]) + 1 then
|
|
||||||
if cursorX - scrollX >= resX then
|
|
||||||
renderBufferFlag = true
|
|
||||||
scrollX = scrollX + 1
|
|
||||||
else
|
|
||||||
if not previousCursorX and not previousCursorY then
|
|
||||||
previousCursorX = cursorX
|
|
||||||
previousCursorY = cursorY
|
|
||||||
end
|
|
||||||
end
|
|
||||||
cursorX = cursorX + 1
|
|
||||||
end
|
|
||||||
if not keyboard.keys.special[eventArgs[4]] then
|
|
||||||
local line = lines[cursorY] or ""
|
|
||||||
line = string.sub(line, 1, cursorX - 1) .. string.char(eventArgs[3]) .. string.sub(line, cursorX, -1)
|
|
||||||
lines[cursorY] = line
|
|
||||||
cursorX = cursorX + 1
|
|
||||||
renderBufferFlag = true
|
|
||||||
end
|
|
||||||
if keyboard.keys[eventArgs[4]] == "back" then
|
|
||||||
local line = lines[cursorY]
|
|
||||||
local prevline = lines[cursorY - 1]
|
|
||||||
if cursorX > 1 then
|
|
||||||
line = string.sub(line, 1, cursorX - 2) .. string.sub(line, cursorX, -1) -- remove 1 char
|
|
||||||
elseif prevline then
|
|
||||||
prevline = prevline .. line -- copy line up to the next before removing it
|
|
||||||
ocelot.log(prevline)
|
|
||||||
line = nil
|
|
||||||
end
|
|
||||||
if line then
|
|
||||||
lines[cursorY] = line
|
|
||||||
else
|
|
||||||
removeLine(cursorY)
|
|
||||||
end
|
|
||||||
lines[cursorY - 1] = prevline
|
|
||||||
if not line then
|
|
||||||
cursorY = cursorY - 1 -- this can only trigger if the line is not the first
|
|
||||||
end
|
|
||||||
if cursorX > 1 then
|
|
||||||
cursorX = cursorX - 1
|
cursorX = cursorX - 1
|
||||||
end
|
end
|
||||||
renderBufferFlag = true
|
if keyboard.keys[eventArgs[4]] == "right" and cursorX < string.len(lines[cursorY]) + 1 then
|
||||||
end
|
if cursorX - scrollX >= resX then
|
||||||
if keyboard.keys[eventArgs[4]] == "enter" then
|
renderBufferFlag = true
|
||||||
addLine(cursorY + 1)
|
scrollX = scrollX + 1
|
||||||
cursorY = cursorY + 1
|
else
|
||||||
cursorX = 1
|
if not previousCursorX and not previousCursorY then
|
||||||
renderBufferFlag = true
|
previousCursorX = cursorX
|
||||||
|
previousCursorY = cursorY
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cursorX = cursorX + 1
|
||||||
|
end
|
||||||
|
if not keyboard.keys.special[eventArgs[4]] then
|
||||||
|
local line = lines[cursorY] or ""
|
||||||
|
line = string.sub(line, 1, cursorX - 1) .. string.char(eventArgs[3]) .. string.sub(line, cursorX, -1)
|
||||||
|
lines[cursorY] = line
|
||||||
|
cursorX = cursorX + 1
|
||||||
|
renderBufferFlag = true
|
||||||
|
end
|
||||||
|
if keyboard.keys[eventArgs[4]] == "back" then
|
||||||
|
local line = lines[cursorY]
|
||||||
|
local prevline = lines[cursorY - 1]
|
||||||
|
if cursorX > 1 then
|
||||||
|
line = string.sub(line, 1, cursorX - 2) .. string.sub(line, cursorX, -1) -- remove 1 char
|
||||||
|
elseif prevline then
|
||||||
|
prevline = prevline .. line -- copy line up to the next before removing it
|
||||||
|
ocelot.log(prevline)
|
||||||
|
line = nil
|
||||||
|
end
|
||||||
|
if line then
|
||||||
|
lines[cursorY] = line
|
||||||
|
else
|
||||||
|
removeLine(cursorY)
|
||||||
|
end
|
||||||
|
lines[cursorY - 1] = prevline
|
||||||
|
if not line then
|
||||||
|
cursorY = cursorY - 1 -- this can only trigger if the line is not the first
|
||||||
|
end
|
||||||
|
if cursorX > 1 then
|
||||||
|
cursorX = cursorX - 1
|
||||||
|
end
|
||||||
|
renderBufferFlag = true
|
||||||
|
end
|
||||||
|
if keyboard.keys[eventArgs[4]] == "enter" then
|
||||||
|
addLine(cursorY + 1)
|
||||||
|
cursorY = cursorY + 1
|
||||||
|
cursorX = 1
|
||||||
|
renderBufferFlag = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
until next(eventArgs) == nil
|
until next(eventArgs) == nil
|
||||||
|
|||||||
Reference in New Issue
Block a user