oops - care for clickPos being nil.
authorClaus Gittinger <cg@exept.de>
Wed, 16 Jun 1999 22:03:54 +0200
changeset 1922 87222b5b9e32
parent 1921 93c064603431
child 1923 cc9c075f0bc5
oops - care for clickPos being nil.
TextView.st
--- a/TextView.st	Thu Jun 10 18:17:13 1999 +0200
+++ b/TextView.st	Wed Jun 16 22:03:54 1999 +0200
@@ -665,154 +665,154 @@
 
     "if moved outside of view, start autoscroll"
     (y < 0) ifTrue:[
-	self compressMotionEvents:false.
-	self startAutoScrollUp:y.
-	^ self
+        self compressMotionEvents:false.
+        self startAutoScrollUp:y.
+        ^ self
     ].
     (y > height) ifTrue:[
-	self compressMotionEvents:false.
-	self startAutoScrollDown:(y - height).
-	^ self
+        self compressMotionEvents:false.
+        self startAutoScrollDown:(y - height).
+        ^ self
     ].
     ((x < 0) and:[leftOffset ~~ 0]) ifTrue:[
-	self compressMotionEvents:false.
-	self startAutoScrollLeft:x.
-	^ self
+        self compressMotionEvents:false.
+        self startAutoScrollLeft:x.
+        ^ self
     ].
     (x > width) ifTrue:[
-	self compressMotionEvents:false.
-	self startAutoScrollRight:(x - width).
-	^ self
+        self compressMotionEvents:false.
+        self startAutoScrollRight:(x - width).
+        ^ self
     ].
 
     "move inside - stop autoscroll if any"
     autoScrollBlock notNil ifTrue:[
-	self stopScrollSelect
+        self stopScrollSelect
     ].
 
     movedVisibleLine := self visibleLineOfY:y.
     movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
     (x < leftMargin) ifTrue:[
-	movedCol := 0
+        movedCol := 0
     ] ifFalse:[
-	movedCol := self colOfX:x inVisibleLine:movedVisibleLine
+        movedCol := self colOfX:x inVisibleLine:movedVisibleLine
     ].
     ((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[
-	selectionStartLine notNil ifTrue:[
-	    ^ self
-	].
-	(clickPos x - x) abs < 3 ifTrue:[
-	    (clickPos y - y) abs < 3 ifTrue:[
-		^ self
-	    ]
-	].
-	selectionStartLine := clickLine.
-	selectionStartCol := clickCol.
-	selectionEndLine := selectionStartLine.
-	selectionEndCol := selectionStartCol.
-
-	oldStartLine := selectionStartLine.
-	oldEndLine := selectionEndLine.
-	oldStartCol := selectionStartCol.
-	oldEndCol := selectionEndCol-1.
+        selectionStartLine notNil ifTrue:[
+            ^ self
+        ].
+        (clickPos isNil 
+        or:[(clickPos x - x) abs < 3 
+            and:[(clickPos y - y) abs < 3]]) ifTrue:[
+            ^ self
+        ].
+        selectionStartLine := clickLine.
+        selectionStartCol := clickCol.
+        selectionEndLine := selectionStartLine.
+        selectionEndCol := selectionStartCol.
+
+        oldStartLine := selectionStartLine.
+        oldEndLine := selectionEndLine.
+        oldStartCol := selectionStartCol.
+        oldEndCol := selectionEndCol-1.
     ] ifFalse:[
-	selectionStartLine isNil ifTrue:[
-	    selectionStartLine := clickLine.
-	    selectionStartCol := clickCol.
-	    selectionEndLine := selectionStartLine.
-	    selectionEndCol := selectionStartCol
-	].
-	oldStartLine := selectionStartLine.
-	oldEndLine := selectionEndLine.
-	oldStartCol := selectionStartCol.
-	oldEndCol := selectionEndCol.
+        selectionStartLine isNil ifTrue:[
+            selectionStartLine := clickLine.
+            selectionStartCol := clickCol.
+            selectionEndLine := selectionStartLine.
+            selectionEndCol := selectionStartCol
+        ].
+        oldStartLine := selectionStartLine.
+        oldEndLine := selectionEndLine.
+        oldStartCol := selectionStartCol.
+        oldEndCol := selectionEndCol.
     ].
 
     "find out if we are before or after initial click"
     movedUp := false.
     (movedLine < clickStartLine) ifTrue:[
-	movedUp := true
+        movedUp := true
     ] ifFalse:[
-	(movedLine == clickStartLine) ifTrue:[
-	    (movedCol < clickStartCol) ifTrue:[
-		movedUp := true
-	    ]
-	]
+        (movedLine == clickStartLine) ifTrue:[
+            (movedCol < clickStartCol) ifTrue:[
+                movedUp := true
+            ]
+        ]
     ].
 
     movedUp ifTrue:[
-	"change selectionStart"
-	selectionStartCol := movedCol.
-	selectionStartLine := movedLine.
-	selectionEndCol := clickStartCol.
-	selectionEndLine := clickStartLine.
-	selectStyle notNil ifTrue:[
-	    selectionEndCol := wordEndCol.
-	    selectionEndLine := wordEndLine.
-	]
+        "change selectionStart"
+        selectionStartCol := movedCol.
+        selectionStartLine := movedLine.
+        selectionEndCol := clickStartCol.
+        selectionEndLine := clickStartLine.
+        selectStyle notNil ifTrue:[
+            selectionEndCol := wordEndCol.
+            selectionEndLine := wordEndLine.
+        ]
     ] ifFalse:[
-	"change selectionEnd"
-	selectionEndCol := movedCol.
-	selectionEndLine := movedLine.
-	selectionStartCol := clickStartCol.
-	selectionStartLine := clickStartLine.
-	selectStyle notNil ifTrue:[
-	    selectionStartCol := wordStartCol.
-	    selectionStartLine := wordStartLine.
-	]
+        "change selectionEnd"
+        selectionEndCol := movedCol.
+        selectionEndLine := movedLine.
+        selectionStartCol := clickStartCol.
+        selectionStartLine := clickStartLine.
+        selectStyle notNil ifTrue:[
+            selectionStartCol := wordStartCol.
+            selectionStartLine := wordStartLine.
+        ]
     ].
 
     selectionStartLine isNil ifTrue:[^ self].
 
     (selectionStartCol == 0) ifTrue:[
-	selectionStartCol := 1
+        selectionStartCol := 1
     ].
 
     "
      if in word-select, just catch the rest of the word
     "
     (selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[
-	movedUp ifTrue:[
-	    selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
-	] ifFalse:[
-	    selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
-	    selectionEndCol == 0 ifTrue:[
-		selectionEndLine := selectionEndLine + 1
-	    ]
-	].
+        movedUp ifTrue:[
+            selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
+        ] ifFalse:[
+            selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
+            selectionEndCol == 0 ifTrue:[
+                selectionEndLine := selectionEndLine + 1
+            ]
+        ].
     ].
 
     selectStyle == #line ifTrue:[
-	movedUp ifTrue:[
-	    selectionStartCol := 1.
-	] ifFalse:[
-	    selectionEndCol := 0.
-	    selectionEndLine := selectionEndLine + 1
-	]
+        movedUp ifTrue:[
+            selectionStartCol := 1.
+        ] ifFalse:[
+            selectionEndCol := 0.
+            selectionEndLine := selectionEndLine + 1
+        ]
     ].
 
     self validateNewSelection.
 
     (oldStartLine == selectionStartLine) ifTrue:[
-	(oldStartCol ~~ selectionStartCol) ifTrue:[
-	    self redrawLine:oldStartLine 
-		       from:((selectionStartCol min:oldStartCol) max:1)
-			 to:((selectionStartCol max:oldStartCol) max:1)
-	]
+        (oldStartCol ~~ selectionStartCol) ifTrue:[
+            self redrawLine:oldStartLine 
+                       from:((selectionStartCol min:oldStartCol) max:1)
+                         to:((selectionStartCol max:oldStartCol) max:1)
+        ]
     ] ifFalse:[
-	self redrawFromLine:(oldStartLine min:selectionStartLine)
-			 to:(oldStartLine max:selectionStartLine)
+        self redrawFromLine:(oldStartLine min:selectionStartLine)
+                         to:(oldStartLine max:selectionStartLine)
     ].
 
     (oldEndLine == selectionEndLine) ifTrue:[
-	(oldEndCol ~~ selectionEndCol) ifTrue:[
-	    self redrawLine:oldEndLine 
-		       from:((selectionEndCol min:oldEndCol) max:1)
-			 to:((selectionEndCol max:oldEndCol) max:1)
-	]
+        (oldEndCol ~~ selectionEndCol) ifTrue:[
+            self redrawLine:oldEndLine 
+                       from:((selectionEndCol min:oldEndCol) max:1)
+                         to:((selectionEndCol max:oldEndCol) max:1)
+        ]
     ] ifFalse:[
-	self redrawFromLine:(oldEndLine min:selectionEndLine)
-			 to:(oldEndLine max:selectionEndLine)
+        self redrawFromLine:(oldEndLine min:selectionEndLine)
+                         to:(oldEndLine max:selectionEndLine)
     ].
     clickLine := movedLine.
     clickCol := movedCol
@@ -2959,5 +2959,5 @@
 !TextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.136 1999-05-20 15:24:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.137 1999-06-16 20:03:54 cg Exp $'
 ! !