Paragraph>>displaySelectionInLine: line on: aCanvas
| leftX rightX w caretColor |
selectionStart ifNil: [^self]. "No selection"
aCanvas isShadowDrawing ifTrue: [ ^self ]. "don't draw selection with shadow"
selectionStart = selectionStop
ifTrue:
["Only show caret on line where clicked"
selectionStart textLine ~= line ifTrue: [^self]]
ifFalse:
["Test entire selection before or after here"
(selectionStop stringIndex < line first
or: [selectionStart stringIndex > (line last + 1)]) ifTrue: [^self]. "No selection on this line"
(selectionStop stringIndex = line first
and: [selectionStop textLine ~= line]) ifTrue: [^self]. "Selection ends on line above"
(selectionStart stringIndex = (line last + 1)
and: [selectionStop textLine ~= line]) ifTrue: [^self]]. "Selection begins on line below"
leftX := (selectionStart stringIndex < line first
ifTrue: [line ]
ifFalse: [selectionStart ])left.
rightX := (selectionStop stringIndex > (line last + 1) or:
[selectionStop stringIndex = (line last + 1)
and: [selectionStop textLine ~= line]])
ifTrue: [line right]
ifFalse: [selectionStop left].
selectionStart = selectionStop
ifTrue:
[rightX := rightX + 1.
w := self caretWidth.
caretRect := (leftX-w) <at> line top corner: (rightX+w) <at> line bottom.
self showCaret ifFalse:[^self].
caretColor := self insertionPointColor.
1 to: w
do:
[:i |
"Draw caret triangles at top and bottom"
aCanvas fillRectangle: ((leftX - w + i - 1) <at> (line top + i - 1)
extent: ((w - i) * 2 + 3) <at> 1)
color: caretColor.
aCanvas fillRectangle: ((leftX - w + i - 1) <at> (line bottom - i)
extent: ((w - i) * 2 + 3) <at> 1)
color: caretColor].
aCanvas fillRectangle: (leftX <at> line top corner: rightX <at> line bottom)
color: caretColor]
ifFalse:
[caretRect := nil.
aCanvas fillRectangle: (leftX <at> line top corner: rightX <at> line bottom)
color: self selectionColor]
Paragraph class>>insertionPointColor has the color. I was fed up of blue, turned it red

This one is hardcoded and could take a hint from the selection color twiceDarker for example.
Phil
2012/7/20 Denis Kudriashov
<dionisiydk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Hello
2012/7/20 Fernando Olivero
<fernando.olivero-BHDiRLqP7qo@public.gmane.org>
Hi Sean, you can take a look at Athens-PangoCairo (in squeaksource).
Using NativeBoost, i'm using the Pango layout library [1], and the
Pango-Cairo binding [2], to avoid laying out text using the outdated
(and messy) stuff in the image.
Check out the classes: ParagraphDescription & AthensPangoCairoParagraph.
I'm using them as the basis for the TextShape,LabelShape, and
EditableTextShape in Shapes / Gaucho ( using TextEditor,
SingleLineEditor ).
Maybe somebody can do the same for Morphic? use Pango to layout the
text, and code a new TextMorph on top of it?
How I can try your code?
Do you have ready image to play with it?
I am very interested with clean and simple alternative to morphic. I want it for Presenty framework.
(But I really like morphic as live user interface environment)
Best regards,
Denis
--
Philippe Back
Dramatic Performance Improvements
Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027 Mail:
phil-xfc0EfG9EVpKErsXAC5tcw@public.gmane.org | Web:
http://philippeback.eu | Blog:
http://philippeback.beHigh Octane SPRL
rue cour Boisacq 101
1301 Bierges
Belgium