DiffTextView.st
author Claus Gittinger <cg@exept.de>
Wed, 05 Jun 2019 14:16:59 +0200
changeset 18805 f6df57c6dbfb
parent 18278 0aafdc282b1c
child 19289 12fbc454fa61
permissions -rw-r--r--
#BUGFIX by cg class: AbstractFileBrowser changed: #currentFileNameHolder endless loop if file not present.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     1
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
     3
	      All Rights Reserved
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     4
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    10
 hereby transferred.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    11
"
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
    12
"{ Package: 'stx:libtool' }"
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
    13
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
    14
"{ NameSpace: Smalltalk }"
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
    15
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    16
TwoColumnTextView subclass:#DiffTextView
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    17
	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    18
		removedBgColor changedColor changedBgColor changedSpacesOnlyColor
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    19
		changedSpacesOnlyBgColor diffLineNumbers'
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
    20
	classVariableNames:'DiffCommandTemplate'
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    21
	poolDictionaries:''
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    22
	category:'Views-Text'
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    23
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    24
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    25
AbstractBackground subclass:#DiffTextScrollerBackground
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    26
	instanceVariableNames:'diffView'
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    27
	classVariableNames:''
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    28
	poolDictionaries:''
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    29
	privateIn:DiffTextView
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    30
!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
    31
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    32
!DiffTextView class methodsFor:'documentation'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    33
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    34
copyright
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    35
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    36
 COPYRIGHT (c) 1994 by Claus Gittinger
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
    37
	      All Rights Reserved
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    38
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    39
 This software is furnished under a license and may be used
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    40
 only in accordance with the terms of that license and with the
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    42
 be provided or otherwise made available to, or used by, any
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    43
 other person.  No title to or ownership of the software is
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    44
 hereby transferred.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    45
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    46
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    47
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    48
documentation
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    49
"
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    50
    a view showing diff output (see unix manual pages)
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    51
    in a user-friendly form.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    52
    The view is created and opened with:
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    53
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    54
        d := DiffTextView openOn:text1 and:text2
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    55
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    56
    or:
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    57
        d := DiffTextView openOn:text1 label:l1
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    58
                             and:text2 label:l2
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    59
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    60
    and it will show the differences side-by-side.
533
5bf1a4a2adad checkin from browser
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
    61
