DiffTextView.st
author Jan Vrany <jan.vrany@labware.com>
Sat, 30 Sep 2023 22:55:25 +0100
branchjv
changeset 19648 5df52d354504
parent 18532 cccb41254edf
permissions -rw-r--r--
`TestRunner2`: do not use `#keysAndValuesCollect:` ...as semantics differ among smalltalk dialects. This is normally not a problem until we use code that adds this as a "compatibility" method. So to stay on a safe side, avoid using this method.
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
"
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
    12
"{ Package: 'stx:libtool' }"
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
    13
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
    14
"{ NameSpace: Smalltalk }"
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
    15
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    16
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
    17
	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
    18
		removedBgColor changedColor changedBgColor changedSpacesOnlyColor
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    19
		changedSpacesOnlyBgColor diffLineNumbers'
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
    20
	classVariableNames:'DiffCommandTemplate'
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    21
	poolDictionaries:''
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    22
	category:'Views-Text'
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    23
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    24
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    25
AbstractBackground subclass:#DiffTextScrollerBackground
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    26
	instanceVariableNames:'diffView'
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    27
	classVariableNames:''
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    28
	poolDictionaries:''
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    29
	privateIn:DiffTextView
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    30
!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    31
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    32
!DiffTextView class methodsFor:'documentation'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    33
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    34
copyright
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    35
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    36
 COPYRIGHT (c) 1994 by Claus Gittinger
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    37
	      All Rights Reserved
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    38
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    39
 This software is furnished under a license and may be used
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    40
 only in accordance with the terms of that license and with the
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    42
 be provided or otherwise made available to, or used by, any
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    43
 other person.  No title to or ownership of the software is
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    44
 hereby transferred.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    45
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    46
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    47
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    48
documentation
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    49
"
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    50
    a view showing diff output (see unix manual pages)
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    51
    in a user-friendly form.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    52
    The view is created and opened with:
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    53
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    54
        d := DiffTextView openOn:text1 and:text2
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    55
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    56
    or:
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    57
        d := DiffTextView openOn:text1 label:l1
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    58
                             and:text2 label:l2
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    59
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    60
    and it will show the differences side-by-side.
533
5bf1a4a2adad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
    61
