The Trunk: Morphic-mt.1240.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.1240.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1240.mcz

==================== Summary ====================

Name: Morphic-mt.1240
Author: mt
Time: 6 August 2016, 11:06:18.098798 am
UUID: f0f2f997-dd26-7544-9175-7ca9e0bebb78
Ancestors: Morphic-mt.1239

Fixes the search bar to not intern search terms as symbols by accident.

Add preference to turn off the "smart" in the search bar. It's remains on by default.

=============== Diff against Morphic-mt.1239 ===============

Item was changed:
  Model subclass: #SearchBar
  instanceVariableNames: 'originatingWidget searchTerm selection resultsWidget workspace scratchPad'
+ classVariableNames: 'UseScratchPad UseSmartSearch'
- classVariableNames: 'UseScratchPad'
  poolDictionaries: ''
  category: 'Morphic-Menus-DockingBar'!

Item was added:
+ ----- Method: SearchBar class>>useSmartSearch (in category 'preferences') -----
+ useSmartSearch
+ <preference: 'Smart search'
+ category: 'docking bars'
+ description: 'When enabled, the docking bar search tries to find globals or full class names first, then tries to browse implementors, then tries to find class names if the search term starts uppercase, and finally invoke the regular message names search. When disabled, do only the last.'
+ type: #Boolean>
+ ^ UseSmartSearch ifNil: [ true ]!

Item was added:
+ ----- Method: SearchBar class>>useSmartSearch: (in category 'preferences') -----
+ useSmartSearch: aBoolean
+ UseSmartSearch := aBoolean.!

Item was changed:
  ----- Method: SearchBar>>smartSearch:in: (in category 'searching') -----
  smartSearch: text in: morph
  "Take the user input and perform an appropriate search"
  | input newContents |
  self removeResultsWidget.
  input := text asString ifEmpty:[^self].
+ self class useSmartSearch ifFalse: [^ ToolSet default browseMessageNames: input].
+
+ "If it is a global or a full class name, browse that class."
  (Smalltalk bindingOf: input) ifNotNil:[:assoc| | global |
- "It's a global or a class"
  global := assoc value.
+ ^ToolSet browse: (global isBehavior ifTrue:[global] ifFalse:[global class]) selector: nil].
- ^ToolSet browse: (global isBehavior ifTrue:[global] ifFalse:[global class]) selector: nil.
- ].
- (SystemNavigation new allImplementorsOf: input asSymbol) ifNotEmpty:[:list|
- ^SystemNavigation new
- browseMessageList: list
- name: 'Implementors of ' , input
- ].
- input first isUppercase ifTrue:[
- (UIManager default classFromPattern: input withCaption: '') ifNotNil:[:aClass|
- ^ToolSet browse: aClass selector: nil.
- ].
- ] ifFalse:[
- ^ToolSet default browseMessageNames: input
- ].
- newContents := input, ' -- not found.'.
 
+ "If it is a symbol and there are implementors of it, browse those implementors."
+ (Symbol lookup: input) ifNotNil: [:selector |
+ (SystemNavigation new allImplementorsOf: selector) ifNotEmpty:[:list|
+ ^SystemNavigation new
+ browseMessageList: list
+ name: 'Implementors of ' , input]].
+
+ "If it starts uppercase, browse classes if any. Otherwise, just search for messages."
+ input first isUppercase
+ ifTrue: [
+ (UIManager default classFromPattern: input withCaption: '')
+ ifNotNil:[:aClass| ^ToolSet browse: aClass selector: nil]
+ ifNil: [
+ newContents := input, ' -- not found.'.
+ self searchTerm: newContents.
+ self selection: (input size+1 to: newContents size).
+ self currentHand newKeyboardFocus: morph textMorph.
+ ^ self]]
+ ifFalse: [
+ ToolSet default browseMessageNames: input].!
- self searchTerm: newContents.
- self selection: (input size+1 to: newContents size).
- self currentHand newKeyboardFocus: morph textMorph.!