[Pkg] The Trunk: Morphic-ul.555.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jul 9 14:23:53 UTC 2011
Levente Uzonyi uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ul.555.mcz
==================== Summary ====================
Name: Morphic-ul.555
Author: ul
Time: 9 July 2011, 4:22:56.282 pm
UUID: ba403dfa-f93e-8449-8441-16d3fcc2f254
Ancestors: Morphic-ael.554
A bit faster and cleaner PluggableListMorph >> #basicKeyPressed:.
=============== Diff against Morphic-ael.554 ===============
Item was changed:
----- Method: PluggableListMorph>>basicKeyPressed: (in category 'model access') -----
basicKeyPressed: aChar
+
+ | milliseconds slowKeyStroke listSize newSelectionIndex oldSelectionIndex startIndex |
+ oldSelectionIndex := newSelectionIndex := self getCurrentSelectionIndex.
+ listSize := self getListSize.
+ milliseconds := Time millisecondClockValue.
+ slowKeyStroke := (Time milliseconds: milliseconds since: lastKeystrokeTime) > 300.
+ lastKeystrokeTime := milliseconds.
- | oldSelection nextSelection max milliSeconds slowKeyStroke nextSelectionList nextSelectionText |
- nextSelection := oldSelection := self getCurrentSelectionIndex.
- max := self maximumSelection.
- milliSeconds := Time millisecondClockValue.
- slowKeyStroke := milliSeconds - lastKeystrokeTime > 300.
- lastKeystrokeTime := milliSeconds.
- nextSelectionList := OrderedCollection newFrom: (self getList copyFrom: oldSelection + 1 to: max).
- nextSelectionList addAll: (self getList copyFrom: 1 to: ((oldSelection - 1) max: 0)).
slowKeyStroke
ifTrue: ["forget previous keystrokes and search in following elements"
lastKeystrokes := aChar asLowercase asString.
+ newSelectionIndex := newSelectionIndex \\ listSize + 1 ]
- oldSelection > 0 ifTrue: [nextSelectionList addLast: (self getList at: oldSelection)]]
ifFalse: ["append quick keystrokes but don't move selection if it still matches"
+ lastKeystrokes := lastKeystrokes , aChar asLowercase asString ].
- lastKeystrokes := lastKeystrokes , aChar asLowercase asString.
- oldSelection > 0 ifTrue: [nextSelectionList addFirst: (self getList at: oldSelection)]].
- "Get rid of blanks and style used in some lists"
- nextSelectionText := nextSelectionList
- detect: [:a | a asString withBlanksTrimmed asLowercase beginsWith: lastKeystrokes]
- ifNone: [^ self flash "match not found"].
"No change if model is locked"
+ model okToChange ifFalse: [ ^self ].
+ "Get rid of blanks and style used in some lists"
+ startIndex := newSelectionIndex.
+ [
+ (self getListItem: newSelectionIndex) asString
+ withBlanksTrimmed asLowercase beginsWith: lastKeystrokes ]
+ whileFalse: [
+ (newSelectionIndex := newSelectionIndex \\ listSize + 1) = startIndex ifTrue: [
+ ^self flash. "Not in list." ] ].
+ newSelectionIndex = oldSelectionIndex ifTrue: [ ^self flash ]. "Same selection."
+ ^self changeModelSelection: newSelectionIndex!
- model okToChange ifFalse: [^ self].
- nextSelection := self getList findFirst: [:a | a = nextSelectionText].
- oldSelection == nextSelection ifTrue: [^ self flash].
- ^ self changeModelSelection: nextSelection!
More information about the Packages
mailing list