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