--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Tools__StringSearchToolForTextView.st Fri Apr 04 18:22:56 2008 +0200
@@ -0,0 +1,271 @@
+"{ Package: 'stx:libtool' }"
+
+"{ NameSpace: Tools }"
+
+StringSearchTool subclass:#StringSearchToolForTextView
+ instanceVariableNames:'textView matchHolder'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-Tools'
+!
+
+
+!StringSearchToolForTextView class methodsFor:'interface specs'!
+
+windowSpec
+ "This resource specification was automatically generated
+ by the UIPainter of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIPainter may not be able to read the specification."
+
+ "
+ UIPainter new openOnClass:Tools::StringSearchToolForTextView andSelector:#windowSpec
+ Tools::StringSearchToolForTextView new openInterface:#windowSpec
+ Tools::StringSearchToolForTextView open
+ "
+
+ <resource: #canvas>
+
+ ^
+ #(FullSpec
+ name: windowSpec
+ window:
+ (WindowSpec
+ label: 'Tools::StringSearchTool'
+ name: 'Tools::StringSearchTool'
+ min: (Point 10 10)
+ max: (Point 1024 768)
+ bounds: (Rectangle 0 0 801 27)
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (ViewSpec
+ name: 'SearchBox'
+ layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+ level: -1
+ component:
+ (SpecCollection
+ collection: (
+ (ActionButtonSpec
+ label: 'closeSearchBarIcon'
+ name: 'hideSearchBarButton'
+ layout: (LayoutFrame 1 0 2 0 22 0 23 0)
+ hasCharacterOrientedLabel: false
+ translateLabel: true
+ model: hideSearchBar
+ )
+ (LabelSpec
+ label: 'Search:'
+ name: 'SearchLabel'
+ layout: (LayoutFrame 23 0 1 0 76 0 23 0)
+ translateLabel: true
+ adjust: right
+ )
+ (InputFieldSpec
+ name: 'SearchEntryField'
+ layout: (LayoutFrame 82 0 1 0 278 0 23 0)
+ model: searchTextHolder
+ immediateAccept: true
+ acceptOnReturn: true
+ acceptOnTab: true
+ acceptOnLostFocus: true
+ modifiedChannel: searchTextModifiedHolder
+ acceptOnPointerLeave: false
+ postBuildCallback: postBuildSearchTextView:
+ )
+ (ActionButtonSpec
+ label: 'searchNextIcon'
+ name: 'SearchNextButton'
+ layout: (LayoutFrame 284 0 2 0 305 0 23 0)
+ hasCharacterOrientedLabel: false
+ translateLabel: true
+ model: searchNextText
+ )
+ (ActionButtonSpec
+ label: 'searchPreviousIcon'
+ name: 'searchPreviousButton'
+ layout: (LayoutFrame 312 0 2 0 333 0 23 0)
+ hasCharacterOrientedLabel: false
+ translateLabel: true
+ model: searchPreviousText
+ )
+ (CheckBoxSpec
+ label: 'Ignore case'
+ name: 'IgnoreCaseCheckBox'
+ layout: (LayoutFrame 338 0 1 0 428 0 23 0)
+ model: ignoreCaseHolder
+ translateLabel: true
+ )
+ (CheckBoxSpec
+ label: 'Match'
+ name: 'MatchCheckBox'
+ layout: (LayoutFrame 427 0 1 0 487 0 23 0)
+ model: matchHolder
+ translateLabel: true
+ )
+ (LabelSpec
+ label: 'SearchBarImageInfoLabel'
+ name: 'SearchBarImageInfoLabel'
+ layout: (LayoutFrame 489 0 1 0 513 0 23 0)
+ hasCharacterOrientedLabel: false
+ translateLabel: true
+ labelChannel: searchBarImageInfoLabelHolder
+ )
+ (LabelSpec
+ label: 'SearchBarInfoLabel'
+ name: 'SearchBarInfoLabel'
+ layout: (LayoutFrame 516 0 1 0 794 0 23 0)
+ translateLabel: true
+ labelChannel: searchBarInfoLabelHolder
+ adjust: left
+ )
+ )
+
+ )
+ )
+ )
+
+ )
+ )
+! !
+
+!StringSearchToolForTextView methodsFor:'accessing'!
+
+textView
+ ^ textView
+!
+
+textView:something
+ textView := something.
+! !
+
+!StringSearchToolForTextView methodsFor:'aspects'!
+
+matchHolder
+
+ matchHolder isNil ifTrue:[
+ matchHolder := false asValue.
+"/ if your app needs to be notified of changes, uncomment one of the lines below:
+"/ matchHolder addDependent:self.
+ matchHolder onChangeSend:#matchHolderChanged to:self.
+
+ ].
+ ^ matchHolder.
+
+ "Created: / 16-06-2007 / 06:45:04 / Administrador"
+ "Modified: / 16-06-2007 / 19:32:15 / Administrador"
+! !
+
+!StringSearchToolForTextView methodsFor:'change & update'!
+
+matchHolderChanged
+
+ self searchNextTextIncludingCurrentSelection: true.
+! !
+
+!StringSearchToolForTextView methodsFor:'initialization & release'!
+
+postBuildSearchTextView: anEditFieldView
+
+ super postBuildSearchTextView: anEditFieldView.
+ anEditFieldView crAction: self crAction.
+! !
+
+!StringSearchToolForTextView methodsFor:'public'!
+
+crAction
+
+ ^ [self returnFocusToTextView]
+!
+
+returnFocusToTextView
+
+ textView takeFocus
+! !
+
+!StringSearchToolForTextView methodsFor:'searching'!
+
+hideSearchBar
+
+ masterApplication isNil ifTrue:[^ self].
+ masterApplication hideSearchBar.
+ self returnFocusToTextView.
+!
+
+searchNextTextFromBeginning
+ |searchText ignoreCase match absentBlock|
+
+ searchText := searchTextView contents.
+ searchText isEmptyOrNil ifTrue:[^self].
+ self textView isNil ifTrue:[^ self].
+ ignoreCase := self ignoreCaseHolder value.
+ match := self matchHolder value.
+ absentBlock := [self searchTextNotFound.].
+ self textView
+ searchFwd:searchText
+ ignoreCase:ignoreCase
+ match: match
+ startingAtLine:1
+ col:0
+ ifAbsent:absentBlock
+!
+
+searchNextTextIncludingCurrentSelection: includeCurrentSelection
+ |searchText ignoreCase match absentBlock startCol startLine|
+
+ self searchTextStarted.
+ searchText := searchTextView contents.
+ searchText isEmptyOrNil ifTrue:[^self].
+ self textView isNil ifTrue:[^ self].
+ ignoreCase := self ignoreCaseHolder value.
+ match := self matchHolder value.
+ absentBlock := [self searchNextTextReachEnd].
+ (self textView hasSelection and:[includeCurrentSelection])
+ ifTrue:[
+ startCol := ((self textView selectionStartCol ? 2) - 1) max: 1.
+ startLine := (self textView selectionStartLine ? 1).
+ self textView searchFwd:searchText ignoreCase:ignoreCase match: match startingAtLine:startLine col:startCol ifAbsent:absentBlock.
+ ] ifFalse:[
+ self textView searchFwd:searchText ignoreCase:ignoreCase match: match ifAbsent:absentBlock
+ ].
+!
+
+searchPreviousText
+
+ |searchText ignoreCase absentBlock|
+
+ self searchTextStarted.
+ searchText := searchTextView contents.
+ searchText isEmptyOrNil ifTrue:[^self].
+ ignoreCase := self ignoreCaseHolder value.
+ self textView isNil ifTrue:[^ self].
+ absentBlock := [self searchPreviousTextReachBeginning].
+ self textView searchBwd:searchText ignoreCase:ignoreCase ifAbsent:absentBlock.
+!
+
+searchPreviousTextFromEnd
+
+ |searchText ignoreCase absentBlock startLine startCol|
+
+ searchText := searchTextView contents.
+ searchText isEmptyOrNil ifTrue:[^self].
+ ignoreCase := self ignoreCaseHolder value.
+ self textView isNil ifTrue:[^ self].
+ absentBlock := [self searchTextNotFound.].
+ startLine := self textView numberOfLines + 1.
+ startCol := 1.
+ self textView
+ searchBwd:searchText
+ ignoreCase:ignoreCase
+ startingAtLine:startLine
+ col:startCol
+ ifAbsent:absentBlock
+! !
+
+!StringSearchToolForTextView class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libtool/Tools__StringSearchToolForTextView.st,v 1.1 2008-04-04 16:22:56 fm Exp $'
+! !