Text.st
author Claus Gittinger <cg@exept.de>
Fri, 28 Aug 2015 14:00:51 +0200
changeset 3598 04be25181a2e
parent 3472 a61d50c15405
child 3644 baa4ec9a3b28
permissions -rw-r--r--
class: Text changed: #displayOn:x:y:opaque: just in case the run-array and string sizes differ
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
     1
"{ Encoding: utf8 }"
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
     2
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1996 by Claus Gittinger
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
891
f21b987d97b6 more to compare
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
    14
"{ Package: 'stx:libbasic2' }"
f21b987d97b6 more to compare
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
    15
3472
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
    16
"{ NameSpace: Smalltalk }"
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
    17
3174
a0dd35569355 class: Text
Stefan Vogel <sv@exept.de>
parents: 3158
diff changeset
    18
CharacterArray subclass:#Text
963
0d5ef474ea17 draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents: 954
diff changeset
    19
	instanceVariableNames:'string runs'
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
    20
	classVariableNames:'BackgroundColorEmphasis ColorEmphasis ItalicEmphasis BoldEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
    21
		UnderlineEmphasis UnderwaveEmphasis OverlineEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
    22
		StrikeoutEmphasis ReverseEmphasis BoldUnderlineEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
    23
		BoldOverlineEmphasis BoldUnderwaveEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
    24
		ItalicUnderlineEmphasis ItalicUnderwaveEmphasis
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
    25
		UnderlineColorEmphasis StrikeoutColorEmphasis EtchColorEmphasis
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
    26
		FontEmphasis'
963
0d5ef474ea17 draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents: 954
diff changeset
    27
	poolDictionaries:''
0d5ef474ea17 draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents: 954
diff changeset
    28
	category:'Collections-Text'
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
454
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
    31
!Text class methodsFor:'documentation'!
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
copyright
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 COPYRIGHT (c) 1996 by Claus Gittinger
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
              All Rights Reserved
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 This software is furnished under a license and may be used
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 only in accordance with the terms of that license and with the
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 inclusion of the above copyright notice.   This software may not
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 be provided or otherwise made available to, or used by, any
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 other person.  No title to or ownership of the software is
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 hereby transferred.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
documentation
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    Texts add emphasis information to a string.
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    51
    Texts and strings should behave interchanchably to the outside
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    52
    world, except that texts keep per-character emphasis information.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    53
    (strings return nil, when asked for an elements emphasis).
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    54
    Use #string, to get a texts underlying string without any emphasis
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    55
    information.
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    57
    Currently, the following attributes are supported:
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    58
        #bold     
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    59
        #italic  
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    60
        #underline  
