Caret position refactor.

Break single CaretPosition into having two caretPositionInternals (selection start and end, potentially equal).
Store caretPositionInternal as {lineIndex, positionWithinLine} pair.

Other minor improvements and API updates.