--- a/TextView.st Fri Jul 24 17:41:41 2015 +0200
+++ b/TextView.st Fri Jul 24 20:09:16 2015 +0200
@@ -4939,6 +4939,37 @@
^ self
"Modified: 29.4.1996 / 12:32:08 / cg"
+!
+
+withSelectionForeground:hilightFg background:hilightBg do:aBlock
+ "evaluate aBlock while the selection is shown highlighted with colors passed as args."
+
+ |oldFg oldBg|
+
+ "
+ change color of selection & hide cursor
+ "
+ oldFg := selectionFgColor.
+ oldBg := selectionBgColor.
+ selectionBgColor := hilightBg.
+ selectionFgColor := hilightFg.
+
+ expandingTop := true. "/ hack to make the top of the selection visible
+ self makeSelectionVisible.
+ selectionStartLine notNil ifTrue:[
+ selectionEndLine notNil ifTrue:[
+ self redrawFromLine:selectionStartLine to:selectionEndLine.
+ ].
+ ].
+ self flush.
+
+ aBlock ensure:[
+ "
+ undo selection color change and show cursor again
+ "
+ selectionFgColor := oldFg.
+ selectionBgColor := oldBg.
+ ].
! !
!TextView methodsFor:'testing'!