Skip to content

Instantly share code, notes, and snippets.

@Srlion
Last active January 10, 2019 11:55
Show Gist options
  • Save Srlion/c05782fceb7a5c4f0d03f7bc3622e559 to your computer and use it in GitHub Desktop.
Save Srlion/c05782fceb7a5c4f0d03f7bc3622e559 to your computer and use it in GitHub Desktop.
-- af needs to be remade because string.Split is slow
GetCaretLine = function(s)
local caretPos = s:GetCaretPos() + 1
local splittedText = s:GetText():Split("\n")
local len = 0
for k, v in ipairs(splittedText) do
len = len + #v + 1
if (caretPos <= len) then
return k
end
end
end
print(GetCaretLine(DTextEntry))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment