--- a/Text.st Mon Mar 30 18:22:16 1998 +0200
+++ b/Text.st Tue Mar 31 20:02:24 1998 +0200
@@ -523,15 +523,19 @@
a text object will be returned. Otherwise, a string (i.e. without emphasis)
is returned."
+ |newRuns|
+
aStringOrText hasChangeOfEmphasis ifTrue:[
^ self species new
string:(string , aStringOrText)
emphasisCollection:(runs , aStringOrText emphasisCollection)
].
runs notNil "self hasChangeOfEmphasis" ifTrue:[
+ newRuns := runs copyFrom:1 to:(runs size).
+
^ self species new
string:(string , aStringOrText)
- emphasisCollection:(runs deepCopy add:nil withOccurrences:(aStringOrText size); yourself)
+ emphasisCollection:(newRuns add:nil withOccurrences:(aStringOrText size); yourself)
].
^ string , aStringOrText string
@@ -542,7 +546,7 @@
('hello' asText allBold) , (' world' asText allBold)
"
- "Modified: 11.7.1996 / 13:22:39 / cg"
+ "Modified: / 31.3.1998 / 16:34:04 / cg"
!
concatenateFromString:aString
@@ -746,30 +750,51 @@
emphasisAt:characterIndex add:newEmphasis
"add to the emphasis at some index. return the receiver"
- |e|
+ |e prevE|
e := runs at:characterIndex.
e := self class addEmphasis:newEmphasis to:e.
+
+ "/ if its equal to the previous emphasis, make it identical.
+
+ characterIndex > 1 ifTrue:[
+ prevE := runs at:characterIndex-1.
+ e = prevE ifTrue:[
+ e := prevE
+ ]
+ ].
runs at:characterIndex put:e
"
(Text string:'hello') allBold emphasisAt:2 add:#italic
"
- "Created: 14.5.1996 / 16:48:39 / cg"
- "Modified: 14.5.1996 / 17:13:47 / cg"
+ "Created: / 14.5.1996 / 16:48:39 / cg"
+ "Modified: / 31.3.1998 / 15:29:14 / cg"
!
emphasisAt:characterIndex put:emphasis
"change the emphasis at some index. return the receiver"
- runs at:characterIndex put:emphasis
+ |e prevE|
+
+ e := emphasis.
+
+ "/ if its equal to the previous emphasis, make it identical.
+
+ characterIndex > 1 ifTrue:[
+ prevE := runs at:characterIndex-1.
+ emphasis = prevE ifTrue:[
+ e := prevE
+ ]
+ ].
+ runs at:characterIndex put:e
"
(Text string:'hello') allBold emphasisAt:2 put:#italic
"
- "Modified: 12.5.1996 / 12:40:31 / cg"
+ "Modified: / 31.3.1998 / 16:45:14 / cg"
!
emphasisAt:characterIndex remove:emphasisToRemove
@@ -839,6 +864,11 @@
|newRuns|
+start to:stop do:[:pos |
+ runs at:pos put:emphasis
+].
+^ self.
+
newRuns := RunArray new.
"/ for now - a q&d hack
@@ -857,7 +887,7 @@
emphasizeFrom:7 to:11 with:#italic
"
- "Modified: 11.5.1996 / 14:30:02 / cg"
+ "Modified: / 31.3.1998 / 17:56:28 / cg"
!
emphasizeFrom:start with:emphasis
@@ -1116,6 +1146,6 @@
!Text class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.37 1998-03-12 13:43:29 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.38 1998-03-31 18:02:24 cg Exp $'
! !
Text initialize!