class: DiffTextView
added: #updateScrollbarBackground
changed:
#initialize
#processDiffList:from:and:
#updateListsFrom:and:diffs:
scrollbar colorization
--- a/DiffTextView.st Fri Jan 24 18:06:39 2014 +0100
+++ b/DiffTextView.st Sun Jan 26 14:54:14 2014 +0100
@@ -339,8 +339,6 @@
nr2 := text2 size + 1.
state := #finish.
] ifFalse:[
- diffLineNumbers add:l1 size.
-
s := ReadStream on:entry.
nr1 := Integer readFrom:s.
s peek == $, ifTrue:[
@@ -355,6 +353,7 @@
] ifFalse:[
nr3 := nil
].
+ diffLineNumbers add:{ op . nr1 . nr2 }.
op == $c ifTrue:[
state := #changed.
@@ -400,7 +399,6 @@
idx2 := idx2 + 1.
].
-
"
add a separating line, except at end
"
@@ -409,10 +407,9 @@
showSeparators ifTrue:[
l1 add:'--------'.
l2 add:'--------'.
- ]
+ ].
]
].
-
] ifFalse:[
state == #changed ifTrue:[
line1 := line2 := nil.
@@ -525,7 +522,7 @@
]
"must be in finish otherwise"
]
- ]
+ ].
].
dIdx := dIdx + 1
].
@@ -578,15 +575,55 @@
textView1 list:lists first.
textView2 list:lists second.
+
+ self updateScrollbarBackground
+!
+
+updateScrollbarBackground
+ "define a background in the scroller allowing quick positioning to changes"
+
+ |container vScroller thumb|
+
+ (container := self container) isScrollWrapper ifTrue:[
+ (vScroller := container verticalScrollBar) notNil ifTrue:[
+ (thumb := vScroller thumb) notNil ifTrue:[
+ thumb
+ backgroundDrawHook:[:x :y :w :h |
+ |overAllHeight|
+
+ overAllHeight := textViews first numberOfLines.
+ 1 to:overAllHeight do:[:lineNr |
+ |l1 l2 isDiff yThumb clr e|
+
+ l1 := textViews first listAt:lineNr.
+ l2 := textViews second listAt:lineNr.
+ (l1 notNil and:[l1 isText]) ifTrue:[
+ e := l1 emphasis
+ ] ifFalse:[
+ (l2 notNil and:[l2 isText ]) ifTrue:[
+ e := l2 emphasis
+ ]
+ ].
+ e size > 0 ifTrue:[
+ clr := Text extractEmphasis:#backgroundColor from:(e at:1).
+ thumb paint:clr.
+ yThumb := (thumb height * (lineNr / overAllHeight)) rounded.
+ thumb displayLineFromX:1 y:yThumb toX:thumb width-2 y:yThumb.
+ ].
+ ]
+ ]
+ ]
+ ]
+ ].
! !
!DiffTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.58 2013-03-11 11:51:45 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.59 2014-01-26 13:54:14 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.58 2013-03-11 11:51:45 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.59 2014-01-26 13:54:14 cg Exp $'
! !