Introduce cursorToOffset
This isn't in the public API yet but is a useful addition as Kate also needs such a helper function. Doing it in the buffer allows for optimizations that are just not possible if one does it from the outside.
An added benefit is that KateViewAccessible is now much faster
The counterpart offsetToCursor will come in a follow up