--- a/TextView.st Wed Mar 10 23:38:39 1999 +0100
+++ b/TextView.st Fri Mar 12 09:34:57 1999 +0100
@@ -12,7 +12,7 @@
ListView subclass:#TextView
instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine
- selectionEndCol clickStartLine clickStartCol clickLine clickCol
+ selectionEndCol clickPos clickStartLine clickStartCol clickLine clickCol
clickCount expandingTop wordStartCol wordStartLine wordEndCol
wordEndLine selectionFgColor selectionBgColor selectStyle
directoryForFileDialog defaultFileNameForFileDialog
@@ -575,35 +575,35 @@
beginCol := self findBeginOfWordAtLine:selectLine col:selectCol.
endCol := self findEndOfWordAtLine:selectLine col:selectCol.
endCol == 0 ifTrue:[
- endLine := selectLine + 1
+ endLine := selectLine + 1
].
"is the initial character within a word ?"
(wordCheck value:thisCharacter) ifTrue:[
- "
- try to catch a blank ...
- "
-
- WordSelectCatchesBlanks ifTrue:[
- ((beginCol == 1)
- or:[(self characterAtLine:selectLine col:(beginCol - 1))
- ~~ Character space]) ifTrue:[
- ((self characterAtLine:selectLine col:(endCol + 1))
- == Character space) ifTrue:[
- endCol := endCol + 1.
- flag := #wordRight
- ]
- ] ifFalse:[
- beginCol := beginCol - 1.
- flag := #wordLeft
- ].
- ].
+ "
+ try to catch a blank ...
+ "
+
+ WordSelectCatchesBlanks ifTrue:[
+ ((beginCol == 1)
+ or:[(self characterAtLine:selectLine col:(beginCol - 1))
+ ~~ Character space]) ifTrue:[
+ ((self characterAtLine:selectLine col:(endCol + 1))
+ == Character space) ifTrue:[
+ endCol := endCol + 1.
+ flag := #wordRight
+ ]
+ ] ifFalse:[
+ beginCol := beginCol - 1.
+ flag := #wordLeft
+ ].
+ ].
].
aFiveArgBlock value:selectLine
- value:beginCol
- value:endLine
- value:endCol
- value:flag
+ value:beginCol
+ value:endLine
+ value:endCol
+ value:flag
"Modified: 18.3.1996 / 17:31:04 / cg"
! !
@@ -665,149 +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
- ].
- selectionStartLine := clickLine.
- selectionStartCol := clickCol.
- selectionEndLine := selectionStartLine.
- selectionEndCol := selectionStartCol.
-
- oldStartLine := selectionStartLine.
- oldEndLine := selectionEndLine.
- oldStartCol := selectionStartCol.
- oldEndCol := selectionEndCol-1.
+ 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.
] 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
@@ -855,6 +860,7 @@
((button == 1) or:[button == #select]) ifTrue:[
clickVisibleLine := self visibleLineOfY:y.
+ clickPos := x @ y.
clickCol := self colOfX:x inVisibleLine:clickVisibleLine.
clickLine := self visibleLineToAbsoluteLine:clickVisibleLine.
clickStartLine := clickLine.
@@ -1422,12 +1428,12 @@
"/ searchBox addButton:(Button label:(resources at:'all'));
lastSearchPattern notNil ifTrue:[
- stringHolder value:lastSearchPattern
+ stringHolder value:lastSearchPattern
].
self hasSelection ifTrue:[
- selectionStartLine == selectionEndLine ifTrue:[
- stringHolder value:self selection
- ]
+ selectionStartLine == selectionEndLine ifTrue:[
+ stringHolder value:self selection
+ ]
].
patternField selectAll.
@@ -1435,28 +1441,28 @@
searchBox open.
searchBox accepted ifTrue:[
- pattern := stringHolder value.
- pattern := pattern string withoutSeparators. "/ is that a good idea ?
- pattern notEmpty ifTrue:[
- LastSearchPatterns isNil ifTrue:[
- LastSearchPatterns := OrderedCollection new.
- ].
- (LastSearchPatterns includes:pattern) ifTrue:[
- LastSearchPatterns remove:pattern.
- ] ifFalse:[
- LastSearchPatterns size > 10 ifTrue:[
- LastSearchPatterns removeFirst
- ]
- ].
- LastSearchPatterns addFirst:pattern.
-
- ign := caseHolder value.
- fwd ifFalse:[
- self searchBwd:pattern ignoreCase:ign.
- ] ifTrue:[
- self searchFwd:pattern ignoreCase:ign.
- ]
- ]
+ pattern := stringHolder value.
+ pattern := pattern string withoutSeparators. "/ is that a good idea ?
+ pattern notEmpty ifTrue:[
+ LastSearchPatterns isNil ifTrue:[
+ LastSearchPatterns := OrderedCollection new.
+ ].
+ (LastSearchPatterns includes:pattern) ifTrue:[
+ LastSearchPatterns remove:pattern.
+ ] ifFalse:[
+ LastSearchPatterns size > 10 ifTrue:[
+ LastSearchPatterns removeFirst
+ ]
+ ].
+ LastSearchPatterns addFirst:pattern.
+
+ ign := caseHolder value.
+ fwd ifFalse:[
+ self searchBwd:pattern ignoreCase:ign.
+ ] ifTrue:[
+ self searchFwd:pattern ignoreCase:ign.
+ ]
+ ]
].
"/ searchBox :=
@@ -2435,7 +2441,7 @@
sel := self selection.
sel notNil ifTrue:[
- self setSearchPattern:sel
+ self setSearchPattern:sel
]
"Modified: / 6.3.1999 / 23:48:04 / cg"
@@ -2445,9 +2451,9 @@
"set the searchpattern for future searches"
aString isNil ifTrue:[
- lastSearchPattern := aString
+ lastSearchPattern := aString
] ifFalse:[
- lastSearchPattern := aString withoutSeparators string
+ lastSearchPattern := aString withoutSeparators string
].
"Modified: / 6.3.1999 / 23:47:36 / cg"
@@ -2916,5 +2922,5 @@
!TextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.131 1999-03-07 13:28:32 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.132 1999-03-12 08:34:57 cg Exp $'
! !