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