2240
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    62
    The colors mean:
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    63
        red             - removed
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    64
        green           - added
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    65
        blue            - changed
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    66
        light-blue        changed, but not really (i.e. spaces only)
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    67
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    68
    For a real world application and use of this widget, 
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    69
    see the ChangesBrowsers `compare', 
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    70
    or the browsers 'compare with repository' functions.
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    71
2246
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    72
    Notice:
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    73
        A diff command must be available on your system and found
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    74
        along the PATH (you will see a warning on stderr, if there is no diff).
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    75
        We use gnu-diff.
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    76
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    77
    [see also:]
1276
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    78
        TextView EditTextView Diff3TextView
519
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    79
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    80
    [author:]
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    81
        Claus Gittinger
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    82
"
1276
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    83
!
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    84
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    85
examples
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    86
"
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    87
                                                        [exBegin]
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    88
    |text1 text2|
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    89
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    90
    text1 := 'hello world
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    91
here is some difference
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    92
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    93
this line has been removed
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    94
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    95
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    96
'.
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    97
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    98
    text2 := 'hello world
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    99
where is the difference ?
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   100
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   101
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   102
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   103
this line has been added
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   104
'.
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   105
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   106
    DiffTextView openOn:text1 label:'text1'
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   107
                    and:text2 label:'text2'
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   108
                                                        [exEnd]
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   109
"
242
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   110
! !
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   111
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   112
!DiffTextView class methodsFor:'instance creation'!
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   113
2948
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   114
openOnClass:classA labelA:lblA andClass:classB labelB:lblB title:title ifSame:sameAction
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   115
    "provided for protocol compatibility with the VersionDiffBrowser;
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   116
     actually, the classes are ignored here"
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   117
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   118
    |v aStream sourceA sourceB|
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   119
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   120
    aStream := '' writeStream.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   121
    Method flushSourceStreamCache.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   122
    classA fileOutOn:aStream withTimeStamp:false.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   123
    sourceA := aStream contents asString.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   124
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   125
    aStream := '' writeStream.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   126
    Method flushSourceStreamCache.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   127
    classB fileOutOn:aStream withTimeStamp:false.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   128
    sourceB := aStream contents asString.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   129
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   130
    v := self 
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   131
            openOn:sourceA label:lblA
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   132
            and:sourceB label:lblB.      
8334
db98cf285160 window title
Claus Gittinger <cg@exept.de>
parents: 8209
diff changeset
   133
    v topView label:title.
2948
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   134
    ^ v
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   135
!
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   136
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   137
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   138
    "provided for protocol compatibility with the VersionDiffBrowser;
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   139
     actually, the class is ignored here"
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   140
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   141
    ^ self 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   142
        openOnClass:someClass 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   143
        labelA:lblA sourceA:sourceA 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   144
        labelB:lblB sourceB:sourceB 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   145
        title:'Comparing ' , someClass name.
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   146
!
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   147
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   148
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   149
    "provided for protocol compatibility with the VersionDiffBrowser;
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   150
     actually, the class is ignored here"
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   151
2848
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   152
    ^ self
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   153
        openOnClass:someClass 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   154
        labelA:lblA sourceA:sourceA 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   155
        labelB:lblB sourceB:sourceB 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   156
        title:title ifSame:nil
2848
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   157
!
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   158
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   159
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title ifSame:sameAction
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   160
    "provided for protocol compatibility with the VersionDiffBrowser;
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   161
     actually, the class is ignored here"
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   162
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   163
    |v|
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   164
2750
eed89615e816 startup bug fix
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   165
    v := self 
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   166
            openOn:sourceA label:lblA
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   167
            and:sourceB label:lblB.      
3050
56e5cc9afece *** empty log message ***
penk
parents: 2948
diff changeset
   168
    v topView label:title.
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   169
    ^ v
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   170
! !
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   171
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   172
!DiffTextView class methodsFor:'defaults'!
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   173
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   174
diffCommand
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   175
    "return the diff-command (with argument placeHolders)"
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   176
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   177
    "/ forwarded, for backward compatibility...
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   178
    ^ DiffListUtility diffCommand
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   179
!
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   180
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   181
diffCommandTemplate:aCommandTemplateString
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   182
    "set the diff-command template"
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   183
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   184
    "/ forwarded for backward compatibility
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   185
    DiffListUtility diffCommandTemplate:aCommandTemplateString
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   186
! !
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   187
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   188
!DiffTextView methodsFor:'accessing'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   189
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   190
text1:t1 text2:t2
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   191
    "set the two texts which are to be diffed;
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   192
     execute DiffCommand and update the two textViews."
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   193
6577
51b89422d7de be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents: 6413
diff changeset
   194
    |text1 text2 diffList|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   195
12383
d1476f5b8c95 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 8934
diff changeset
   196
    text1 := t1 asStringCollection.
d1476f5b8c95 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 8934
diff changeset
   197
    text2 := t2 asStringCollection.
15014
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   198
    text1 = text2 ifTrue:[
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   199
        diffList := #()
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   200
    ] ifFalse:[
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   201
        diffList := self diffListFor:text1 and:text2.
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   202
    ].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   203
    self updateListsFrom:text1 and:text2 diffs:diffList
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   204
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   205
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   206
     |v|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   207
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   208
     v := HVScrollableView for:DiffTextView.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   209
     v scrolledView text1:('../libview/Color.st' asFilename readStream contents)
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   210
                    text2:('../libview/Color.st.old' asFilename readStream contents).
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   211
     v open
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   212
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   213
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   214
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   215
     |v t1 t2|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   216
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   217
     t1 := '
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   218
one
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   219
two
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   220
three
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   221
four
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   222
'.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   223
     t2 := '
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   224
one
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   225
two-a
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   226
two-b
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   227
three
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   228
three-b
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   229
four
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   230
'.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   231
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   232
     v := DiffTextView new.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   233
     v text1:t1 text2:t2.
69
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
   234
     v open
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   235
    "
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   236
7768
a05e40490dbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   237
    "Modified: / 27-03-2007 / 12:06:46 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   238
! !
183
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
!DiffTextView methodsFor:'initialization'!
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   241
2246
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   242
addNextPreviousButtons
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   243
    super addNextPreviousButtons.
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   244
    nextPrevButtonPanel beVisible.
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   245
!
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   246
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   247
initStyle
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   248
    super initStyle.
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
    showSeparators := false.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   251
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   252
    (useColors := device hasColors) ifTrue:[
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   253
        addedColor := self whiteColor.
2240
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   254
        addedBgColor := Color red.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   255
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   256
        removedColor := self blackColor.
2240
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   257
        removedBgColor := Color green.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   258
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   259
        changedColor := self whiteColor.
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   260
        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
   261
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   262
        changedSpacesOnlyColor := self whiteColor.
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   263
        changedSpacesOnlyBgColor := Color blue lightened.
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   264
    ] ifFalse:[
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   265
        showSeparators := true.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   266
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   267
        (useColors := device hasGreyscales) ifTrue:[
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   268
            addedBgColor := removedBgColor := changedBgColor := Color grey:80.
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   269
            addedColor := removedColor := changedColor := self blackColor.
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   270
        ] ifFalse:[
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   271
            addedBgColor := removedBgColor := changedBgColor := self blackColor.
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   272
            addedColor := removedColor := changedColor := self whiteColor.
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   273
        ].
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   274
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   275
        changedSpacesOnlyColor := self whiteColor.
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   276
        changedSpacesOnlyBgColor := self blackColor.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   277
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   278
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   279
    "Created: 16.11.1995 / 16:59:48 / cg"
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   280
    "Modified: 14.6.1996 / 16:14:39 / cg"
14431
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   281
!
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   282
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   283
postRealize
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   284
    super postRealize.
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   285
    self moveToNextChanged
183
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
!DiffTextView methodsFor:'private'!
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   289
6577
51b89422d7de be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents: 6413
diff changeset
   290
diffListFor:text1 and:text2
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   291
    "return a raw difflist for the two texts which are to be diffed"
7602
cf179604a91b Quick compare if both strings are the same
Stefan Vogel <sv@exept.de>
parents: 7526
diff changeset
   292
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   293
    ^ DiffListUtility diffListFor:text1 and:text2
6577
51b89422d7de be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents: 6413
diff changeset
   294
!
51b89422d7de be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents: 6413
diff changeset
   295
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   296
processDiffList:diffList from:text1 and:text2
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   297
    "given the two texts in text1 and text2, and the diff-output in diffList,
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   298
     return new left and right lists."
7177
92e1bdd56342 oops - care for CRLF (msdos)
ca
parents: 6649
diff changeset
   299
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   300
    |idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry l1 l2 any delta s1 s2 line1 line2|
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   301
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   302
    diffList size == 1 ifTrue:[
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   303
        ^ { diffList. diffList }
6577
51b89422d7de be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents: 6413
diff changeset
   304
    ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   305
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   306
    diffLineNumbers := OrderedCollection new.
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   307
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   308
    l1 := OrderedCollection new.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   309
    l2 := OrderedCollection new.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   310
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   311
    idx1 := 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   312
    idx2 := 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
    dIdx := 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   315
    dEnd := diffList size + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   316
    state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   317
    [dIdx <= dEnd] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   318
        dIdx == dEnd ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   319
            "dummy cleanup entry"
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   320
            entry := nil.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   321
            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   322
        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   323
            entry := diffList at:dIdx.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   324
        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   325
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   326
        state == #initial ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   327
            "entry is of the form <nr> <op> <offs> [<offs2>]"
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
             fill up to size difference from previous change
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
            delta := l1 size - l2 size.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   333
            delta > 0 ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   334
                delta timesRepeat:[l2 add:nil]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   335
            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   336
                delta < 0 ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   337
                    delta negated timesRepeat:[l1 add:nil]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   338
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   339
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   340
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   341
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   342
             except for the first chunk, add a separating line
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   343
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   344
            l1 size ~~ 0 ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   345
                showSeparators ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   346
                    l1 add:'--------'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   347
                    l2 add:'--------'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   348
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   349
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   350
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   351
             in cleanup ?
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
            entry isNil ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   354
                nr1 := text1 size + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   355
                nr2 := text2 size + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   356
                state := #finish.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   357
            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   358
                s := ReadStream on:entry.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   359
                nr1 := Integer readFrom:s.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   360
                s peek == $, ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   361
                    s next.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   362
                    Integer readFrom:s
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   363
                ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   364
                op := s next.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   365
                nr2 := Integer readFrom:s.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   366
                s peek == $, ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   367
                    s next.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   368
                    nr3 := Integer readFrom:s
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
                    nr3 := nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   371
                ].
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   372
                diffLineNumbers add:{ op . nr1 . nr2 }.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   373
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   374
                op == $c ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   375
                    state := #changed.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   376
                ] ifFalse:[
2246
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   377
                    (op == $a) ifTrue:[
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   378
                        state := #added.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   379
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   380
                        op == $d ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   381
                            state := #deleted
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
                            self halt:'unexpected diff entry'.
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
                    ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   386
                ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   387
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   388
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   389
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   390
"/ 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
   391
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   392
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   393
             copy over unchanged lines
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   394
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   395
            any := false.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   396
            [idx1 < nr1] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   397
"/ '< add:' print. idx1 printNL.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   398
                l1 add:(text1 at:idx1).
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
                any := true.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   401
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   402
            [idx2 < nr2] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   403
"/ '> add:' print. idx2 printNL.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   404
                l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   405
                idx2 := idx2 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   406
                any := true.
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
            state == #added ifTrue:[
4489
0deb97a82d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4413
diff changeset
   410
                l1 add:(text1 at:idx1 ifAbsent:'').
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   411
                idx1 := idx1 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   412
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   413
            state == #deleted ifTrue:[
4489
0deb97a82d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4413
diff changeset
   414
                l2 add:(text2 at:idx2 ifAbsent:'').
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   415
                idx2 := idx2 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   416
            ].
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
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   419
             add a separating line, except at end
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   420
            "
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   421
            any ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   422
                state ~~ #finish ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   423
                    showSeparators ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   424
                        l1 add:'--------'.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   425
                        l2 add:'--------'.
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   426
                    ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   427
                ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   428
            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   429
        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   430
            state == #changed ifTrue:[
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   431
                line1 := line2 := nil.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   432
                (entry at:1) == $< ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   433
                    useColors ifTrue:[
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   434
                        (l2 size >= idx1
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   435
                        and:[(s2 := line2 := l2 at:idx1) notNil
12455
dab98ae0d660 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12383
diff changeset
   436
                        and:[(line2 asString string withoutSeparators = (line1 := text1 at:idx1) asString string withoutSeparators)
2141
1758f387ebe7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1440
diff changeset
   437
                              "/ or:[(s2 asString withoutSeparators withTabsExpanded = (text1 at:idx1) withoutSeparators withTabsExpanded)]  
1758f387ebe7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1440
diff changeset
   438
                        ]]) ifTrue:[
12455
dab98ae0d660 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12383
diff changeset
   439
                            line1 := Text string:line1 
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   440
                                         foregroundColor:changedSpacesOnlyColor
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   441
                                         backgroundColor:changedSpacesOnlyBgColor.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   442
                            line2 := Text string:line2 asString 
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   443
                                         foregroundColor:changedSpacesOnlyColor 
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   444
                                         backgroundColor:changedSpacesOnlyBgColor.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   445
2262
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   446
                            line1 string withoutTrailingSeparators = line2 string withoutTrailingSeparators ifTrue:[
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   447
                                line1 := line1 string.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   448
                                line2 := line2 string.
6413
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   449
                            ] ifFalse:[
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   450
                                line1 withoutSeparators withTabsExpanded = line2 withoutSeparators withTabsExpanded
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   451
                                ifTrue:[
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   452
                                    line1 := line1 string.
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   453
                                    line2 := line2 string.
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   454
                                ]
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   455
                            ].
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   456
                            l1 add:line1.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   457
                            l2 at:idx1 put:line2.
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   458
                        ] ifFalse:[
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   459
                            line1 := Text string:(text1 at:idx1) 
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   460
                                         foregroundColor:changedColor 
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   461
                                         backgroundColor:changedBgColor.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   462
                            l1 add:line1.
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   463
                        ]
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   464
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   465
                        l1 add:(text1 at:idx1).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   466
                    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   467
                    idx1 := idx1 + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   468
                ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   469
                    (entry at:1) == $> ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   470
                        useColors ifTrue:[
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   471
                            (l1 size >= idx2
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   472
                            and:[(s1 := line1 := l1 at:idx2) notNil
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   473
                            and:[(s1 asString string withoutSeparators = (text2 at:idx2) string withoutSeparators)
2141
1758f387ebe7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1440
diff changeset
   474
                                  "/ or:[(s1 asString withoutSeparators withTabsExpanded = (text2 at:idx2) withoutSeparators withTabsExpanded)]  
1758f387ebe7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1440
diff changeset
   475
                            ]]) ifTrue:[
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   476
                                line2 := Text string:(text2 at:idx2) 
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   477
                                            foregroundColor:changedSpacesOnlyColor 
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   478
                                            backgroundColor:changedSpacesOnlyBgColor.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   479
                                line1 := Text string:line1 asString 
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   480
                                            foregroundColor:changedSpacesOnlyColor 
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   481
                                            backgroundColor:changedSpacesOnlyBgColor.
2262
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   482
                                line1 string withoutTrailingSeparators = line2 string withoutTrailingSeparators ifTrue:[
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   483
                                    line1 := line1 string.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   484
                                    line2 := line2 string.
6413
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   485
                                ] ifFalse:[
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   486
                                    line1 withoutSeparators withTabsExpanded = line2 withoutSeparators withTabsExpanded
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   487
                                    ifTrue:[
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   488
                                        line1 := line1 string.
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   489
                                        line2 := line2 string.
ee2f36cef562 care for space vs. tab
Claus Gittinger <cg@exept.de>
parents: 6397
diff changeset
   490
                                    ]
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   491
                                ].
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   492
                                l2 add:line2.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   493
                                l1 at:idx2 put:line1.
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   494
                            ] ifFalse:[
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   495
                                line2 := Text string:(text2 at:idx2) foregroundColor:changedColor backgroundColor:changedBgColor.
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   496
                                l2 add:line2
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   497
                            ]
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   498
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   499
                            l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   500
                        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   501
                        idx2 := idx2 + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   502
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   503
                        (entry at:1) == $- ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   504
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   505
                            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   506
                            dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   507
                        ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   508
                    ]
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   509
                ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   510
            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   511
                state == #added ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   512
                    (entry at:1) == $> ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   513
                        useColors ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   514
                            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
   515
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   516
                            l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   517
                        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   518
                        idx2 := idx2 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   519
                        l1 add:nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   520
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   521
                        state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   522
                        dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   523
                    ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   524
                ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   525
                    state == #deleted ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   526
                        (entry at:1) == $< ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   527
                            useColors ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   528
                                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
   529
                            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   530
                                l1 add:(text1 at:idx1).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   531
                            ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   532
                            idx1 := idx1 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   533
                            l2 add:nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   534
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   535
                            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   536
                            dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   537
                        ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   538
                    ] 
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   539
                    "must be in finish otherwise"
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   540
                ]
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   541
            ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   542
        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   543
        dIdx := dIdx + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   544
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   545
    [l1 size < l2 size] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   546
        l1 add:''.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   547
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   548
    [l2 size < l1 size] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   549
        l2 add:''.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   550
    ].
2262
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   551
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   552
    "/ fixup - diff -b is ignoring lines which differ in leading space only ...
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   553
    1 to:l1 size do:[:idx |
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   554
        |line1 line2|
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   555
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   556
        line1 := l1 at:idx.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   557
        line2 := l2 at:idx.
2268
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   558
        (line1 notNil and:[line1 hasChangeOfEmphasis not]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   559
            (line2 notNil and:[line2 hasChangeOfEmphasis not]) ifTrue:[
2262
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   560
                line1 withTabsExpanded withoutTrailingSeparators
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   561
                ~= line2 withTabsExpanded withoutTrailingSeparators 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   562
                ifTrue:[
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   563
                    line1 := Text string:line1 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   564
                                 foregroundColor:changedSpacesOnlyColor
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   565
                                 backgroundColor:changedSpacesOnlyBgColor.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   566
                    line2 := Text string:line2 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   567
                                 foregroundColor:changedSpacesOnlyColor 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   568
                                 backgroundColor:changedSpacesOnlyBgColor.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   569
                    l1 at:idx put:line1.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   570
                    l2 at:idx put:line2.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   571
                ]
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   572
            ]        
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   573
        ]
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   574
    ].
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   575
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   576
    ^ { l1. l2 }
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   577
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   578
    "Modified: / 13.7.1999 / 14:12:11 / cg"
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   579
!
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   580
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   581
updateListsFrom:text1 and:text2 diffs:diffList
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   582
    "given the two texts in text1 and text2, and the diff-output in diffList,
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   583
     update my views contents"
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   584
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   585
    |lists textView1 textView2|
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   586
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   587
    textView1 := textViews at:1.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   588
    textView2 := textViews at:2.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   589
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   590
    lists := self processDiffList:diffList from:text1 and:text2.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   591
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   592
    textView1 list:lists first.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   593
    textView2 list:lists second.
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   594
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   595
    self updateScrollbarBackground
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   596
!
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   597
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   598
updateScrollbarBackground
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   599
    "define a background in the scroller allowing quick positioning to changes"
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   600
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   601
    |container vScroller thumb|
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   602
16329
8727c046cfe7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16246
diff changeset
   603
    ((container := self container) notNil
8727c046cfe7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16246
diff changeset
   604
    and:[container isScrollWrapper]) ifTrue:[
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   605
        (vScroller := container verticalScrollBar) notNil ifTrue:[
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   606
            (thumb := vScroller thumb) notNil ifTrue:[
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   607
                thumb viewBackground:(DiffTextScrollerBackground new diffView:self).
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   608
            ]
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   609
        ]
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   610
    ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   611
! !
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   612
14984
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   613
!DiffTextView::DiffTextScrollerBackground class methodsFor:'documentation'!
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   614
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   615
documentation
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   616
"
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   617
    I am a scroller background used by the diff-text-viewers.
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   618
    I draws line-markers at positions where differences between two texts are.
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   619
"
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   620
! !
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   621
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   622
!DiffTextView::DiffTextScrollerBackground methodsFor:'accessing'!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   623
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   624
diffView:something
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   625
    diffView := something.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   626
! !
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   627
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   628
!DiffTextView::DiffTextScrollerBackground methodsFor:'drawing'!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   629
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   630
fillRectangleX:x y:y width:w height:h in:aScroller
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   631
    |leftTextView rightTextView overAllHeight|
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   632
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   633
    leftTextView := diffView textViews first.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   634
    rightTextView := diffView textViews second.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   635
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   636
    overAllHeight := leftTextView numberOfLines.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   637
    1 to:overAllHeight do:[:lineNr |
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   638
        |l1 l2 isDiff yThumb clr e|
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   639
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   640
        yThumb := (aScroller height * (lineNr / overAllHeight)) rounded.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   641
        (yThumb >= y and:[yThumb <= (y+h)]) ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   642
            l1 := leftTextView listAt:lineNr.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   643
            l2 := rightTextView listAt:lineNr.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   644
            (l1 notNil and:[l1 isText]) ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   645
                e := l1 emphasis
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   646
            ] ifFalse:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   647
                (l2 notNil and:[l2 isText ]) ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   648
                    e := l2 emphasis
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   649
                ]
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   650
            ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   651
            e size > 0 ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   652
                |el|
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   653
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   654
                el := e detect:[:el | (Text extractEmphasis:#backgroundColor from:el) notNil] ifNone:nil.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   655
                el notNil ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   656
                    clr := Text extractEmphasis:#backgroundColor from:el.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   657
                    (clr brightness > 0.5) ifTrue:[ clr := clr darkened ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   658
                    aScroller paint:clr.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   659
                    aScroller displayLineFromX:1 y:yThumb toX:aScroller width-2 y:yThumb.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   660
                ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   661
            ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   662
        ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   663
    ]
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   664
! !
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   665
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   666
!DiffTextView::DiffTextScrollerBackground methodsFor:'ignored conversion'!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   667
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   668
asFormOn:aDevice
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   669
    "superclass AbstractBackground says that I am responsible to implement this method"
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   670
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   671
    ^ self 
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   672
!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   673
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   674
onDevice:aDevice
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   675
    "superclass AbstractBackground says that I am responsible to implement this method"
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   676
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   677
    ^ self 
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   678
! !
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   679
242
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   680
!DiffTextView class methodsFor:'documentation'!
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   681
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   682
version
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   683
    ^ '$Header$'
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   684
!
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   685
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   686
version_CVS
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   687
    ^ '$Header$'
2268
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   688
! !
12383
d1476f5b8c95 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 8934
diff changeset
   689