<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
<div><span style="font-size: 13.3333px">Hi Eduardo --</span></div>
<div><span style="font-size: 13.3333px"><br>
</span></div>
<div><span style="font-size: 13.3333px">Here are some thoughts.</span></div>
<div><span style="font-size: 13.3333px"><br>
</span></div>
<div><span style="font-size: 13.3333px">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.</span></div>
<div><span style="font-size: 13.3333px"><br>
</span></div>
<div><span style="font-size: 13.3333px">Second, there might be more than one path to an object, some shorter and more readable than others. Some more stable than others.</span></div>
<div><span style="font-size: 13.3333px"><br>
</span></div>
<div><span style="font-size: 13.3333px">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.</span></div>
<div><span style="font-size: 13.3333px"><br>
</span></div>
<div><span style="font-size: 13.3333px">Fourth, classes implementing a Singleton pattern expose "global instances" via certain messages such as #uniqueInstance, #default, #current, ...</span></div>
<div><span style="font-size: 13.3333px"><br>
</span></div>
<div><span style="font-size: 13.3333px">SystemNavigation default browseAllImplementorsOfList: #(uniqueInstance default current).</span></div>
<div><span style="font-size: 13.3333px"><br>
</span></div>
<div><span style="font-size: 13.3333px">Best,</span></div>
<div><span style="font-size: 13.3333px">Marce</span></div>
<div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
<p style="color: #AAAAAA; margin-top: 10px;">Am 01.02.2023 06:22:11 schrieb Eduardo Ochs <eduardoochs@gmail.com>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">Hi list,<br>
<br>
I'm trying to port to Squeak an idea that use a lot in Emacs, that is<br>
to use one-liners as hyperlinks. There's a page with a detailed<br>
explanation of that idea in this link,<br>
<br>
http://anggtwu.net/eev-squeak.html<br>
<br>
and here goes a short explanation, and a question.<br>
<br>
I'm working on a class called "See", and my one-liners that work as<br>
hyperlinks always start with "See". For example, these ones<br>
<br>
See class: HelpBrowser.<br>
See class: HelpBrowser method: #accept:.<br>
See class: See.<br>
See class: See classMethod: #item1ctsa:.<br>
See class: See classMethod: #class:method:.<br>
See class: See classMethod: #class:classMethod:.<br>
<br>
make the SystemBrowser display different pieces of information, and<br>
these one liners<br>
<br>
See fileList.<br>
See helpBrowser.<br>
See messageNames.<br>
See methodFinder.<br>
<br>
are equivalent to running:<br>
<br>
Tools -> File List<br>
Apps -> Help Browser<br>
World -> open -> message names<br>
World -> open -> method finder<br>
<br>
but there are LOTS of menu entries that I don't know how to implement<br>
as one-liners, because their "targets" are objects that I don't know<br>
how to access from "global code"... let me explain this.<br>
<br>
When I run "See methodFinder" it runs this: "ECToolSet<br>
openSelectorBrowser". I discovered that the "action" associated to<br>
"World -> open -> method finder" is "ECToolSet openSelectorBrowser" by<br>
using the halo to duplicate the entry "method finder" in the menu<br>
"World -> open", and then I examined the "contents", the "target", the<br>
"selector", and "arguments" of that first item of that menu with just<br>
one entry. Here is a visual explanation in a screenshot,<br>
<br>
http://anggtwu.net/IMAGES/2023-squeak-item1ctsa.png<br>
<br>
and in that case my function that returns the fields "contents",<br>
"target", "selector", and "arguments" of a menu item returns this:<br>
<br>
{'method finder' . ECToolSet . #openSelectorBrowser . #()}<br>
<br>
When I try to do the same for "Help -> Squeak help" I get:<br>
<br>
{'Squeak Help' . a TheWorldMainDockingBar . #squeakHelp . nil}<br>
<br>
note the "a"... =(<br>
<br>
When I run this to try to find a global variable that holds an object<br>
of the class TheWorldMainDockingBar,<br>
<br>
Smalltalk globals keysAndValuesDo: [:k :v |<br>
(v isKindOf: TheWorldMainDockingBar) ifTrue: [ Transcript show: k; cr. ]<br>
].<br>
<br>
it returns nothing. So I wrote these two methods in my class "See" to<br>
help me find active morphs of a given class,<br>
<br>
--snip--snip--<br>
!See class methodsFor: 'other links' stamp: 'Edrx 2/1/2023 00:55'!<br>
worldMorphs<br>
"Return an OrderCollection with all the morphs whose world is non-nil.<br>
Test:<br>
See worldMorphs explore.<br>
"<br>
^ Morph allSubInstances select: [ :m | m world notNil ].<br>
! !<br>
<br>
!See class methodsFor: 'other links' stamp: 'Edrx 2/1/2023 00:57'!<br>
worldMorphs: class<br>
"Return an OrderCollection with all the morphs whose world<br>
is non-nil, and that are objects of the given class.<br>
Test:<br>
(See worldMorphs: DockingBarItemMorph) explore.<br>
"<br>
^ Morph allSubInstances<br>
select: [ :m | (m world notNil) and: [m isKindOf: class] ]<br>
! !<br>
--snip--snip--<br>
<br>
but for the class TheWorldMainDockingBar this one-liner<br>
<br>
(See worldMorphs: TheWorldMainDockingBar) explore.<br>
<br>
returned no instances...<br>
<br>
Any suggestions?<br>
<br>
Thanks in advance,<br>
Eduardo Ochs<br>
http://anggtwu.net/eev-squeak.html<br>
http://anggtwu.net/SQUEAK/See.st.html<br>
http://anggtwu.net/SQUEAK/See.st<br>
<br>
<br>
P.S.: I tried to send questions to the beginners mailing list, but<br>
that list is kind of dead... so I tried to make my question a bit less<br>
beginner-ish, and I am sending it here to squeak-dev...<br>
<br>
</div>
</blockquote>
</div>
</body>
</html>