checkin from browser
authorClaus Gittinger <cg@exept.de>
Mon, 09 Sep 1996 20:41:46 +0200
changeset 713 bbed5ec2fbeb
parent 712 72dd9d6a9ea3
child 714 3caae72f99d2
checkin from browser
Diff3TextView.st
Diff3TxtV.st
--- a/Diff3TextView.st	Mon Sep 09 18:55:51 1996 +0200
+++ b/Diff3TextView.st	Mon Sep 09 20:41:46 1996 +0200
@@ -18,7 +18,7 @@
 	category:'Views-Text'
 !
 
-!Diff3TextView class methodsFor:'documentation'!
+!Diff3TextView  class methodsFor:'documentation'!
 
 copyright
 "
@@ -48,7 +48,7 @@
 "
 ! !
 
-!Diff3TextView class methodsFor:'instance creation'!
+!Diff3TextView  class methodsFor:'instance creation'!
 
 openOnMergedText:text label:firstLabel label:secondLabel label:thirdLabel
     "open up a view showing firstText, secondText and thirdText side-by-side,
@@ -86,6 +86,95 @@
     "Modified: 12.12.1995 / 13:09:13 / cg"
 ! !
 
+!Diff3TextView  class methodsFor:'public helpers'!
+
+emphasizeMergedDiff3Text:mergedText emphasize1:e1 emphasize2:e2 emphasizeSep:e3
+    "given the merge()/rcsmerge() merged output (as created by 'cvs update'),
+     create & return a text object which contains the conflicts 
+     highlighted.
+     CAVEAT: this is a highly specialized method - probably not the right place
+     for it here ..."
+
+    |dIdx dEnd state s entry c list skip sep|
+
+    list := OrderedCollection new.
+
+    dIdx := 1.
+    dEnd := mergedText size + 1.
+    state := #initial.
+    [dIdx < dEnd] whileTrue:[
+        dIdx == dEnd ifTrue:[
+            "dummy cleanup entry"
+            entry := nil.
+            state := #initial.
+        ] ifFalse:[
+            entry := mergedText at:dIdx.
+            dIdx := dIdx + 1.
+        ].
+
+        skip := false.
+
+        entry notNil ifTrue:[
+            sep := nil.
+
+            (entry startsWith:'<<<<<<<') ifTrue:[
+                state := 1. skip := true. sep := '----- your version ----'.
+            ] ifFalse:[
+                (entry startsWith:'|||||||') ifTrue:[
+                    state := 2. skip := true.
+                ] ifFalse:[
+                    (entry startsWith:'=======') ifTrue:[
+                        state == 2 ifFalse:[
+                            state := 23        "/ on both 2 and 3
+                        ] ifTrue:[
+                            state := 3         "/ only in 3
+                        ].
+                        skip := true.
+                        sep := '----- other version ----'.
+                    ] ifFalse:[
+                        (entry startsWith:'>>>>>>>') ifTrue:[
+                            state := #initial.
+                            skip := true.
+                            sep := '------------------------'.
+                        ]
+                    ]
+                ]
+            ].
+
+            sep notNil ifTrue:[
+                list add:(Text 
+                            string:sep 
+                            emphasis:e3).
+            ].
+
+            skip ifFalse:[
+                state == #initial ifTrue:[
+                    list add:entry
+                ].
+                state == 1 ifTrue:[
+                    e1 notNil ifTrue:[
+                        list add:(Text string:entry emphasis:e1)
+                    ] ifFalse:[
+                        list add:entry
+                    ]
+                ].
+                (state == 3 or:[state == 23]) ifTrue:[
+                    e2 notNil ifTrue:[
+                        list add:(Text string:entry emphasis:e2)
+                    ] ifFalse:[
+                        list add:entry
+                    ]
+                ].
+            ].
+        ].
+    ].
+
+    ^ list
+
+    "Created: 9.9.1996 / 19:54:00 / cg"
+    "Modified: 9.9.1996 / 20:41:40 / cg"
+! !
+
 !Diff3TextView methodsFor:'initialization'!
 
 initStyle
@@ -233,8 +322,8 @@
     "Modified: 13.12.1995 / 19:56:32 / cg"
 ! !
 
-!Diff3TextView class methodsFor:'documentation'!
+!Diff3TextView  class methodsFor:'documentation'!
 
 version
-^ '$Header: /cvs/stx/stx/libtool/Diff3TextView.st,v 1.3 1995-12-13 19:03:36 cg Exp $'
+^ '$Header: /cvs/stx/stx/libtool/Diff3TextView.st,v 1.4 1996-09-09 18:41:46 cg Exp $'
 ! !
