[Pharo-dev] confused about printString and printIt

Ben Coman btc at openinworld.com
Sun Feb 19 10:33:20 EST 2017


On Sun, Feb 19, 2017 at 1:26 AM, stepharong <stepharong at free.fr> wrote:
>
> Hi guys
>
> I'm working on an introduction chapter for my future book and I do not like
> the behavior I see in latest pharo 60.
>
> And I do not understand the behavior of print-it
>
> (MFDirectory new name: 'comics')
> comics/
>
>
> (MFDirectory new name: 'comics') printString
>>>>
>>>> 'comics/'
>
>
>
> Why print it does not produce ''?
>
>
> Stef
>
>
> printIt
>         | printString |
>         self
>                 evaluateSelectionAndDo: [ :result |
>                         printString := [ result printString ]
>                                 on: Error
>                                 do: [ '<error in printString: try ''Inspect
> it'' to debug>' ].
>                         self afterSelectionInsertAndSelect: printString ]

btw, the code you reference there does not get executed from
Playground.  This does...
    (GLMGenericAction new)
        title: 'Print it';
        action: [ :aPresentation |  aPresentation printSelection ];
        keymap: PharoShortcuts current printItShortcut;
        yourself.

from GLMRubricSmalltalkCodePresentation>>executionSelectionActions

which announces GLMPrintSelection
leading to GLMMorphicPharoScriptRenderer>>evaluateAndPopPrintHighlight
    GLMPrintPopper
        installAlarm: #popupPrint
        for: self

GLMMorphicPharoCodeRenderer>>popupPrint
"Evaluates selected code and prints it in a popper"
textMorph textArea editor highlightEvaluateAndDo: [ :result |
textMorph shoutStyler style: textMorph text.
GLMPrintPopper new
openFromRubric: textMorph textArea withResult: result ]

cheers -ben



More information about the Pharo-dev mailing list