B:BD[
9.148] → [
9.148:296]
local byteoffset = utf8.offset(lines[#lines], -1)
if byteoffset then
lines[#lines] = string.sub(lines[#lines], 1, byteoffset-1)
if cursor_pos > 1 then
local byte_start = utf8.offset(lines[cursor_line], cursor_pos-1)
local byte_end = utf8.offset(lines[cursor_line], cursor_pos)
if byte_start then
if byte_end then
lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)..string.sub(lines[cursor_line], byte_end)
else
lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)
end
cursor_pos = cursor_pos-1
end
end
end
elseif chord == 'left' then
if cursor_pos > 1 then
cursor_pos = cursor_pos - 1
end
elseif chord == 'right' then
if cursor_pos <= #lines[cursor_line] then
cursor_pos = cursor_pos + 1
end
elseif chord == 'delete' then
if cursor_pos <= #lines[cursor_line] then
local byte_start = utf8.offset(lines[cursor_line], cursor_pos)
local byte_end = utf8.offset(lines[cursor_line], cursor_pos+1)
if byte_start then
if byte_end then
lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)..string.sub(lines[cursor_line], byte_end)
else
lines[cursor_line] = string.sub(lines[cursor_line], 1, byte_start-1)
end
-- no change to cursor_pos