[squeak-dev] wait2ms (The Trunk: ST80-dtl.141.mcz)

Yoshiki Ohshima Yoshiki.Ohshima at acm.org
Mon Feb 11 23:27:02 UTC 2013


On Sun, Feb 10, 2013 at 6:52 AM, David T. Lewis <lewis at mail.msen.com> wrote:
> Hi Yoshiki,
>
> Thank you for explaining this.
>
> I am still confused on one point. Can you say if the #zapSelectionWithCompositionWith:
> method should be changed? Here is the change that I was proposing:
>
> zapSelectionWithCompositionWith: aString
>         "Deselect, and replace the selection text by aString.
>          Remember the resulting selectionInterval in UndoInterval and otherInterval.
>          Do not set up for undo."
>
>         | stream newString aText beforeChar |
>         wasComposition := false.
>         ((aString isEmpty or: [(beforeChar := self charBefore) isNil]) or: [
>                 aString size = 1 and: [(Unicode isComposition: aString first) not]]) ifTrue: [
>                         ^ self zapSelectionWith: (Text string: aString emphasis: emphasisHere)].
>
>         stream := UnicodeCompositionStream on: (String new: 16).
>         stream nextPut: beforeChar.
>         stream nextPutAll: aString.
>         newString := stream contents.
>         aText := Text string: newString emphasis: emphasisHere.
>         wasComposition := true.
>         self markBlock < self pointBlock
>                 ifTrue: [ self setMark: self markBlock stringIndex - 1.
>                                 self zapSelectionWith: aText.
>                                 self setMark: self markBlock stringIndex + 1]
>                 ifFalse: [ self setPoint: self pointBlock stringIndex - 1.
>                                 self zapSelectionWith: aText.
>                                 self setPoint: self pointBlock stringIndex + 1]
>
>
> But I do not know if this is correct, or if we should leave the method
> as it is now:
>
>         ( ... )
>         Text := Text string: newString emphasis: emphasisHere.
>         self markBlock < self pointBlock
>                 ifTrue: [self setMark: self markBlock stringIndex - 1]
>                 ifFalse: [self setPoint: self  pointBlock stringIndex - 1].
>
>         wasComposition := true.
>         self zapSelectionWith: aText.

My memory on this is murky but I think what I wrote was not perfect.
At one point, OLPC XO had two theories on inputting accented
characters and it did gave us a "naked" composition character on its
own.  In that case, that composition character has to be tested with
the "beforeChar" and may have to be combined with it.  So, beforeChar
may be replaced with the new string.  So, the code supported both
ways, if IIRC.

I need to test things to see whether we need to fiddle with the off-by-one...

-- 
-- Yoshiki


More information about the Squeak-dev mailing list