Given a character index, for example the 42nd character, how can I get at which line and which column that character is in a textarea? Given manual line-breaks and text wrapping.
I've tried iterating through the characters and checking for new lines (\n
) to increase the line counter, but I have no idea how to check for automatic wrapping. Even using the cols
attribute doesn't seem very reliable for this.