ParagraphEditor
Last updated at 6:01 pm UTC on 5 July 2018
ParagraphEditor is a class worth exploring with the SystemBrowser if you want to configure keyboard related things in your image.
Most important are the methods called in the initialize method on the class side:
initialize
UndoSelection _ FindText _ ChangeText _ Text new.
UndoMessage _ Message selector: #halt.
self initializeCmdKeyShortcuts.
self initializeShiftCmdKeyShortcuts.
self initializeTextEditorMenus
See also TextMorphEditor (a subclass)
Alan Kay - http://www.vpri.org/pdf/hc_user_interface.pdf, p. 11,

Implementation
ParagraphEditor is a controller for editing paragraphs (displayable strings). It uses the following variables:
- startIndex/stopIndex - indices tracking the substring with a text that is being edited.
- startBlock/stopBlock - indices tracking the characters rendered within a single rectangle
- startSelection/stopSelection - indices of selection spanning characters
A selection may start its mark and stop at a point in forward or reverse direction while editing, but the start always refers to the smaller index and the stop to the larger index.
Example
From a post by Bob Arning
If you have a paragraph "ab" and
- "a" is selected, then
- selectionStart: a CharacterBlock with index 1 and character $a and rectangle 3@0 corner: 11@18.0 in a TextLine 1 to: 2
- selectionStop: a CharacterBlock with index 2 and character $b and rectangle 11@0 corner: 20@18.0 in a TextLine 1 to: 2
- if the cursor is between 'a' and 'b' then,
- selectionStart: a CharacterBlock with index 2 and character $b and rectangle 11@0 corner: 20@18.0
in a TextLine 1 to: 2
- selectionStop: a CharacterBlock with index 2 and character $b and rectangle 11@0 corner: 20@18.0
in a TextLine 1 to: 2
In the first case, the editor will highlight from the topLeft 3@0 of selectionStart to the bottomLeft (11@18) of selectionStop. In the second case, since the two are equal, it just displays the I-bar cursor along the left edge of either.
In either case, the stopIndex is one more than selectionStop:
selection
"Answer the text in the paragraph that is currently selected."
^paragraph text copyFrom: self startIndex to: self stopIndex - 1
returns the selected characters