In a Gedit plugin written in Python, I can get the offset of the beginning of the current line with
document = window.get_active_document()
offset = document.get_iter_at_mark(document.get_insert())
How could I get the offset of the end of this same line? For now I am using a workaround: I get the offset of the next line and subtract the offset of the desired line from it, and subtract 1 (with an special case treated for the last line). Is there a better way of doing it?
A bit late, I know, but better late than never. I am running gedit 3.2.3 and I don’t know how much these things change from one version to another, but this works for me:
Edit 1: Was not accounting for the case where the file wasn’t terminated by a newline character
Edit 2: Account for different definitions of the end of line
PS: Whether this or your currently solution is “cleaner” or “better”, I don’t know, I guess that’s subjective.