Wrap replaceSelections in an operation

Issue #2485
Fix bug in posFromMouse for rectangular coords

It was returning negative values in the ch field.

Issue #2485