[squeak-dev] Case sensitive "source with it" works in MVC but not in Morphic, what to do?

David T. Lewis lewis at mail.msen.com
Tue May 14 12:06:32 UTC 2013


On Mon, May 13, 2013 at 10:19:23AM -0700, tim Rowledge wrote:
> 
> On 13-05-2013, at 7:36 AM, "David T. Lewis" <lewis at mail.msen.com> wrote:
> 
> > On Mon, May 13, 2013 at 12:42:19PM +0200, Bert Freudenberg wrote:
> >> 
> >> I use it: shift-click followed by CMD-E is the quickest way to look at the implementation behind a menu item. OTOH, a morphic halo menu entry might be more appropriate for that function.
> >> 
> > 
> > I see no straightforward way to eliminate the conflict between conflict
> > between usage of shift state for Morphic, versus usage of shift state to
> > control case sensitive search.
> 
> 
> We could change the modifier key used for direct-to-morphic selections and leave the shift to pass on to deeper code.
> 
> And I see Bob has already pointed out making proper usage of hierarchical menus as an option; yet again a place where the RISC OS way has been doing it better for decades. Why on earth do we still have places where secondary menus have to be triggered by clicking on a menu option 'foobly?' ?
> 
> We could also consider menu items that are shift-sensitive and update to suit. Apple managed to get that one reasonably correct for the quit/force quit menu item for example. Just as long as it doesn't result in yet another slowdown of everything in the system.
> 
> A really basic point underlying all this is that the UI level should handle all the UI stuff and pass suitable parameters down to the tools that said UI triggers. There is no way that the method to search all the sources should get a morphic event passed to it, for example. Pass it a boolean for shift, a number for 'time held down', a point for where clicked, but never, never a morphic event.
>

For purposes of comparison, the attached change set implements the approach
of using explicit menu picks, and eliminating the reliance on Sensor shiftPressed.

Pro: This eliminates the conflicting usages of the shift state, and it
makes the functions explicit in the menus.

Con: It adds more stuff to the menus, and it removes the uniform shortcut
of using the shift key to control case sensitive searches.

I'm not suggesting that this is the best solution, I'm just posting it
for evaluation.

Dave
 
-------------- next part --------------
'From Squeak3.11alpha of 8 May 2013 [latest update: #12679] on 13 May 2013 at 11:21:13 pm'!
"Change Set:		CaseSensitiveSearchInMenus-dtl
Date:			13 May 2013
Author:			David T. Lewis

Control case-sensitive search of source, strings and comments by means of explicit menu selections. Eliminate use of shift key as a meta-control for case sensitive searching from menus."!


!ParagraphEditor methodsFor: 'editing keys' stamp: 'dtl 5/13/2013 23:19'!
methodStringsContainingIt: characterStream 
	"Invoked from cmd-E -- open a browser on all methods holding string constants containing it.  Flushes typeahead. "

	sensor keyboard.	
	self methodStringsMatchCaseContainingIt.
	^ true! !

!ParagraphEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 21:11'!
classCommentsContainingIt
	"Open a browser class comments which contain the current selection somewhere in them."

	self lineSelectAndEmptyCheck: [^ self].
	self terminateAndInitializeAround: [
		self systemNavigation browseClassCommentsWithString: self selection string matchCase: false]! !

!ParagraphEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 21:11'!
classCommentsMatchCaseContainingIt
	"Open a browser class comments which contain the current selection somewhere in them."

	self lineSelectAndEmptyCheck: [^ self].
	self terminateAndInitializeAround: [
		self systemNavigation browseClassCommentsWithString: self selection string matchCase: true]! !

!ParagraphEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 18:56'!
methodSourceContainingIt
	"Open a browser on methods that contain the current selection in their source
	(case-insensitive full-text search of source)."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseMethodsWithSourceString: self selection string matchCase: false! !

!ParagraphEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 18:56'!
methodSourceMatchCaseContainingIt
	"Open a browser on methods that contain the current selection in their source
	(case-sensitive full-text search of source)."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseMethodsWithSourceString: self selection string matchCase: true! !

!ParagraphEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 20:55'!
methodStringsContainingIt
	"Open a browser on methods which contain the current selection as part of a string constant."

	self lineSelectAndEmptyCheck: [^ self].
	self terminateAndInitializeAround: [self systemNavigation browseMethodsWithString: self selection string matchCase: false]! !

!ParagraphEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 21:01'!
methodStringsMatchCaseContainingIt
	"Open a browser on methods which contain the current selection as part of a string constant."

	self lineSelectAndEmptyCheck: [^ self].
	self terminateAndInitializeAround: [self systemNavigation browseMethodsWithString: self selection string matchCase: true]! !


!PluggableTextMorph methodsFor: 'menu commands' stamp: 'dtl 5/13/2013 21:08'!
classCommentsMatchCaseContainingIt
	self handleEdit: [textMorph editor classCommentsMatchCaseContainingIt]! !

!PluggableTextMorph methodsFor: 'menu commands' stamp: 'dtl 5/9/2013 21:49'!
methodSourceMatchCaseContainingIt
	self handleEdit: [textMorph editor methodSourceMatchCaseContainingIt]! !

!PluggableTextMorph methodsFor: 'menu commands' stamp: 'dtl 5/13/2013 20:56'!
methodStringsContainingIt
	self handleEdit: [textMorph editor methodStringsContainingIt]! !

!PluggableTextMorph methodsFor: 'menu commands' stamp: 'dtl 5/13/2013 21:04'!
methodStringsMatchCaseContainingIt
	self handleEdit: [textMorph editor methodStringsMatchCaseContainingIt]! !


