[Draft] Line boundaries

Rewrite of line boundary detection logic to address issues #555, #405, #227, #225, #224, #185, #124 and #98.

This also removes the last uses of the gui.SelectionMover class, allowing it to be removed.