Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
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,

Note_about_ParagraphEditor.png

Implementation

ParagraphEditor is a controller for editing paragraphs (displayable strings). It uses the following variables:
  1. startIndex/stopIndex - indices tracking the substring with a text that is being edited.
  2. startBlock/stopBlock - indices tracking the characters rendered within a single rectangle
  3. 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
in a TextLine 1 to: 2
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