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