TextView.st
changeset 185 3bcf27f3ac8a
parent 174 d80a6cc3f9b2
child 186 9d73373b1e32
--- a/TextView.st	Fri Nov 17 18:23:19 1995 +0100
+++ b/TextView.st	Sat Nov 18 18:02:58 1995 +0100
@@ -46,7 +46,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.26 1995-11-11 16:23:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.27 1995-11-18 17:02:58 cg Exp $'
 !
 
 documentation
@@ -1114,11 +1114,31 @@
      Performs foundBlock with line/col as argument if found, notFoundBlock if not.
      If there is a nesting error, performs failBlock."
 
-    |i direction lineString line col parChar charSet ignoreSet closingChar 
+    ^ self
+	searchForMatchingParenthesisFromLine:startLine col:startCol
+		     ifFound:foundBlock 
+		  ifNotFound:notFoundBlock
+		     onError:failBlock
+		    ignoring:#( $' $" )
+
+    "Modified: 18.11.1995 / 16:28:23 / cg"
+!
+
+searchForMatchingParenthesisFromLine:startLine col:startCol
+		     ifFound:foundBlock 
+		  ifNotFound:notFoundBlock
+		     onError:failBlock
+		    ignoring:ignoreSet
+    "search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. 
+     Search for the corresponding character is done forward if its an opening,
+     backwards if its a closing parenthesis.
+     Performs foundBlock with line/col as argument if found, notFoundBlock if not.
+     If there is a nesting error, performs failBlock."
+
+    |i direction lineString line col parChar charSet  closingChar 
      ignoring delta endCol cc incSet decSet nesting maxLine|
 
     charSet := #( $( $) $[ $] ${ $} ).
-    ignoreSet := #( $' $" ).
 
     parChar := self characterAtLine:startLine col:startCol.
     i := charSet indexOf:parChar.
@@ -1191,6 +1211,8 @@
     ].
 
     ^ notFoundBlock value
+
+    "Modified: 18.11.1995 / 16:30:56 / cg"
 ! !
 
 !TextView methodsFor:'redrawing'!
@@ -1590,8 +1612,16 @@
 		    ('()[]{}<>' includes:(sel at:1)) ifTrue:[
 			self searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
 			      ifFound:[:line :col | 
+					  |prevLine prevCol|
+
+					  prevLine := firstLineShown.
+					  prevCol := leftOffset.
 					  self selectFromLine:selectionStartLine col:selectionStartCol
-						       toLine:line col:col
+						       toLine:line col:col.
+					  "/ undo scroll operation ...
+					  (')]}>' includes:(sel at:1)) ifTrue:[
+					       self scrollToLine:prevLine; scrollToCol:prevCol.
+					  ]
 				      ]
 			   ifNotFound:[self showNotFound]
 			      onError:[device beep].
@@ -1628,6 +1658,8 @@
     ] ifFalse:[
 	super buttonMultiPress:button x:x y:y
     ]
+
+    "Modified: 18.11.1995 / 16:18:15 / cg"
 !
 
 buttonMotion:buttonMask x:x y:y