DiffTextView.st
author Claus Gittinger <cg@exept.de>
Thu, 31 Jul 1997 21:21:36 +0200
changeset 1265 3db375412f5d
parent 623 48cc09809032
child 1276 66761d461a39
permissions -rw-r--r--
avoid caching a debugger which got destroyed (for example: from launchers destroy-view menu)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     1
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
     3
	      All Rights Reserved
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     4
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    10
 hereby transferred.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    11
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    12
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    13
TwoColumnTextView subclass:#DiffTextView
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    14
	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    15
		removedBgColor changedColor changedBgColor changedSpacesOnlyColor
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    16
		changedSpacesOnlyBgColor diffLineNumbers'
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    17
	classVariableNames:''
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    18
	poolDictionaries:''
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    19
	category:'Views-Text'
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    20
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    21
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    22
!DiffTextView class methodsFor:'documentation'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    23
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    24
copyright
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    25
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    26
 COPYRIGHT (c) 1994 by Claus Gittinger
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    27
	      All Rights Reserved
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    28
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    29
 This software is furnished under a license and may be used
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    34
 hereby transferred.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    35
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    36
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    37
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    38
documentation
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    39
"
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    40
    a view showing diff output (see unix manual pages)
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    41
    in a user-friendly form.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    42
    The view is created and opened with:
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    43
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    44
        d := DiffTextView openOn:text1 and:text2
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    45
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    46
    or:
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    47
        d := DiffTextView openOn:text1 label:l1
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    48
                             and:text2 label:l2
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    49
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    50
    and it will show the differences side-by-side.
533
5bf1a4a2adad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
    51
5bf1a4a2adad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
    52
    For a real world application, 