2240
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    62
    The colors mean:
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    63
        red             - removed
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    64
        green           - added
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    65
        blue            - changed
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    66
        light-blue        changed, but not really (i.e. spaces only)
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    67
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    68
    For a real world application and use of this widget, 
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    69
    see the ChangesBrowsers `compare', 
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
    70
    or the browsers 'compare with repository' functions.
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    71
2246
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    72
    Notice:
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    73
        A diff command must be available on your system and found
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    74
        along the PATH (you will see a warning on stderr, if there is no diff).
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    75
        We use gnu-diff.
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
    76
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
    77
    [see also:]
1276
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    78
        TextView EditTextView Diff3TextView
519
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    79
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    80
    [author:]
95f7a0a41c05 documentation
Claus Gittinger <cg@exept.de>
parents: 507
diff changeset
    81
        Claus Gittinger
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    82
"
1276
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    83
!
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    84
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    85
examples
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    86
"
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    87
                                                        [exBegin]
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    88
    |text1 text2|
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    89
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    90
    text1 := 'hello world
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    91
here is some difference
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    92
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    93
this line has been removed
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    94
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    95
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    96
'.
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    97
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    98
    text2 := 'hello world
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    99
where is the difference ?
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   100
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   101
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   102
more text
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   103
this line has been added
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   104
'.
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   105
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   106
    DiffTextView openOn:text1 label:'text1'
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   107
                    and:text2 label:'text2'
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   108
                                                        [exEnd]
66761d461a39 added example
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   109
"
242
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   110
! !
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   111
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   112
!DiffTextView class methodsFor:'instance creation'!
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   113
2948
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   114
openOnClass:classA labelA:lblA andClass:classB labelB:lblB title:title ifSame:sameAction
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   115
    "provided for protocol compatibility with the VersionDiffBrowser;
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   116
     actually, the classes are ignored here"
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   117
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   118
    |v aStream sourceA sourceB|
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   119
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   120
    aStream := '' writeStream.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   121
    Method flushSourceStreamCache.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   122
    classA fileOutOn:aStream withTimeStamp:false.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   123
    sourceA := aStream contents asString.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   124
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   125
    aStream := '' writeStream.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   126
    Method flushSourceStreamCache.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   127
    classB fileOutOn:aStream withTimeStamp:false.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   128
    sourceB := aStream contents asString.
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   129
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   130
    v := self 
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   131
            openOn:sourceA label:lblA
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   132
            and:sourceB label:lblB.      
8334
db98cf285160 window title
Claus Gittinger <cg@exept.de>
parents: 8209
diff changeset
   133
    v topView label:title.
2948
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   134
    ^ v
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   135
!
cf5b7f232536 VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   136
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   137
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   138
    "provided for protocol compatibility with the VersionDiffBrowser;
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   139
     actually, the class is ignored here"
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   140
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   141
    ^ self 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   142
        openOnClass:someClass 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   143
        labelA:lblA sourceA:sourceA 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   144
        labelB:lblB sourceB:sourceB 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   145
        title:'Comparing ' , someClass name.
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   146
!
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   147
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   148
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   149
    "provided for protocol compatibility with the VersionDiffBrowser;
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   150
     actually, the class is ignored here"
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   151
2848
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   152
    ^ self
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   153
        openOnClass:someClass 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   154
        labelA:lblA sourceA:sourceA 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   155
        labelB:lblB sourceB:sourceB 
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   156
        title:title ifSame:nil
2848
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   157
!
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   158
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   159
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title ifSame:sameAction
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   160
    "provided for protocol compatibility with the VersionDiffBrowser;
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   161
     actually, the class is ignored here"
1b7a2ff36ccc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2750
diff changeset
   162
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   163
    |v|
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   164
2750
eed89615e816 startup bug fix
Claus Gittinger <cg@exept.de>
parents: 2716
diff changeset
   165
    v := self 
3755
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   166
            openOn:sourceA label:lblA
603db82a35b2 code formatted only
Claus Gittinger <cg@exept.de>
parents: 3678
diff changeset
   167
            and:sourceB label:lblB.      
3050
56e5cc9afece *** empty log message ***
penk
parents: 2948
diff changeset
   168
    v topView label:title.
2716
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   169
    ^ v
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   170
! !
8451e7057f00 some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
   171
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   172
!DiffTextView class methodsFor:'defaults'!
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   173
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   174
diffCommand
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   175
    "return the diff-command (with argument placeHolders)"
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   176
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   177
    "/ forwarded, for backward compatibility...
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   178
    ^ DiffListUtility diffCommand
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   179
!
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   180
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   181
diffCommandTemplate:aCommandTemplateString
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   182
    "set the diff-command template"
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   183
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   184
    "/ forwarded for backward compatibility
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   185
    DiffListUtility diffCommandTemplate:aCommandTemplateString
45
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   186
! !
950b84ba89e6 *** empty log message ***
claus
parents: 36
diff changeset
   187
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   188
!DiffTextView methodsFor:'accessing'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   189
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   190
text1:t1 text2:t2
1440
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   191
    "set the two texts which are to be diffed;
6a68adba9c33 allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents: 1276
diff changeset
   192
     execute DiffCommand and update the two textViews."
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   193
6577
51b89422d7de be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents: 6413
diff changeset
   194
    |text1 text2 diffList|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   195
12383
d1476f5b8c95 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 8934
diff changeset
   196
    text1 := t1 asStringCollection.
d1476f5b8c95 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 8934
diff changeset
   197
    text2 := t2 asStringCollection.
15014
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   198
    text1 = text2 ifTrue:[
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   199
        diffList := #()
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   200
    ] ifFalse:[
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   201
        diffList := self diffListFor:text1 and:text2.
57e3d245860c class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14984
diff changeset
   202
    ].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   203
    self updateListsFrom:text1 and:text2 diffs:diffList
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   204
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   205
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   206
     |v|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   207
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   208
     v := HVScrollableView for:DiffTextView.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   209
     v scrolledView text1:('../libview/Color.st' asFilename readStream contents)
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   210
                    text2:('../libview/Color.st.old' asFilename readStream contents).
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   211
     v open
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   212
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   213
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   214
    "
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   215
     |v t1 t2|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   216
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   217
     t1 := '
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   218
one
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   219
two
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   220
three
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   221
four
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   222
'.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   223
     t2 := '
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   224
one
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   225
two-a
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   226
two-b
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   227
three
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   228
three-b
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   229
four
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   230
'.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   231
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   232
     v := DiffTextView new.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   233
     v text1:t1 text2:t2.
69
0d6acfdae045 *** empty log message ***
claus
parents: 52
diff changeset
   234
     v open
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   235
    "
507
90ed76da5ade commentary
Claus Gittinger <cg@exept.de>
parents: 318
diff changeset
   236
7768
a05e40490dbb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7602
diff changeset
   237
    "Modified: / 27-03-2007 / 12:06:46 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   238
! !
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   239
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   240
!DiffTextView methodsFor:'initialization'!
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   241
2246
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   242
addNextPreviousButtons
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   243
    super addNextPreviousButtons.
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   244
    nextPrevButtonPanel beVisible.
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   245
!
34262ef77055 comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents: 2240
diff changeset
   246
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   247
initStyle
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   248
    super initStyle.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   249
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   250
    showSeparators := false.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   251
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   252
    (useColors := device hasColors) ifTrue:[
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   253
        addedColor := self whiteColor.
2240
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   254
        addedBgColor := Color red.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   255
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   256
        removedColor := self blackColor.
2240
eb2688b9cf45 exchanged red/green colors.
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   257
        removedBgColor := Color green.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   258
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   259
        changedColor := self whiteColor.
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   260
        changedBgColor := Color blue.
313
c143d37be2e9 lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   261
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   262
        changedSpacesOnlyColor := self whiteColor.
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   263
        changedSpacesOnlyBgColor := Color blue lightened.
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   264
    ] ifFalse:[
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   265
        showSeparators := true.
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   266
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   267
        (useColors := device hasGreyscales) ifTrue:[
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   268
            addedBgColor := removedBgColor := changedBgColor := Color grey:80.
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   269
            addedColor := removedColor := changedColor := self blackColor.
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   270
        ] ifFalse:[
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   271
            addedBgColor := removedBgColor := changedBgColor := self blackColor.
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   272
            addedColor := removedColor := changedColor := self whiteColor.
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   273
        ].
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   274
16744
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   275
        changedSpacesOnlyColor := self whiteColor.
072de442c2fa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16329
diff changeset
   276
        changedSpacesOnlyBgColor := self blackColor.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   277
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   278
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   279
    "Created: 16.11.1995 / 16:59:48 / cg"
623
48cc09809032 fixed for greyscale displays
Claus Gittinger <cg@exept.de>
parents: 544
diff changeset
   280
    "Modified: 14.6.1996 / 16:14:39 / cg"
14431
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   281
!
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   282
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   283
postRealize
db727d8b39c6 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13954
diff changeset
   284
    super postRealize.
18278
0aafdc282b1c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17817
diff changeset
   285
    self moveToNextChangedAfter:1
0aafdc282b1c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17817
diff changeset
   286
0aafdc282b1c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17817
diff changeset
   287
    "Modified: / 23-07-2018 / 09:47:19 / Claus Gittinger"
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
17817
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   302
    |idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry l1 l2 any delta s1 s2 line1 line2 common|
8934
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
17817
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   438
                        and:[(line2 asString string withTabsExpanded withoutSeparators = (line1 := text1 at:idx1) asString string withTabsExpanded 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
17817
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   475
                            and:[(s1 asString string withTabsExpanded withoutSeparators = (text2 at:idx2) string withTabsExpanded 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:[
17817
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   497
                                line2 := text2 at:idx2.
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   498
                                line1 notNil ifTrue:[
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   499
                                    common := line1 string commonPrefixWith: line2 string.
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   500
                                ] ifFalse:[
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   501
                                    common := nil
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   502
                                ].    
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   503
                                common size > 0 ifTrue:[
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   504
                                    line2 := (Text string:common foregroundColor:changedSpacesOnlyColor backgroundColor:changedSpacesOnlyBgColor)
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   505
                                             , (Text string:(line2 copyFrom:common size+1) foregroundColor:changedColor backgroundColor:changedBgColor).
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   506
                                ] ifFalse:[    
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   507
                                    line2 := Text string:line2 foregroundColor:changedColor backgroundColor:changedBgColor.
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   508
                                ].
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   509
                                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
   510
                            ]
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   511
                        ] ifFalse:[
17817
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   512
                            l2 add:line2.
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   513
                        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   514
                        idx2 := idx2 + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   515
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   516
                        (entry at:1) == $- ifTrue:[
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
                            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   519
                            dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   520
                        ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   521
                    ]
2260
2c093fe9ddb1 fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents: 2246
diff changeset
   522
                ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   523
            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   524
                state == #added ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   525
                    (entry at:1) == $> ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   526
                        useColors ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   527
                            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
   528
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   529
                            l2 add:(text2 at:idx2).
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   530
                        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   531
                        idx2 := idx2 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   532
                        l1 add:nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   533
                    ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   534
                        state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   535
                        dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   536
                    ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   537
                ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   538
                    state == #deleted ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   539
                        (entry at:1) == $< ifTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   540
                            useColors ifTrue:[
544
dea45065e7f1 use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   541
                                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
   542
                            ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   543
                                l1 add:(text1 at:idx1).
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
                            idx1 := idx1 + 1.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   546
                            l2 add:nil
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   547
                        ] ifFalse:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   548
                            state := #initial.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   549
                            dIdx := dIdx - 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   550
                        ]
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   551
                    ] 
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   552
                    "must be in finish otherwise"
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   553
                ]
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   554
            ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   555
        ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   556
        dIdx := dIdx + 1
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   557
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   558
    [l1 size < l2 size] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   559
        l1 add:''.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   560
    ].
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   561
    [l2 size < l1 size] whileTrue:[
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   562
        l2 add:''.
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   563
    ].
2262
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   564
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   565
    "/ 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
   566
    1 to:l1 size do:[:idx |
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   567
        |line1 line2|
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   568
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   569
        line1 := l1 at:idx.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   570
        line2 := l2 at:idx.
2268
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   571
        (line1 notNil and:[line1 hasChangeOfEmphasis not]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   572
            (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
   573
                line1 withTabsExpanded withoutTrailingSeparators
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   574
                ~= line2 withTabsExpanded withoutTrailingSeparators 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   575
                ifTrue:[
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   576
                    line1 := Text string:line1 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   577
                                 foregroundColor:changedSpacesOnlyColor
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   578
                                 backgroundColor:changedSpacesOnlyBgColor.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   579
                    line2 := Text string:line2 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   580
                                 foregroundColor:changedSpacesOnlyColor 
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   581
                                 backgroundColor:changedSpacesOnlyBgColor.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   582
                    l1 at:idx put:line1.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   583
                    l2 at:idx put:line2.
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   584
                ]
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   585
            ]        
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   586
        ]
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   587
    ].
75d490e87d95 oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents: 2260
diff changeset
   588
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   589
    ^ { l1. l2 }
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   590
17817
1b622818977b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 17396
diff changeset
   591
    "Modified: / 29-11-2017 / 11:06:54 / cg"
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   592
!
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
updateListsFrom:text1 and:text2 diffs:diffList
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   595
    "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
   596
     update my views contents"
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   597
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   598
    |lists textView1 textView2|
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   599
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   600
    textView1 := textViews at:1.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   601
    textView2 := textViews at:2.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   602
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   603
    lists := self processDiffList:diffList from:text1 and:text2.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   604
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   605
    textView1 list:lists first.
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   606
    textView2 list:lists second.
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   607
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   608
    self updateScrollbarBackground
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   609
!
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   610
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   611
updateScrollbarBackground
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   612
    "define a background in the scroller allowing quick positioning to changes"
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   613
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   614
    |container vScroller thumb|
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   615
16329
8727c046cfe7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16246
diff changeset
   616
    ((container := self container) notNil
8727c046cfe7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16246
diff changeset
   617
    and:[container isScrollWrapper]) ifTrue:[
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   618
        (vScroller := container verticalScrollBar) notNil ifTrue:[
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   619
            (thumb := vScroller thumb) notNil ifTrue:[
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   620
                thumb viewBackground:(DiffTextScrollerBackground new diffView:self).
13784
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   621
            ]
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   622
        ]
0b7b083dc0e4 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 12455
diff changeset
   623
    ].
183
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   624
! !
908f1f2c3ca0 added labels to diff-view
Claus Gittinger <cg@exept.de>
parents: 178
diff changeset
   625
14984
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   626
!DiffTextView::DiffTextScrollerBackground class methodsFor:'documentation'!
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   627
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   628
documentation
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   629
"
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   630
    I am a scroller background used by the diff-text-viewers.
17396
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   631
    I draw line-markers at positions where differences between two texts are.
14984
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   632
"
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   633
! !
f793f5784905 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 14431
diff changeset
   634
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   635
!DiffTextView::DiffTextScrollerBackground methodsFor:'accessing'!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   636
17396
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   637
diffView:aDiffTextView
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   638
    diffView := aDiffTextView.
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   639
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   640
    "Modified (format): / 12-02-2017 / 12:53:09 / cg"
13793
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
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   643
!DiffTextView::DiffTextScrollerBackground methodsFor:'drawing'!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   644
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   645
fillRectangleX:x y:y width:w height:h in:aScroller
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   646
    |leftTextView rightTextView overAllHeight|
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   647
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   648
    leftTextView := diffView textViews first.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   649
    rightTextView := diffView textViews second.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   650
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   651
    overAllHeight := leftTextView numberOfLines.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   652
    1 to:overAllHeight do:[:lineNr |
17396
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   653
        |l1 l2 yThumb clr e|
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   654
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   655
        yThumb := (aScroller height * (lineNr / overAllHeight)) rounded.
17396
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   656
        (yThumb between:y and:(y + h)) ifTrue:[
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   657
            l1 := leftTextView listAt:lineNr.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   658
            l2 := rightTextView listAt:lineNr.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   659
            (l1 notNil and:[l1 isText]) ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   660
                e := l1 emphasis
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   661
            ] ifFalse:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   662
                (l2 notNil and:[l2 isText ]) ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   663
                    e := l2 emphasis
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
            ].
17396
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   666
            e notEmptyOrNil ifTrue:[
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   667
                |el|
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   668
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   669
                el := e detect:[:el | (Text extractEmphasis:#backgroundColor from:el) notNil] ifNone:nil.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   670
                el notNil ifTrue:[
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   671
                    clr := Text extractEmphasis:#backgroundColor from:el.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   672
                    (clr brightness > 0.5) ifTrue:[ clr := clr darkened ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   673
                    aScroller paint:clr.
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   674
                    aScroller displayLineFromX:1 y:yThumb toX:aScroller width-2 y:yThumb.
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
            ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   677
        ].
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   678
    ]
17396
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   679
cdea4100c71b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 16744
diff changeset
   680
    "Modified: / 12-02-2017 / 12:54:36 / cg"
13793
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   681
! !
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   682
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   683
!DiffTextView::DiffTextScrollerBackground methodsFor:'ignored conversion'!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   684
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   685
asFormOn:aDevice
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   686
    "superclass AbstractBackground says that I am responsible to implement this method"
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   687
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   688
    ^ self 
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   689
!
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   690
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   691
onDevice:aDevice
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   692
    "superclass AbstractBackground says that I am responsible to implement this method"
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   693
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   694
    ^ self 
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   695
! !
bbc2c030ce04 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 13786
diff changeset
   696
242
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   697
!DiffTextView class methodsFor:'documentation'!
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   698
85bf88a27903 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   699
version
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   700
    ^ '$Header$'
8934
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   701
!
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   702
7cc2affd9bb9 started to refactor into DiffListUtility
Claus Gittinger <cg@exept.de>
parents: 8676
diff changeset
   703
version_CVS
16246
c5c24804be28 device access
Claus Gittinger <cg@exept.de>
parents: 15014
diff changeset
   704
    ^ '$Header$'
2268
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   705
! !
12383
d1476f5b8c95 class: DiffTextView
Claus Gittinger <cg@exept.de>
parents: 8934
diff changeset
   706