Sunday, February 24, 2013

Pasting Over A Selection (Status)

Getting the modified lines reported correctly when pasting text over a selection is proving to be very difficult.  There are several conditions to check including whether the start of the selection is at the beginning of the line, end of the line, both (on a blank line), or neither (middle of the line); the same for the end of the selection; the number of new lines in the text being inserted, and if the text being inserted starts with or ends with a new line.

These conditions are using to determine the starting line and number of lines (if any) to report as being deleted, if the line that start position is at should be reported as modified, not modified, be included with the deleted lines or the inserted lines, the lines that have been inserted, and if the line the cursor ends up on is modified, not modified or should be marked as a new line to be inserted.

Some of the if statements for these checks are five to eight lines long.  I already know how to simplify if statements for up to four conditions using Karnaugh Maps, but I had to learn how to do ones with five and six conditions (not easy) and gets worst with more conditions.  So I'm going to take a step back and see if there is an easier what handle all this...