insertionPointManager ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

insertionPointManager ?

Rick Hedin
Hello all.  I would like to know where the cursor (caret, insertion point, selection) is in some text in a TextEditorView/TextEditorController pair.  This works:
 
Controller>>keyPressedEvent:  self view startBlock stringIndex
 
But it makes me uncomfortable.  Perhaps in some circumstances, there might be more than one character block.
 
I see that there is something called insertionPointManager, and things called characterBlocks.  But I suspect there is a bigger picture I'm not seeing.  I know the Smalltalk ethos is "read the design out of the code" but I am finding that difficult.  Can someone "tell the story" of this design / arrangement? 
 
         Regards,
 
         Rick

--
I insist on rapport!

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: insertionPointManager ?

Travis Griggs-4

On Apr 26, 2011, at 9:28 AM, Rick Hedin wrote:

> Hello all.  I would like to know where the cursor (caret, insertion point, selection) is in some text in a TextEditorView/TextEditorController pair.  This works:
>  
> Controller>>keyPressedEvent:  self view startBlock stringIndex
>  
> But it makes me uncomfortable.  Perhaps in some circumstances, there might be more than one character block.

There is only one startBlock. You can get CharacterBlocks for any of the characters in the editor, regardless of whether they're selected or not using the methods. You either get them from a string index (characterBlockForIndex:) or from an x,y point (characterBlockAtPoint:).

A CharacterBlock is just a specialized Rectangle. It is the rectangle that the character currently occupies. And it knows indirectly, via it's stringIndex, what character it represents the bounds of.

I've often added helper APIs to fetch the selectionRange as an Interval


>  I see that there is something called insertionPointManager, and things called characterBlocks.  But I suspect there is a bigger picture I'm not seeing.  I know the Smalltalk ethos is "read the design out of the code" but I am finding that difficult.  Can someone "tell the story" of this design / arrangement?

InsertionPointManager is about drawing the text input cursor (when there is nothing selected).

I'm not sure there is a story for the design anymore. Or more succinctly, this stuff was implemented years ago, like in early versions of ObjectWorks in the mid 80's. So there was probably a story at that time. And then a couple of times, a person has come along and done a raft of work, each time with a new story. Kind of like the way oral tradition is passed down, periodically going thru revisions, creating mythology. The best I'd be able to offer as a current Bard for this, would be supposition and guess. But I can answer the more direct questions like above...

--
Travis Griggs
Objologist
I multiply all time estimates by pi, to account for running around in circles.




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: insertionPointManager ?

Rick Hedin
Hi Travis.
 
I thought a "character block" was a block of characters.  And if you inserted characters into the middle of a character block, "they" probably allocated and linked in a new character block, rather than growing the existing character block.  I was completely off!
 
So, I suspect that the startBlock is the first character in the selection range.  And that if there is no selection, the startBlock and the stopBlock specify the same character.  (Although with two physically separate characterBlocks.) 
 
 
              Regards,
 
              Rick

On Tue, Apr 26, 2011 at 12:14 PM, Travis Griggs <[hidden email]> wrote:

On Apr 26, 2011, at 9:28 AM, Rick Hedin wrote:

> Hello all.  I would like to know where the cursor (caret, insertion point, selection) is in some text in a TextEditorView/TextEditorController pair.  This works:
>
> Controller>>keyPressedEvent:  self view startBlock stringIndex
>
> But it makes me uncomfortable.  Perhaps in some circumstances, there might be more than one character block.

There is only one startBlock. You can get CharacterBlocks for any of the characters in the editor, regardless of whether they're selected or not using the methods. You either get them from a string index (characterBlockForIndex:) or from an x,y point (characterBlockAtPoint:).

A CharacterBlock is just a specialized Rectangle. It is the rectangle that the character currently occupies. And it knows indirectly, via it's stringIndex, what character it represents the bounds of.

I've often added helper APIs to fetch the selectionRange as an Interval


>  I see that there is something called insertionPointManager, and things called characterBlocks.  But I suspect there is a bigger picture I'm not seeing.  I know the Smalltalk ethos is "read the design out of the code" but I am finding that difficult.  Can someone "tell the story" of this design / arrangement?

InsertionPointManager is about drawing the text input cursor (when there is nothing selected).

I'm not sure there is a story for the design anymore. Or more succinctly, this stuff was implemented years ago, like in early versions of ObjectWorks in the mid 80's. So there was probably a story at that time. And then a couple of times, a person has come along and done a raft of work, each time with a new story. Kind of like the way oral tradition is passed down, periodically going thru revisions, creating mythology. The best I'd be able to offer as a current Bard for this, would be supposition and guess. But I can answer the more direct questions like above...

--
Travis Griggs
Objologist
I multiply all time estimates by pi, to account for running around in circles.






--
I insist on rapport!

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc