get position in string from caret position
Maybe there's some simple solution to this but I've been searching for some time and couldn't find any:
When you read getCaretPosition from JEditorPane, the position will not correspond to the string's index from getText, if you use "text/html" to display HTML.
E.g. if you have the text "<html>hello</html>" and the cursor is between the h and e, the caret position will be 2, but the index of the 'e' in the string is 7.
How can I convert from the caret position to the corresponding position of the letter to the right of the caret, within the string (so, if the cursor is between the h and e, how do I get the correct index for e within the string returned by getText)?