Let's say I want to give my user the ability to select some text and convert it to some other text, for instance to mangle it with ROT13 cipher. And selection could be made of several ranges, including in table cells. How would I go about this? My first idea was something like the code below, but some kind of update is required, because I only see the change if I scroll the text out view and back in, and even then the changed text does not reflow, but it continues after the right margin. Also, ability to undo the changes would be nice.