more emphasis stuff
authorClaus Gittinger <cg@exept.de>
Thu, 22 Jul 1999 15:09:37 +0200
changeset 777 ce839c02dfb6
parent 776 de39b88575e3
child 778 76cff2957cd3
more emphasis stuff
Text.st
--- a/Text.st	Mon Jul 19 10:04:56 1999 +0200
+++ b/Text.st	Thu Jul 22 15:09:37 1999 +0200
@@ -936,6 +936,39 @@
     "Modified: 14.5.1996 / 15:02:11 / cg"
 !
 
+emphasisFrom:start to:stop add:newEmphasis
+    "add to the emphasis within some range. return the receiver"
+
+    start to:stop do:[:characterIndex |
+        self emphasisAt:characterIndex add:newEmphasis
+    ].
+
+    "
+     (Text string:'hello') allBold 
+        emphasisFrom:2 to:4 add:#italic
+
+     Transcript showCR:((Text string:'hello') allBold 
+                            emphasisFrom:2 to:4 add:#italic)
+
+    "
+!
+
+emphasisFrom:start to:stop remove:anEmphasis
+    "remove from the emphasis within some range. return the receiver"
+
+    start to:stop do:[:characterIndex |
+        self emphasisAt:characterIndex remove:anEmphasis
+    ].
+
+    "
+     (Text string:'hello') allBold 
+        emphasisFrom:2 to:4 remove:#bold
+
+     Transcript showCR:((Text string:'hello') allBold 
+                            emphasisFrom:2 to:4 remove:#bold)
+    "
+!
+
 emphasizeAllWith:emphasis
     "change the emphasis of all characters"
 
@@ -969,19 +1002,18 @@
     |newRuns|
 
     runs from:start to:stop put:emphasis.
-^ self.
 
-    newRuns := RunArray new.
-
-    "/ for now - a q&d hack
-    1 to:start-1 do:[:i |
-        newRuns add:(runs at:i).
-    ].
-    newRuns add:emphasis withOccurrences:(stop - start + 1).
-    stop+1 to:string size do:[:i |
-        newRuns add:(runs at:i)
-    ].
-    runs := newRuns
+"/    newRuns := RunArray new.
+"/
+"/    "/ for now - a q&d hack
+"/    1 to:start-1 do:[:i |
+"/        newRuns add:(runs at:i).
+"/    ].
+"/    newRuns add:emphasis withOccurrences:(stop - start + 1).
+"/    stop+1 to:string size do:[:i |
+"/        newRuns add:(runs at:i)
+"/    ].
+"/    runs := newRuns
 
     "
      (Text string:'hello world') 
@@ -1269,6 +1301,6 @@
 !Text class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.57 1999-07-06 23:58:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.58 1999-07-22 13:09:37 cg Exp $'
 ! !
 Text initialize!