<div dir="ltr">Hi Tobias,<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 27, 2015 at 10:56 PM, Tobias Pape <span dir="ltr">&lt;<a href="mailto:Das.Linux@gmx.de" target="_blank">Das.Linux@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Eliot,<br>
<span class=""><br>
On 28.08.2015, at 00:09, <a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a> wrote:<br>
<br>
&gt; Item was added:<br>
&gt; + ----- Method: ChangeSorter&gt;&gt;monticelloChangeSetMenu: (in category &#39;*Monticello-changeSet menu&#39;) -----<br>
&gt; + monticelloChangeSetMenu: aMenu<br>
&gt; +     &lt;changeSetMenuShifted: false&gt;<br>
&gt; +     &lt;menuPriority: 600&gt;<br>
&gt; +     &quot;Sigh, when implementing menu pragmas this is not what I had in mind...&quot;<br>
&gt; +     aMenu add: &#39;delete Monticello load change sets&#39; action: #deleteMonticelloChangeSets.<br>
&gt; +     (aMenu submorphs<br>
&gt; +                                             detect: [:m| m isMenuItemMorph and: [m contents beginsWith: &#39;destroy change set&#39;]]<br>
&gt; +                                             ifNone: []) ifNotNil:<br>
&gt; +             [:destroyItem| | item |<br>
&gt; +             aMenu removeMorph: (item := aMenu submorphs last).<br>
&gt; +             aMenu addMorph: item after: destroyItem].<br>
&gt; +     ^aMenu!<br>
<br>
</span>Can you explain what you want to achieve<br>
and how I can make this more convenient?<br></blockquote><div><br></div><div>We can talk this over when we meet in Palo Alto, but the idea is an important one, and I&#39;m paying for having been too lazy to write it up properly.  Let me try and give a quick sketch here.</div><div><br></div><div>The goals are to</div><div><br></div><div>- allow package load to augment menus without the original definitions of those menus knowing anything about the subsequently loaded packages.</div><div>- to allow menus to be augmented with single actions defined in methods that implement those actions<br></div><div>- and, depending on menu implementation, either</div><div>  - if menus are created every time a user invokes a menu, then to simply include the relevant extensions in the menu</div><div>  - if menus are stored in variables, to automatically construct, or reconstruct the menu when either loading or unloading of a package changes the items in a menu</div><div><br></div><div>We design menu pragmas in action methods to specify</div><div>- the (name of the) menu to be extended</div><div>- the text of the menu entry</div><div>- information regarding what group of items the menu item belongs with</div><div>- information regarding the menu item&#39;s relative order with respect to other elements in the group</div><div><br></div><div>Rationale:</div><div>With this specification a package can extend any number of menus in tools simply by being loaded, with no collisions with any other packages defining extensions on those menus.  Tools become freely pluggable, and system configurations constructed from different sets of loaded packages are decoupled; we don&#39;t need many menu definitions, just an initial base menu which is extended with the current set of extensions.</div><div><br></div><div>For this to work we need to &quot;name&quot; menus, and to use some numbering scheme to define groups (menu entries between lines) and elements within each group.  One simple scheme is to use numbers:</div><div>- the definitions of initial base menus number groups, so that the first group (the items before the first line) is numbered group 10, and the second group 20, and so on, allowing extensions to specify new groups by using group numbers that are not a multiple of 10</div><div>- the definitions of entries within groups are numbered, again in multiples of 10, so that the extension can fit anywhere in the group </div><div><br></div><div>So given</div><div><div>MenuMorph fromArray: {</div><div><span class="" style="white-space:pre">                </span>{&#39;find...(f)&#39; translated.<span class="" style="white-space:pre">                                </span>#find}.</div><div><span class="" style="white-space:pre">                </span>{&#39;find again (g)&#39; translated.<span class="" style="white-space:pre">                        </span>#findAgain}.</div><div><span class="" style="white-space:pre">                </span>{&#39;set search string (h)&#39; translated.<span class="" style="white-space:pre">        </span>#setSearchString}.</div><div><span class="" style="white-space:pre">                </span>#-.</div><div><span class="" style="white-space:pre">                </span>{&#39;do again (j)&#39; translated.<span class="" style="white-space:pre">                        </span>#again}.</div><div><span class="" style="white-space:pre">                </span>{&#39;undo (z)&#39; translated.<span class="" style="white-space:pre">                                </span>#undo}.</div><div><span class="" style="white-space:pre">                </span>#-.</div><div><span class="" style="white-space:pre">                </span>{&#39;copy (c)&#39; translated.<span class="" style="white-space:pre">                                </span>#copySelection}.</div><div><span class="" style="white-space:pre">                </span>{&#39;cut (x)&#39; translated.<span class="" style="white-space:pre">                                </span>#cut}.</div><div><span class="" style="white-space:pre">                </span>{&#39;paste (v)&#39; translated.<span class="" style="white-space:pre">                                </span>#paste}.</div><div><span class="" style="white-space:pre">                </span>{&#39;paste...&#39; translated.<span class="" style="white-space:pre">                                </span>#pasteRecent}.</div><div><span class="" style="white-space:pre">                </span>#-.</div><div><span class="" style="white-space:pre">                </span>{&#39;set font... (k)&#39; translated.<span class="" style="white-space:pre">                        </span>#offerFontMenu}.</div><div><span class="" style="white-space:pre">                </span>{&#39;set style... (K)&#39; translated.<span class="" style="white-space:pre">                </span>#changeStyle}.</div><div><span class="" style="white-space:pre">                </span>{&#39;set alignment...&#39; translated.<span class="" style="white-space:pre">                </span>#chooseAlignment}.</div><div><span class="" style="white-space:pre">                </span>&quot;</div><div><span class="" style="white-space:pre">                </span>#-.</div><div><span class="" style="white-space:pre">                </span>{&#39;more...&#39; translated.<span class="" style="white-space:pre">                                </span>#shiftedTextPaneMenuRequest}.</div><div><span class="" style="white-space:pre">                </span>&quot;</div><div><span class="" style="white-space:pre">        </span>}</div></div><div><br></div><div>you could imagine the following numberings:</div><div><br></div><div>    10.01    find</div><div>    10.02    findAgain</div><div>    10.03    setSearchString</div><div>-</div><div>    20.01    again</div><div>    20.02    undo</div><div>-</div><div>    30.01    copySelection</div><div>    30.02    cut</div><div>    30.03    paste</div><div>    30.04    pasteRecent</div><div>-</div><div>    40.01    offerFontMenu</div><div>    40.02    changeStyle</div><div>    40.03    chooseAlignment</div><div><br></div><div>So I can specify e.g. a new group inserted before the first one by using, e.g. 5.005 as an index, and can slot an item between again and undo using 20.015, etc.</div><div><br></div><div>This gives us menu pragmas that look like:</div><div><br></div><div>TextEditor methodsFor: &#39;*SpellChecker-extensions&#39; stamp: &#39;mad hacker 9/9/1999&#39;</div><div>spellCheck</div><div>    &lt;menuAction: #yellowButtonMenu</div><div>      label: &#39;spell check selection (s)&#39;</div><div>      position: 10.035&gt;</div><div>    ...code implementing spell checking...</div><div></div></div><div><br></div><div>(note that the action, #spellCheck, is implicit, it is the selector of the method containing the pragma)</div><div><br></div><div>and</div><div><div>  - if menus are created every time a user invokes a menu, then search for pragmas within the relevant class hierarchy, compute, sort and insert individual extensions to the menu </div><div>  - if menus are stored in variables, to have compilation and method removal send a message to the class to/from which method(s) are added/removed so that the class can recompute menus (as in the line above) when code is added/removed.</div></div><div><br></div><div>What I saw in ChangeSorter was quite different.  It seems to be a way of specifying entire menus, and I&#39;m not sure how these menus are to be combined.  Maybe I&#39;m misunderstanding the way the scheme is supposed to work.  What I&#39;ve described above is very close to the one that pragmas came from in the first place, which was my attempt to decouple the components that could be loaded into VisualWorks when we decomposed the system into easily loadable parcels.  Up until that point VisualWorks had had all its tool menus predefined, disabling items that were to do with components delivered as file-ins that weren&#39;t yet filed-in.  It was too rigid.  It didn&#39;t allow for future expansion.  And so I had the idea of menu pragmas to decouple things.  Steve Dahl then came up with the scheme to define a base menu, number its items appropriately, and extend the menu.</div><div><br></div><div>One of the things that&#39;s really nice about the VisualWorks scheme is that the menu pragma itself is actually implemented (remember that pragmas are Message instances with literal parameters).  The class MenuBuilder (IIRC) implemented various menu pragma methods so the patten is</div><div><br></div><div>- in the method that defines the base menu, define the base menu, create an editor on it, ask the editor to collect the pragmas and augment the menu with those found</div><div>- the menu editor then collects the menu pragmas and then performs each one to collect the information from it</div><div><br></div><div>So one can find other menu pragmas using senders, and find the editor using implementors, and one can extend the scheme by adding additional methods to MenuEditor, again possibly loaded from packages.</div><div><br></div><div><br></div><div>HTH</div><div><br></div><div>_,,,^..^,,,_<br></div><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>best, Eliot</div></span></div></div></div>
</div></div>