Code Shopping Support in Squeak [GOODIE] EditableSelectorBrowser
Ned Konz
ned at bike-nomad.com
Fri Mar 9 07:40:23 UTC 2001
On Thursday 08 March 2001 22:20, Karl Ramberg wrote:
> > I am at least vaguely aware that Squeak has implemented some coolness
> > that allows us to find methods a tad more effectively than in the past.
> > It would be a great boon to the community if someone would point them
> > out. I'd be happy to return the favor by following up and writing
> > something on the topic for the Swiki.
>
> Did you look at the MethodFinder (also called SelectorFinder ?)
> Most easy accessed trough the World menu/Open.../MethodFinder
> It also have have some class examples.
I wrote a little modification that displays the method text in the bottom
pane; it's attached.
--
Ned Konz
currently: Stanwood, WA
email: ned at bike-nomad.com
homepage: http://bike-nomad.com
-------------- next part --------------
'From Squeak3.1alpha of 7 February 2001 [latest update: #3536] on 9 February 2001 at 11:18:30 am'!
"Change Set: EditableSelectorBrowser-nk
Date: 9 February 2001
Author: Ned Konz
This change set provides a Method Browser that has an
area to view and/or edit code in the bottom, instead of
just displaying help text.
Constructors have been added to SelectorBrowser as well:
SelectorBrowser open opens a new non-editable browser
SelectorBrowser openEditable opens an editable browser
"!
SelectorBrowser subclass: #EditableSelectorBrowser
instanceVariableNames: 'methodText '
classVariableNames: ''
poolDictionaries: ''
category: 'Tools-Browser'!
!EditableSelectorBrowser commentStamp: 'nk 2/9/2001 10:51' prior: 0!
I am a Method Browser that has an area to view and/or edit code in the bottom, instead of just displaying help text.
Written by Ned Konz, ned at bike-nomad.com, sometime in the year 2000.
I can be constructed by:
EditableSelectorBrowser open
or
SelectorBrowser openEditable!
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 7/15/2000 09:42'!
byExample
| source |
source _ self formattedSource.
^ source isEmpty ifTrue: [ super byExample] ifFalse: [ source ]! !
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 2/9/2001 10:48'!
byExample: newText
| selectedMessageCategoryName selector |
methodText _ newText.
selectedMessageCategoryName _ nil.
selector _ self selectedClass
compile: newText asText
classified: selectedMessageCategoryName
notifying: nil.
^selector == nil! !
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 2/9/2001 10:48'!
classListDoubleClicked
Browser fullOnClass: self selectedClass selector: self selectedMessageName! !
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 2/9/2001 10:50'!
classListIndex: anInteger
classListIndex _ anInteger.
methodText _ classListIndex > 0
ifTrue: [ self formattedSource ]
ifFalse: [ '' ].
self changed: #byExample;
changed: #classListIndex! !
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 7/15/2000 09:40'!
formattedSource
| source |
source _ (self selectedClass ifNotNil: [ self selectedClass
sourceCodeAt: self selectedMessageName
ifAbsent: [''] ] ifNil: [ '' ]) asText.
source isEmpty
ifTrue: [^ source].
Preferences browseWithPrettyPrint
ifTrue: [source _ self selectedClass compilerClass new
format: source
in: self selectedClass
notifying: nil
decorated: Preferences colorWhenPrettyPrinting].
^ source! !
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 7/15/2000 10:03'!
initialExtent
^ RealEstateAgent standardWindowExtent! !
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 7/15/2000 08:59'!
messageListIndex: anInteger
super messageListIndex: anInteger.
self changed: #byExample! !
!EditableSelectorBrowser methodsFor: 'as yet unclassified' stamp: 'nk 7/26/2000 15:48'!
morphicWindow
"Make sure that I warn before discarding edits"
| win codePane classListMorph |
win _ super morphicWindow.
codePane _ self dependents
detect: [:dep | (dep isKindOf: PluggableTextMorph)
and: [dep getTextSelector == #byExample]]
ifNone: [].
codePane
ifNotNil: [codePane askBeforeDiscardingEdits: true].
classListMorph _ self dependents
detect: [:dep | (dep isKindOf: PluggableListMorph)
and: [dep getListSelector == #classList]]
ifNone: [].
classListMorph doubleClickSelector: #classListDoubleClicked.
^ win! !
!SelectorBrowser class methodsFor: 'as yet unclassified' stamp: 'nk 7/15/2000 10:17'!
open
"Open a new instance of me"
^ self new open! !
!SelectorBrowser class methodsFor: 'as yet unclassified' stamp: 'nk 7/15/2000 10:17'!
openEditable
"Open a new instance of EditableSelectorBrowser"
^ EditableSelectorBrowser new open! !
"Postscript:
This opens a new browser."
EditableSelectorBrowser open!
More information about the Squeak-dev
mailing list
|