TextView.st
changeset 5543 39eb7c59b271
parent 5523 1d2ed51687e2
child 5547 5637fb125cbf
equal deleted inserted replaced
5542:2b73601f4549 5543:39eb7c59b271
    27 		DefaultSelectionBackgroundColor
    27 		DefaultSelectionBackgroundColor
    28 		DefaultAlternativeSelectionForegroundColor
    28 		DefaultAlternativeSelectionForegroundColor
    29 		DefaultAlternativeSelectionBackgroundColor MatchDelayTime
    29 		DefaultAlternativeSelectionBackgroundColor MatchDelayTime
    30 		WordSelectCatchesBlanks LastSearchPatterns
    30 		WordSelectCatchesBlanks LastSearchPatterns
    31 		NumRememberedSearchPatterns LastSearchIgnoredCase
    31 		NumRememberedSearchPatterns LastSearchIgnoredCase
    32 		LastSearchWasMatch DefaultParenthesisSpecification'
    32 		LastSearchWasMatch DefaultParenthesisSpecification
       
    33 		LastSearchWasMatchWithRegex LastSearchWasWithWrapAtEnd'
    33 	poolDictionaries:''
    34 	poolDictionaries:''
    34 	category:'Views-Text'
    35 	category:'Views-Text'
    35 !
    36 !
    36 
    37 
    37 !TextView class methodsFor:'documentation'!
    38 !TextView class methodsFor:'documentation'!
   379       (WindowSpec
   380       (WindowSpec
   380          label: 'String search'
   381          label: 'String search'
   381          name: 'String search'
   382          name: 'String search'
   382          min: (Point 10 10)
   383          min: (Point 10 10)
   383          max: (Point 1280 1024)
   384          max: (Point 1280 1024)
   384          bounds: (Rectangle 0 0 319 266)
   385          bounds: (Rectangle 0 0 411 272)
   385        )
   386        )
   386        component: 
   387        component: 
   387       (SpecCollection
   388       (SpecCollection
   388          collection: (
   389          collection: (
   389           (LabelSpec
   390           (LabelSpec
   423                    activeHelpKey: searchCaseSensitive
   424                    activeHelpKey: searchCaseSensitive
   424                    level: 0
   425                    level: 0
   425                    tabable: true
   426                    tabable: true
   426                    model: caseSensitive
   427                    model: caseSensitive
   427                    translateLabel: true
   428                    translateLabel: true
   428                    extent: (Point 319 24)
   429                    extent: (Point 411 24)
   429                  )
   430                  )
   430                 (CheckBoxSpec
   431                 (ViewSpec
   431                    label: 'Match (forward only)'
   432                    name: 'MatchBox'
   432                    name: 'matchCheckBox'
   433                    component: 
   433                    activeHelpKey: matchSearch
   434                   (SpecCollection
   434                    level: 0
   435                      collection: (
   435                    tabable: true
   436                       (CheckBoxSpec
   436                    model: match
   437                          label: 'Match (forward only)'
   437                    translateLabel: true
   438                          name: 'matchCheckBox'
   438                    extent: (Point 319 24)
   439                          layout: (LayoutFrame 0 0 0 0 260 0 0 1)
       
   440                          activeHelpKey: matchSearch
       
   441                          level: 0
       
   442                          tabable: true
       
   443                          model: match
       
   444                          translateLabel: true
       
   445                        )
       
   446                       (CheckBoxSpec
       
   447                          label: 'Regex Match'
       
   448                          name: 'CheckBox6'
       
   449                          layout: (LayoutFrame -151 1 0 0 0 1 22 0)
       
   450                          visibilityChannel: match
       
   451                          enableChannel: match
       
   452                          model: matchWithRegex
       
   453                          translateLabel: true
       
   454                        )
       
   455                       )
       
   456                     
       
   457                    )
       
   458                    extent: (Point 411 24)
   439                  )
   459                  )
   440                 (CheckBoxSpec
   460                 (CheckBoxSpec
   441                    label: 'Search Full Words'
   461                    label: 'Search Full Words'
   442                    name: 'CheckBox2'
   462                    name: 'CheckBox2'
   443                    activeHelpKey: searchFullWord
   463                    activeHelpKey: searchFullWord
   444                    level: 0
   464                    level: 0
   445                    enableChannel: searchFullWordEnabled
   465                    enableChannel: searchFullWordEnabled
   446                    tabable: true
   466                    tabable: true
   447                    model: searchFullWord
   467                    model: searchFullWord
   448                    translateLabel: true
   468                    translateLabel: true
   449                    extent: (Point 319 24)
   469                    extent: (Point 411 24)
   450                  )
   470                  )
   451                 (CheckBoxSpec
   471                 (CheckBoxSpec
   452                    label: 'At Begin of Line Only'
   472                    label: 'At Begin of Line Only'
   453                    name: 'CheckBox5'
   473                    name: 'CheckBox5'
   454                    activeHelpKey: searchAtBeginOfLineOnly
   474                    activeHelpKey: searchAtBeginOfLineOnly
   455                    level: 0
   475                    level: 0
   456                    tabable: true
   476                    tabable: true
   457                    model: searchAtBeginOfLineOnly
   477                    model: searchAtBeginOfLineOnly
   458                    translateLabel: true
   478                    translateLabel: true
   459                    extent: (Point 319 24)
   479                    extent: (Point 411 24)
   460                  )
   480                  )
   461                 (CheckBoxSpec
   481                 (CheckBoxSpec
   462                    label: 'Variable Only'
   482                    label: 'Variable Only'
   463                    name: 'CheckBox1'
   483                    name: 'CheckBox1'
   464                    activeHelpKey: searchVariable
   484                    activeHelpKey: searchVariable
   467                    enableChannel: searchVariableEnabled
   487                    enableChannel: searchVariableEnabled
   468                    tabable: true
   488                    tabable: true
   469                    model: searchVariable
   489                    model: searchVariable
   470                    translateLabel: true
   490                    translateLabel: true
   471                    labelChannel: stringWithVariableUnderCursorHolder
   491                    labelChannel: stringWithVariableUnderCursorHolder
   472                    extent: (Point 319 24)
   492                    extent: (Point 411 24)
   473                  )
   493                  )
   474                 (CheckBoxSpec
   494                 (CheckBoxSpec
   475                    label: 'Select Lines'
   495                    label: 'Select Lines'
   476                    name: 'CheckBox3'
   496                    name: 'CheckBox3'
   477                    activeHelpKey: selectLines
   497                    activeHelpKey: selectLines
   481                    model: selectLines
   501                    model: selectLines
   482                    translateLabel: true
   502                    translateLabel: true
   483                    extent: (Point 302 24)
   503                    extent: (Point 302 24)
   484                  )
   504                  )
   485                 (ViewSpec
   505                 (ViewSpec
   486                    name: 'Box1'
   506                    name: 'ReplaceBox'
   487                    component: 
   507                    component: 
   488                   (SpecCollection
   508                   (SpecCollection
   489                      collection: (
   509                      collection: (
   490                       (CheckBoxSpec
   510                       (CheckBoxSpec
   491                          label: 'Global Replace With:'
   511                          label: 'Global Replace With:'
   492                          name: 'CheckBox4'
   512                          name: 'CheckBox4'
   493                          layout: (LayoutFrame 0 0 0 0 162 0 23 0)
   513                          layout: (LayoutFrame 0 0 0 0 180 0 23 0)
   494                          activeHelpKey: replaceText
   514                          activeHelpKey: replaceText
   495                          level: 0
   515                          level: 0
   496                          enableChannel: replaceEnabled
   516                          enableChannel: replaceEnabled
   497                          tabable: true
   517                          tabable: true
   498                          model: replaceBoolean
   518                          model: replaceBoolean
   499                          translateLabel: true
   519                          translateLabel: true
   500                        )
   520                        )
   501                       (InputFieldSpec
   521                       (InputFieldSpec
   502                          name: 'ReplaceEntryField'
   522                          name: 'ReplaceEntryField'
   503                          layout: (LayoutFrame 164 0 0 0 -2 1 22 0)
   523                          layout: (LayoutFrame 180 0 0 0 -2 1 22 0)
   504                          activeHelpKey: replaceText
   524                          activeHelpKey: replaceText
   505                          visibilityChannel: replaceBoolean
   525                          visibilityChannel: replaceBoolean
   506                          enableChannel: replaceBoolean
   526                          enableChannel: replaceBoolean
   507                          model: replaceTextHolder
   527                          model: replaceTextHolder
   508                          acceptOnReturn: true
   528                          acceptOnReturn: true
   510                          acceptOnPointerLeave: true
   530                          acceptOnPointerLeave: true
   511                        )
   531                        )
   512                       )
   532                       )
   513                     
   533                     
   514                    )
   534                    )
   515                    extent: (Point 319 24)
   535                    extent: (Point 411 24)
   516                  )
   536                  )
   517                 )
   537                 )
   518               
   538               
   519              )
   539              )
   520            )
   540            )
  1979 !
  1999 !
  1980 
  2000 
  1981 changeFont
  2001 changeFont
  1982     "pop up a fontPanel to change font"
  2002     "pop up a fontPanel to change font"
  1983 
  2003 
  1984     |newFont|
  2004     |newFont fp|
  1985 
  2005 
  1986     self withWaitCursorDo:[
  2006     self withWaitCursorDo:[
  1987         newFont := FontPanel fontFromUserInitial:font.
  2007         fp := FontPanel new.
       
  2008         fp withChangeFontInViewsAllCheckBox:true.
       
  2009         newFont := fp fontFromUserInitial:font.
  1988     ].
  2010     ].
  1989     newFont notNil ifTrue:[
  2011     newFont notNil ifTrue:[
  1990         self font:newFont.
  2012         self font:newFont.
       
  2013         fp changeFontInAllViews ifTrue:[
       
  2014             "/ user checked this box - change the defaults,
       
  2015             "/ and update all other textviews now.
       
  2016 
       
  2017             TextView defaultFont:newFont.
       
  2018             UserPreferences current fontPreferences
       
  2019                 at:#Text put:(newFont storeString).
       
  2020             DebugView newDebugger.
       
  2021             TextView allSubInstances do:[:v |
       
  2022                 v font:newFont
       
  2023             ].    
       
  2024         ].    
  1991     ]
  2025     ]
  1992 
  2026 
  1993     "Modified: 27.2.1996 / 00:53:51 / cg"
  2027     "Modified: 27.2.1996 / 00:53:51 / cg"
  1994 !
  2028 !
  1995 
  2029 
  2161 
  2195 
  2162     "
  2196     "
  2163      Q: is it a good idea to preserve the last searchstring between views?
  2197      Q: is it a good idea to preserve the last searchstring between views?
  2164      cg: yes - turns out to be useful and less confusing than keeping last per view
  2198      cg: yes - turns out to be useful and less confusing than keeping last per view
  2165     "
  2199     "
  2166     |searchBox patternHolder caseHolder matchHolder fwd ign match initialString
  2200     |searchBox patternHolder caseHolder matchHolder matchWithRegexHolder
       
  2201      wrapAtEndHolder fwd ign match initialString
  2167      bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder
  2202      bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder
  2168      replaceBooleanEnabledHolder replaceBooleanHolder replaceTextHolder
  2203      replaceBooleanEnabledHolder replaceBooleanHolder replaceTextHolder
  2169      searchAtBeginOfLineOnlyHolder|
  2204      searchAtBeginOfLineOnlyHolder|
  2170 
  2205 
  2171     searchBarActionBlock notNil ifTrue:[
  2206     searchBarActionBlock notNil ifTrue:[
  2179     ign := lastSearchIgnoredCase "? LastSearchIgnoredCase " ? true.
  2214     ign := lastSearchIgnoredCase "? LastSearchIgnoredCase " ? true.
  2180     caseHolder := ign not asValue.
  2215     caseHolder := ign not asValue.
  2181 
  2216 
  2182     match := lastSearchWasMatch ? LastSearchWasMatch ? false.
  2217     match := lastSearchWasMatch ? LastSearchWasMatch ? false.
  2183     matchHolder := match asValue.
  2218     matchHolder := match asValue.
       
  2219     matchWithRegexHolder := (LastSearchWasMatchWithRegex ? false) asValue.
       
  2220     wrapAtEndHolder := (LastSearchWasWithWrapAtEnd ? false) asValue.
  2184     searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
  2221     searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
  2185     searchFullWordHolder := false asValue.
  2222     searchFullWordHolder := false asValue.
  2186     searchAtBeginOfLineOnlyHolder := false asValue.
  2223     searchAtBeginOfLineOnlyHolder := false asValue.
  2187     replaceBooleanHolder := false asValue.
  2224     replaceBooleanHolder := false asValue.
  2188     replaceTextHolder := '' asValue.
  2225     replaceTextHolder := '' asValue.
  2224             searchAction := [self searchVariableWithSyntaxElement:selectedVariable forward:fwd].
  2261             searchAction := [self searchVariableWithSyntaxElement:selectedVariable forward:fwd].
  2225         ] ifFalse:[
  2262         ] ifFalse:[
  2226             lastSearchWasVariableSearch := false.
  2263             lastSearchWasVariableSearch := false.
  2227             LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
  2264             LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
  2228             LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
  2265             LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
       
  2266             LastSearchWasMatchWithRegex := matchWithRegexHolder value.
  2229             pattern := patternHolder value.
  2267             pattern := patternHolder value.
  2230             pattern notEmptyOrNil ifTrue:[
  2268             pattern notEmptyOrNil ifTrue:[
  2231                 searchAction := [
  2269                 searchAction := [
  2232                     self searchUsingSpec:(
  2270                     self searchUsingSpec:(
  2233                         ListView::SearchSpec new
  2271                         ListView::SearchSpec new
  2234                             pattern:pattern
  2272                             pattern:pattern
  2235                             ignoreCase:lastSearchIgnoredCase
  2273                             ignoreCase:lastSearchIgnoredCase
  2236                             match: lastSearchWasMatch
  2274                             match: lastSearchWasMatch 
       
  2275                             regexMatch:matchWithRegexHolder value 
  2237                             variable: searchVariableHolder value
  2276                             variable: searchVariableHolder value
  2238                             fullWord: searchFullWordHolder value
  2277                             fullWord: searchFullWordHolder value
  2239                             forward:fwd
  2278                             forward:fwd
  2240                             atBeginOfLineOnly:searchAtBeginOfLineOnlyHolder value).
  2279                             atBeginOfLineOnly:searchAtBeginOfLineOnlyHolder value
       
  2280                             wrapAroundEndOfText:wrapAtEndHolder value).
  2241                 ]
  2281                 ]
  2242             ]
  2282             ]
  2243         ].
  2283         ].
  2244 
  2284 
  2245         replaceBooleanHolder value ifTrue:[
  2285         replaceBooleanHolder value ifTrue:[
  2283         bindings at:#nextAction put:[doSearch value:true.  "searchBox doAccept."].
  2323         bindings at:#nextAction put:[doSearch value:true.  "searchBox doAccept."].
  2284         bindings at:#prevAction put:[doSearch value:false. "fwd := false. searchBox doAccept."].
  2324         bindings at:#prevAction put:[doSearch value:false. "fwd := false. searchBox doAccept."].
  2285     ].
  2325     ].
  2286     bindings at:#caseSensitive put:caseHolder.
  2326     bindings at:#caseSensitive put:caseHolder.
  2287     bindings at:#match put:matchHolder.
  2327     bindings at:#match put:matchHolder.
       
  2328     bindings at:#matchWithRegex put:matchWithRegexHolder.
  2288     bindings at:#patternList put:LastSearchPatterns.
  2329     bindings at:#patternList put:LastSearchPatterns.
  2289 
  2330 
  2290     self supportsSyntaxElements ifFalse:[
  2331     self supportsSyntaxElements ifFalse:[
  2291         bindings at:#searchVariableVisible put:false.
  2332         bindings at:#searchVariableVisible put:false.
  2292     ] ifTrue:[
  2333     ] ifTrue:[
  2551 
  2592 
  2552 !TextView methodsFor:'native widget support'!
  2593 !TextView methodsFor:'native widget support'!
  2553 
  2594 
  2554 nativeWindowType
  2595 nativeWindowType
  2555     "return a symbol describing my native window type 
  2596     "return a symbol describing my native window type 
  2556      (may be used internally by the device as a native window creation hint)"
  2597      (may be used internally by the device as a native window creation hint,
       
  2598       if the device supports native windows)"
  2557 
  2599 
  2558     ^ #TextView
  2600     ^ #TextView
  2559 
  2601 
  2560     "Created: 2.5.1997 / 14:41:00 / cg"
  2602     "Created: 2.5.1997 / 14:41:00 / cg"
  2561 ! !
  2603 ! !