TextView.st
changeset 1755 ab3c4ee45498
parent 1750 d87cc464fde2
child 1761 e35b524d6d64
--- a/TextView.st	Fri Feb 26 13:45:05 1999 +0100
+++ b/TextView.st	Mon Mar 01 19:42:08 1999 +0100
@@ -665,137 +665,149 @@
 
     "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:[^ self].
-
-    selectionStartLine isNil ifTrue:[
-	selectionStartLine := clickLine.
-	selectionStartCol := clickCol.
-	selectionEndLine := selectionStartLine.
-	selectionEndCol := selectionStartCol
+    ((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[
+        selectionStartLine notNil 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.
     ].
-    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
@@ -2899,5 +2911,5 @@
 !TextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.126 1999-02-19 18:11:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.127 1999-03-01 18:42:08 cg Exp $'
 ! !