Text.st
changeset 3598 04be25181a2e
parent 3472 a61d50c15405
child 3644 baa4ec9a3b28
--- a/Text.st	Fri Aug 28 13:55:47 2015 +0200
+++ b/Text.st	Fri Aug 28 14:00:51 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1996 by Claus Gittinger
               All Rights Reserved
@@ -215,7 +217,7 @@
     "create a new empty Text instance.
      Redefined for string-protocol compatibility"
 
-    ^ super new string:(String new) emphasis:nil
+    ^ super new string:'' emphasis:nil
 
     "Text new"
 
@@ -725,7 +727,15 @@
 
 postCopy
     string := string copy.
-    runs := runs copy
+    runs := runs copy.
+
+    "
+     |t|
+
+     t := 'hello' emphasizeAllWith:#bold.
+     t inspect. t copy inspect.
+     t emphasisAllRemove:#bold.
+    "
 ! !
 
 !Text methodsFor:'displaying'!
@@ -754,6 +764,11 @@
     x := x0.
     bold := italic := underline := underwave := strikeout := reverse := false.
 
+    runs size > string size ifTrue:[
+        Transcript showCR:'inconsistent text: runs size > string size'.
+        runs := runs copyTo:(string size)
+    ].
+
     runs runsDo:[:len :emphasis |
         wasItalic := italic.
         color := savedPaint.
@@ -937,6 +952,11 @@
     aGC basicFont:savedFont.
     aGC paint:savedPaint on:savedBgPaint.
 
+    pos < string size ifTrue:[
+       "/ draw rest
+       aGC displayString:string from:pos to:string size x:x y:y.
+    ].
+
     "Created: / 12.5.1996 / 11:14:30 / cg"
     "Modified: / 7.7.1999 / 00:08:12 / cg"
 ! !
@@ -1199,7 +1219,7 @@
             e := prevE
         ]
     ].
-    runs at:characterIndex put:e
+    runs at:characterIndex put:e.
 
     "
      (Text string:'hello') allBold emphasisAt:2 add:#italic
@@ -1224,7 +1244,7 @@
             e := prevE
         ]
     ].
-    runs at:characterIndex put:e
+    runs at:characterIndex put:e.
 
     "
      (Text string:'hello') allBold emphasisAt:2 put:#italic
@@ -1240,7 +1260,7 @@
 
     e := runs at:characterIndex.
     e := self class removeEmphasis:emphasisToRemove from:e.
-    runs at:characterIndex put:e
+    runs at:characterIndex put:e.
 
     "
      (Text string:'hello') 
@@ -1321,7 +1341,7 @@
 emphasizeAllWith:emphasis
     "change the emphasis of all characters"
 
-    runs := RunArray new:(string size) withAll:emphasis
+    runs := RunArray new:(string size) withAll:emphasis.
 
     "
      (Text string:'hello') allBold emphasizeAllWith:#italic 
@@ -1523,7 +1543,7 @@
     "set the string and emphasis collection.
      The emphasis collection contains per-character information."
 
-    runs := emphasisCollection
+    runs := emphasisCollection.
 
     "Created: / 7.4.1998 / 08:52:03 / cg"
 !
@@ -1533,19 +1553,19 @@
 !
 
 setRuns:anArrayOrRunArray
-    runs := anArrayOrRunArray
+    runs := anArrayOrRunArray.
 !
 
 setString:aString setRuns:anArrayOrRunArray
     string := aString.
-    runs := anArrayOrRunArray
+    runs := anArrayOrRunArray.
 !
 
 string:aString emphasis:emphasis
     "set the string and emphasis. The emphasis is applied to all characters."
 
     string := aString string.
-    runs   := RunArray new:string size withAll:emphasis
+    runs   := RunArray new:string size withAll:emphasis.
 
     "
      |t|
@@ -1853,7 +1873,7 @@
     ].
         
     string replaceFrom:start to:stop with:aCollection startingAt:startIndex.
-    self emphasizeFrom:start to:stop with:nil
+    self emphasizeFrom:start to:stop with:nil.
 
     "
      ((Text string:'hello') allBold emphasisAt:2 put:#italic)
@@ -1869,11 +1889,11 @@
 !Text class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.128 2015-01-29 17:54:22 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.128 2015-01-29 17:54:22 cg Exp $'
+    ^ '$Header$'
 ! !