#UI_ENHANCEMENT by cg
class: Tools::NewSystemBrowser class
changed: #askForClassToSearch:single:msgTail:resources:filter:forBrowser:thenDo:
--- a/Tools__NewSystemBrowser.st Fri Jul 14 15:28:58 2017 +0200
+++ b/Tools__NewSystemBrowser.st Sat Jul 15 15:28:37 2017 +0200
@@ -18770,25 +18770,28 @@
updateClassAndNameList value.
updateList := [
- |nameToSearch list namesStarting namesIncluding lcName nameList classList|
+ |nameToSearch list namesStarting namesIncluding lcName nameList classList isMatch labelText|
(nameToSearch := classNameHolder value withoutSeparators) isEmpty ifTrue:[
- showingWhatLabel label:(resources string:'Recently visited:').
+ labelText := 'Recently visited:'.
list := (showFullNameHolder value ifTrue:[colorizedFullNames] ifFalse:[colorizedShortNames]).
] ifFalse:[
(nameToSearch includesString:'>>') ifTrue:[
nameToSearch := (nameToSearch copyTo:(nameToSearch indexOfString:'>>')-1) withoutSeparators.
].
- showingWhatLabel label:(resources string:'Matching classes:').
+ isMatch := nameToSearch includesMatchCharacters.
+ labelText := 'Matching classes:'.
+ labelText := isMatch ifTrue:['Matching classes (pattern):'] ifFalse:['Matching classes (fuzzy match):'].
+
nameList := showFullNameHolder value ifTrue:[ allFullNames ] ifFalse:[ allNames ].
classList := showFullNameHolder value ifTrue:[ allClassesByFullName ] ifFalse:[ allClasses ].
lcName := nameToSearch asLowercase.
- (lcName includesString:'::') ifTrue:[
+ false "(lcName includesString:'::')" ifTrue:[
list := OrderedCollection new.
allClasses doWithIndex:[:cls :idx |
|isIncluded|
- (nameToSearch includesMatchCharacters) ifTrue:[
+ isMatch ifTrue:[
isIncluded := (lcName match:cls name asLowercase)
] ifFalse:[
isIncluded := (cls name includesString:lcName caseSensitive:false)
@@ -18798,11 +18801,11 @@
].
].
] ifFalse:[
- (nameToSearch includesMatchCharacters) ifTrue:[
+ isMatch ifTrue:[
list := (1 to:nameList size)
select:[:idx |
|nm|
- nm := nameList at:idx.
+ nm := allFullNames "nameList" at:idx.
(lcName match:nm asLowercase)
or:[ lcName match:(classList at:idx) name caseSensitive:false]
] thenCollect:[:idx | nameList at:idx].
@@ -18812,17 +18815,36 @@
matches := OrderedCollection new.
matcher := FuzzyMatcher pattern:lcName.
- nameList do:[:eachClassName |
+ allFullNames "nameList" do:[:eachClassName |
matcher
match:eachClassName
- ifScored: [ :score | matches add: eachClassName -> score ]
+ ifScored: [:score |
+ matches add: { eachClassName . score . (matcher indexes copy) }
+ ]
].
- matches sort:[:a :b |
- a value < b value
- or:[ a value = b value and:[ a key > b key]]
+ matches
+ sort:[:a :b |
+ |score_a score_b|
+
+ score_a := a at:2.
+ score_b := b at:2.
+ score_a < score_b
+ or:[ score_a = score_b and:[ (a at:1) > (b at:1)]
+ ]
].
matches reverse.
- namesIncluding := (matches copyTo:(matches size min:150)) collect:#key
+ namesIncluding := (matches copyTo:(matches size min:150))
+ collect:[:triple |
+ |name score indexes|
+ name := triple first.
+ indexes := triple third.
+ name := name asText withColor:Color gray slightlyDarkened.
+ indexes do:[:each |
+ "/ name emphasiseFrom:each to:each with:{ #bold . #color->Color black }
+ name emphasiseFrom:each to:each with:{ #color->Color black }
+ ].
+ name
+ ].
] ifFalse:[
namesIncluding := (1 to:nameList size)
select:[:idx |
@@ -18837,6 +18859,7 @@
]
]
].
+ showingWhatLabel label:(resources string:labelText).
box listView
list:list;
scrollToLine:((list findFirst:[:line | (line ? '') startsWith:lcName]) max:1)
@@ -18914,7 +18937,7 @@
^ className
"Modified: / 04-09-2013 / 17:48:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 14-07-2017 / 00:42:24 / cg"
+ "Modified: / 15-07-2017 / 15:25:12 / cg"
!
enterBoxTitle:title okText:okText label:label