[squeak-dev] {'Squeak Help' . a TheWorldMainDockingBar . #squeakHelp . nil}

Taeumel, Marcel Marcel.Taeumel at hpi.de
Wed Feb 1 10:22:07 UTC 2023


Hi Eduardo --

Here are some thoughts.

First, not all visible objects have elegant (or domain-specific) ways to access them. You might have to use meta-programming à la #instVarNamed: or #allInstances to reach them.

Second, there might be more than one path to an object, some shorter and more readable than others. Some more stable than others.

Third, besides classes (i.e., "Smalltalk allClasses"), there are other globals (i.e., "Smalltalk globals select: [:ea | ea isBehavior not]"), which might help you find long-living objects of interest.

Fourth, classes implementing a Singleton pattern expose "global instances" via certain messages such as #uniqueInstance, #default, #current, ...

SystemNavigation default browseAllImplementorsOfList: #(uniqueInstance default current).

Best,
Marce

Am 01.02.2023 06:22:11 schrieb Eduardo Ochs <eduardoochs at gmail.com>:

Hi list,

I'm trying to port to Squeak an idea that use a lot in Emacs, that is
to use one-liners as hyperlinks. There's a page with a detailed
explanation of that idea in this link,

http://anggtwu.net/eev-squeak.html

and here goes a short explanation, and a question.

I'm working on a class called "See", and my one-liners that work as
hyperlinks always start with "See". For example, these ones

See class: HelpBrowser.
See class: HelpBrowser method: #accept:.
See class: See.
See class: See classMethod: #item1ctsa:.
See class: See classMethod: #class:method:.
See class: See classMethod: #class:classMethod:.

make the SystemBrowser display different pieces of information, and
these one liners

See fileList.
See helpBrowser.
See messageNames.
See methodFinder.

are equivalent to running:

Tools -> File List
Apps -> Help Browser
World -> open -> message names
World -> open -> method finder

but there are LOTS of menu entries that I don't know how to implement
as one-liners, because their "targets" are objects that I don't know
how to access from "global code"... let me explain this.

When I run "See methodFinder" it runs this: "ECToolSet
openSelectorBrowser". I discovered that the "action" associated to
"World -> open -> method finder" is "ECToolSet openSelectorBrowser" by
using the halo to duplicate the entry "method finder" in the menu
"World -> open", and then I examined the "contents", the "target", the
"selector", and "arguments" of that first item of that menu with just
one entry. Here is a visual explanation in a screenshot,

http://anggtwu.net/IMAGES/2023-squeak-item1ctsa.png

and in that case my function that returns the fields "contents",
"target", "selector", and "arguments" of a menu item returns this:

{'method finder' . ECToolSet . #openSelectorBrowser . #()}

When I try to do the same for "Help -> Squeak help" I get:

{'Squeak Help' . a TheWorldMainDockingBar . #squeakHelp . nil}

note the "a"... =(

When I run this to try to find a global variable that holds an object
of the class TheWorldMainDockingBar,

Smalltalk globals keysAndValuesDo: [:k :v |
(v isKindOf: TheWorldMainDockingBar) ifTrue: [ Transcript show: k; cr. ]
].

it returns nothing. So I wrote these two methods in my class "See" to
help me find active morphs of a given class,

--snip--snip--
!See class methodsFor: 'other links' stamp: 'Edrx 2/1/2023 00:55'!
worldMorphs
"Return an OrderCollection with all the morphs whose world is non-nil.
Test:
See worldMorphs explore.
"
^ Morph allSubInstances select: [ :m | m world notNil ].
! !

!See class methodsFor: 'other links' stamp: 'Edrx 2/1/2023 00:57'!
worldMorphs: class
"Return an OrderCollection with all the morphs whose world
is non-nil, and that are objects of the given class.
Test:
(See worldMorphs: DockingBarItemMorph) explore.
"
^ Morph allSubInstances
select: [ :m | (m world notNil) and: [m isKindOf: class] ]
! !
--snip--snip--

but for the class TheWorldMainDockingBar this one-liner

(See worldMorphs: TheWorldMainDockingBar) explore.

returned no instances...

Any suggestions?

Thanks in advance,
Eduardo Ochs
http://anggtwu.net/eev-squeak.html
http://anggtwu.net/SQUEAK/See.st.html
http://anggtwu.net/SQUEAK/See.st


P.S.: I tried to send questions to the beginners mailing list, but
that list is kind of dead... so I tried to make my question a bit less
beginner-ish, and I am sending it here to squeak-dev...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230201/d6ec2260/attachment.html>


More information about the Squeak-dev mailing list