--- a/Diff3TxtV.st	Mon Sep 09 18:55:51 1996 +0200
+++ b/Diff3TxtV.st	Mon Sep 09 20:41:46 1996 +0200
@@ -18,7 +18,7 @@
 	category:'Views-Text'
 !
 
-!Diff3TextView class methodsFor:'documentation'!
+!Diff3TextView  class methodsFor:'documentation'!
 
 copyright
 "
@@ -48,7 +48,7 @@
 "
 ! !
 
-!Diff3TextView class methodsFor:'instance creation'!
+!Diff3TextView  class methodsFor:'instance creation'!
 
 openOnMergedText:text label:firstLabel label:secondLabel label:thirdLabel
     "open up a view showing firstText, secondText and thirdText side-by-side,
@@ -86,6 +86,95 @@
     "Modified: 12.12.1995 / 13:09:13 / cg"
 ! !
 
+!Diff3TextView  class methodsFor:'public helpers'!
+
+emphasizeMergedDiff3Text:mergedText emphasize1:e1 emphasize2:e2 emphasizeSep:e3
+    "given the merge()/rcsmerge() merged output (as created by 'cvs update'),
+     create & return a text object which contains the conflicts 
+     highlighted.
+     CAVEAT: this is a highly specialized method - probably not the right place
+     for it here ..."
+
+    |dIdx dEnd state s entry c list skip sep|
+
+    list := OrderedCollection new.
+
+    dIdx := 1.
+    dEnd := mergedText size + 1.
+    state := #initial.
+    [dIdx < dEnd] whileTrue:[
+        dIdx == dEnd ifTrue:[
+            "dummy cleanup entry"
+            entry := nil.
+            state := #initial.
+        ] ifFalse:[
+            entry := mergedText at:dIdx.
+            dIdx := dIdx + 1.
+        ].
+
+        skip := false.
+
+        entry notNil ifTrue:[
+            sep := nil.
+
+            (entry startsWith:'<<<<<<<') ifTrue:[
+                state := 1. skip := true. sep := '----- your version ----'.
+            ] ifFalse:[
+                (entry startsWith:'|||||||') ifTrue:[
+                    state := 2. skip := true.
+                ] ifFalse:[
+                    (entry startsWith:'=======') ifTrue:[
+                        state == 2 ifFalse:[
+                            state := 23        "/ on both 2 and 3
+                        ] ifTrue:[
+                            state := 3         "/ only in 3
+                        ].
+                        skip := true.
+                        sep := '----- other version ----'.
+                    ] ifFalse:[
+                        (entry startsWith:'>>>>>>>') ifTrue:[
+                            state := #initial.
+                            skip := true.
+                            sep := '------------------------'.
+                        ]
+                    ]
+                ]
+            ].
+
+            sep notNil ifTrue:[
+                list add:(Text 
+                            string:sep 
+                            emphasis:e3).
+            ].
+
+            skip ifFalse:[
+                state == #initial ifTrue:[
+                    list add:entry
+                ].
+                state == 1 ifTrue:[
+                    e1 notNil ifTrue:[
+                        list add:(Text string:entry emphasis:e1)
+                    ] ifFalse:[
+                        list add:entry
+                    ]
+                ].
+                (state == 3 or:[state == 23]) ifTrue:[
+                    e2 notNil ifTrue:[
+                        list add:(Text string:entry emphasis:e2)
+                    ] ifFalse:[
+                        list add:entry
+                    ]
+                ].
+            ].
+        ].
+    ].
+
+    ^ list
+
+    "Created: 9.9.1996 / 19:54:00 / cg"
+    "Modified: 9.9.1996 / 20:41:40 / cg"
+! !
+
 !Diff3TextView methodsFor:'initialization'!
 
 initStyle
@@ -233,8 +322,8 @@
     "Modified: 13.12.1995 / 19:56:32 / cg"
 ! !
 
-!Diff3TextView class methodsFor:'documentation'!
+!Diff3TextView  class methodsFor:'documentation'!
 
 version
-^ '$Header: /cvs/stx/stx/libtool/Attic/Diff3TxtV.st,v 1.3 1995-12-13 19:03:36 cg Exp $'
+^ '$Header: /cvs/stx/stx/libtool/Attic/Diff3TxtV.st,v 1.4 1996-09-09 18:41:46 cg Exp $'
 ! !