!StringHolder class methodsFor: 'yellow button menu' stamp: 'dtl 5/13/2013 20:57'!
shiftedYellowButtonMenuItems
	"Returns the standard yellow button menu items"
	| entries |
	entries := OrderedCollection withAll:
		{
			{'explain' translated.					#explain}.
			{'pretty print' translated.				#prettyPrint}.
			{'pretty print with color' translated.		#prettyPrintWithColor}.
			{'file it in (G)' translated.					#fileItIn}.
			{'spawn (o)' translated.					#spawn}.
			#-.
			{'browse it (b)' translated.				#browseIt}.
			{'senders of it (n)' translated.			#sendersOfIt}.
			{'implementors of it (m)' translated.		#implementorsOfIt}.
			{'references to it (N)' translated.			#referencesToIt}.
			#-.
			{'selectors containing it (W)' translated.	#methodNamesContainingIt}.
			{'method strings with it' translated.	#methodStringsContainingIt}.
			{'method strings with it matching case (E)' translated.	#methodStringsMatchCaseContainingIt}.
			{'method source with it' translated.		#methodSourceContainingIt}.
			{'method source with it matching case' translated.	#methodSourceMatchCaseContainingIt}.
			{'class names containing it' translated.	#classNamesContainingIt}.
			{'class comments with it' translated.		#classCommentsContainingIt}.
			{'class comments with it matching case' translated.		#classCommentsMatchCaseContainingIt}.
			{'change sets with it' translated.			#browseChangeSetsWithSelector}.
			#-.
			{'save contents to file...' translated.		#saveContentsInFile}.
			{'send contents to printer' translated.		#sendContentsToPrinter}.
			{'printer setup' translated.				#printerSetup}.
			#-.
		}.
	Smalltalk isMorphic ifFalse: [ entries add: 
			{'special menu...' translated.				#presentSpecialMenu}.].
	entries add:
			{'more...' translated.					#yellowButtonActivity}.
	^ entries! !


!SystemNavigation methodsFor: 'browse' stamp: 'dtl 5/13/2013 19:05'!
browseClassCommentsWithString: aString
	"Smalltalk browseClassCommentsWithString: 'my instances' "
	"Launch a message list browser on all class comments containing aString as a substring."

	^self browseClassCommentsWithString: aString matchCase: Sensor shiftPressed
! !

!SystemNavigation methodsFor: 'browse' stamp: 'dtl 5/13/2013 21:29'!
browseClassCommentsWithString: aString matchCase: caseSensitive
	"Smalltalk browseClassCommentsWithString: 'my instances' "
	"Launch a message list browser on all class comments containing aString as a substring."

	| suffix list |

	suffix := caseSensitive
		ifTrue: [' (case-sensitive)']
		ifFalse: [' (case-insensitive)'].
	list := Set new.
	Cursor wait showWhile: [
		Smalltalk allClassesDo: [:class | 
			(class organization classComment asString findString: aString 
							startingAt: 1 caseSensitive: caseSensitive) > 0 ifTrue: [
								list add: (
									MethodReference new
										setStandardClass: class
										methodSymbol: #Comment
								)
							]
		]
	].
	^ self 
		browseMessageList: list asSortedCollection
		name: 'Class comments containing ' , aString printString , suffix
		autoSelect: aString! !

!SystemNavigation methodsFor: 'browse' stamp: 'dtl 5/13/2013 23:09'!
browseMethodsWithSourceString: aString 
	"SystemNavigation new browseMethodsWithSourceString: 'SourceString'"
	"Launch a browser on all methods whose source code contains aString as 
	a substring."

	^ self browseMethodsWithSourceString: aString matchCase: Sensor shiftPressed
! !

!SystemNavigation methodsFor: 'browse' stamp: 'dtl 5/13/2013 21:29'!
browseMethodsWithSourceString: aString matchCase: caseSensitive
	"SystemNavigation new browseMethodsWithSourceString: 'SourceString' caseSensitive: true"
	"Launch a browser on all methods whose source code contains aString as 
	a substring."
	| suffix |
	suffix := caseSensitive
				ifTrue: [' (case-sensitive)']
				ifFalse: [' (case-insensitive)'].
	^ self
		browseMessageList: (self allMethodsWithSourceString: aString matchCase: caseSensitive)
		name: 'Methods containing ' , aString printString , suffix
		autoSelect: aString! !


!TextEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 21:12'!
classCommentsContainingIt
	"Open a browser class comments which contain the current selection somewhere in them."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseClassCommentsWithString: self selection string matchCase: false! !

!TextEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 21:12'!
classCommentsMatchCaseContainingIt
	"Open a browser class comments which contain the current selection somewhere in them."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseClassCommentsWithString: self selection string matchCase: true! !

!TextEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 18:56'!
methodSourceContainingIt
	"Open a browser on methods that contain the current selection in their source
	(case-insensitive full-text search of source)."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseMethodsWithSourceString: self selection string matchCase: false! !

!TextEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 18:56'!
methodSourceMatchCaseContainingIt
	"Open a browser on methods that contain the current selection in their source
	(case-sensitive full-text search of source)."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseMethodsWithSourceString: self selection string matchCase: true! !

!TextEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 20:56'!
methodStringsContainingIt
	"Open a browser on methods which contain the current selection as part of a string constant."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseMethodsWithString: self selection string matchCase: false! !

!TextEditor methodsFor: 'menu messages' stamp: 'dtl 5/13/2013 21:01'!
methodStringsMatchCaseContainingIt
	"Open a browser on methods which contain the current selection as part of a string constant."

	self lineSelectAndEmptyCheck: [^ self].
	self systemNavigation browseMethodsWithString: self selection string matchCase: true! !

!TextEditor methodsFor: 'editing keys' stamp: 'dtl 5/13/2013 23:20'!
methodStringsContainingIt: aKeyboardEvent 
	"Invoked from cmd-E -- open a browser on all methods holding string constants containing it.  Flushes typeahead. "

	self methodStringsMatchCaseContainingIt.
	^ true! !

TextEditor removeSelector: #methodStringsContainingit!
PluggableTextMorph removeSelector: #methodStringsContainingit!
ParagraphEditor removeSelector: #methodStringsContainingit!
ParagraphEditor removeSelector: #methodStringsMatchCaseContainingit!


More information about the Squeak-dev mailing list