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