TextView.st
changeset 2324 98f7a9a4c50a
parent 2306 39f295426770
child 2336 696bb43bfc90
--- a/TextView.st	Sun Nov 26 14:39:28 2000 +0100
+++ b/TextView.st	Mon Dec 04 18:58:28 2000 +0100
@@ -1142,6 +1142,7 @@
     ((sel := self selection) size == 1 
     and:[(sel := sel at:1) size == 1]) ifTrue:[
         ch := sel at:1.
+
         ('()[]{}<>' includes:ch) ifTrue:[
             self searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
                   ifFound:[:line :col | 
@@ -2451,10 +2452,10 @@
 !
 
 searchForMatchingParenthesisFromLine:startLine col:startCol
-		     ifFound:foundBlock 
-		  ifNotFound:notFoundBlock
-		     onError:failBlock
-		    ignoring:ignoreSet
+                     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.
@@ -2479,7 +2480,7 @@
     parChar := self characterAtLine:startLine col:startCol.
     i := charSet indexOf:parChar.
     i == 0 ifTrue:[
-	^ failBlock value   "not a parenthesis"
+        ^ failBlock value   "not a parenthesis"
     ].
     direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i.
     closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i.
@@ -2487,13 +2488,13 @@
     col := startCol.
     line := startLine.
     direction == #fwd ifTrue:[
-	delta := 1.
-	incSet := #( $( $[ ${ "$<" ).
-	decSet := #( $) $] $} "$>" ).
+        delta := 1.
+        incSet := #( $( $[ ${ "$<" ).
+        decSet := #( $) $] $} "$>" ).
     ] ifFalse:[
-	delta := -1.
-	incSet := #( $) $] $} "$>" ).
-	decSet := #( $( $[ ${ "$<" ).
+        delta := -1.
+        incSet := #( $) $] $} "$>" ).
+        decSet := #( $( $[ ${ "$<" ).
     ].
     anySet := Set new.
     anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
@@ -2506,99 +2507,102 @@
 
     col := col + delta.
     [nesting ~~ 0] whileTrue:[
-	(lineString notNil
-	and:[lineString includesAny:anySet]) ifTrue:[
-	    direction == #fwd ifTrue:[
-		endCol := lineString size.
-	    ] ifFalse:[
-		endCol := 1
-	    ].
-
-	    col to:endCol by:delta do:[:rCol |
-		runCol := rCol.
-
-		cc := lineString at:runCol.
-		runCol < lineString size ifTrue:[
-		    nextCC := lineString at:runCol+1
-		] ifFalse:[
-		    nextCC := nil
-		].
-		runCol > 1 ifTrue:[
-		    prevCC := lineString at:runCol-1
-		] ifFalse:[
-		    prevCC := nil
-		].
-
-		ign := skip := false.
-		(cc == $"   
-		and:[nextCC == $/ or:[prevCC == $$ ]]) ifTrue:[
-		    "/ do nothing
-
-		    skip := true.
-		] ifFalse:[
-		    ignoreSet do:[:ignore |
-			ignore == cc ifTrue:[
-			    ign := true
-			] ifFalse:[
-			    ignore isString ifTrue:[
-				cc == (ignore at:2) ifTrue:[
-				    runCol > 1 ifTrue:[
-					(lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
-					    skip := true
-					]
-				    ]
-				] ifFalse:[
-				    cc == (ignore at:1) ifTrue:[
-					runCol < lineString size ifTrue:[
-					    (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
-						skip := true
-					    ]
-					]
-				    ]
-				]
-			    ]
-			]
-		    ]
-		].
-
-		ign ifTrue:[
-		    ignoring := ignoring not
-		].
-
-		ignoring ifFalse:[
-		    skip ifFalse:[
-			(incSet includes:cc) ifTrue:[
-			    nesting := nesting + 1
-			] ifFalse:[
-			    (decSet includes:cc) ifTrue:[
-				nesting := nesting - 1
-			    ]
-			]
-		    ]
-		].
-
-		nesting == 0 ifTrue:[
-		    "check if legal"
-
-		    skip ifFalse:[
-			cc == closingChar ifFalse:[
-			    ^ failBlock value
-			].
-			^ foundBlock value:line value:runCol.
-		    ]
-		]
-	    ].
-	].
-	line := line + delta.
-	(line < 1 or:[line > maxLine]) ifTrue:[
-	    ^ failBlock value
-	].
-	lineString := list at:line.
-	direction == #fwd ifTrue:[
-	    col := 1
-	] ifFalse:[
-	    col := lineString size
-	]
+        (lineString notNil
+        and:[lineString includesAny:anySet]) ifTrue:[
+            direction == #fwd ifTrue:[
+                endCol := lineString size.
+            ] ifFalse:[
+                endCol := 1
+            ].
+
+            col to:endCol by:delta do:[:rCol |
+                runCol := rCol.
+
+                cc := lineString at:runCol.
+                runCol < lineString size ifTrue:[
+                    nextCC := lineString at:runCol+1
+                ] ifFalse:[
+                    nextCC := nil
+                ].
+                runCol > 1 ifTrue:[
+                    prevCC := lineString at:runCol-1
+                ] ifFalse:[
+                    prevCC := nil
+                ].
+
+                ign := skip := false.
+
+                "/ check for comments.
+
+                ((cc == $" and:[nextCC == $/])
+                or:[prevCC == $$ ]) ifTrue:[
+                    "/ do nothing
+
+                    skip := true.
+                ] ifFalse:[
+                    ignoreSet do:[:ignore |
+                        ignore == cc ifTrue:[
+                            ign := true
+                        ] ifFalse:[
+                            ignore isString ifTrue:[ 
+                                cc == (ignore at:2) ifTrue:[
+                                    runCol > 1 ifTrue:[
+                                        (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
+                                            skip := true
+                                        ]
+                                    ]
+                                ] ifFalse:[
+                                    cc == (ignore at:1) ifTrue:[
+                                        runCol < lineString size ifTrue:[
+                                            (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
+                                                skip := true
+                                            ]
+                                        ]
+                                    ]
+                                ]
+                            ]
+                        ]
+                    ]
+                ].
+
+                ign ifTrue:[
+                    ignoring := ignoring not
+                ].
+
+                ignoring ifFalse:[
+                    skip ifFalse:[
+                        (incSet includes:cc) ifTrue:[
+                            nesting := nesting + 1
+                        ] ifFalse:[
+                            (decSet includes:cc) ifTrue:[
+                                nesting := nesting - 1
+                            ]
+                        ]
+                    ]
+                ].
+
+                nesting == 0 ifTrue:[
+                    "check if legal"
+
+                    skip ifFalse:[
+                        cc == closingChar ifFalse:[
+                            ^ failBlock value
+                        ].
+                        ^ foundBlock value:line value:runCol.
+                    ]
+                ]
+            ].
+        ].
+        line := line + delta.
+        (line < 1 or:[line > maxLine]) ifTrue:[
+            ^ failBlock value
+        ].
+        lineString := list at:line.
+        direction == #fwd ifTrue:[
+            col := 1
+        ] ifFalse:[
+            col := lineString size
+        ]
     ].
     ^ notFoundBlock value
 
@@ -3179,5 +3183,5 @@
 !TextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.159 2000-11-09 11:15:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.160 2000-12-04 17:58:28 cg Exp $'
 ! !