759
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
    61
        #underwave  
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    62
        #strikeout
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    63
        (#color -> aColor)
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    64
        (#backgroundColor -> aColor)
759
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
    65
        (#underlineColor -> aColor)
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
    66
        (#strikeoutColor -> aColor)
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    67
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    68
    Attributes may be combined (pass an array of above) as emphasis.
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    69
    See examples.
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
    70
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    This class is not yet fully implemented - being constructed.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    [author:]
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
        Claus Gittinger
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    [see also:]
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
        CharacterArray String RunArray
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
"
313
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    79
!
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    80
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    81
examples
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    82
"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    83
  plain string (for comparison):
313
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    84
                                                                        [exBegin]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    85
    Dialog
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    86
        warn:'hello'
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    87
                                                                        [exEnd]
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    88
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    89
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
    90
  emphasized strings as dialog titles:
313
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    91
                                                                        [exBegin]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    92
    Dialog
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    93
        warn:((Text string:'hello') allBold)
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    94
                                                                        [exEnd]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    95
                                                                        [exBegin]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    96
    Dialog
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    97
        warn:(Text string:'hello' emphasis:#italic)
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    98
                                                                        [exEnd]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
    99
                                                                        [exBegin]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   100
    Dialog
702
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   101
        warn:(Text string:'hello' emphasis:#(underline))
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   102
                                                                        [exEnd]
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   103
                                                                        [exBegin]
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   104
    Dialog
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   105
        warn:(Text string:'hello' emphasis:#(underwave))
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   106
                                                                        [exEnd]
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   107
                                                                        [exBegin]
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   108
    Dialog
313
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   109
        warn:(Text string:'hello' emphasis:#(bold underline))
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   110
                                                                        [exEnd]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   111
                                                                        [exBegin]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   112
    Dialog
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   113
        warn:(Text string:'hello' 
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   114
                 emphasis:(Array with:#bold
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   115
                                 with:#strikeout
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   116
                                 with:(#color->Color red)))
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   117
                                                                        [exEnd]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   118
                                                                        [exBegin]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   119
    Dialog
315
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   120
        warn:(Text string:'hello' 
759
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
   121
                 emphasis:(Array with:(#color->Color black)
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
   122
                                 with:#underwave
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
   123
                                 with:(#underlineColor->Color red)))
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
   124
                                                                        [exEnd]
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
   125
                                                                        [exBegin]
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
   126
    Dialog
3527d6b2fb6d new emphasises: #underlineColor->aColor and
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
   127
        warn:(Text string:'hello' 
315
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   128
                 emphasis:(Array with:#bold
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   129
                                 with:#strikeout
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   130
                                 with:(#color->Color red)
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   131
                                 with:(#backgroundColor->Color yellow)))
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   132
                                                                        [exEnd]
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   133
                                                                        [exBegin]
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   134
    Dialog
313
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   135
        warn:(Text string:'hello' color:(Color red))
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   136
                                                                        [exEnd]
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   137
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   138
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   139
  in an editTextView:
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   140
                                                                        [exBegin]
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   141
    |t v|
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   142
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   143
    t := 'The quick brown fox jumps over the lazy dog' asText.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   144
    t emphasizeFrom:(t findString:'quick') count:5 with:#bold.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   145
    t emphasizeFrom:(t findString:'brown') count:9 
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   146
                                         with:(Array with:#color->(Color name:'brown')
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   147
                                                     with:#bold).
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   148
    t emphasizeFrom:(t findString:'lazy') count:4 
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   149
                                          with:(Array with:#color->(Color red)
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   150
                                                      with:#italic).
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   151
    t emphasizeFrom:(t findString:'dog') count:3 with:#underline.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   152
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   153
    v := HVScrollableView for:EditTextView.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   154
    v contents:t.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   155
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   156
    v width:450.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   157
    v open.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   158
                                                                        [exEnd]
313
46cf6fb8ed5d examples
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   159
"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
454
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   162
!Text class methodsFor:'initialization'!
314
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   163
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   164
initialize
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   165
    "initialize the class"
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   166
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   167
    "
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   168
     consider this a kludge:
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   169
     I want to inherit behavior from CharacterArray, but not
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   170
     its implementation (indexed access).
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   171
    "
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   172
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   173
    self flags:(Behavior flagRegular).
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   174
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   175
    BackgroundColorEmphasis := #backgroundColor.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   176
    ColorEmphasis := #color.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   177
    ItalicEmphasis := #italic.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   178
    BoldEmphasis := #bold.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   179
    UnderlineEmphasis := #underline.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   180
    UnderwaveEmphasis := #underwave.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   181
    OverlineEmphasis := #overline. 
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   182
    StrikeoutEmphasis := #strikeout.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   183
    ReverseEmphasis := #reverse.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   184
    BoldUnderlineEmphasis := #boldUnderline.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   185
    BoldOverlineEmphasis := #boldOverline. 
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   186
    BoldUnderwaveEmphasis := #boldUnderwave.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   187
    ItalicUnderlineEmphasis := #italicUnderline. 
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   188
    ItalicUnderwaveEmphasis := #italicUnderwave.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   189
    UnderlineColorEmphasis := #underlineColor. 
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   190
    StrikeoutColorEmphasis := #strikeoutColor. 
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   191
    EtchColorEmphasis := #etchColor.
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   192
    FontEmphasis := #font.
314
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   193
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   194
    "
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   195
     Text initialize
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   196
    "
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   197
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   198
    "Modified: 12.5.1996 / 17:53:50 / cg"
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   199
! !
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   200
454
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   201
!Text class methodsFor:'instance creation'!
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
fromString:aString 
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   204
    "create a Text instance, for the characters in aString,
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   205
     without emphasis."
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   206
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   207
    ^ super new string:aString emphasis:nil
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
     Text fromString:'hello'
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   213
    "Modified: 12.5.1996 / 17:05:34 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   216
new
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   217
    "create a new empty Text instance.
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   218
     Redefined for string-protocol compatibility"
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   219
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   220
    ^ super new string:'' emphasis:nil
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   221
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   222
    "Text new"
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   223
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   224
    "Modified: 12.5.1996 / 17:05:17 / cg"
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   225
    "Modified: 31.12.1996 / 12:39:57 / stefan"
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   226
!
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   227
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   228
new:size
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   229
    "create a new empty Text instance.
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   230
     Redefined for string-protocol compatibility"
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   231
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   232
    ^ self string:(String new:size)
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   233
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   234
    "Created: 12.5.1996 / 11:57:27 / cg"
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   235
    "Modified: 12.5.1996 / 17:05:17 / cg"
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   236
!
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   237
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
string:aString 
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   239
    "create a Text instance, for the characters in aString,
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   240
     without emphasis."
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   241
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   242
    ^ super new string:aString emphasis:nil
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
     Text string:'hello'
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   248
    "Modified: 12.5.1996 / 17:05:00 / cg"
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   249
!
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   250
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   251
string:aString color:aColor
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   252
    "create a Text instance, for the characters in aString,
345
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   253
     which are colored as aColor (only the foregroundColor is affected).
496
509b18547136 comment
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
   254
     This is a shortCut for creating an emphasis of (#color->aColor)"
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   255
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   256
    ^ super new string:aString emphasis:(#color->aColor)
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   257
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   258
    "
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   259
     Dialog
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   260
        information:(Text string:'hello' color:(Color red))
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   261
    "
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   262
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   263
    "Created: 12.5.1996 / 17:03:20 / cg"
496
509b18547136 comment
Claus Gittinger <cg@exept.de>
parents: 466
diff changeset
   264
    "Modified: 27.2.1997 / 10:13:36 / cg"
344
72fe9b7ae4b5 added #string:color:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
   265
!
72fe9b7ae4b5 added #string:color:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 343
diff changeset
   266
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
string:aString emphasis:attribute
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   268
    "create a Text instance, for the characters in aString,
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   269
     which are emphasized as described by attribute."
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   270
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   271
    ^ super new string:aString emphasis:attribute
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
     Text string:'hello' emphasis:#bold
309
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   275
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   276
     Dialog
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   277
        information:(Text string:'hello' emphasis:#bold)
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   278
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   279
     Dialog
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   280
        information:(Text string:'hello' emphasis:#italic)
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   281
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   282
     Dialog
6458ec5cc033 added convenient #string:color: instance creation message
Claus Gittinger <cg@exept.de>
parents: 308
diff changeset
   283
        information:(Text string:'hello' emphasis:#underline)
310
2c2ce53ef527 strikeout
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   284
2c2ce53ef527 strikeout
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   285
     Dialog
2c2ce53ef527 strikeout
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   286
        information:(Text string:'hello' emphasis:#strikeout)
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
310
2c2ce53ef527 strikeout
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   289
    "Modified: 12.5.1996 / 17:16:03 / cg"
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   290
!
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   291
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   292
string:aString emphasisCollection:attributeCollection
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   293
    "create a Text instance, for the characters in aString,
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   294
     which are individually emphasized as described by attributeCollection."
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   295
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   296
    ^ super new string:aString emphasisCollection:attributeCollection
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   297
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   298
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   299
     Text 
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   300
        string:'hello' 
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   301
        emphasisCollection:#(#bold #bold #italic #italic #italic)
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   302
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   303
     Dialog
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   304
        information:(Text 
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   305
                        string:'hello' 
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   306
                        emphasisCollection:#(#bold #bold #italic #italic #(#underline italic)))
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   307
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   308
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   309
    "Created: 14.5.1996 / 14:02:18 / cg"
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   310
    "Modified: 14.5.1996 / 15:01:28 / cg"
345
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   311
!
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   312
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   313
string:aString foregroundColor:fgColor backgroundColor:bgColor
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   314
    "create a Text instance, for the characters in aString,
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   315
     which are colored in fgColor on bgColor.
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   316
     This is a shortCut for creating an emphasis of 
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   317
     #( #color->fgColor) (#backgroundColor->bgColor)"
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   318
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   319
    ^ super new 
345
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   320
        string:aString 
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   321
        emphasis:(Array with:#color->fgColor
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   322
                        with:#backgroundColor->bgColor)
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   323
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   324
    "
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   325
     Dialog
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   326
        information:(Text string:'hello' 
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   327
                          foregroundColor:(Color red)
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   328
                          backgroundColor:(Color yellow))
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   329
    "
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   330
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   331
    "Modified: 11.5.1996 / 14:21:01 / cg"
062032f9e401 renamed to #string:foregroundColor:backgroundColor:
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
   332
    "Created: 16.5.1996 / 12:37:24 / cg"
395
30c7f6a7c9bb class string:runs
ca
parents: 394
diff changeset
   333
!
30c7f6a7c9bb class string:runs
ca
parents: 394
diff changeset
   334
30c7f6a7c9bb class string:runs
ca
parents: 394
diff changeset
   335
string:aString runs:aRun
30c7f6a7c9bb class string:runs
ca
parents: 394
diff changeset
   336
    "create a Text instance, for the characters in aString,
30c7f6a7c9bb class string:runs
ca
parents: 394
diff changeset
   337
     which are individually emphasized as described by attributeCollection."
30c7f6a7c9bb class string:runs
ca
parents: 394
diff changeset
   338
466
a806fe2ac753 'Text new' noe returns an empty text instead of an invalid text
Stefan Vogel <sv@exept.de>
parents: 454
diff changeset
   339
    ^ super new string:aString emphasisCollection:aRun.
2016
9ad5248e5920 Text class>>#writeStream - answer a TextStream
Stefan Vogel <sv@exept.de>
parents: 1780
diff changeset
   340
!
9ad5248e5920 Text class>>#writeStream - answer a TextStream
Stefan Vogel <sv@exept.de>
parents: 1780
diff changeset
   341
2259
d9b94e7b06a5 +uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   342
uninitializedNew:size
d9b94e7b06a5 +uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   343
    "for compatibility only"
d9b94e7b06a5 +uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   344
d9b94e7b06a5 +uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   345
    ^ self new:size
d9b94e7b06a5 +uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   346
!
d9b94e7b06a5 +uninitializedNew for compatibility
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   347
2867
daa1394cdf05 class: Text
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   348
writeStreamClass
daa1394cdf05 class: Text
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   349
    "the class used by writeStream"
2016
9ad5248e5920 Text class>>#writeStream - answer a TextStream
Stefan Vogel <sv@exept.de>
parents: 1780
diff changeset
   350
2867
daa1394cdf05 class: Text
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   351
    ^ TextStream
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   354
!Text class methodsFor:'emphasis constants'!
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   355
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   356
backgroundColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   357
    ^ BackgroundColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   358
!
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   359
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   360
foregroundColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   361
    ^ ColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   362
! !
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   363
454
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   364
!Text class methodsFor:'emphasis helper'!
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   365
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   366
addEmphasis:e1 to:e2
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   367
    "merge two emphasis's into one"
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   368
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   369
    |ne|
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   370
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   371
    e1 isNil ifTrue:[^ e2].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   372
    e2 isNil ifTrue:[^ e1].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   373
    e1 == e2 ifTrue:[^ e1].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   374
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   375
    (e1 isSymbol 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   376
     or:[e1 isAssociation]) ifTrue:[
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   377
        (e2 isSymbol 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   378
         or:[e2 isAssociation]) ifTrue:[
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   379
            ^ Array with:e1 with:e2
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   380
        ].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   381
        (e2 includes:e1) ifTrue:[^ e2].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   382
        ^ e2 copyWith:e1
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   383
    ].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   384
    (e2 isSymbol 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   385
     or:[e2 isAssociation]) ifTrue:[
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   386
        (e1 includes:e2) ifTrue:[^ e1].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   387
        ^ e1 copyWith:e2
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   388
    ].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   389
    "/ ould use:
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   390
    "/    ^ (e1 asSet addAll:e2; asArray)
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   391
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   392
    "/ but we do it manually, to preserve the
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   393
    "/ order. (should create longer runs, while editing)
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   394
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   395
    ne := e1.
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   396
    e2 do:[:e |
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   397
        (ne includes:e) ifFalse:[
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   398
           ne := ne copyWith:e
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   399
        ]
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   400
    ].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   401
    ^ ne.
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   402
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   403
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   404
     Text addEmphasis:#bold to:#bold           
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   405
     Text addEmphasis:#bold to:#italic         
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   406
     Text addEmphasis:#bold to:#(italic strikeout)   
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   407
     Text addEmphasis:#italic to:#(italic strikeout) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   408
     Text addEmphasis:#(italic strikeout) to:#bold  
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   409
     Text addEmphasis:#(italic strikeout) to:#italic 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   410
     Text addEmphasis:#(italic strikeout) to:#(bold underline) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   411
     Text addEmphasis:(#color->Color red) to:#(bold underline) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   412
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   413
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   414
    "Modified: 14.5.1996 / 17:15:44 / cg"
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   415
!
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   416
339
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   417
emphasis:e1 includes:e2
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   418
    "return true, if e1 includes e2.
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   419
     e2 should be a single emphasis."
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   420
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   421
    e1 isNil ifTrue:[^ false].
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   422
    e2 isNil ifTrue:[^ false].
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   423
    e1 == e2 ifTrue:[^ true].
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   424
754
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   425
    e1 isSymbol ifTrue:[
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   426
        ^ false
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   427
    ].
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   428
    e1 isAssociation ifTrue:[
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   429
        ^ e1 key == e2
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   430
    ].
339
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   431
    (e1 isSymbol 
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   432
     or:[e1 isAssociation]) ifTrue:[
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   433
        ^ false
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   434
    ].
1780
7c4a4bb27a4f fix: includesEmph
sr
parents: 1757
diff changeset
   435
    e2 isSymbol ifTrue:[
7c4a4bb27a4f fix: includesEmph
sr
parents: 1757
diff changeset
   436
        ^ (e1 includes:e2) or:[e1 contains:[:e |e isAssociation and:[e key == e2]]].
7c4a4bb27a4f fix: includesEmph
sr
parents: 1757
diff changeset
   437
    ].
7c4a4bb27a4f fix: includesEmph
sr
parents: 1757
diff changeset
   438
    e2 isAssociation ifTrue:[
7c4a4bb27a4f fix: includesEmph
sr
parents: 1757
diff changeset
   439
        ^ (e1 includes:e2 key) or:[e1 contains:[:e |e isAssociation and:[e key == e2 key]]].
339
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   440
    ].
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   441
    ^ false
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   442
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   443
    "
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   444
     Text emphasis:#bold includes:#bold           
1780
7c4a4bb27a4f fix: includesEmph
sr
parents: 1757
diff changeset
   445
     Text emphasis:#bold includes:#italic         
339
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   446
     Text emphasis:#(italic strikeout) includes:#bold  
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   447
     Text emphasis:#(italic strikeout) includes:#italic 
754
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   448
     Text emphasis:(#color->Color red) includes:#color 
339
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   449
    "
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   450
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   451
    "Modified: 14.5.1996 / 17:45:11 / cg"
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   452
!
4d1140308a76 emphasis helper
Claus Gittinger <cg@exept.de>
parents: 336
diff changeset
   453
407
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   454
extractEmphasis:key from:e
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   455
    "if key is included in the emphasis, e then return the key.
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   456
     Otherwise, if a n association with that key is included, return the value.
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   457
     Otherwise, return nil."
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   458
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   459
    e isNil ifTrue:[^ nil].
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   460
    key == e ifTrue:[^ e].
754
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   461
    e isSymbol ifTrue:[^ nil].
407
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   462
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   463
    e isAssociation ifTrue:[
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   464
        e key == key ifTrue:[^ e value].
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   465
        ^ nil
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   466
    ].
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   467
    e do:[:entry | 
754
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   468
        entry == key ifTrue:[^ key].
407
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   469
        entry isAssociation ifTrue:[
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   470
            entry key == key ifTrue:[
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   471
                ^ entry value
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   472
            ]
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   473
        ]
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   474
    ].
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   475
    ^ nil
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   476
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   477
    "
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   478
     Text extractEmphasis:#bold  from:#bold           
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   479
     Text extractEmphasis:#bold  from:#italic           
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   480
     Text extractEmphasis:#bold  from:#(italic strikeout)           
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   481
     Text extractEmphasis:#bold  from:#(italic bold)           
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   482
     Text extractEmphasis:#color  from:(#color->Color red)           
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   483
     Text extractEmphasis:#color  from:(#foo->Color red)           
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   484
    "
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   485
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   486
    "Modified: 14.5.1996 / 17:45:11 / cg"
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   487
    "Created: 11.7.1996 / 09:49:58 / cg"
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   488
!
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
   489
2731
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   490
removeEmphasis:emToRemove from:empArg
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   491
    "remove an emphasis; if it was not in empArg, do nothing"
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   492
2731
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   493
    |ne idx emp|
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   494
2731
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   495
    emp := empArg.
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   496
    emToRemove isNil ifTrue:[^ emp].
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   497
    emp isNil ifTrue:[^ emp].
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   498
    emToRemove == emp ifTrue:[^ nil].
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   499
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   500
    emp isSymbol ifTrue:[
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   501
        emToRemove isSymbol ifTrue:[^ emp].  "/ knowing they are not identical
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   502
        emToRemove isAssociation ifTrue:[
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   503
            emToRemove key == emp ifTrue:[^ nil].
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   504
            ^ emp
755
3711135b1687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 754
diff changeset
   505
        ].
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   506
        (emToRemove includes:emp) ifTrue:[^ nil].
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   507
        ^ emp
755
3711135b1687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 754
diff changeset
   508
    ].
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   509
    emp isAssociation ifTrue:[
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   510
        emToRemove isSymbol ifTrue:[
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   511
            emp key == emToRemove ifTrue:[^ nil].
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   512
            ^ emp
755
3711135b1687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 754
diff changeset
   513
        ].
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   514
        emToRemove isAssociation ifTrue:[
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   515
            emToRemove key == emp key ifTrue:[^ nil].
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   516
            ^ emp
755
3711135b1687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 754
diff changeset
   517
        ].
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   518
        (emToRemove includes:emp) ifTrue:[^ nil].
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   519
        ^ emp
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   520
    ].
834
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   521
    "/ e2 must be a collection
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   522
    (emToRemove isSymbol 
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   523
     or:[emToRemove isAssociation]) ifTrue:[
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   524
        (emp includes:emToRemove) ifTrue:[
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   525
            ne := emp copyWithout:emToRemove.
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   526
            ne size == 1 ifTrue:[^ ne at:1].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   527
            ne size == 0 ifTrue:[^ nil].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   528
            ^ ne
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   529
        ].
834
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   530
        
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   531
        idx := emp findFirst:[:em | em isAssociation and:[em key == emToRemove]].
2731
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   532
        (idx ~~ 0) ifTrue:[
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   533
            emp := emp copyWithoutIndex:idx.
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   534
            [ 
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   535
                idx := emp findFirst:[:em | em isAssociation and:[em key == emToRemove]] startingAt:idx.
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   536
                idx ~~ 0 
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   537
            ] whileTrue:[
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   538
                emp := emp copyWithoutIndex:idx.
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   539
            ]
834
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
   540
        ].
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   541
        ^ emp
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   542
    ].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   543
754
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   544
    "/ could use:
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   545
    "/    ^ (e2 asSet removeAll:e1; asArray)
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   546
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   547
    "/ but we do it manually, to preserve the
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   548
    "/ order. (should create longer runs, while editing)
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   549
1068
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   550
    ne := emp.
8fe441b49dbe removeEmphasis fixed
Michael Beyl <mb@exept.de>
parents: 1067
diff changeset
   551
    emToRemove do:[:e |
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   552
        (ne includes:e) ifTrue:[
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   553
           ne := ne copyWithout:e
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   554
        ]
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   555
    ].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   556
    ne size == 1 ifTrue:[^ ne at:1].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   557
    ne size == 0 ifTrue:[^ nil].
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   558
    ^ ne.
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   559
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   560
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   561
     Text removeEmphasis:#bold from:#bold           
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   562
     Text removeEmphasis:#bold from:#italic         
1067
d00cacc63c2e comment
Claus Gittinger <cg@exept.de>
parents: 1065
diff changeset
   563
     Text removeEmphasis:#bold from:#(italic strikeout)    
3472
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
   564
     Text removeEmphasis:#bold from:#(italic bold strikeout)    
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   565
     Text removeEmphasis:#italic from:#(italic strikeout) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   566
     Text removeEmphasis:#(italic strikeout) from:#bold  
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   567
     Text removeEmphasis:#(italic strikeout) from:#italic  
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   568
     Text removeEmphasis:#(italic strikeout) from:#(bold underline) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   569
     Text removeEmphasis:#(italic strikeout bold) from:#(bold underline) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   570
     Text removeEmphasis:#(italic strikeout bold underline) from:#(bold underline) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   571
     Text removeEmphasis:(#color->Color red) from:#(bold underline) 
756
43d8932d307a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 755
diff changeset
   572
     Text removeEmphasis:(#color->Color red) from:(#color->Color red) 
1067
d00cacc63c2e comment
Claus Gittinger <cg@exept.de>
parents: 1065
diff changeset
   573
     Text removeEmphasis:#color from:(#color->Color red)   
d00cacc63c2e comment
Claus Gittinger <cg@exept.de>
parents: 1065
diff changeset
   574
     Text removeEmphasis:#color from:(#backgroundColor->Color red)      
754
3478532ba8af emphasis extraction fix
Claus Gittinger <cg@exept.de>
parents: 735
diff changeset
   575
     Text removeEmphasis:#color from:(Array with:#bold with:#underline with:#color->Color red) 
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   576
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   577
2731
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   578
    "Modified: / 25-01-2001 / 15:24:46 / ps"
6dec3016c2a5 changed: #removeEmphasis:from:
Claus Gittinger <cg@exept.de>
parents: 2675
diff changeset
   579
    "Modified (comment): / 06-03-2012 / 18:23:32 / cg"
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   580
! !
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
   581
735
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   582
!Text methodsFor:'accessing'!
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   583
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   584
at:characterIndex
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   585
    "return the plain character at characterIndex"
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   586
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   587
    ^ string at:characterIndex
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   588
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   589
    "Created: 11.5.1996 / 14:25:41 / cg"
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   590
    "Modified: 16.5.1996 / 11:15:33 / cg"
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   591
!
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   592
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   593
at:characterIndex put:aCharacter
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   594
    "change the character at characterIndex to be aCharacter.
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   595
     The emphasis (if any) of that character remains unchanged."
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   596
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   597
    ^ string at:characterIndex put:aCharacter
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   598
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   599
    "Created: 11.5.1996 / 14:25:49 / cg"
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   600
    "Modified: 16.5.1996 / 11:15:57 / cg"
2734
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   601
!
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   602
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   603
byteAt:characterIndex
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   604
    "return the plain character at characterIndex"
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   605
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   606
    ^ string byteAt:characterIndex
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   607
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   608
    "Created: 11.5.1996 / 14:25:41 / cg"
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   609
    "Modified: 16.5.1996 / 11:15:33 / cg"
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   610
!
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   611
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   612
byteAt:characterIndex put:aCharacter
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   613
    "change the character at characterIndex to be aCharacter.
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   614
     The emphasis (if any) of that character remains unchanged."
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   615
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   616
    ^ string byteAt:characterIndex put:aCharacter
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   617
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   618
    "Created: 11.5.1996 / 14:25:49 / cg"
Stefan Vogel <sv@exept.de>
parents: 2733
diff changeset
   619
    "Modified: 16.5.1996 / 11:15:57 / cg"
735
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   620
! !
6ca1d0dd6526 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
   621
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
!Text methodsFor:'comparing'!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
= aStringOrText
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
    "compare the receiver and the argument, ignoring emphasis"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
384
866650ee29fd fixed = for non-string args
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   627
    aStringOrText isString ifFalse:[^ false].
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    ^ string = aStringOrText string
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
     'hello' asText = 'hello'        
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
     'hello' asText = 'hello' asText 
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
     'hello' asText allBold = 'hello' 
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
384
866650ee29fd fixed = for non-string args
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   637
    "Modified: 4.6.1996 / 11:14:58 / cg"
662
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   638
!
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   639
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   640
hash
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   641
    "return a suitable hashcode (req'd since = is redefined)"
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   642
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   643
    ^ string hash
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   644
856b381b8308 need #hash
Claus Gittinger <cg@exept.de>
parents: 661
diff changeset
   645
    "Created: / 19.6.1998 / 04:15:57 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
!Text methodsFor:'converting'!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
asText
1645
bc07074c18f4 documentation
Stefan Vogel <sv@exept.de>
parents: 1402
diff changeset
   651
    "return a Text-object (string with emphasis) from myself.
bc07074c18f4 documentation
Stefan Vogel <sv@exept.de>
parents: 1402
diff changeset
   652
     I am already a text object."
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   653
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
    ^ self
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
    "Created: 11.5.1996 / 14:08:36 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   657
    "Modified: 16.5.1996 / 11:15:12 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
!Text methodsFor:'copying'!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
, aStringOrText
2733
987dba8e00b6 comment/format in: #,
Claus Gittinger <cg@exept.de>
parents: 2731
diff changeset
   663
    "concatenate the receiver's characters with the argument's characters, 
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   664
     and return string or text object containing those characters.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
   665
     If either the receiver or the argument contains emphasis information,
2733
987dba8e00b6 comment/format in: #,
Claus Gittinger <cg@exept.de>
parents: 2731
diff changeset
   666
     a text object will be returned. 
987dba8e00b6 comment/format in: #,
Claus Gittinger <cg@exept.de>
parents: 2731
diff changeset
   667
     Otherwise, a string (i.e. without emphasis) is returned."
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   669
    |newRuns|
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   670
758
5dc694e5c8db checkin from browser
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
   671
    aStringOrText isCharacter ifTrue:[
5dc694e5c8db checkin from browser
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
   672
        ^ self , aStringOrText asString
5dc694e5c8db checkin from browser
Claus Gittinger <cg@exept.de>
parents: 756
diff changeset
   673
    ].
615
3be71f2a9b9b a very 'uebel' error fixed (?) in #,
tz
parents: 607
diff changeset
   674
    aStringOrText hasChangeOfEmphasis ifTrue:[    
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   675
        ^ self species new
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   676
            string:(string , aStringOrText)
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   677
            emphasisCollection:(runs , aStringOrText emphasisCollection)
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   678
    ].
615
3be71f2a9b9b a very 'uebel' error fixed (?) in #,
tz
parents: 607
diff changeset
   679
    runs notNil "self hasChangeOfEmphasis" ifTrue:[ 
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
   680
        newRuns := runs copyFrom:1 to:(runs size).
2852
0361a1a06b43 class: Text
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   681
        newRuns add:nil withOccurrences:(aStringOrText size).
408
90799280d574 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 407
diff changeset
   682
        ^ self species new
90799280d574 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 407
diff changeset
   683
            string:(string , aStringOrText)
2852
0361a1a06b43 class: Text
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   684
            emphasisCollection:newRuns
408
90799280d574 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 407
diff changeset
   685
    ].
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   686
    ^ string , aStringOrText string
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   687
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   688
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   689
     ('hello' asText allBold) , ' world'    
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   690
     'hello' , (' world' asText allBold)
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   691
     'hello' , ' world'
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   692
     ('hello' asText allBold) , (' world' asText allBold)
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   693
    "
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
2733
987dba8e00b6 comment/format in: #,
Claus Gittinger <cg@exept.de>
parents: 2731
diff changeset
   695
    "Modified: / 31-03-1998 / 16:34:04 / cg"
987dba8e00b6 comment/format in: #,
Claus Gittinger <cg@exept.de>
parents: 2731
diff changeset
   696
    "Modified (comment): / 01-04-2012 / 13:20:02 / cg"
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   697
!
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   698
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   699
concatenateFromString:aString
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   700
    "return the concatenation of aString and myself.
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   701
     This may be a Text (if I have emphasis) or a string (if not)."
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   702
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   703
    self hasChangeOfEmphasis ifTrue:[
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   704
        ^ self species new
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   705
                string:(aString , string)
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   706
                emphasisCollection:((RunArray new:(aString size)) , runs).
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   707
    ].
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   708
    ^ aString , string
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   709
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
   710
    "Modified: 14.5.1996 / 15:56:05 / cg"
394
26ea25797eae redefined postCopy
ca
parents: 393
diff changeset
   711
!
26ea25797eae redefined postCopy
ca
parents: 393
diff changeset
   712
454
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   713
copyFrom:start to:stop
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   714
    "return the subcollection starting at index start, anInteger and ending
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   715
     at stop, anInteger."
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   716
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   717
    self hasChangeOfEmphasis ifTrue:[
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   718
        ^ self species new
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   719
                string:(string copyFrom:start to:stop)
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   720
                emphasisCollection:(runs copyFrom:start to:stop).
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   721
    ].
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   722
    ^ string copyFrom:start to:stop
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   723
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   724
    "Modified: 14.5.1996 / 15:56:05 / cg"
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   725
    "Created: 22.10.1996 / 21:01:16 / cg"
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   726
!
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
   727
394
26ea25797eae redefined postCopy
ca
parents: 393
diff changeset
   728
postCopy
26ea25797eae redefined postCopy
ca
parents: 393
diff changeset
   729
    string := string copy.
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   730
    runs := runs copy.
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   731
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   732
    "
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   733
     |t|
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   734
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   735
     t := 'hello' emphasizeAllWith:#bold.
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   736
     t inspect. t copy inspect.
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   737
     t emphasisAllRemove:#bold.
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   738
    "
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   739
! !
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   740
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   741
!Text methodsFor:'displaying'!
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   742
963
0d5ef474ea17 draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents: 954
diff changeset
   743
displayOn:aGC x:x0 y:y opaque:opaqueWanted
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   744
    "display the receiver on a GC"
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   745
1000
927894af9a9f etching
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   746
    |savedFont savedPaint savedFgPaint savedBgPaint font color boldFont italicFont boldItalicFont 
927894af9a9f etching
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   747
     bgPaint etchColor ulPaint strikePaint
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   748
     wasItalic overline altFont
702
0c2c9b9fb4aa added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   749
     bold italic underline underwave strikeout reverse
310
2c2ce53ef527 strikeout
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   750
     pos    "{ Class: SmallInteger }"
2c2ce53ef527 strikeout
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   751
     endPos "{ Class: SmallInteger }"
410
3d42216e96b0 oops - x can be float in displayOn... in case of scaling in the GC
Claus Gittinger <cg@exept.de>
parents: 409
diff changeset
   752
     x      
310
2c2ce53ef527 strikeout
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   753
     l      "{ Class: SmallInteger }"
963
0d5ef474ea17 draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents: 954
diff changeset
   754
     yL k value device opaque|
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   755
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   756
    savedFont := aGC basicFont.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   757
    savedPaint := aGC paint.
315
e4ef56137893 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 314
diff changeset
   758
    savedBgPaint := aGC backgroundPaint.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   759
963
0d5ef474ea17 draw opaque - if backgroundCOlor is set
Claus Gittinger <cg@exept.de>
parents: 954
diff changeset
   760
    opaque := opaqueWanted.
705
9e247eeb134a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 702
diff changeset
   761
    device := aGC graphicsDevice.
9e247eeb134a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 702
diff changeset
   762
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   763
    pos := 1.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   764
    x := x0.
975
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   765
    bold := italic := underline := underwave := strikeout := reverse := false.
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   766
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   767
    runs size > string size ifTrue:[
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   768
        Transcript showCR:'inconsistent text: runs size > string size'.
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   769
        runs := runs copyTo:(string size)
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   770
    ].
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   771
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   772
    runs runsDo:[:len :emphasis |
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   773
        wasItalic := italic.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   774
        color := savedPaint.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   775
        bold := italic := underline := underwave := strikeout := reverse := false.
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   776
        altFont := nil.
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   777
        bgPaint := savedBgPaint.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   778
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   779
        emphasis isSymbol ifTrue:[
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   780
            emphasis == BoldEmphasis ifTrue:[bold := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   781
            ifFalse:[emphasis == ItalicEmphasis ifTrue:[italic := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   782
            ifFalse:[emphasis == UnderlineEmphasis ifTrue:[underline := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   783
            ifFalse:[emphasis == OverlineEmphasis ifTrue:[overline := true]   "MB:added"
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   784
            ifFalse:[emphasis == UnderwaveEmphasis ifTrue:[underwave := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   785
            ifFalse:[emphasis == StrikeoutEmphasis ifTrue:[strikeout := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   786
            ifFalse:[emphasis == ReverseEmphasis ifTrue:[reverse := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   787
            ifFalse:[emphasis == BoldUnderlineEmphasis ifTrue:[bold := underline := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   788
            ifFalse:[emphasis == BoldOverlineEmphasis ifTrue:[bold := overline := true]     "MB:added"
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   789
            ifFalse:[emphasis == BoldUnderwaveEmphasis ifTrue:[bold := underwave := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   790
            ifFalse:[emphasis == ItalicUnderlineEmphasis ifTrue:[italic := underline := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   791
            ifFalse:[emphasis == ItalicUnderwaveEmphasis ifTrue:[italic := underwave := true]
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   792
            ]]]]]]]]]]]
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   793
        ] ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   794
            (emphasis isMemberOf:Association) ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   795
                value := emphasis value.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   796
                value notNil ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   797
                    k := emphasis key.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   798
                    k == ColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   799
                        color := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   800
                        "/ emphasis value:color.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   801
                    ] ifFalse:[k == BackgroundColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   802
                        bgPaint := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   803
                        "/ emphasis value:bgPaint.
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   804
                        opaque := true.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   805
                    ] ifFalse:[k == UnderlineColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   806
                        ulPaint := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   807
                        "/ emphasis value:ulPaint.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   808
                    ] ifFalse:[k == StrikeoutColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   809
                        strikePaint := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   810
                        "/ emphasis value:strikePaint.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   811
                    ] ifFalse:[k == EtchColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   812
                        etchColor := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   813
                        "/ emphasis value:etchColor.
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   814
                    ] ifFalse:[k == FontEmphasis ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   815
                        altFont := value onDevice:device.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   816
                        "/ emphasis value:altFont.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   817
                    ]]]]]]
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   818
                ]
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   819
            ] ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   820
                emphasis notNil ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   821
                    emphasis do:[:entry |
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   822
                        entry == BoldEmphasis ifTrue:[bold := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   823
                        ifFalse:[entry == ItalicEmphasis ifTrue:[italic := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   824
                        ifFalse:[entry == UnderlineEmphasis ifTrue:[underline := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   825
                        ifFalse:[entry == OverlineEmphasis ifTrue:[overline := true] 
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   826
                        ifFalse:[entry == UnderwaveEmphasis ifTrue:[underwave := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   827
                        ifFalse:[entry == StrikeoutEmphasis ifTrue:[strikeout := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   828
                        ifFalse:[entry == ReverseEmphasis ifTrue:[reverse := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   829
                        ifFalse:[entry == BoldUnderlineEmphasis ifTrue:[bold := underline := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   830
                        ifFalse:[emphasis == BoldUnderwaveEmphasis ifTrue:[bold := underwave := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   831
                        ifFalse:[entry == ItalicUnderlineEmphasis ifTrue:[italic := underline := true]
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   832
                        ifFalse:[emphasis == ItalicUnderwaveEmphasis ifTrue:[italic := underwave := true]
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   833
                        ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   834
                            (entry isMemberOf:Association) ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   835
                                value := entry value.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   836
                                value notNil ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   837
                                    k := entry key.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   838
                                    k == ColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   839
                                        color := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   840
                                        "/ entry value:color.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   841
                                    ] ifFalse:[k == BackgroundColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   842
                                        bgPaint := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   843
                                        "/ entry value:bgPaint.
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   844
                                        opaque := true.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   845
                                    ] ifFalse:[k == UnderlineColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   846
                                        ulPaint := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   847
                                        "/ entry value:ulPaint.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   848
                                    ] ifFalse:[k == StrikeoutColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   849
                                        strikePaint := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   850
                                        "/ entry value:strikePaint.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   851
                                    ] ifFalse:[k == EtchColorEmphasis ifTrue:[
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   852
                                        etchColor := value onDevice:device.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   853
                                        "/ entry value:etchColor.
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   854
                                    ] ifFalse:[k == FontEmphasis ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   855
                                        altFont := value onDevice:device.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   856
                                        "/ entry value:altFont.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   857
                                    ]]]]]]
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   858
                                ]
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   859
                            ]
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   860
                        ]]]]]]]]]]]
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   861
                    ]
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   862
                ]
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   863
            ]
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   864
        ].
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   865
        altFont notNil ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   866
            font := altFont.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   867
        ] ifFalse:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   868
            bold ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   869
                italic ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   870
                    boldItalicFont isNil ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   871
                        boldItalicFont := savedFont asBold asItalic onDevice:device
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   872
                    ].
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   873
                    font := boldItalicFont.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   874
                ] ifFalse:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   875
                    boldFont isNil ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   876
                        boldFont := savedFont asBold onDevice:device
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   877
                    ].
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   878
                    font := boldFont.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   879
                ]
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   880
            ] ifFalse:[
3158
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   881
                italic ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   882
                    italicFont isNil ifTrue:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   883
                        italicFont := savedFont asItalic onDevice:device
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   884
                    ].
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   885
                    font := italicFont.
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   886
                ] ifFalse:[
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   887
                    font := savedFont
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   888
                ]
32762c55c099 class: Text
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   889
            ].
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   890
        ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   891
        aGC basicFont:font.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   892
        reverse ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   893
            aGC paint:bgPaint on:color.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   894
            opaque := true.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   895
        ] ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   896
            aGC paint:color on:bgPaint.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   897
        ].
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
   898
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   899
        endPos := pos + len - 1.
2110
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
   900
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   901
"/ disabled - it is too ugly (and not handled correctly, anyway).
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   902
"/        wasItalic ~~ italic ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   903
"/            italic ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   904
"/                "/ going from italic to non-italic; leave some space for the shear
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   905
"/                x := x + (font width " // 2" )
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   906
"/            ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   907
"/        ].
975
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   908
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   909
        (opaque and:[etchColor isNil]) ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   910
            aGC displayOpaqueString:string from:pos to:endPos x:x y:y.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   911
        ] ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   912
            etchColor notNil ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   913
                opaque ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   914
                    "/ sigh - must draw the background rectangle;
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   915
                    "/ its easier (and faster) to draw the string twice here ...
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   916
                    aGC displayOpaqueString:string from:pos to:endPos x:x y:y.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   917
                ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   918
                savedFgPaint := aGC paint.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   919
                aGC paint:etchColor.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   920
                aGC displayString:string from:pos to:endPos x:x+1 y:y+1.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   921
                aGC paint:savedFgPaint.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   922
            ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   923
            aGC displayString:string from:pos to:endPos x:x y:y.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   924
        ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   925
        l := font widthOf:string from:pos to:endPos.
975
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
   926
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   927
        underline ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   928
            ulPaint notNil ifTrue:[aGC paint:ulPaint].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   929
            yL := y+1.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   930
            aGC displayLineFromX:x y:yL toX:x+l-1 y:yL
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   931
        ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   932
        (overline ? false) ifTrue:[                      "MB:added v"
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   933
            ulPaint notNil ifTrue:[aGC paint:ulPaint].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   934
            yL := y-(font heightOf: string) + 2.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   935
            aGC displayLineFromX:x y:yL toX:x+l-1 y:yL
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   936
        ].                                               "MB:added ^"
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   937
        underwave ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   938
            ulPaint notNil ifTrue:[aGC paint:ulPaint].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   939
            yL := y+1.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   940
            aGC displayHorizontalWavelineFromX:x y:yL toX:x+l-1
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   941
        ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   942
        strikeout ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   943
            strikePaint notNil ifTrue:[aGC paint:strikePaint].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   944
            yL := y-(font ascent//2).
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   945
            aGC displayLineFromX:x y:yL toX:x+l-1 y:yL
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   946
        ].
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   947
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   948
        x := x + l.
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
   949
        pos := endPos + 1
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
    ].
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   951
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   952
    aGC basicFont:savedFont.
316
628f72ebc5bc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 315
diff changeset
   953
    aGC paint:savedPaint on:savedBgPaint.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   954
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   955
    pos < string size ifTrue:[
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   956
       "/ draw rest
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   957
       aGC displayString:string from:pos to:string size x:x y:y.
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   958
    ].
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
   959
591
dfa5c6178f6d care to use deviceFont in width-query
Claus Gittinger <cg@exept.de>
parents: 549
diff changeset
   960
    "Created: / 12.5.1996 / 11:14:30 / cg"
761
d77e2c17f2a1 underwave
Claus Gittinger <cg@exept.de>
parents: 760
diff changeset
   961
    "Modified: / 7.7.1999 / 00:08:12 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
!Text methodsFor:'emphasis'!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   966
actionForAll:aBlock
2311
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   967
    "change the actionBlock of all characters. 
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   968
     Some widgets use this like a href if clicked onto the text."
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   969
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   970
    self emphasisAllAdd:(#actionBlock -> aBlock).
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   971
2311
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   972
    "transcript ignores this...
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   973
     Transcript showCR:
2311
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   974
        ((Text string:'hello - click on me') actionForAll:[Transcript flash]) 
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   975
    "
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   976
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   977
    "labels also...
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   978
     Label new
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   979
        label: ((Text string:'hello - click on me') actionForAll:[Transcript flash]);
ffc769e95190 comment/format in: #actionForAll:
Claus Gittinger <cg@exept.de>
parents: 2305
diff changeset
   980
        open
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   981
    "
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   982
!
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
   983
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
allBold
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
    "make all characters bold"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
2852
0361a1a06b43 class: Text
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
   987
    self emphasisAllAdd:BoldEmphasis
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
     (Text string:'hello') allBold
2056
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
   991
     Transcript showCR: ('hello' allBold)   
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
406
b4bf187dd46d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 404
diff changeset
   994
    "Modified: 10.7.1996 / 12:07:51 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
2110
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
   997
allBoldOverline
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
   998
    "make all characters bold and overline"
2110
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
   999
2852
0361a1a06b43 class: Text
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
  1000
    self emphasisAllAdd:BoldOverlineEmphasis
2110
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1001
!
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1002
734
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1003
allItalic
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1004
    "make all characters italic"
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1005
2852
0361a1a06b43 class: Text
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
  1006
    self emphasisAllAdd:ItalicEmphasis
734
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1007
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1008
    "
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1009
     (Text string:'hello') allItalic
2056
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1010
     Transcript showCR: ('hello' allItalic)   
734
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1011
    "
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1012
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1013
    "Modified: 10.7.1996 / 12:07:51 / cg"
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1014
!
ae8cae5d7296 + #allItalic
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
  1015
3472
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1016
allNonBold
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1017
    "make all characters non-bold"
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1018
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1019
    self emphasisAllRemove:BoldEmphasis
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1020
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1021
    "
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1022
     (Text string:'hello') allBold allNonBold
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1023
    "
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1024
!
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1025
2110
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1026
allOverline
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1027
    "make all characters overline"
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1028
2852
0361a1a06b43 class: Text
Claus Gittinger <cg@exept.de>
parents: 2830
diff changeset
  1029
    self emphasisAllAdd:OverlineEmphasis
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1030
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1031
    "
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1032
     Transcript showCR: ('hello' asText allOverline)   
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1033
    "
2110
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1034
!
54019b63a74f overline & boldOverline
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1035
2056
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1036
allStrikedOut
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1037
    "strikeOut all characters"
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1038
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1039
    self emphasisAllAdd:StrikeoutEmphasis.
2056
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1040
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1041
    "
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1042
     Transcript showCR: ('hello' allStrikedOut)   
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1043
    "
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1044
!
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1045
1020
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1046
allUnderlined
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1047
    "underline all characters"
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1048
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1049
    self emphasisAllAdd:UnderlineEmphasis.
1020
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1050
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1051
    "
2056
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1052
     Transcript showCR:('hello' allUnderlined) 
1020
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1053
    "
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1054
!
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1055
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1056
allUnderwaved
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1057
    "underwave all characters"
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1058
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1059
    self emphasisAllAdd:UnderwaveEmphasis.
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1060
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1061
    "
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1062
     Transcript showCR:('hello' asText allUnderwaved) 
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1063
    "
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1064
!
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1065
1019
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1066
backgroundColorizeAllWith:aColor
2552
a891a2d361b8 comment/format in: #backgroundColorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1067
    "change the bg-color of all characters"
1019
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1068
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1069
    self emphasisAllAdd:(BackgroundColorEmphasis -> aColor).
1019
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1070
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1071
    "
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1072
     Transcript showCR:
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1073
        ((Text string:'hello') backgroundColorizeAllWith:(Color red)) 
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1074
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1075
     Transcript showCR:
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1076
        ('hello' allBold backgroundColorizeAllWith:(Color red)) 
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1077
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1078
     Transcript showCR:
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1079
        ('hello' asText backgroundColorizeAllWith:(Color red)) 
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1080
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1081
     Transcript showCR:
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1082
        ('hello ' , ('red' allBold backgroundColorizeAllWith:(Color red)) , ' world')
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1083
    "
2552
a891a2d361b8 comment/format in: #backgroundColorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1084
a891a2d361b8 comment/format in: #backgroundColorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1085
    "Modified: / 01-04-2011 / 16:19:21 / cg"
1019
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1086
!
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1087
999
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1088
colorizeAllWith:aColor
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1089
    "change the color of all characters"
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1090
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1091
    self emphasisAllAdd:(ColorEmphasis -> aColor).
999
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1092
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1093
    "
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1094
     Transcript showCR:
1019
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1095
        ((Text string:'hello') colorizeAllWith:(Color red)) 
999
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1096
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1097
     Transcript showCR:
2056
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1098
        ('hello' colorizeAllWith:(Color red)) 
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1099
3a6abb99746f more emphasis
Claus Gittinger <cg@exept.de>
parents: 2051
diff changeset
  1100
     Transcript showCR:
1019
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1101
        ('hello' allBold colorizeAllWith:(Color red)) 
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1102
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1103
     Transcript showCR:
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1104
        ('hello' asText colorizeAllWith:(Color red)) 
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1105
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1106
     Transcript showCR:
38ec486889d9 colorizeAllWith: ADDs to the emphasis (used to SET it)
Claus Gittinger <cg@exept.de>
parents: 1000
diff changeset
  1107
        ('hello ' , ('red' allBold colorizeAllWith:(Color red)) , ' world')
999
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1108
    "
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1109
!
c702e6ff076e added #colorizeAllWith:
Claus Gittinger <cg@exept.de>
parents: 975
diff changeset
  1110
2312
ab6ab043d9ca comment/format in: #colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
  1111
colorizeAllWith:fgColor on:bgColor
1648
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1112
    "change the color and bg-color of all characters"
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1113
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1114
    self emphasisAllAdd:(ColorEmphasis -> fgColor).
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1115
    self emphasisAllAdd:(BackgroundColorEmphasis -> bgColor).
1648
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1116
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1117
    "
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1118
     Transcript showCR:
2312
ab6ab043d9ca comment/format in: #colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 2311
diff changeset
  1119
        ((Text string:'hello') colorizeAllWith:(Color blue) on:(Color yellow)) 
1648
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1120
    "
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1121
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1122
    "Created: / 05-08-2006 / 14:48:13 / cg"
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1123
!
e5bb0f9263a1 colorizeAllWith:on:
Claus Gittinger <cg@exept.de>
parents: 1645
diff changeset
  1124
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1125
emphasis
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1126
    "return the emphasis"
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1127
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1128
    ^ runs
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1129
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1130
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1131
     (Text string:'hello') allBold emphasis 
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1132
     'hello' emphasis   
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1133
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1134
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1135
    "Modified: 11.5.1996 / 14:22:31 / cg"
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1136
    "Created: 14.5.1996 / 13:59:03 / cg"
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1137
!
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1138
1070
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1139
emphasis:emArray
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1140
    1 to:string size do:[:characterIndex |
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1141
        self emphasisAt:characterIndex put:(emArray at:characterIndex)
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1142
    ].
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1143
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1144
    "
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1145
     (Text string:'hello') emphasis:#(italic bold italic bold bold)
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1146
    "
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1147
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1148
    "Modified: / 31.3.1998 / 16:45:14 / cg"
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1149
!
b1d7a3c99d6f +emphasis:
Michael Beyl <mb@exept.de>
parents: 1069
diff changeset
  1150
778
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1151
emphasisAllAdd:newEmphasis
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1152
    "add to the emphasis to all characters. return the receiver"
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1153
3116
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1154
    runs isNil ifTrue:[ ^ self ].   "/ just in case: empty
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1155
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1156
    (runs conform:[:runValue | runValue isNil]) ifTrue:[
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1157
        "/ no emphasis - happens often
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1158
        runs atAllPut:newEmphasis.
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1159
    ] ifFalse:[
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1160
        self emphasisFrom:1 to:(self size) add:newEmphasis
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1161
    ].
778
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1162
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1163
    "
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1164
     (Text string:'hello') allBold 
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1165
        emphasisAllAdd:#italic
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1166
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1167
     Transcript show:((Text string:'hello') allBold 
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1168
                        emphasisAllAdd:#italic)
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1169
    "
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1170
!
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1171
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1172
emphasisAllRemove:anEmphasis
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1173
    "remove the emphasis from all characters. return the receiver"
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1174
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1175
    self emphasisFrom:1 to:(self size) remove:anEmphasis
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1176
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1177
    "
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1178
     ((Text string:'hello') emphasizeAllWith:#(bold italic))
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1179
        emphasisAllRemove:#italic
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1180
834
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1181
     ((Text string:'hello') emphasizeAllWith:(Array with:#color->Color red
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1182
                                                    with:#italic))
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1183
        emphasisAllRemove:#italic
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1184
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1185
     ((Text string:'hello') emphasizeAllWith:(Array with:#color->Color red
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1186
                                                    with:#italic))
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1187
        emphasisAllRemove:#color
08c8f9d9ca0a fixed removal of an association-emphasis by key.
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1188
778
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1189
     Transcript show:(((Text string:'hello') emphasizeAllWith:#(bold italic)) 
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1190
                        emphasisAllRemove:#italic)
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1191
    "
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1192
!
76cff2957cd3 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
  1193
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
emphasisAt:characterIndex
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
    "return the emphasis at some index"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
    ^ runs at:characterIndex
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
     (Text string:'hello') allBold emphasisAt:2 
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
    "Modified: 11.5.1996 / 14:22:31 / cg"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1206
emphasisAt:characterIndex add:newEmphasis
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1207
    "add to the emphasis at some index. return the receiver"
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1208
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1209
    |e prevE|
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1210
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1211
    e := runs at:characterIndex.
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1212
    e := self class addEmphasis:newEmphasis to:e.
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1213
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1214
    "/ if its equal to the previous emphasis, make it identical.
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1215
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1216
    characterIndex > 1 ifTrue:[
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1217
        prevE := runs at:characterIndex-1.
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1218
        e = prevE ifTrue:[
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1219
            e := prevE
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1220
        ]
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1221
    ].
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1222
    runs at:characterIndex put:e.
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1223
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1224
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1225
     (Text string:'hello') allBold emphasisAt:2 add:#italic
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1226
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1227
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1228
    "Created: / 14.5.1996 / 16:48:39 / cg"
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1229
    "Modified: / 31.3.1998 / 15:29:14 / cg"
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1230
!
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1231
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1232
emphasisAt:characterIndex put:emphasis
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1233
    "change the emphasis at some index. return the receiver"
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1234
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1235
    |e prevE|
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1236
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1237
    e := emphasis.
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1238
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1239
    "/ if its equal to the previous emphasis, make it identical.
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1240
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1241
    characterIndex > 1 ifTrue:[
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1242
        prevE := runs at:characterIndex-1.
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1243
        emphasis = prevE ifTrue:[
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1244
            e := prevE
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1245
        ]
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1246
    ].
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1247
    runs at:characterIndex put:e.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1248
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1249
    "
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1250
     (Text string:'hello') allBold emphasisAt:2 put:#italic
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1251
    "
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1252
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1253
    "Modified: / 31.3.1998 / 16:45:14 / cg"
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1254
!
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1255
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1256
emphasisAt:characterIndex remove:emphasisToRemove
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1257
    "remove from the emphasis at some index. return the receiver"
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1258
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1259
    |e|
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1260
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1261
    e := runs at:characterIndex.
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1262
    e := self class removeEmphasis:emphasisToRemove from:e.
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1263
    runs at:characterIndex put:e.
336
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1264
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1265
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1266
     (Text string:'hello') 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1267
        allBold emphasisAt:2 remove:#bold
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1268
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1269
     (Text string:'hello' emphasis:#(bold italic)) 
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1270
        emphasisAt:2 remove:#bold
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1271
    "
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1272
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1273
    "Created: 14.5.1996 / 16:48:39 / cg"
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1274
    "Modified: 14.5.1996 / 17:25:04 / cg"
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1275
!
5fd5fcc38eaa helpers to add/remove emphasis
Claus Gittinger <cg@exept.de>
parents: 335
diff changeset
  1276
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1277
emphasisCollection
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1278
    "return the emphasis"
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1279
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1280
    ^ runs
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1281
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1282
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1283
     (Text string:'hello') allBold emphasis 
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1284
     'hello' emphasis   
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1285
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1286
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1287
    "Created: 14.5.1996 / 13:59:03 / cg"
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1288
    "Modified: 14.5.1996 / 15:02:11 / cg"
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1289
!
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1290
777
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1291
emphasisFrom:start to:stop add:newEmphasis
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1292
    "add to the emphasis within some range. return the receiver"
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1293
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1294
    start to:stop do:[:characterIndex |
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1295
        self emphasisAt:characterIndex add:newEmphasis
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1296
    ].
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1297
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1298
    "
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1299
     (Text string:'hello') allBold 
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1300
        emphasisFrom:2 to:4 add:#italic
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1301
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1302
     Transcript showCR:((Text string:'hello') allBold 
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1303
                            emphasisFrom:2 to:4 add:#italic)
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1304
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1305
    "
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1306
!
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1307
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1308
emphasisFrom:start to:stop remove:anEmphasis
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1309
    "remove from the emphasis within some range. return the receiver"
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1310
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1311
    start to:stop do:[:characterIndex |
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1312
        self emphasisAt:characterIndex remove:anEmphasis
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1313
    ].
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1314
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1315
    "
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1316
     (Text string:'hello') allBold 
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1317
        emphasisFrom:2 to:4 remove:#bold
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1318
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1319
     Transcript showCR:((Text string:'hello') allBold 
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1320
                            emphasisFrom:2 to:4 remove:#bold)
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1321
    "
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1322
!
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1323
2240
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1324
emphasiseFrom:start to:stop with:newEmphasis
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1325
    "set to the emphasis within some range. return the receiver"
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1326
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1327
    start to:stop do:[:characterIndex |
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1328
        self emphasisAt:characterIndex put:newEmphasis
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1329
    ].
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1330
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1331
    "
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1332
     (Text string:'hello') allBold 
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1333
        emphasiseFrom:2 to:4 with:#italic
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1334
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1335
     Transcript showCR:((Text string:'hello') allBold 
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1336
                            emphasiseFrom:2 to:4 with:#italic)
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1337
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1338
    "
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1339
!
ee1b89564617 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2233
diff changeset
  1340
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
emphasizeAllWith:emphasis
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
    "change the emphasis of all characters"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1344
    runs := RunArray new:(string size) withAll:emphasis.
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
     (Text string:'hello') allBold emphasizeAllWith:#italic 
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
    "Modified: 11.5.1996 / 14:22:52 / cg"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1353
emphasizeFrom:start count:count with:emphasis
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1354
    "change the emphasis of a range of characters, given startIndex and count."
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1355
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1356
    self emphasizeFrom:start to:(start+count-1) with:emphasis
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1357
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1358
    "
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1359
     (Text string:'hello world') 
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1360
        emphasizeFrom:1 count:5 with:#bold;
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1361
        emphasizeFrom:7 count:5 with:#italic
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1362
    "
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1363
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1364
    "Modified: 11.5.1996 / 14:30:02 / cg"
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1365
    "Created: 16.5.1996 / 10:52:27 / cg"
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1366
!
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1367
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
emphasizeFrom:start to:stop with:emphasis
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
    "change the emphasis of a range of characters"
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1370
3010
0137a29fee34 class: Text
Claus Gittinger <cg@exept.de>
parents: 3009
diff changeset
  1371
"/    |newRuns|
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
631
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1373
    runs from:start to:stop put:emphasis.
626
3485b60b6a70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 621
diff changeset
  1374
777
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1375
"/    newRuns := RunArray new.
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1376
"/
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1377
"/    "/ for now - a q&d hack
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1378
"/    1 to:start-1 do:[:i |
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1379
"/        newRuns add:(runs at:i).
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1380
"/    ].
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1381
"/    newRuns add:emphasis withOccurrences:(stop - start + 1).
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1382
"/    stop+1 to:string size do:[:i |
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1383
"/        newRuns add:(runs at:i)
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1384
"/    ].
ce839c02dfb6 more emphasis stuff
Claus Gittinger <cg@exept.de>
parents: 762
diff changeset
  1385
"/    runs := newRuns
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
     (Text string:'hello world') 
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
        emphasizeFrom:1 to:5 with:#bold;
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
        emphasizeFrom:7 to:11 with:#italic
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1392
631
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1393
    "Modified: / 7.4.1998 / 08:52:18 / cg"
347
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1394
!
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1395
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1396
emphasizeFrom:start with:emphasis
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1397
    "change the emphasis of some characters upTo the end"
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1398
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1399
    self emphasizeFrom:start to:(self size) with:emphasis
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1400
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1401
    "
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1402
     (Text string:'hello world') 
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1403
        emphasizeFrom:1 count:5 with:#bold;
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1404
        emphasizeFrom:7 with:#italic
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1405
    "
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1406
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1407
    "Modified: 11.5.1996 / 14:30:02 / cg"
6f50e1be3ba4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1408
    "Created: 17.5.1996 / 15:15:32 / cg"
1020
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1409
!
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1410
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1411
strikeoutAll
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1412
    "strikeout all characters"
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1413
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1414
    self emphasisAllAdd:StrikeoutEmphasis.
1020
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1415
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1416
    "
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1417
     Transcript showCR:
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1418
        ('hello' asText strikeoutAll) 
a6304ef6b18a more: allUnderlined; backgroundColorize and strikeoutAll
Claus Gittinger <cg@exept.de>
parents: 1019
diff changeset
  1419
    "
1069
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1420
!
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1421
3248
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1422
withColor:aColor
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1423
    "change the color of all characters"
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1424
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1425
    self emphasisAllAdd:(ColorEmphasis -> aColor).
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1426
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1427
    "
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1428
     Transcript showCR:
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1429
        ((Text string:'hello') colorizeAllWith:(Color red)) 
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1430
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1431
     Transcript showCR:
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1432
        ('hello' colorizeAllWith:(Color red)) 
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1433
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1434
     Transcript showCR:
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1435
        ('hello' allBold colorizeAllWith:(Color red)) 
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1436
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1437
     Transcript showCR:
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1438
        ('hello' asText colorizeAllWith:(Color red)) 
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1439
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1440
     Transcript showCR:
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1441
        ('hello ' , ('red' allBold colorizeAllWith:(Color red)) , ' world')
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1442
    "
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1443
!
309a8d08428a class: Text
Claus Gittinger <cg@exept.de>
parents: 3174
diff changeset
  1444
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1445
withoutAnyColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1446
    ^ (self withoutEmphasis:BackgroundColorEmphasis) withoutEmphasis:ColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1447
!
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1448
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1449
withoutBackgroundColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1450
    ^ self withoutEmphasis:BackgroundColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1451
!
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1452
1069
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1453
withoutEmphasis:emphasisToRemove 
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1454
    |newText anyEmphasis|
1069
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1455
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1456
    self hasChangeOfEmphasis ifTrue:[
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1457
        newText := self copyFrom:1 to:self size.
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1458
        anyEmphasis := false.
1069
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1459
        1 to:newText size do:[:col |
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1460
            |em newem|
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1461
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1462
            em := (newText emphasis) at:col.
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1463
            em notNil ifTrue:[
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1464
                newem := Text removeEmphasis:emphasisToRemove from:em.
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1465
                newem ~~ em ifTrue:[
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1466
                    newText emphasisAt:col put:newem.
2323
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
  1467
                ].
f9c28c6c7295 withoutEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2322
diff changeset
  1468
                newem notNil ifTrue:[ anyEmphasis := true ].
1069
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1469
            ].
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1470
        ].
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1471
        anyEmphasis ifFalse:[^ newText string].
1069
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1472
        ^ newText
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1473
    ].
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1474
    ^ self
2322
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1475
!
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1476
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1477
withoutForegroundColorEmphasis
3dc982ce8487 emphasis handling cleanup
Claus Gittinger <cg@exept.de>
parents: 2312
diff changeset
  1478
    ^ self withoutEmphasis:ColorEmphasis
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
1757
65c6d9b60ca4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1648
diff changeset
  1481
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
!Text methodsFor:'printing & storing'!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1484
displayOn:aGCOrStream
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1485
    "append a printed representation from which the receiver can be reconstructed
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1486
     to aStream."
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1487
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1488
    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1489
    "/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
3325
802a684bf3d9 displayOn: cleanup
Claus Gittinger <cg@exept.de>
parents: 3273
diff changeset
  1490
    (aGCOrStream isStream) ifTrue:[
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1491
        aGCOrStream nextPutAll:'(Text string:'.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1492
        string storeOn:aGCOrStream.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1493
        aGCOrStream nextPutAll:' runs:'.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1494
        runs displayOn:aGCOrStream.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1495
        aGCOrStream nextPutAll:')'.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1496
        ^ self.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1497
    ].
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1498
    ^ self displayOn:aGCOrStream x:0 y:0.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1499
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1500
    "Created: 11.5.1996 / 14:27:09 / cg"
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1501
    "Modified: 16.5.1996 / 11:23:32 / cg"
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1502
!
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1503
3273
7cf94988dc15 class: Text
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
  1504
displayString
7cf94988dc15 class: Text
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
  1505
    "return a string used when displaying the receiver in a view."
7cf94988dc15 class: Text
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
  1506
7cf94988dc15 class: Text
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
  1507
    ^ self.
7cf94988dc15 class: Text
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
  1508
!
7cf94988dc15 class: Text
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
  1509
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1510
printOn:aStream
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1511
    "print the receivers characters (including emphasis) on
409
7e8c2457d5f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 408
diff changeset
  1512
     aStream. 
1077
4117a0e655cd Save old emphasis on #printOn:
Stefan Vogel <sv@exept.de>
parents: 1070
diff changeset
  1513
     Notice, that some streams simply ignore the emphasis"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1514
2051
d55c088e8bfd Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 2016
diff changeset
  1515
    aStream nextPutAllText:self
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1517
    "
407
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
  1518
     Transcript showCR:'hello world'.
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
  1519
     Transcript showCR:'hello world' asText allBold.
a6e616d1d1bc better #printOn:
Claus Gittinger <cg@exept.de>
parents: 406
diff changeset
  1520
     Transcript showCR:('hello world' asText emphasizeAllWith:#italic).
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1521
    "
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
409
7e8c2457d5f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 408
diff changeset
  1523
    "Modified: 12.7.1996 / 10:15:47 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1524
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1525
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
storeOn:aStream
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1527
    "append a printed representation from which the receiver can be reconstructed
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1528
     to aStream."
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1529
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
    aStream nextPutAll:'(Text string:'.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
    string storeOn:aStream.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1532
    aStream nextPutAll:' runs:'.
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
    runs storeOn:aStream.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1534
    aStream nextPutAll:')'.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1536
    "Created: 11.5.1996 / 14:27:09 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1537
    "Modified: 16.5.1996 / 11:23:32 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1538
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1539
1200
fefe87f822bc method category rename
Claus Gittinger <cg@exept.de>
parents: 1173
diff changeset
  1540
!Text methodsFor:'private-accessing'!
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
631
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1542
emphasisCollection:emphasisCollection
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1543
    "set the string and emphasis collection.
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1544
     The emphasis collection contains per-character information."
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1545
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1546
    runs := emphasisCollection.
631
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1547
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1548
    "Created: / 7.4.1998 / 08:52:03 / cg"
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1549
!
3423da7cf851 added #emphasisCollection:
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1550
2959
248125161a88 class: Text
Claus Gittinger <cg@exept.de>
parents: 2868
diff changeset
  1551
runs
248125161a88 class: Text
Claus Gittinger <cg@exept.de>
parents: 2868
diff changeset
  1552
    ^ runs
248125161a88 class: Text
Claus Gittinger <cg@exept.de>
parents: 2868
diff changeset
  1553
!
248125161a88 class: Text
Claus Gittinger <cg@exept.de>
parents: 2868
diff changeset
  1554
3009
32460e623a13 class: Text
Claus Gittinger <cg@exept.de>
parents: 2959
diff changeset
  1555
setRuns:anArrayOrRunArray
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1556
    runs := anArrayOrRunArray.
3009
32460e623a13 class: Text
Claus Gittinger <cg@exept.de>
parents: 2959
diff changeset
  1557
!
32460e623a13 class: Text
Claus Gittinger <cg@exept.de>
parents: 2959
diff changeset
  1558
32460e623a13 class: Text
Claus Gittinger <cg@exept.de>
parents: 2959
diff changeset
  1559
setString:aString setRuns:anArrayOrRunArray
872
2ca6864d13bb new private accessor (for subclass compatibility)
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
  1560
    string := aString.
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1561
    runs := anArrayOrRunArray.
872
2ca6864d13bb new private accessor (for subclass compatibility)
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
  1562
!
2ca6864d13bb new private accessor (for subclass compatibility)
Claus Gittinger <cg@exept.de>
parents: 854
diff changeset
  1563
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1564
string:aString emphasis:emphasis
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1565
    "set the string and emphasis. The emphasis is applied to all characters."
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1566
428
3cdcd0597bf0 bug fix: implicit set string to String not Text
ca
parents: 410
diff changeset
  1567
    string := aString string.
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1568
    runs   := RunArray new:string size withAll:emphasis.
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1569
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1570
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1571
     |t|
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1573
     t := Text new string:'hello' emphasis:#bold.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
     t emphasisAt:2.
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1575
    "
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1576
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1577
    "Modified: 16.5.1996 / 11:24:03 / cg"
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1578
!
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1579
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1580
string:aString emphasisCollection:emphasisCollection
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1581
    "set the string and emphasis collection.
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1582
     The emphasis collection contains per-character information."
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1583
428
3cdcd0597bf0 bug fix: implicit set string to String not Text
ca
parents: 410
diff changeset
  1584
    string := aString string.
1160
a68cecd42784 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
  1585
    string size == 0 ifTrue:[
a68cecd42784 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
  1586
        runs := RunArray new.
a68cecd42784 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
  1587
    ] ifFalse:[
a68cecd42784 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
  1588
        runs := emphasisCollection asRunArray
a68cecd42784 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
  1589
    ].
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1590
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1591
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1592
     |t|
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1593
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1594
     t := Text new string:'hello' emphasisCollection:(#bold #bold #bold #italic #italic).
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1595
     t emphasisAt:2.
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1596
    "
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1597
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1598
    "Created: 14.5.1996 / 14:03:29 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1599
    "Modified: 16.5.1996 / 11:24:21 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1602
!Text methodsFor:'queries'!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1604
emphasisAtPoint:aPoint on:aGC
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1605
    "return the emphasis at a given point, or nil if there is none"
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1606
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1607
    |pointX savedFont boldFont italicFont bold italic wasItalic pos f l device posX|
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1608
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1609
    pointX := aPoint x.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1610
    device := aGC graphicsDevice.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1611
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1612
    savedFont := aGC basicFont onDevice:device.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1613
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1614
    pos := 1.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1615
    posX := 0.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1616
    l := 0.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1617
    italic := false.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1618
    runs runsDo:[:len :emphasis |
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1619
        wasItalic := italic.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1620
        emphasis isSymbol ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1621
            bold := (emphasis == #bold).
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1622
            italic := (emphasis == #italic).
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1623
        ] ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1624
            (emphasis isNil 
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1625
            or:[emphasis isMemberOf:Association]) ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1626
                bold := italic := false
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1627
            ] ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1628
                bold := emphasis includesIdentical:#bold.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1629
                italic := emphasis includesIdentical:#italic.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1630
            ]
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1631
        ].
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1632
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1633
        bold ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1634
            boldFont isNil ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1635
                boldFont := savedFont asBold onDevice:device
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1636
            ].
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1637
            f := boldFont.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1638
        ] ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1639
            italic ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1640
                italicFont isNil ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1641
                    italicFont := savedFont asItalic onDevice:device
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1642
                ].
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1643
                f := italicFont
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1644
            ] ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1645
                f := savedFont
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1646
            ]
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1647
        ].
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1648
        f := f onDevice:device.
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1649
"/ disabled - it is too ugly (and not handled correctly, anyway).
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1650
"/        wasItalic ~~ italic ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1651
"/            italic ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1652
"/                "/ going from italic to non-italic; leave some space for the shear
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1653
"/                l := l + (f width " // 2" )
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1654
"/            ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1655
"/        ].
2128
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1656
        l := (f widthOf:string from:pos to:(pos + len - 1)).
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1657
        (pointX between:posX and:posX + l) ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1658
            ^ emphasis
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1659
        ].
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1660
        pos := pos + len.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1661
        posX := posX + l.
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1662
    ].
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1663
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1664
    ^ nil
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1665
!
Stefan Vogel <sv@exept.de>
parents: 2110
diff changeset
  1666
1401
450cdbacff60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1200
diff changeset
  1667
encoding
450cdbacff60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1200
diff changeset
  1668
    ^ string encoding
450cdbacff60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1200
diff changeset
  1669
!
450cdbacff60 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1200
diff changeset
  1670
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1671
hasChangeOfEmphasis
2830
b69f6dc901f0 comment/format in: #hasChangeOfEmphasis
Claus Gittinger <cg@exept.de>
parents: 2734
diff changeset
  1672
    "return true, if the receiver contains non-empty emphasis information
b69f6dc901f0 comment/format in: #hasChangeOfEmphasis
Claus Gittinger <cg@exept.de>
parents: 2734
diff changeset
  1673
     i.e. any non-normal (=emphasized) characters"
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1674
3472
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1675
    ^ runs notEmptyOrNil
a61d50c15405 class: Text
Claus Gittinger <cg@exept.de>
parents: 3325
diff changeset
  1676
       and:[ runs contains:[:e | e notNil] ]
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1677
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1678
    "Created: 11.5.1996 / 14:03:19 / cg"
335
4adf1b6b4063 concatenating mixed texts & strings
Claus Gittinger <cg@exept.de>
parents: 316
diff changeset
  1679
    "Modified: 14.5.1996 / 15:51:01 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1680
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1681
2578
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1682
hasEmphasis: emphasis
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1683
    "return true, if the receiver contains given emphasis"
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1684
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1685
    "HACK!!!!!!"
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1686
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1687
    | emphasisArray  |
2675
ba4427ed6582 changed: #hasEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
  1688
2578
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1689
    (emphasis isSymbol or:[emphasis isAssociation]) ifTrue:[
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1690
        emphasisArray := Array with: emphasis
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1691
    ] ifFalse:[
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1692
        emphasisArray := emphasis.
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1693
    ].
2675
ba4427ed6582 changed: #hasEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
  1694
    emphasisArray isNil ifTrue:[^false].
2578
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1695
    
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1696
    runs do:[:runEmph|    
3116
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1697
        emphasisArray do:[:searchEmph|
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1698
            (runEmph = searchEmph 
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1699
            or: [runEmph isCollection 
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1700
                 and:[runEmph isSymbol not 
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1701
                 and:[runEmph includes: searchEmph]]]
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1702
            ) ifTrue:[
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1703
                ^ true
2578
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1704
            ]                    
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1705
        ]
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1706
    ].
3116
4e7534b4d5f1 class: Text
Claus Gittinger <cg@exept.de>
parents: 3010
diff changeset
  1707
    ^ false
2578
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1708
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1709
    "
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1710
        'Hello' asText allBold hasEmphasis: #bold.
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1711
        'Hello' asText allBold allUnderlined hasEmphasis: #bold.
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1712
        'Hello' asText allBold allUnderlined hasEmphasis: #italic.                              
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1713
        ('Hello' asText allBold allUnderlined , ' World' asText allItalic) hasEmphasis: #italic.
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1714
    "
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1715
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1716
    "Created: / 20-07-2011 / 17:51:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2675
ba4427ed6582 changed: #hasEmphasis:
Claus Gittinger <cg@exept.de>
parents: 2583
diff changeset
  1717
    "Modified (format): / 18-11-2011 / 14:55:10 / cg"
2578
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1718
!
0b44903b0406 Added Text>>hasEmphasis:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2552
diff changeset
  1719
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1720
heightOn:aGC
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1721
    "return the number of device units, required on aGC's device"
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1722
621
6a975c3fd2fd need deviceFont for height/width query
ca
parents: 615
diff changeset
  1723
    ^ (aGC font onDevice:aGC device) heightOf:string
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1724
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1725
    "Created: 12.5.1996 / 11:02:03 / cg"
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1726
!
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1727
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
indexOf:aCharacter startingAt:index
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1729
    "search aCharacters index in the underlying string"
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1730
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1731
    ^ string indexOf:aCharacter startingAt:index
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
    "Created: 11.5.1996 / 13:58:56 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1734
    "Modified: 16.5.1996 / 11:25:12 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1735
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1737
isText
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1738
    "return true if this is a Text object - always true here"
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1739
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1740
    ^ true
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1741
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1742
    "Created: 12.5.1996 / 10:56:24 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1743
    "Modified: 16.5.1996 / 11:25:29 / cg"
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1744
!
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1745
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1746
occurrencesOf:aCharacter
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1747
    "count & return the number of occurrences of aCharacter in the 
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1748
     underlying string"
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1749
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
    ^ string occurrencesOf:aCharacter
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
    "Created: 11.5.1996 / 13:58:46 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1753
    "Modified: 16.5.1996 / 11:25:51 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
size
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1757
    "return the number of characters in the underlying string"
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1758
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
    ^ string size
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
    "Created: 11.5.1996 / 14:25:15 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1762
    "Modified: 16.5.1996 / 11:26:08 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1763
!
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1764
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
string
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1766
    "return the receiver without any emphasis information
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1767
     i.e. the underlying string."
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1768
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
    ^ string
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
    "Created: 11.5.1996 / 13:58:38 / cg"
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1772
    "Modified: 16.5.1996 / 11:26:30 / cg"
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1773
!
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1774
1069
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1775
widthFrom:startIndex to:endIndex on:aGC
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1776
    "return the number of device units, required on aGC's device"
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1777
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1778
    ^ (self copyFrom:startIndex to:endIndex) widthOn:aGC
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1779
!
069382332bdb +withoutEmphasis:
Michael Beyl <mb@exept.de>
parents: 1068
diff changeset
  1780
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1781
widthOn:aGC
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1782
    "return the number of device units, required on aGC's device"
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1783
975
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
  1784
    |savedFont boldFont italicFont bold italic wasItalic pos f l device|
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1785
404
14cf34141532 use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  1786
    device := aGC graphicsDevice.
14cf34141532 use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  1787
794
a2e8a5cd0512 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 779
diff changeset
  1788
    savedFont := aGC basicFont onDevice:device.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1789
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1790
    pos := 1.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1791
    l := 0.
975
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
  1792
    italic := false.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1793
    runs runsDo:[:len :emphasis |
975
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
  1794
        wasItalic := italic.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1795
        emphasis isSymbol ifTrue:[
975
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
  1796
            bold := (emphasis == #bold).
4a2048f291eb care for some spacing, when going from italic to non-italic
Claus Gittinger <cg@exept.de>
parents: 963
diff changeset
  1797
            italic := (emphasis == #italic).
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1798
        ] ifFalse:[
308
bb9472eec501 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
  1799
            (emphasis isNil 
bb9472eec501 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 307
diff changeset
  1800
            or:[emphasis isMemberOf:Association]) ifTrue:[
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1801
                bold := italic := false
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1802
            ] ifFalse:[
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1803
                bold := emphasis includesIdentical:#bold.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1804
                italic := emphasis includesIdentical:#italic.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1805
            ]
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1806
        ].
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1807
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1808
        bold ifTrue:[
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1809
            boldFont isNil ifTrue:[
899
fe2b44d0d9c1 moved #sameEmphasisAs: and #sameStringAndEmphasisAs:
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
  1810
                boldFont := savedFont asBold onDevice:device
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1811
            ].
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1812
            f := boldFont.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1813
        ] ifFalse:[
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1814
            italic ifTrue:[
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1815
                italicFont isNil ifTrue:[
899
fe2b44d0d9c1 moved #sameEmphasisAs: and #sameStringAndEmphasisAs:
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
  1816
                    italicFont := savedFont asItalic onDevice:device
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1817
                ].
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1818
                f := italicFont
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1819
            ] ifFalse:[
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1820
                f := savedFont
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1821
            ]
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1822
        ].
899
fe2b44d0d9c1 moved #sameEmphasisAs: and #sameStringAndEmphasisAs:
Claus Gittinger <cg@exept.de>
parents: 892
diff changeset
  1823
        f := f onDevice:device.
2233
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1824
"/ disabled - it is too ugly (and not handled correctly, anyway).
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1825
"/        wasItalic ~~ italic ifTrue:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1826
"/            italic ifFalse:[
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1827
"/                "/ going from italic to non-italic; leave some space for the shear
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1828
"/                l := l + (f width " // 2" )
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1829
"/            ].
04205abedbff space insertion at italic-nonItalic boundaries removed.
Claus Gittinger <cg@exept.de>
parents: 2181
diff changeset
  1830
"/        ].
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1831
        l := l + (f widthOf:string from:pos to:(pos + len - 1)).
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1832
        pos := pos + len
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1833
    ].
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1834
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1835
    ^ l
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1836
404
14cf34141532 use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  1837
    "Modified: 5.7.1996 / 17:54:58 / cg"
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1838
! !
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1839
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1840
!Text methodsFor:'replacing'!
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1841
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1842
replaceFrom:start to:stop with:aCollection startingAt:startIndex
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1843
    "replace a range of characters, from another string or text object.
607
bf216b414680 comment
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1844
     The corresponding characters' emphasis information is also copied.
bf216b414680 comment
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1845
     Return the receiver."
343
01f88d90c385 commentary
Claus Gittinger <cg@exept.de>
parents: 339
diff changeset
  1846
2181
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1847
    |idx maxCharacter|
1402
2fe462e2fe8e care for text with twobyte strings
Claus Gittinger <cg@exept.de>
parents: 1401
diff changeset
  1848
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1849
    aCollection isString ifTrue:[
2181
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1850
        aCollection bitsPerCharacter > string bitsPerCharacter ifTrue:[
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1851
            "have to create a new string with appropriate character size"
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1852
            string := aCollection string species fromString:string.
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1853
        ].
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1854
        aCollection hasChangeOfEmphasis ifTrue:[
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1855
            string replaceFrom:start to:stop with:aCollection startingAt:startIndex.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1856
            idx := startIndex.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1857
            start to:stop do:[:col |
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1858
                self emphasisAt:col put:(aCollection emphasisAt:idx).
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1859
                idx := idx + 1.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1860
            ].
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1861
            ^ self.
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1862
        ]
2181
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1863
    ] ifFalse:[
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1864
        "aCollection is an arbitrary SequenceableCollection"
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1865
        maxCharacter := $0.    "some 8-bit character"
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1866
        aCollection do:[:eachCharacter |
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1867
            maxCharacter := maxCharacter max:eachCharacter
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1868
        ].
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1869
        maxCharacter bitsPerCharacter > string bitsPerCharacter ifTrue:[
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1870
            "have to create a new string with appropriate character size"
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1871
            string := maxCharacter stringSpecies fromString:string.
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1872
        ].
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1873
    ].
2181
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1874
        
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1875
    string replaceFrom:start to:stop with:aCollection startingAt:startIndex.
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1876
    self emphasizeFrom:start to:stop with:nil.
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1877
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1878
    "
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1879
     ((Text string:'hello') allBold emphasisAt:2 put:#italic)
2181
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1880
        replaceFrom:1 to:3 with:'HEL' startingAt:1
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1881
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1882
     ((Text string:'hello') allBold emphasisAt:2 put:#italic)
86122f38fc09 Fix #replaceFrom:to:with:startingAt:
Stefan Vogel <sv@exept.de>
parents: 2128
diff changeset
  1883
        replaceFrom:1 to:3 with:#($H $E $L) startingAt:1
307
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1884
    "
8d58cb6e618b fixes & addons
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1885
607
bf216b414680 comment
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1886
    "Modified: / 28.1.1998 / 16:50:06 / cg"
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1887
! !
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1888
454
ffc79ebcbb20 oops - copyFrom:to: clobbered the emphasis
Claus Gittinger <cg@exept.de>
parents: 450
diff changeset
  1889
!Text class methodsFor:'documentation'!
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1890
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
version
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1892
    ^ '$Header$'
2305
2108d674c8b2 comment/format in: #writeStream
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1893
!
2108d674c8b2 comment/format in: #writeStream
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1894
2108d674c8b2 comment/format in: #writeStream
Claus Gittinger <cg@exept.de>
parents: 2259
diff changeset
  1895
version_CVS
3598
04be25181a2e class: Text
Claus Gittinger <cg@exept.de>
parents: 3472
diff changeset
  1896
    ^ '$Header$'
304
dee14fa0f2f7 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1897
! !
1160
a68cecd42784 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
  1898
2867
daa1394cdf05 class: Text
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
  1899
314
42526a763add checkin from browser
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1900
Text initialize!