Diff3TextView.st
author Claus Gittinger <cg@exept.de>
Mon, 09 Sep 1996 20:41:46 +0200
changeset 713 bbed5ec2fbeb
parent 290 5b9361cfa7b8
child 2245 0d94b4d7d4bc
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
     3
              All Rights Reserved
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
ThreeColumnTextView subclass:#Diff3TextView
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
		removedBgColor changedColor changedBgColor'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Views-Text'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    21
!Diff3TextView  class methodsFor:'documentation'!
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    26
              All Rights Reserved
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    39
    a view showing merged diff3 (see rcsmerge / merge unix manual pages) output in a 
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    user-friendly form.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    The view is created and opened with:
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    43
       d := Diff3TextView openOn:text label:l1 label:l2 label:l3.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    45
    and it will show the 3 versions side-by-side
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    46
    Its main use is for the SourceCodeManager, to show merged sources after
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    47
    a failed checkin.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    51
!Diff3TextView  class methodsFor:'instance creation'!
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
openOnMergedText:text label:firstLabel label:secondLabel label:thirdLabel
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    "open up a view showing firstText, secondText and thirdText side-by-side,
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
     and labels for all views."
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    |top v l1 l2 l3|
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    top := StandardSystemView label:'three texts'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    l1 := Label label:firstLabel in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    l1 origin:0.0@0.0 corner:0.33@(l1 height).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    l2 := Label label:secondLabel in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    l2 origin:0.33@0.0 corner:0.67@(l1 height).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    l3 := Label label:thirdLabel in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    l3 origin:0.67@0.0 corner:1.0@(l1 height).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    v := HVScrollableView 
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
               for:self 
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
               miniScrollerH:true miniScrollerV:false
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
               in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    v origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    v scrolledView updateListsFromMergedText:text.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    ^ top open
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
     ThreeColumnTextView
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
        openOn:('smalltalk.rc' asFilename contentsOfEntireFile)
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
        label:'smalltalk.rc'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        and:('display.rc' asFilename contentsOfEntireFile)
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
        label:'display.rc'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
        and:('private.rc' asFilename contentsOfEntireFile)
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        label:'private.rc'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    "Modified: 12.12.1995 / 13:09:13 / cg"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    89
!Diff3TextView  class methodsFor:'public helpers'!
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    90
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    91
emphasizeMergedDiff3Text:mergedText emphasize1:e1 emphasize2:e2 emphasizeSep:e3
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    92
    "given the merge()/rcsmerge() merged output (as created by 'cvs update'),
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    93
     create & return a text object which contains the conflicts 
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    94
     highlighted.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    95
     CAVEAT: this is a highly specialized method - probably not the right place
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    96
     for it here ..."
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    97
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    98
    |dIdx dEnd state s entry c list skip sep|
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
    99
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   100
    list := OrderedCollection new.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   101
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   102
    dIdx := 1.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   103
    dEnd := mergedText size + 1.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   104
    state := #initial.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   105
    [dIdx < dEnd] whileTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   106
        dIdx == dEnd ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   107
            "dummy cleanup entry"
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   108
            entry := nil.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   109
            state := #initial.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   110
        ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   111
            entry := mergedText at:dIdx.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   112
            dIdx := dIdx + 1.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   113
        ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   114
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   115
        skip := false.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   116
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   117
        entry notNil ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   118
            sep := nil.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   119
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   120
            (entry startsWith:'<<<<<<<') ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   121
                state := 1. skip := true. sep := '----- your version ----'.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   122
            ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   123
                (entry startsWith:'|||||||') ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   124
                    state := 2. skip := true.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   125
                ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   126
                    (entry startsWith:'=======') ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   127
                        state == 2 ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   128
                            state := 23        "/ on both 2 and 3
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   129
                        ] ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   130
                            state := 3         "/ only in 3
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   131
                        ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   132
                        skip := true.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   133
                        sep := '----- other version ----'.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   134
                    ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   135
                        (entry startsWith:'>>>>>>>') ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   136
                            state := #initial.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   137
                            skip := true.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   138
                            sep := '------------------------'.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   139
                        ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   140
                    ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   141
                ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   142
            ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   143
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   144
            sep notNil ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   145
                list add:(Text 
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   146
                            string:sep 
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   147
                            emphasis:e3).
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   148
            ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   149
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   150
            skip ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   151
                state == #initial ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   152
                    list add:entry
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   153
                ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   154
                state == 1 ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   155
                    e1 notNil ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   156
                        list add:(Text string:entry emphasis:e1)
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   157
                    ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   158
                        list add:entry
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   159
                    ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   160
                ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   161
                (state == 3 or:[state == 23]) ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   162
                    e2 notNil ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   163
                        list add:(Text string:entry emphasis:e2)
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   164
                    ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   165
                        list add:entry
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   166
                    ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   167
                ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   168
            ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   169
        ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   170
    ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   171
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   172
    ^ list
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   173
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   174
    "Created: 9.9.1996 / 19:54:00 / cg"
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   175
    "Modified: 9.9.1996 / 20:41:40 / cg"
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   176
! !
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   177
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
!Diff3TextView methodsFor:'initialization'!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
initStyle
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    super initStyle.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    showSeparators := false.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    useColors := ColoredListEntry notNil.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    useColors ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
	device hasColors ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
	    addedColor := Color black.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
	    addedBgColor := Color green.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
	    removedColor := Color white.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
	    removedBgColor := Color red.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
	    changedColor := Color white.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
	    changedBgColor := Color blue.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
	] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
	    addedBgColor := removedBgColor := changedBgColor := Color black.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
	    addedColor := removedColor := changedColor := Color white.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
	]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    "Created: 16.11.1995 / 16:59:48 / cg"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    "Modified: 12.12.1995 / 12:25:55 / cg"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