5bf1a4a2adad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
    53
    see the ChangesBrowsers `compare' function.
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    54
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    55
    [see also:]
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    56
        TextView EditTextView
519
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    57
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    58
    [author:]
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    59
        Claus Gittinger
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    60
"
242
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    61
! !
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    62
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    63
!DiffTextView class methodsFor:'defaults'!
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    64
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    65
diffCommand
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    66
    "return the diff-command (with arguments)"
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    67
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    68
    ^ 'diff -b'
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    69
! !
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    70
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    71
!DiffTextView methodsFor:'accessing'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    72
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    73
text1:t1 text2:t2
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    74
    "set the two texts which are to be diffed"
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    75
110
claus
parents: 69
diff changeset
    76
    |tmpFile1 tmpFile2 name1 tmpName2 stream line text1 text2 diffList pidString|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    77
69
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
    78
    text1 := t1 asStringCollection.
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
    79
    text2 := t2 asStringCollection.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    80
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    81
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    82
     save them texts in two temporary files ...
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    83
    "
69
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
    84
    tmpFile1 := Filename newTemporary.
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
    85
    stream := tmpFile1 writeStream.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    86
    text1 do:[:line |
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    87
        stream nextPutAll:line; cr
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    88
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    89
    stream close.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    90
69
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
    91
    tmpFile2 := Filename newTemporary.
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
    92
    stream := tmpFile2 writeStream.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    93
    text2 do:[:line |
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    94
        stream nextPutAll:line; cr
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    95
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    96
    stream close.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    97
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    98
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    99
     start diff on it ...
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   100
    "
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   101
    stream := PipeStream 
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   102
                readingFrom:self class diffCommand , ' ' , 
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   103
                            tmpFile1 asString, ' ' , tmpFile2 asString.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   104
    stream isNil ifTrue:[
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   105
        self error:'cannot execute diff'.
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   106
        text1 := text2 := nil.
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   107
    ] ifFalse:[
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   108
        diffList := OrderedCollection new.
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   109
        [stream atEnd] whileFalse:[
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   110
            line := stream nextLine.
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   111
            line notNil ifTrue:[diffList add:line]
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   112
        ].
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   113
        stream close.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   114
    ].
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   115
69
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
   116
    tmpFile1 delete.
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
   117
    tmpFile2 delete.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   118
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   119
    self updateListsFrom:text1 and:text2 diffs:diffList
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   120
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   121
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   122
     |v|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   123
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   124
     v := HVScrollableView for:DiffTextView.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   125
     v scrolledView text1:('../libview/Color.st' asFilename readStream contents)
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   126
                    text2:('../libview/Color.st.old' asFilename readStream contents).
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   127
     v open
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   128
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   129
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   130
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   131
     |v t1 t2|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   132
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   133
     t1 := '
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   134
one
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   135
two
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   136
three
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   137
four
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   138
'.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   139
     t2 := '
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   140
one
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   141
two-a
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   142
two-b
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   143
three
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   144
three-b
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   145
four
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   146
'.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   147
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   148
     v := DiffTextView new.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   149
     v text1:t1 text2:t2.
69
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
   150
     v open
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   151
    "
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   152
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   153
    "Modified: 25.4.1996 / 13:33:52 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   154
! !
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   155
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   156
!DiffTextView methodsFor:'initialization'!
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   157
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   158
initStyle
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   159
    super initStyle.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   160
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   161
    showSeparators := false.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   162
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   163
    (useColors := device hasColors) ifTrue:[
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   164
        addedColor := Color black.
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   165
        addedBgColor := Color green.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   166
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   167
        removedColor := Color white.
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   168
        removedBgColor := Color red.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   169
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   170
        changedColor := Color white.
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   171
        changedBgColor := Color blue.
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   172
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   173
        changedSpacesOnlyColor := Color white.
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   174
        changedSpacesOnlyBgColor := Color blue lightened.
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   175
    ] ifFalse:[
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   176
        showSeparators := true.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   177
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   178
        (useColors := device hasGreyscales) ifTrue:[
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   179
            addedBgColor := removedBgColor := changedBgColor := Color grey:80.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   180
            addedColor := removedColor := changedColor := Color black.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   181
        ] ifFalse:[
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   182
            addedBgColor := removedBgColor := changedBgColor := Color black.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   183
            addedColor := removedColor := changedColor := Color white.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   184
        ].
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   185
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   186
        changedSpacesOnlyColor := Color white.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   187
        changedSpacesOnlyBgColor := Color black.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   188
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   189
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   190
    "Created: 16.11.1995 / 16:59:48 / cg"
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   191
    "Modified: 14.6.1996 / 16:14:39 / cg"
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   192
! !
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   193
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   194
!DiffTextView methodsFor:'private'!
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   195
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   196
updateListsFrom:text1 and:text2 diffs:diffList
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   197
    "given the two texts in text1 and text2, and the diff-output in diffList,
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   198
     update my views contents"
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   199
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   200
    |idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry c l1 l2 any delta
318
2a2009875ee4 handle nil entries
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   201
     textView1 textView2 s1 s2|
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   202
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   203
    diffLineNumbers := OrderedCollection new.
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   204
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   205
    textView1 := textViews at:1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   206
    textView2 := textViews at:2.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   207
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   208
    l1 := OrderedCollection new.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   209
    l2 := OrderedCollection new.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   210
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   211
    idx1 := 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   212
    idx2 := 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   213
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   214
    dIdx := 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   215
    dEnd := diffList size + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   216
    state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   217
    [dIdx <= dEnd] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   218
        dIdx == dEnd ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   219
            "dummy cleanup entry"
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   220
            entry := nil.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   221
            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   222
        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   223
            entry := diffList at:dIdx.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   224
        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   225
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   226
        state == #initial ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   227
            "entry is of the form <nr> <op> <offs> [<offs2>]"
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   228
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   229
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   230
             fill up to size difference from previous change
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   231
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   232
            delta := l1 size - l2 size.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   233
            delta > 0 ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   234
                delta timesRepeat:[l2 add:nil]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   235
            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   236
                delta < 0 ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   237
                    delta negated timesRepeat:[l1 add:nil]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   238
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   239
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   240
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   241
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   242
             except for the first chunk, add a separating line
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   243
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   244
            l1 size ~~ 0 ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   245
                showSeparators ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   246
                    l1 add:'--------'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   247
                    l2 add:'--------'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   248
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   249
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   250
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   251
             in cleanup ?
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   252
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   253
            entry isNil ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   254
                nr1 := text1 size + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   255
                nr2 := text2 size + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   256
                state := #finish.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   257
            ] ifFalse:[
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   258
                diffLineNumbers add:l1 size.
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   259
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   260
                s := ReadStream on:entry.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   261
                nr1 := Integer readFrom:s.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   262
                s peek == $, ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   263
                    s next.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   264
                    Integer readFrom:s
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   265
                ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   266
                op := s next.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   267
                nr2 := Integer readFrom:s.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   268
                s peek == $, ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   269
                    s next.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   270
                    nr3 := Integer readFrom:s
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   271
                ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   272
                    nr3 := nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   273
                ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   274
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   275
                op == $c ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   276
                    state := #changed.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   277
                ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   278
                    op == $a ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   279
                        state := #added.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   280
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   281
                        op == $d ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   282
                            state := #deleted
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   283
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   284
                            self halt:'unexpected diff entry'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   285
                        ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   286
                    ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   287
                ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   288
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   289
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   290
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   291
"/ nr1 print. ' ' print. op print. ' ' print. nr2 print. ' , ' print. nr3 printNL.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   292
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   293
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   294
             copy over unchanged lines
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   295
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   296
            any := false.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   297
            [idx1 < nr1] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   298
"/ '< add:' print. idx1 printNL.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   299
                l1 add:(text1 at:idx1).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   300
                idx1 := idx1 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   301
                any := true.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   302
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   303
            [idx2 < nr2] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   304
"/ '> add:' print. idx2 printNL.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   305
                l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   306
                idx2 := idx2 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   307
                any := true.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   308
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   309
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   310
            state == #added ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   311
                l1 add:(text1 at:idx1).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   312
                idx1 := idx1 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   313
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   314
            state == #deleted ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   315
                l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   316
                idx2 := idx2 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   317
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   318
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   319
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   320
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   321
             add a separating line, except at end
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   322
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   323
            any ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   324
                state ~~ #finish ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   325
                    showSeparators ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   326
                        l1 add:'--------'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   327
                        l2 add:'--------'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   328
                    ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   329
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   330
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   331
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   332
        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   333
            state == #changed ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   334
                (entry at:1) == $< ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   335
                    useColors ifTrue:[
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   336
                        (l2 size >= idx1
318
2a2009875ee4 handle nil entries
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   337
                        and:[(s2 := l2 at:idx1) notNil
2a2009875ee4 handle nil entries
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   338
                             and:[s2 asString withoutSeparators = (text1 at:idx1) withoutSeparators]]) ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   339
                            l1 add:(Text string:(text1 at:idx1) 
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   340
                                         foregroundColor:changedSpacesOnlyColor
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   341
                                         backgroundColor:changedSpacesOnlyBgColor).
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   342
                            l2 at:idx1 put:(Text string:(l2 at:idx1) asString 
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   343
                                                 foregroundColor:changedSpacesOnlyColor 
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   344
                                                 backgroundColor:changedSpacesOnlyBgColor).
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   345
                        ] ifFalse:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   346
                            l1 add:(Text string:(text1 at:idx1) 
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   347
                                         foregroundColor:changedColor 
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   348
                                         backgroundColor:changedBgColor).
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   349
                        ]
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   350
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   351
                        l1 add:(text1 at:idx1).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   352
                    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   353
                    idx1 := idx1 + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   354
                ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   355
                    (entry at:1) == $> ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   356
                        useColors ifTrue:[
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   357
                            (l1 size >= idx2
318
2a2009875ee4 handle nil entries
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   358
                            and:[(s1 := l1 at:idx2) notNil
2a2009875ee4 handle nil entries
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   359
                                and:[s1 asString withoutSeparators = (text2 at:idx2) withoutSeparators]]) ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   360
                                l2 add:(Text string:(text2 at:idx2) foregroundColor:changedSpacesOnlyColor backgroundColor:changedSpacesOnlyBgColor).
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   361
                                l1 at:idx2 put:(Text string:(l1 at:idx2) asString foregroundColor:changedSpacesOnlyColor backgroundColor:changedSpacesOnlyBgColor).
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   362
                            ] ifFalse:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   363
                                l2 add:(Text string:(text2 at:idx2) foregroundColor:changedColor backgroundColor:changedBgColor)
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   364
                            ]
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   365
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   366
                            l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   367
                        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   368
                        idx2 := idx2 + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   369
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   370
                        (entry at:1) == $- ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   371
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   372
                            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   373
                            dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   374
                        ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   375
                    ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   376
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   377
            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   378
                state == #added ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   379
                    (entry at:1) == $> ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   380
                        useColors ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   381
                            l2 add:(Text string:(text2 at:idx2) foregroundColor:addedColor backgroundColor:addedBgColor )
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   382
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   383
                            l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   384
                        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   385
                        idx2 := idx2 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   386
                        l1 add:nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   387
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   388
                        state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   389
                        dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   390
                    ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   391
                ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   392
                    state == #deleted ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   393
                        (entry at:1) == $< ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   394
                            useColors ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   395
                                l1 add:(Text string:(text1 at:idx1) foregroundColor:removedColor backgroundColor:removedBgColor ).
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   396
                            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   397
                                l1 add:(text1 at:idx1).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   398
                            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   399
                            idx1 := idx1 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   400
                            l2 add:nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   401
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   402
                            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   403
                            dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   404
                        ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   405
                    ] 
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   406
                    "must be in finish otherwise"
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   407
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   408
            ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   409
        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   410
        dIdx := dIdx + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   411
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   412
    [l1 size < l2 size] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   413
        l1 add:''.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   414
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   415
    [l2 size < l1 size] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   416
        l2 add:''.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   417
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   418
    textView1 list:l1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   419
    textView2 list:l2
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   420
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   421
    "Modified: 16.5.1996 / 12:38:49 / cg"
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   422
! !
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   423
242
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   424
!DiffTextView class methodsFor:'documentation'!
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   425
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   426
version
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   427
^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.20 1996-06-14 14:16:26 cg Exp $'! !