<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>It's good to remember what startIndex/startBlock/selectionStart
      and stopIndex/stopBlock/selectionStop are used for. If you have a
      paragraph with two characters 'ab' <br>
    </p>
    <p>...and the 'a' is selected, then this is what the paragraph is
      thinking<br>
    </p>
    <p><font face="Georgia">selectionStart:     a CharacterBlock with
        index 1 and character $a and rectangle 3@0 corner: <a class="moz-txt-link-abbreviated" href="mailto:11@18.0">11@18.0</a><br>
         in a TextLine 1 to: 2<br>
        selectionStop:     a CharacterBlock with index 2 and character
        $b and rectangle 11@0 corner: <a class="moz-txt-link-abbreviated" href="mailto:20@18.0">20@18.0</a><br>
         in a TextLine 1 to: 2<br>
      </font></p>
    <p>...if the cursor is between 'a' and 'b' then this happens</p>
    <p>selectionStart:     a CharacterBlock with index 2 and character
      $b and rectangle 11@0 corner: <a class="moz-txt-link-abbreviated" href="mailto:20@18.0">20@18.0</a><br>
       in a TextLine 1 to: 2<br>
      selectionStop:     a CharacterBlock with index 2 and character $b
      and rectangle 11@0 corner: <a class="moz-txt-link-abbreviated" href="mailto:20@18.0">20@18.0</a><br>
       in a TextLine 1 to: 2<br>
    </p>
    <p>So, in the first case, it can highlight from the topLeft of
      selectionStart to the bottomLeft of selectionStop. In the second
      case, since the two are equal, it just displays the cursor along
      the left edge of either.</p>
    <p>In either case, the stopIndex is one more than last selected
      character and</p>
    selection<br>
        "Answer the text in the paragraph that is currently selected."<br>
    <br>
        ^paragraph text copyFrom: self startIndex to: self stopIndex - 1
    <br>
    <br>
    returns the selected characters.<br>
    <br>
    <div class="moz-cite-prefix">On 7/5/18 7:17 AM, David T. Lewis
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20180705111745.GA33796@shell.msen.com">
      <pre wrap="">On Thu, Jul 05, 2018 at 02:51:58PM +0530, K K Subbu wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">On Wednesday 04 July 2018 09:23 PM, David T. Lewis wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">A clue that this might be accumulation of kludges: Looking at senders of
selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
of methods that subtract 1 from the stop index when before calling the 
method
that adds 1 back to the stop index. This certainly does not have a good 
smell.
</pre>
        </blockquote>
        <pre wrap="">Looks like different intervals for dealing with selections and 
substrings. I see that the names used are start/stop instead of 
startIndex/stopIndex. I found this consistent pattern in all methods 
that deal with selections.

  stop = (stopIndex - 1)
  stopIndex = (stop + 1)

Regular methods that deal with substrings like 
AbstractFont>>#widthOString... and BitBlt>>#primDisplayString... and the 
scanner methods iterate over aString with:

   startIndex to: stopIndex

while Editor>>selectionInterval extracts selections with startIndex to: 
(stopIndex-1).

Regards .. Subbu

</pre>
      </blockquote>
      <pre wrap="">
Ah yes, that makes sense now. Thank you for the explanation.

Dave
 

</pre>
    </blockquote>
    <br>
  </body>
</html>