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