!Diff3TextView methodsFor:'private'!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
updateListsFromMergedText:mergedText
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    "given the merge()/rcsmerge() merged output (as created by 'cvs update'),
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
     update my views contents"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    |idx1 idx2 idx3 dIdx dEnd state s nr1 nr2 nr3 entry c l1 l2 l3  
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
     textView1 textView2 textView3 skip max|
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
    textView1 := textViews at:1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    textView2 := textViews at:2.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    textView3 := textViews at:3.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    l1 := OrderedCollection new.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    l2 := OrderedCollection new.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    l3 := OrderedCollection new.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    idx1 := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    idx2 := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    idx3 := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    dIdx := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    dEnd := mergedText size + 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    state := #initial.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    [dIdx < dEnd] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        dIdx == dEnd ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
            "dummy cleanup entry"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
            entry := nil.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
            state := #initial.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
        ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
            entry := mergedText at:dIdx.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
            dIdx := dIdx + 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
        ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
        state == #initial ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
             fill up to size difference from previous change
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
            max := (l1 size max:l2 size) max:l3 size.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
            [l1 size < max] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
                l1 add:nil
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
            [l2 size < max] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
                l2 add:nil
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
            [l3 size < max] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
                l3 add:nil
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
        
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
             except for the first chunk, add a separating line
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
            l1 size ~~ 0 ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
                showSeparators ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
                    l1 add:'--------'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
                    l2 add:'--------'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
                    l3 add:'--------'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
                ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
        ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
        skip := false.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
        entry notNil ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
            (entry startsWith:'<<<<<<<') ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
                state := 1. skip := true.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
            ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
                (entry startsWith:'|||||||') ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
                    state := 2. skip := true.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
                ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
                    (entry startsWith:'=======') ifTrue:[
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   277
                        state == 2 ifFalse:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   278
                            state := 23        "/ on both 2 and 3
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   279
                        ] ifTrue:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   280
                            state := 3         "/ only in 3
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   281
                        ].
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   282
                        skip := true.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
                        (entry startsWith:'>>>>>>>') ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
                            state := #initial.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
                            skip := true.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
                        ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
                ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
            skip ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
                (state == #initial or:[state == 1]) ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
                    (useColors and:[state == 1]) ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
                        l1 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
                        l1 add:entry
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
                ].
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   300
                (state == #initial or:[state == 2 or:[state == 23]]) ifTrue:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   301
                    (useColors and:[state == 2 or:[state == 23]]) ifTrue:[
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
                        l2 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
                        l2 add:entry
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
                ].
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   307
                (state == #initial or:[state == 3 or:[state == 23]]) ifTrue:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   308
                    (useColors and:[state == 3 or:[state == 23]]) ifTrue:[
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
                        l3 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
                        l3 add:entry
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
                ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
        ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
        
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    textView1 list:l1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    textView2 list:l2.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    textView3 list:l3.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   322
    "Modified: 13.12.1995 / 19:56:32 / cg"
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   325
!Diff3TextView  class methodsFor:'documentation'!
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
version
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   328
^ '$Header: /cvs/stx/stx/libtool/Diff3TextView.st,v 1.4 1996-09-09 18:41:46 cg Exp $'
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
! !