--- a/TextView.st Sat Oct 20 17:39:04 2012 +0200
+++ b/TextView.st Tue Oct 23 14:58:41 2012 +0200
@@ -311,6 +311,41 @@
"Modified: / 03-07-2006 / 16:29:42 / cg"
! !
+!TextView class methodsFor:'help specs'!
+
+flyByHelpSpec
+ "This resource specification was automatically generated
+ by the UIHelpTool of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIHelpTool may not be able to read the specification."
+
+ "
+ UIHelpTool openOnClass:TextView
+ "
+
+ <resource: #help>
+
+ ^ Dictionary new addPairsFrom:#(
+
+#matchSearch
+'Search for a pattern (glob) as opposed to a direct string search'
+
+#searchCaseSensitive
+'Care for case differences'
+
+#searchFullWord
+'Search only for full words (ignore occurrences as substring)'
+
+#searchPattern
+'String or match-pattern to be searched'
+
+#searchVariable
+'Search only for that variable name (ignore occurrences in other contexts)'
+
+)
+! !
+
!TextView class methodsFor:'interface specs'!
searchDialogSpec
@@ -335,14 +370,93 @@
name: 'String search'
min: (Point 10 10)
max: (Point 1280 1024)
- bounds: (Rectangle 0 0 302 161)
+ bounds: (Rectangle 0 0 302 189)
)
component:
(SpecCollection
collection: (
+ (LabelSpec
+ label: 'SearchPattern:'
+ name: 'label'
+ layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
+ level: 0
+ translateLabel: true
+ adjust: left
+ )
+ (ComboBoxSpec
+ name: 'patternComboBox'
+ layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
+ activeHelpKey: searchPattern
+ tabable: true
+ model: searchPattern
+ immediateAccept: false
+ acceptOnLeave: true
+ acceptOnReturn: true
+ acceptOnTab: true
+ acceptOnLostFocus: true
+ acceptOnPointerLeave: false
+ autoSelectInitialText: true
+ comboList: patternList
+ )
+ (VerticalPanelViewSpec
+ name: 'VerticalPanel1'
+ layout: (LayoutFrame 0 0.0 52 0 0 1.0 -30 1)
+ horizontalLayout: fit
+ verticalLayout: top
+ component:
+ (SpecCollection
+ collection: (
+ (CheckBoxSpec
+ label: 'Case Sensitive'
+ name: 'ignoreCaseCheckBox'
+ activeHelpKey: searchCaseSensitive
+ level: 0
+ tabable: true
+ model: caseSensitive
+ translateLabel: true
+ extent: (Point 302 24)
+ )
+ (CheckBoxSpec
+ label: 'Match (for Forward only)'
+ name: 'matchCheckBox'
+ activeHelpKey: matchSearch
+ level: 0
+ tabable: true
+ model: match
+ translateLabel: true
+ extent: (Point 302 24)
+ )
+ (CheckBoxSpec
+ label: 'Search Full Words'
+ name: 'CheckBox2'
+ activeHelpKey: searchFullWord
+ level: 0
+ enableChannel: searchFullWordEnabled
+ tabable: true
+ model: searchFullWord
+ translateLabel: true
+ extent: (Point 302 24)
+ )
+ (CheckBoxSpec
+ label: 'Variable Only'
+ name: 'CheckBox1'
+ activeHelpKey: searchVariable
+ level: 0
+ visibilityChannel: searchVariableVisible
+ enableChannel: searchVariableEnabled
+ tabable: true
+ model: searchVariable
+ translateLabel: true
+ labelChannel: stringWithVariableUnderCursorHolder
+ extent: (Point 302 24)
+ )
+ )
+
+ )
+ )
(HorizontalPanelViewSpec
name: 'horizontalPanelView'
- layout: (LayoutFrame 0 0.0 -26 1.0 0 1.0 0 1.0)
+ layout: (LayoutFrame 0 0.0 -28 1.0 0 1.0 0 1.0)
level: 0
horizontalLayout: fitSpace
verticalLayout: center
@@ -386,58 +500,6 @@
)
)
- (LabelSpec
- label: 'SearchPattern:'
- name: 'label'
- layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
- level: 0
- translateLabel: true
- adjust: left
- )
- (ComboBoxSpec
- name: 'patternComboBox'
- layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
- tabable: true
- model: searchPattern
- immediateAccept: false
- acceptOnLeave: true
- acceptOnReturn: true
- acceptOnTab: true
- acceptOnLostFocus: true
- acceptOnPointerLeave: false
- autoSelectInitialText: true
- comboList: patternList
- )
- (CheckBoxSpec
- label: 'Case Sensitive'
- name: 'ignoreCaseCheckBox'
- layout: (LayoutFrame 3 0.0 54 0 -3 1.0 77 0)
- level: 0
- tabable: true
- model: caseSensitive
- translateLabel: true
- )
- (CheckBoxSpec
- label: 'Match (for Forward only)'
- name: 'matchCheckBox'
- layout: (LayoutFrame 3 0.0 78 0 -3 1.0 100 0)
- level: 0
- tabable: true
- model: match
- translateLabel: true
- )
- (CheckBoxSpec
- label: 'Variable Only'
- name: 'CheckBox1'
- layout: (LayoutFrame 3 0.0 102 0 -3 1.0 124 0)
- level: 0
- visibilityChannel: searchVariableVisible
- enableChannel: searchVariableEnabled
- tabable: true
- model: searchVariable
- translateLabel: true
- labelChannel: stringWithVariableUnderCursorHolder
- )
)
)
@@ -2000,7 +2062,7 @@
Q: is it a good idea to preserve the last searchstring between views ?
"
|searchBox patternHolder caseHolder matchHolder fwd ign match initialString
- bindings bldr doSearch modal searchVariableHolder selectedVariable|
+ bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder|
searchBarActionBlock notNil ifTrue:[
self resetVariablesBeforeNewSearch.
@@ -2016,6 +2078,7 @@
match := lastSearchWasMatch ? LastSearchWasMatch ? false.
matchHolder := match asValue.
searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
+ searchFullWordHolder := false asValue.
patternHolder := '' asValue.
@@ -2041,7 +2104,9 @@
fwd := true.
doSearch := [:fwd |
- self resetVariablesBeforeNewSearch.
+ |pattern|
+
+ self resetVariablesBeforeNewSearch.
(self searchVariableVisible
and:[searchVariableHolder value
@@ -2052,12 +2117,22 @@
lastSearchWasVariableSearch := false.
LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
-
- self
- search:patternHolder value
- ignoreCase:lastSearchIgnoredCase
- match: lastSearchWasMatch
- forward:fwd.
+ pattern := patternHolder value.
+ pattern notEmptyOrNil ifTrue:[
+ self searchUsingSpec:(
+ ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:lastSearchIgnoredCase
+ match: lastSearchWasMatch
+ variable: searchVariableHolder value
+ fullWord: searchFullWordHolder value
+ forward:fwd).
+"/ self
+"/ search:patternHolder value
+"/ ignoreCase:lastSearchIgnoredCase
+"/ match: lastSearchWasMatch
+"/ forward:fwd.
+ ]
].
].
@@ -2074,19 +2149,26 @@
bindings at:#match put:matchHolder.
bindings at:#patternList put:LastSearchPatterns.
- selectedVariable := self syntaxElementForSelectedVariable.
- bindings at:#searchVariableEnabled put:(selectedVariable notNil).
- selectedVariable notNil ifTrue:[
- bindings
- at:#stringWithVariableUnderCursorHolder
- put:('Variable ("%1")' bindWith:selectedVariable value).
- searchVariableHolder value:true.
- ] ifFalse:[
- bindings
- at:#stringWithVariableUnderCursorHolder
- put:('Variable (none selected)').
+ self supportsSyntaxElements ifFalse:[
+ bindings at:#searchVariableVisible put:false.
+ ] ifTrue:[
+ bindings at:#searchVariableVisible put:true.
+ selectedVariable := self syntaxElementForSelectedVariable.
+ bindings at:#searchVariableEnabled put:(selectedVariable notNil).
+ selectedVariable notNil ifTrue:[
+ bindings
+ at:#stringWithVariableUnderCursorHolder
+ put:('Variable ("%1")' bindWith:selectedVariable value).
+ searchVariableHolder value:true.
+ ] ifFalse:[
+ bindings
+ at:#stringWithVariableUnderCursorHolder
+ put:('Variable (none selected)').
+ ].
].
bindings at:#searchVariable put:searchVariableHolder.
+ bindings at:#searchFullWord put:searchFullWordHolder.
+ bindings at:#searchFullWordEnabled put:true.
modal ifTrue:[
searchBox := SimpleDialog new.
@@ -2098,6 +2180,7 @@
bldr := searchBox builder.
bldr addBindings:bindings.
+ bldr aspectAt:#flyByHelpSpec put:(self class flyByHelpSpec).
searchBox allButOpenFrom:(self class searchDialogSpec).
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
@@ -2220,6 +2303,22 @@
"Modified: / 23-03-2012 / 12:12:07 / cg"
!
+searchUsingSpec:aSearchSpec
+ self rememberSearchPattern:(aSearchSpec pattern).
+ "/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign.
+ "/ LastSearchWasMatch := match.
+ aSearchSpec forward ifFalse:[
+ lastSearchDirection := #backward.
+ self searchBwdUsingSpec:aSearchSpec
+ ] ifTrue:[
+ lastSearchDirection := #forward.
+ self searchFwdUsingSpec:aSearchSpec
+ ]
+
+ "Created: / 11-07-2006 / 11:18:04 / fm"
+ "Modified: / 23-03-2012 / 12:12:07 / cg"
+!
+
searchVariableVisible
"search variable option in searchbox visible?
(only true for codeview2's textview)"
@@ -2230,6 +2329,8 @@
!
searchVariableWithSyntaxElement:syntaxElementForVariable forward:fwd
+ "this only works for CodeView2::TextView, which supports syntaxElements"
+
|el el2|
lastSearchWasVariableSearch := true.
@@ -3027,6 +3128,7 @@
self
searchBwd:lastSearchPattern
ignoreCase:ign
+ match: match
] ifFalse:[
self
searchFwd:lastSearchPattern
@@ -3040,7 +3142,8 @@
!
searchBwd
- "search backward and -if found- position cursor"
+ "search backward (for the same thing again)
+ If found, position cursor"
|ign selectedVariable|
@@ -3100,17 +3203,9 @@
searchBwd:pattern ifAbsent:aBlock
"do a backward search"
- |pos startLine startCol|
-
- pos := self startPositionForSearchBackward.
- startLine := pos y.
- startCol := pos x.
-
self
- searchBackwardFor:pattern
- startingAtLine:startLine col:startCol
- ifFound:[:line :col |
- self showMatch:pattern isMatch:false atLine:line col:col]
+ searchBwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern)
ifAbsent:aBlock
"Modified: 13.9.1997 / 01:05:49 / cg"
@@ -3119,12 +3214,13 @@
searchBwd:pattern ignoreCase:ign
"do a backward search"
- self searchBwd:pattern
- ignoreCase:ign
- ifAbsent:[
+ self
+ searchBwd:pattern
+ ignoreCase:ign
+ ifAbsent:[
self sensor compressKeyPressEventsWithKey:#FindPrev.
self showNotFound
- ].
+ ].
"/ lastSearchIgnoredCase := ign.
lastSearchPattern := pattern string
@@ -3135,17 +3231,10 @@
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
"do a backward search"
- |pos startLine startCol|
-
- pos := self startPositionForSearchBackward.
- startLine := pos y.
- startCol := pos x.
-
self
- searchBackwardFor:pattern
- ignoreCase:ign
- startingAtLine:startLine col:startCol
- ifFound:[:line :col | self showMatch:pattern isMatch:false atLine:line col:col]
+ searchBwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:ign)
ifAbsent:aBlock
"Modified: 13.9.1997 / 01:05:49 / cg"
@@ -3162,6 +3251,35 @@
"Modified: / 23-03-2012 / 12:12:44 / cg"
!
+searchBwdUsingSpec:searchSpec
+ "do a backward search"
+
+ self
+ searchBwdUsingSpec:searchSpec
+ ifAbsent:[self showNotFound].
+
+"/ lastSearchIgnoredCase := false.
+ lastSearchPattern := searchSpec pattern string
+
+ "Modified: / 21-09-2006 / 16:48:29 / cg"
+!
+
+searchBwdUsingSpec:searchSpec ifAbsent:aBlock
+ "do a backward search"
+
+ |pos startLine startCol|
+
+ pos := self startPositionForSearchBackward.
+ startLine := pos y.
+ startCol := pos x.
+
+ self
+ searchBackwardUsingSpec:searchSpec
+ startingAtLine:startLine col:startCol
+ ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col]
+ ifAbsent:aBlock
+!
+
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol
"select characters enclosed by matching parenthesis if one is under startLine/Col"
@@ -3705,7 +3823,7 @@
!
searchFwd
- "search forward for pattern or selection"
+ "search forward for the same pattern or selection again"
|ign match variable|
@@ -3777,16 +3895,9 @@
searchFwd:pattern ifAbsent:aBlock
"do a forward search"
- |pos startLine startCol|
-
- pos := self startPositionForSearchForward.
- startLine := pos y.
- startCol := pos x.
-
- self
- searchForwardFor:pattern
- startingAtLine:startLine col:startCol
- ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
+ self
+ searchFwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern)
ifAbsent:aBlock
"Modified: / 21-09-2006 / 16:51:28 / cg"
@@ -3795,9 +3906,10 @@
searchFwd:pattern ignoreCase:ign
"do a forward search"
- self
- searchFwd:pattern
- ignoreCase:ign
+ self
+ searchFwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:ign)
ifAbsent:[
self sensor compressKeyPressEventsWithKey:#FindNext.
self showNotFound
@@ -3812,17 +3924,10 @@
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
"do a forward search"
- |pos startLine startCol|
-
- pos := self startPositionForSearchForward.
- startLine := pos y.
- startCol := pos x.
-
- self
- searchForwardFor:pattern
- ignoreCase:ign
- startingAtLine:startLine col:startCol
- ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
+ self
+ searchFwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:ign)
ifAbsent:aBlock
"Modified: 13.9.1997 / 01:05:35 / cg"
@@ -3832,10 +3937,11 @@
searchFwd:pattern ignoreCase:ign match: match
"do a forward search"
- self
- searchFwd:pattern
- ignoreCase:ign
- match: match
+ self
+ searchFwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:ign
+ match:match)
ifAbsent:[
self sensor compressKeyPressEventsWithKey:#FindNext.
self showNotFound
@@ -3851,17 +3957,11 @@
searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock
"do a forward search"
- |pos startLine startCol|
-
- pos := self startPositionForSearchForward.
- startLine := pos y.
- startCol := pos x.
-
self
- searchFwd:pattern
- ignoreCase:ign
- match: match
- startingAtLine:startLine col:startCol
+ searchFwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:ign
+ match:match)
ifAbsent:aBlock
"Modified: 13.9.1997 / 01:05:35 / cg"
@@ -3872,11 +3972,52 @@
"do a forward search"
self
- searchForwardFor:pattern
- ignoreCase:ign
- match: match
+ searchFwdUsingSpec:(ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:ign
+ match:match)
startingAtLine:startLine col:startCol
- ifFound:[:line :col | self showMatch:pattern isMatch:match atLine:line col:col]
+ ifAbsent:aBlock
+!
+
+searchFwdUsingSpec:searchSpec
+ "do a forward search"
+
+ self
+ searchFwdUsingSpec:searchSpec
+ ifAbsent:[self showNotFound].
+
+"/ lastSearchIgnoredCase := false.
+ lastSearchPattern := searchSpec pattern string
+
+ "Modified: / 21-09-2006 / 16:52:04 / cg"
+!
+
+searchFwdUsingSpec:searchSpec ifAbsent:aBlock
+ "do a forward search"
+
+ |pos startLine startCol|
+
+ pos := self startPositionForSearchForward.
+ startLine := pos y.
+ startCol := pos x.
+
+ self
+ searchFwdUsingSpec:searchSpec
+ startingAtLine:startLine col:startCol
+ ifAbsent:aBlock
+
+ "Modified: 13.9.1997 / 01:05:35 / cg"
+ "Created: 13.9.1997 / 06:18:27 / cg"
+!
+
+searchFwdUsingSpec:searchSpec startingAtLine:startLine col:startCol ifAbsent:aBlock
+ "do a forward search"
+
+ self
+ searchForwardUsingSpec:searchSpec
+ startingAtLine:startLine col:startCol
+ ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col]
ifAbsent:aBlock
!
@@ -4570,11 +4711,11 @@
!TextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.340 2012-10-02 14:23:34 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.341 2012-10-23 12:58:41 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.340 2012-10-02 14:23:34 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.341 2012-10-23 12:58:41 cg Exp $'
! !
TextView initialize!