TextView.st
changeset 4462 e7580f29c467
parent 4457 f2efec2e3f93
child 4466 5c7a01426564
equal deleted inserted replaced
4461:9bc209db3be5 4462:e7580f29c467
   309     WordSelectCatchesBlanks := StyleSheet at:'text.wordSelectCatchesBlanks' default:false.
   309     WordSelectCatchesBlanks := StyleSheet at:'text.wordSelectCatchesBlanks' default:false.
   310 
   310 
   311     "Modified: / 03-07-2006 / 16:29:42 / cg"
   311     "Modified: / 03-07-2006 / 16:29:42 / cg"
   312 ! !
   312 ! !
   313 
   313 
       
   314 !TextView class methodsFor:'help specs'!
       
   315 
       
   316 flyByHelpSpec
       
   317     "This resource specification was automatically generated
       
   318      by the UIHelpTool of ST/X."
       
   319 
       
   320     "Do not manually edit this!! If it is corrupted,
       
   321      the UIHelpTool may not be able to read the specification."
       
   322 
       
   323     "
       
   324      UIHelpTool openOnClass:TextView    
       
   325     "
       
   326 
       
   327     <resource: #help>
       
   328 
       
   329     ^ Dictionary new addPairsFrom:#(
       
   330 
       
   331 #matchSearch
       
   332 'Search for a pattern (glob) as opposed to a direct string search'
       
   333 
       
   334 #searchCaseSensitive
       
   335 'Care for case differences'
       
   336 
       
   337 #searchFullWord
       
   338 'Search only for full words (ignore occurrences as substring)'
       
   339 
       
   340 #searchPattern
       
   341 'String or match-pattern to be searched'
       
   342 
       
   343 #searchVariable
       
   344 'Search only for that variable name (ignore occurrences in other contexts)'
       
   345 
       
   346 )
       
   347 ! !
       
   348 
   314 !TextView class methodsFor:'interface specs'!
   349 !TextView class methodsFor:'interface specs'!
   315 
   350 
   316 searchDialogSpec
   351 searchDialogSpec
   317     "This resource specification was automatically generated
   352     "This resource specification was automatically generated
   318      by the UIPainter of ST/X."
   353      by the UIPainter of ST/X."
   333        (WindowSpec
   368        (WindowSpec
   334           label: 'String search'
   369           label: 'String search'
   335           name: 'String search'
   370           name: 'String search'
   336           min: (Point 10 10)
   371           min: (Point 10 10)
   337           max: (Point 1280 1024)
   372           max: (Point 1280 1024)
   338           bounds: (Rectangle 0 0 302 161)
   373           bounds: (Rectangle 0 0 302 189)
   339         )
   374         )
   340         component: 
   375         component: 
   341        (SpecCollection
   376        (SpecCollection
   342           collection: (
   377           collection: (
       
   378            (LabelSpec
       
   379               label: 'SearchPattern:'
       
   380               name: 'label'
       
   381               layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
       
   382               level: 0
       
   383               translateLabel: true
       
   384               adjust: left
       
   385             )
       
   386            (ComboBoxSpec
       
   387               name: 'patternComboBox'
       
   388               layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
       
   389               activeHelpKey: searchPattern
       
   390               tabable: true
       
   391               model: searchPattern
       
   392               immediateAccept: false
       
   393               acceptOnLeave: true
       
   394               acceptOnReturn: true
       
   395               acceptOnTab: true
       
   396               acceptOnLostFocus: true
       
   397               acceptOnPointerLeave: false
       
   398               autoSelectInitialText: true
       
   399               comboList: patternList
       
   400             )
       
   401            (VerticalPanelViewSpec
       
   402               name: 'VerticalPanel1'
       
   403               layout: (LayoutFrame 0 0.0 52 0 0 1.0 -30 1)
       
   404               horizontalLayout: fit
       
   405               verticalLayout: top
       
   406               component: 
       
   407              (SpecCollection
       
   408                 collection: (
       
   409                  (CheckBoxSpec
       
   410                     label: 'Case Sensitive'
       
   411                     name: 'ignoreCaseCheckBox'
       
   412                     activeHelpKey: searchCaseSensitive
       
   413                     level: 0
       
   414                     tabable: true
       
   415                     model: caseSensitive
       
   416                     translateLabel: true
       
   417                     extent: (Point 302 24)
       
   418                   )
       
   419                  (CheckBoxSpec
       
   420                     label: 'Match (for Forward only)'
       
   421                     name: 'matchCheckBox'
       
   422                     activeHelpKey: matchSearch
       
   423                     level: 0
       
   424                     tabable: true
       
   425                     model: match
       
   426                     translateLabel: true
       
   427                     extent: (Point 302 24)
       
   428                   )
       
   429                  (CheckBoxSpec
       
   430                     label: 'Search Full Words'
       
   431                     name: 'CheckBox2'
       
   432                     activeHelpKey: searchFullWord
       
   433                     level: 0
       
   434                     enableChannel: searchFullWordEnabled
       
   435                     tabable: true
       
   436                     model: searchFullWord
       
   437                     translateLabel: true
       
   438                     extent: (Point 302 24)
       
   439                   )
       
   440                  (CheckBoxSpec
       
   441                     label: 'Variable Only'
       
   442                     name: 'CheckBox1'
       
   443                     activeHelpKey: searchVariable
       
   444                     level: 0
       
   445                     visibilityChannel: searchVariableVisible
       
   446                     enableChannel: searchVariableEnabled
       
   447                     tabable: true
       
   448                     model: searchVariable
       
   449                     translateLabel: true
       
   450                     labelChannel: stringWithVariableUnderCursorHolder
       
   451                     extent: (Point 302 24)
       
   452                   )
       
   453                  )
       
   454                
       
   455               )
       
   456             )
   343            (HorizontalPanelViewSpec
   457            (HorizontalPanelViewSpec
   344               name: 'horizontalPanelView'
   458               name: 'horizontalPanelView'
   345               layout: (LayoutFrame 0 0.0 -26 1.0 0 1.0 0 1.0)
   459               layout: (LayoutFrame 0 0.0 -28 1.0 0 1.0 0 1.0)
   346               level: 0
   460               level: 0
   347               horizontalLayout: fitSpace
   461               horizontalLayout: fitSpace
   348               verticalLayout: center
   462               verticalLayout: center
   349               horizontalSpace: 3
   463               horizontalSpace: 3
   350               verticalSpace: 3
   464               verticalSpace: 3
   384                   )
   498                   )
   385                  )
   499                  )
   386                
   500                
   387               )
   501               )
   388             )
   502             )
   389            (LabelSpec
       
   390               label: 'SearchPattern:'
       
   391               name: 'label'
       
   392               layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
       
   393               level: 0
       
   394               translateLabel: true
       
   395               adjust: left
       
   396             )
       
   397            (ComboBoxSpec
       
   398               name: 'patternComboBox'
       
   399               layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
       
   400               tabable: true
       
   401               model: searchPattern
       
   402               immediateAccept: false
       
   403               acceptOnLeave: true
       
   404               acceptOnReturn: true
       
   405               acceptOnTab: true
       
   406               acceptOnLostFocus: true
       
   407               acceptOnPointerLeave: false
       
   408               autoSelectInitialText: true
       
   409               comboList: patternList
       
   410             )
       
   411            (CheckBoxSpec
       
   412               label: 'Case Sensitive'
       
   413               name: 'ignoreCaseCheckBox'
       
   414               layout: (LayoutFrame 3 0.0 54 0 -3 1.0 77 0)
       
   415               level: 0
       
   416               tabable: true
       
   417               model: caseSensitive
       
   418               translateLabel: true
       
   419             )
       
   420            (CheckBoxSpec
       
   421               label: 'Match (for Forward only)'
       
   422               name: 'matchCheckBox'
       
   423               layout: (LayoutFrame 3 0.0 78 0 -3 1.0 100 0)
       
   424               level: 0
       
   425               tabable: true
       
   426               model: match
       
   427               translateLabel: true
       
   428             )
       
   429            (CheckBoxSpec
       
   430               label: 'Variable Only'
       
   431               name: 'CheckBox1'
       
   432               layout: (LayoutFrame 3 0.0 102 0 -3 1.0 124 0)
       
   433               level: 0
       
   434               visibilityChannel: searchVariableVisible
       
   435               enableChannel: searchVariableEnabled
       
   436               tabable: true
       
   437               model: searchVariable
       
   438               translateLabel: true
       
   439               labelChannel: stringWithVariableUnderCursorHolder
       
   440             )
       
   441            )
   503            )
   442          
   504          
   443         )
   505         )
   444       )
   506       )
   445 ! !
   507 ! !
  1998 
  2060 
  1999     "
  2061     "
  2000      Q: is it a good idea to preserve the last searchstring between views ?
  2062      Q: is it a good idea to preserve the last searchstring between views ?
  2001     "
  2063     "
  2002     |searchBox patternHolder caseHolder matchHolder fwd ign match initialString
  2064     |searchBox patternHolder caseHolder matchHolder fwd ign match initialString
  2003      bindings bldr doSearch modal searchVariableHolder selectedVariable|
  2065      bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder|
  2004 
  2066 
  2005     searchBarActionBlock notNil ifTrue:[
  2067     searchBarActionBlock notNil ifTrue:[
  2006         self resetVariablesBeforeNewSearch.
  2068         self resetVariablesBeforeNewSearch.
  2007         searchBarActionBlock value:#search value:self.
  2069         searchBarActionBlock value:#search value:self.
  2008         ^ self
  2070         ^ self
  2014     caseHolder := ign not asValue.
  2076     caseHolder := ign not asValue.
  2015 
  2077 
  2016     match := lastSearchWasMatch ? LastSearchWasMatch ? false.
  2078     match := lastSearchWasMatch ? LastSearchWasMatch ? false.
  2017     matchHolder := match asValue.
  2079     matchHolder := match asValue.
  2018     searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
  2080     searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
       
  2081     searchFullWordHolder := false asValue.
  2019 
  2082 
  2020     patternHolder := '' asValue.
  2083     patternHolder := '' asValue.
  2021 
  2084 
  2022     self setSearchPatternWithMatchEscapes: match.
  2085     self setSearchPatternWithMatchEscapes: match.
  2023 
  2086 
  2039     ].
  2102     ].
  2040 
  2103 
  2041     fwd := true. 
  2104     fwd := true. 
  2042 
  2105 
  2043     doSearch := [:fwd |
  2106     doSearch := [:fwd |
  2044        self resetVariablesBeforeNewSearch.
  2107         |pattern|
       
  2108 
       
  2109         self resetVariablesBeforeNewSearch.
  2045 
  2110 
  2046         (self searchVariableVisible 
  2111         (self searchVariableVisible 
  2047             and:[searchVariableHolder value
  2112             and:[searchVariableHolder value
  2048             and:[selectedVariable notNil]]
  2113             and:[selectedVariable notNil]]
  2049         ) ifTrue:[
  2114         ) ifTrue:[
  2050             self searchVariableWithSyntaxElement:selectedVariable forward:fwd
  2115             self searchVariableWithSyntaxElement:selectedVariable forward:fwd
  2051         ] ifFalse:[
  2116         ] ifFalse:[
  2052             lastSearchWasVariableSearch := false.
  2117             lastSearchWasVariableSearch := false.
  2053             LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
  2118             LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
  2054             LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
  2119             LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
  2055 
  2120             pattern := patternHolder value.
  2056             self 
  2121             pattern notEmptyOrNil ifTrue:[
  2057                 search:patternHolder value 
  2122                 self searchUsingSpec:(
  2058                 ignoreCase:lastSearchIgnoredCase 
  2123                     ListView::SearchSpec new
  2059                 match: lastSearchWasMatch 
  2124                         pattern:pattern
  2060                 forward:fwd.
  2125                         ignoreCase:lastSearchIgnoredCase 
       
  2126                         match: lastSearchWasMatch 
       
  2127                         variable: searchVariableHolder value 
       
  2128                         fullWord: searchFullWordHolder value 
       
  2129                         forward:fwd).
       
  2130 "/                self 
       
  2131 "/                    search:patternHolder value 
       
  2132 "/                    ignoreCase:lastSearchIgnoredCase 
       
  2133 "/                    match: lastSearchWasMatch 
       
  2134 "/                    forward:fwd.
       
  2135             ]
  2061         ].
  2136         ].
  2062     ].
  2137     ].
  2063 
  2138 
  2064     bindings := IdentityDictionary new.
  2139     bindings := IdentityDictionary new.
  2065     bindings at:#searchPattern put:patternHolder.
  2140     bindings at:#searchPattern put:patternHolder.
  2072     ].
  2147     ].
  2073     bindings at:#caseSensitive put:caseHolder.
  2148     bindings at:#caseSensitive put:caseHolder.
  2074     bindings at:#match put:matchHolder.
  2149     bindings at:#match put:matchHolder.
  2075     bindings at:#patternList put:LastSearchPatterns.
  2150     bindings at:#patternList put:LastSearchPatterns.
  2076 
  2151 
  2077     selectedVariable := self syntaxElementForSelectedVariable.
  2152     self supportsSyntaxElements ifFalse:[
  2078     bindings at:#searchVariableEnabled put:(selectedVariable notNil).
  2153         bindings at:#searchVariableVisible put:false.
  2079     selectedVariable notNil ifTrue:[
  2154     ] ifTrue:[
  2080         bindings 
  2155         bindings at:#searchVariableVisible put:true.
  2081             at:#stringWithVariableUnderCursorHolder 
  2156         selectedVariable := self syntaxElementForSelectedVariable.
  2082             put:('Variable ("%1")' bindWith:selectedVariable value).
  2157         bindings at:#searchVariableEnabled put:(selectedVariable notNil).
  2083         searchVariableHolder value:true.
  2158         selectedVariable notNil ifTrue:[
  2084     ] ifFalse:[
  2159             bindings 
  2085         bindings 
  2160                 at:#stringWithVariableUnderCursorHolder 
  2086             at:#stringWithVariableUnderCursorHolder 
  2161                 put:('Variable ("%1")' bindWith:selectedVariable value).
  2087             put:('Variable (none selected)').
  2162             searchVariableHolder value:true.
       
  2163         ] ifFalse:[
       
  2164             bindings 
       
  2165                 at:#stringWithVariableUnderCursorHolder 
       
  2166                 put:('Variable (none selected)').
       
  2167         ].
  2088     ].
  2168     ].
  2089     bindings at:#searchVariable put:searchVariableHolder.
  2169     bindings at:#searchVariable put:searchVariableHolder.
       
  2170     bindings at:#searchFullWord put:searchFullWordHolder.
       
  2171     bindings at:#searchFullWordEnabled put:true.
  2090 
  2172 
  2091     modal ifTrue:[
  2173     modal ifTrue:[
  2092         searchBox := SimpleDialog new.
  2174         searchBox := SimpleDialog new.
  2093     ] ifFalse:[
  2175     ] ifFalse:[
  2094         searchBox := ApplicationModel new.
  2176         searchBox := ApplicationModel new.
  2096     ].
  2178     ].
  2097     searchBox resources:(self resources).
  2179     searchBox resources:(self resources).
  2098 
  2180 
  2099     bldr := searchBox builder.
  2181     bldr := searchBox builder.
  2100     bldr addBindings:bindings.
  2182     bldr addBindings:bindings.
       
  2183     bldr aspectAt:#flyByHelpSpec put:(self class flyByHelpSpec).
  2101     searchBox allButOpenFrom:(self class searchDialogSpec).
  2184     searchBox allButOpenFrom:(self class searchDialogSpec).
  2102 
  2185 
  2103     (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
  2186     (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
  2104     (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
  2187     (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
  2105     (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
  2188     (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
  2218 
  2301 
  2219     "Created: / 11-07-2006 / 11:18:04 / fm"
  2302     "Created: / 11-07-2006 / 11:18:04 / fm"
  2220     "Modified: / 23-03-2012 / 12:12:07 / cg"
  2303     "Modified: / 23-03-2012 / 12:12:07 / cg"
  2221 !
  2304 !
  2222 
  2305 
       
  2306 searchUsingSpec:aSearchSpec
       
  2307     self rememberSearchPattern:(aSearchSpec pattern).
       
  2308     "/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign.
       
  2309     "/ LastSearchWasMatch := match.
       
  2310     aSearchSpec forward ifFalse:[
       
  2311         lastSearchDirection := #backward.
       
  2312         self searchBwdUsingSpec:aSearchSpec
       
  2313     ] ifTrue:[
       
  2314         lastSearchDirection := #forward.
       
  2315         self searchFwdUsingSpec:aSearchSpec
       
  2316     ]
       
  2317 
       
  2318     "Created: / 11-07-2006 / 11:18:04 / fm"
       
  2319     "Modified: / 23-03-2012 / 12:12:07 / cg"
       
  2320 !
       
  2321 
  2223 searchVariableVisible
  2322 searchVariableVisible
  2224     "search variable option in searchbox visible?
  2323     "search variable option in searchbox visible?
  2225      (only true for codeview2's textview)"
  2324      (only true for codeview2's textview)"
  2226 
  2325 
  2227     ^ false
  2326     ^ false
  2228 
  2327 
  2229     "Created: / 08-03-2012 / 14:01:24 / cg"
  2328     "Created: / 08-03-2012 / 14:01:24 / cg"
  2230 !
  2329 !
  2231 
  2330 
  2232 searchVariableWithSyntaxElement:syntaxElementForVariable forward:fwd
  2331 searchVariableWithSyntaxElement:syntaxElementForVariable forward:fwd
       
  2332     "this only works for CodeView2::TextView, which supports syntaxElements"
       
  2333 
  2233     |el el2|
  2334     |el el2|
  2234 
  2335 
  2235     lastSearchWasVariableSearch := true.
  2336     lastSearchWasVariableSearch := true.
  2236     el := fwd 
  2337     el := fwd 
  2237         ifTrue:[syntaxElementForVariable nextElement] 
  2338         ifTrue:[syntaxElementForVariable nextElement] 
  3025     lastSearchPattern notNil ifTrue:[
  3126     lastSearchPattern notNil ifTrue:[
  3026         lastSearchDirection == #backward ifTrue:[
  3127         lastSearchDirection == #backward ifTrue:[
  3027             self 
  3128             self 
  3028                 searchBwd:lastSearchPattern 
  3129                 searchBwd:lastSearchPattern 
  3029                 ignoreCase:ign
  3130                 ignoreCase:ign
       
  3131                 match: match
  3030         ] ifFalse:[
  3132         ] ifFalse:[
  3031             self 
  3133             self 
  3032                 searchFwd:lastSearchPattern 
  3134                 searchFwd:lastSearchPattern 
  3033                 ignoreCase:ign
  3135                 ignoreCase:ign
  3034                 match: match
  3136                 match: match
  3038     "Created: / 03-05-1999 / 15:02:16 / cg"
  3140     "Created: / 03-05-1999 / 15:02:16 / cg"
  3039     "Modified: / 21-09-2006 / 16:47:57 / cg"
  3141     "Modified: / 21-09-2006 / 16:47:57 / cg"
  3040 !
  3142 !
  3041 
  3143 
  3042 searchBwd
  3144 searchBwd
  3043     "search backward and -if found- position cursor"
  3145     "search backward (for the same thing again)
       
  3146      If found, position cursor"
  3044 
  3147 
  3045     |ign selectedVariable|
  3148     |ign selectedVariable|
  3046 
  3149 
  3047     searchAction notNil ifTrue:[
  3150     searchAction notNil ifTrue:[
  3048         "/autosearch is cleared whenever there is search with user selection 
  3151         "/autosearch is cleared whenever there is search with user selection 
  3098 !
  3201 !
  3099 
  3202 
  3100 searchBwd:pattern ifAbsent:aBlock
  3203 searchBwd:pattern ifAbsent:aBlock
  3101     "do a backward search"
  3204     "do a backward search"
  3102 
  3205 
       
  3206     self 
       
  3207         searchBwdUsingSpec:(ListView::SearchSpec new
       
  3208                                         pattern:pattern)
       
  3209         ifAbsent:aBlock
       
  3210 
       
  3211     "Modified: 13.9.1997 / 01:05:49 / cg"
       
  3212 !
       
  3213 
       
  3214 searchBwd:pattern ignoreCase:ign
       
  3215     "do a backward search"
       
  3216 
       
  3217     self
       
  3218         searchBwd:pattern
       
  3219         ignoreCase:ign
       
  3220         ifAbsent:[
       
  3221                     self sensor compressKeyPressEventsWithKey:#FindPrev.
       
  3222                     self showNotFound
       
  3223                  ].
       
  3224     "/ lastSearchIgnoredCase := ign.
       
  3225     lastSearchPattern := pattern string
       
  3226 
       
  3227     "Created: / 13-09-1997 / 06:18:00 / cg"
       
  3228     "Modified: / 23-03-2012 / 12:10:25 / cg"
       
  3229 !
       
  3230 
       
  3231 searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
       
  3232     "do a backward search"
       
  3233 
       
  3234     self 
       
  3235         searchBwdUsingSpec:(ListView::SearchSpec new
       
  3236                                         pattern:pattern
       
  3237                                         ignoreCase:ign)
       
  3238         ifAbsent:aBlock
       
  3239 
       
  3240     "Modified: 13.9.1997 / 01:05:49 / cg"
       
  3241     "Created: 13.9.1997 / 06:18:41 / cg"
       
  3242 !
       
  3243 
       
  3244 searchBwd:pattern ignoreCase:ign match: match
       
  3245     "do a backward search.
       
  3246     match pattern functionality is not yet available for backward search"
       
  3247 
       
  3248     "/ lastSearchWasMatch := match.
       
  3249     self searchBwd:pattern ignoreCase:ign.
       
  3250 
       
  3251     "Modified: / 23-03-2012 / 12:12:44 / cg"
       
  3252 !
       
  3253 
       
  3254 searchBwdUsingSpec:searchSpec
       
  3255     "do a backward search"
       
  3256 
       
  3257     self 
       
  3258         searchBwdUsingSpec:searchSpec
       
  3259         ifAbsent:[self showNotFound].
       
  3260 
       
  3261 "/    lastSearchIgnoredCase := false.
       
  3262     lastSearchPattern := searchSpec pattern string
       
  3263 
       
  3264     "Modified: / 21-09-2006 / 16:48:29 / cg"
       
  3265 !
       
  3266 
       
  3267 searchBwdUsingSpec:searchSpec ifAbsent:aBlock
       
  3268     "do a backward search"
       
  3269 
  3103     |pos startLine startCol|
  3270     |pos startLine startCol|
  3104 
  3271 
  3105     pos :=  self startPositionForSearchBackward.
  3272     pos :=  self startPositionForSearchBackward.
  3106     startLine := pos y.
  3273     startLine := pos y.
  3107     startCol := pos x.
  3274     startCol := pos x.
  3108 
  3275 
  3109     self 
  3276     self 
  3110         searchBackwardFor:pattern 
  3277         searchBackwardUsingSpec:searchSpec
  3111         startingAtLine:startLine col:startCol
  3278         startingAtLine:startLine col:startCol
  3112         ifFound:[:line :col | 
  3279         ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col] 
  3113             self showMatch:pattern isMatch:false atLine:line col:col] 
       
  3114         ifAbsent:aBlock
  3280         ifAbsent:aBlock
  3115 
       
  3116     "Modified: 13.9.1997 / 01:05:49 / cg"
       
  3117 !
       
  3118 
       
  3119 searchBwd:pattern ignoreCase:ign
       
  3120     "do a backward search"
       
  3121 
       
  3122     self searchBwd:pattern 
       
  3123          ignoreCase:ign 
       
  3124          ifAbsent:[
       
  3125                     self sensor compressKeyPressEventsWithKey:#FindPrev.
       
  3126                     self showNotFound
       
  3127                   ].
       
  3128     "/ lastSearchIgnoredCase := ign.
       
  3129     lastSearchPattern := pattern string
       
  3130 
       
  3131     "Created: / 13-09-1997 / 06:18:00 / cg"
       
  3132     "Modified: / 23-03-2012 / 12:10:25 / cg"
       
  3133 !
       
  3134 
       
  3135 searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
       
  3136     "do a backward search"
       
  3137 
       
  3138     |pos startLine startCol|
       
  3139 
       
  3140     pos :=  self startPositionForSearchBackward.
       
  3141     startLine := pos y.
       
  3142     startCol := pos x.
       
  3143 
       
  3144     self 
       
  3145         searchBackwardFor:pattern 
       
  3146         ignoreCase:ign
       
  3147         startingAtLine:startLine col:startCol
       
  3148         ifFound:[:line :col | self showMatch:pattern isMatch:false atLine:line col:col] 
       
  3149         ifAbsent:aBlock
       
  3150 
       
  3151     "Modified: 13.9.1997 / 01:05:49 / cg"
       
  3152     "Created: 13.9.1997 / 06:18:41 / cg"
       
  3153 !
       
  3154 
       
  3155 searchBwd:pattern ignoreCase:ign match: match
       
  3156     "do a backward search.
       
  3157     match pattern functionality is not yet available for backward search"
       
  3158 
       
  3159     "/ lastSearchWasMatch := match.
       
  3160     self searchBwd:pattern ignoreCase:ign.
       
  3161 
       
  3162     "Modified: / 23-03-2012 / 12:12:44 / cg"
       
  3163 !
  3281 !
  3164 
  3282 
  3165 searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol
  3283 searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol
  3166     "select characters enclosed by matching parenthesis if one is under startLine/Col"
  3284     "select characters enclosed by matching parenthesis if one is under startLine/Col"
  3167 
  3285 
  3703 
  3821 
  3704     "Modified: 15.10.1996 / 12:22:30 / cg"
  3822     "Modified: 15.10.1996 / 12:22:30 / cg"
  3705 !
  3823 !
  3706 
  3824 
  3707 searchFwd
  3825 searchFwd
  3708     "search forward for pattern or selection"
  3826     "search forward for the same pattern or selection again"
  3709 
  3827 
  3710     |ign match variable|
  3828     |ign match variable|
  3711 
  3829 
  3712     searchAction notNil ifTrue:[
  3830     searchAction notNil ifTrue:[
  3713         "/ autosearch is cleared whenever there is search with user selection 
  3831         "/ autosearch is cleared whenever there is search with user selection 
  3775 !
  3893 !
  3776 
  3894 
  3777 searchFwd:pattern ifAbsent:aBlock
  3895 searchFwd:pattern ifAbsent:aBlock
  3778     "do a forward search"
  3896     "do a forward search"
  3779 
  3897 
  3780     |pos startLine startCol|
  3898     self
  3781 
  3899         searchFwdUsingSpec:(ListView::SearchSpec new
  3782     pos := self startPositionForSearchForward.
  3900                                 pattern:pattern)
  3783     startLine := pos y.
       
  3784     startCol := pos x.
       
  3785 
       
  3786     self 
       
  3787         searchForwardFor:pattern 
       
  3788         startingAtLine:startLine col:startCol
       
  3789         ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
       
  3790         ifAbsent:aBlock
  3901         ifAbsent:aBlock
  3791 
  3902 
  3792     "Modified: / 21-09-2006 / 16:51:28 / cg"
  3903     "Modified: / 21-09-2006 / 16:51:28 / cg"
  3793 !
  3904 !
  3794 
  3905 
  3795 searchFwd:pattern ignoreCase:ign
  3906 searchFwd:pattern ignoreCase:ign
  3796     "do a forward search"
  3907     "do a forward search"
  3797 
  3908 
  3798     self 
  3909     self
  3799         searchFwd:pattern 
  3910         searchFwdUsingSpec:(ListView::SearchSpec new
  3800         ignoreCase:ign 
  3911                                 pattern:pattern
       
  3912                                 ignoreCase:ign)
  3801         ifAbsent:[
  3913         ifAbsent:[
  3802                     self sensor compressKeyPressEventsWithKey:#FindNext.
  3914                     self sensor compressKeyPressEventsWithKey:#FindNext.
  3803                     self showNotFound
  3915                     self showNotFound
  3804                  ].
  3916                  ].
  3805     "/ lastSearchIgnoredCase := ign.
  3917     "/ lastSearchIgnoredCase := ign.
  3810 !
  3922 !
  3811 
  3923 
  3812 searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
  3924 searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
  3813     "do a forward search"
  3925     "do a forward search"
  3814 
  3926 
  3815     |pos startLine startCol|
  3927     self
  3816 
  3928         searchFwdUsingSpec:(ListView::SearchSpec new
  3817     pos :=  self startPositionForSearchForward.
  3929                                 pattern:pattern
  3818     startLine := pos y.
  3930                                 ignoreCase:ign)
  3819     startCol := pos x.
       
  3820 
       
  3821     self 
       
  3822         searchForwardFor:pattern 
       
  3823         ignoreCase:ign
       
  3824         startingAtLine:startLine col:startCol
       
  3825         ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
       
  3826         ifAbsent:aBlock
  3931         ifAbsent:aBlock
  3827 
  3932 
  3828     "Modified: 13.9.1997 / 01:05:35 / cg"
  3933     "Modified: 13.9.1997 / 01:05:35 / cg"
  3829     "Created: 13.9.1997 / 06:18:27 / cg"
  3934     "Created: 13.9.1997 / 06:18:27 / cg"
  3830 !
  3935 !
  3831 
  3936 
  3832 searchFwd:pattern ignoreCase:ign match: match
  3937 searchFwd:pattern ignoreCase:ign match: match
  3833     "do a forward search"
  3938     "do a forward search"
  3834 
  3939 
  3835     self 
  3940     self
  3836         searchFwd:pattern 
  3941         searchFwdUsingSpec:(ListView::SearchSpec new
  3837         ignoreCase:ign 
  3942                                 pattern:pattern
  3838         match: match
  3943                                 ignoreCase:ign
       
  3944                                 match:match)
  3839         ifAbsent:[
  3945         ifAbsent:[
  3840                     self sensor compressKeyPressEventsWithKey:#FindNext.
  3946                     self sensor compressKeyPressEventsWithKey:#FindNext.
  3841                     self showNotFound
  3947                     self showNotFound
  3842                  ].
  3948                  ].
  3843     "/ lastSearchIgnoredCase := ign.
  3949     "/ lastSearchIgnoredCase := ign.
  3849 !
  3955 !
  3850 
  3956 
  3851 searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock
  3957 searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock
  3852     "do a forward search"
  3958     "do a forward search"
  3853 
  3959 
       
  3960     self 
       
  3961         searchFwdUsingSpec:(ListView::SearchSpec new
       
  3962                                 pattern:pattern
       
  3963                                 ignoreCase:ign
       
  3964                                 match:match)
       
  3965         ifAbsent:aBlock
       
  3966 
       
  3967     "Modified: 13.9.1997 / 01:05:35 / cg"
       
  3968     "Created: 13.9.1997 / 06:18:27 / cg"
       
  3969 !
       
  3970 
       
  3971 searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock
       
  3972     "do a forward search"
       
  3973 
       
  3974     self 
       
  3975         searchFwdUsingSpec:(ListView::SearchSpec new
       
  3976                                 pattern:pattern
       
  3977                                 ignoreCase:ign
       
  3978                                 match:match)
       
  3979         startingAtLine:startLine col:startCol
       
  3980         ifAbsent:aBlock
       
  3981 !
       
  3982 
       
  3983 searchFwdUsingSpec:searchSpec
       
  3984     "do a forward search"
       
  3985 
       
  3986     self 
       
  3987         searchFwdUsingSpec:searchSpec 
       
  3988         ifAbsent:[self showNotFound].
       
  3989 
       
  3990 "/    lastSearchIgnoredCase := false.
       
  3991     lastSearchPattern := searchSpec pattern string
       
  3992 
       
  3993     "Modified: / 21-09-2006 / 16:52:04 / cg"
       
  3994 !
       
  3995 
       
  3996 searchFwdUsingSpec:searchSpec ifAbsent:aBlock
       
  3997     "do a forward search"
       
  3998 
  3854     |pos startLine startCol|
  3999     |pos startLine startCol|
  3855 
  4000 
  3856     pos :=  self startPositionForSearchForward.
  4001     pos := self startPositionForSearchForward.
  3857     startLine := pos y.
  4002     startLine := pos y.
  3858     startCol := pos x.
  4003     startCol := pos x.
  3859 
  4004 
  3860     self 
  4005     self 
  3861         searchFwd:pattern 
  4006         searchFwdUsingSpec:searchSpec 
  3862         ignoreCase:ign
       
  3863         match: match
       
  3864         startingAtLine:startLine col:startCol
  4007         startingAtLine:startLine col:startCol
  3865         ifAbsent:aBlock
  4008         ifAbsent:aBlock
  3866 
  4009 
  3867     "Modified: 13.9.1997 / 01:05:35 / cg"
  4010     "Modified: 13.9.1997 / 01:05:35 / cg"
  3868     "Created: 13.9.1997 / 06:18:27 / cg"
  4011     "Created: 13.9.1997 / 06:18:27 / cg"
  3869 !
  4012 !
  3870 
  4013 
  3871 searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock
  4014 searchFwdUsingSpec:searchSpec startingAtLine:startLine col:startCol ifAbsent:aBlock
  3872     "do a forward search"
  4015     "do a forward search"
  3873 
  4016 
  3874     self 
  4017     self 
  3875         searchForwardFor:pattern 
  4018         searchForwardUsingSpec:searchSpec
  3876         ignoreCase:ign
       
  3877         match: match
       
  3878         startingAtLine:startLine col:startCol
  4019         startingAtLine:startLine col:startCol
  3879         ifFound:[:line :col | self showMatch:pattern isMatch:match atLine:line col:col]
  4020         ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col]
  3880         ifAbsent:aBlock
  4021         ifAbsent:aBlock
  3881 !
  4022 !
  3882 
  4023 
  3883 searchPattern
  4024 searchPattern
  3884     "return the last search pattern"
  4025     "return the last search pattern"
  4568 ! !
  4709 ! !
  4569 
  4710 
  4570 !TextView class methodsFor:'documentation'!
  4711 !TextView class methodsFor:'documentation'!
  4571 
  4712 
  4572 version
  4713 version
  4573     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.340 2012-10-02 14:23:34 cg Exp $'
  4714     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.341 2012-10-23 12:58:41 cg Exp $'
  4574 !
  4715 !
  4575 
  4716 
  4576 version_CVS
  4717 version_CVS
  4577     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.340 2012-10-02 14:23:34 cg Exp $'
  4718     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.341 2012-10-23 12:58:41 cg Exp $'
  4578 ! !
  4719 ! !
  4579 
  4720 
  4580 TextView initialize!
  4721 TextView initialize!