Problems with auto-updating the text of a playground

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with auto-updating the text of a playground

Offray Vladimir Luna Cárdenas-2
Hi,

For my Grafoscopio notebooks,  I have implemented a way to auto-updating
the content of a node, so it is automatically saved in the notebook when
a node content is changed. The problem is that a node contains an
embedded playground that produces text as output when executed (for
example the playground reads a file or scraps HTML or calculates a
hash), the text of the playground is replaced with the executed output.
If the playground produces a visualization or non-textual output, this
doesn't happen.

I imagine that the source of the problem is here:

=======

GrafoscopioNotebook >> autoSaveBodyOf: aNode
     body body class = TextModel
         ifTrue: [ body body whenTextChanged: [ :arg | aNode body: arg ] ].
     body body class = GlamourPresentationModel
         ifTrue: [ | playground |
             playground := body body glmPres.
             playground
                 when: GLMContextChanged
                 do: [ :ann |
                     ann property = #text
                         ifTrue: [ | playgroundText |
                             playgroundText := (playground pane ports
at: 2) value.
                             aNode body: playgroundText ]
                 ]
         ]

=======

as you can see the "when: GLMContextChanged" updates a node body with
the playgroundText, as intended, so I can capture any change of the
playground code, but I would like to add some condition to **not**
update the body content if the text is the result of a playground
execution. There is any way to do this?

Thanks,

Offray


Reply | Threaded
Open this post in threaded view
|

Re: Problems with auto-updating the text of a playground

Tudor Girba-2
Hi,

I am not quite sure I understand your problem, but I believe what you want is to only react to a change in a text.

This information is placed in the #text port. Here is a basic example of how to react to it:
http://ws.stfx.eu/ETEC2JH7363M

Cheers,
Doru


> On Feb 6, 2017, at 2:16 AM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:
>
> Hi,
>
> For my Grafoscopio notebooks,  I have implemented a way to auto-updating the content of a node, so it is automatically saved in the notebook when a node content is changed. The problem is that a node contains an embedded playground that produces text as output when executed (for example the playground reads a file or scraps HTML or calculates a hash), the text of the playground is replaced with the executed output. If the playground produces a visualization or non-textual output, this doesn't happen.
>
> I imagine that the source of the problem is here:
>
> =======
>
> GrafoscopioNotebook >> autoSaveBodyOf: aNode
>    body body class = TextModel
>        ifTrue: [ body body whenTextChanged: [ :arg | aNode body: arg ] ].
>    body body class = GlamourPresentationModel
>        ifTrue: [ | playground |
>            playground := body body glmPres.
>            playground
>                when: GLMContextChanged
>                do: [ :ann |
>                    ann property = #text
>                        ifTrue: [ | playgroundText |
>                            playgroundText := (playground pane ports at: 2) value.
>                            aNode body: playgroundText ]
>                ]
>        ]
>
> =======
>
> as you can see the "when: GLMContextChanged" updates a node body with the playgroundText, as intended, so I can capture any change of the playground code, but I would like to add some condition to **not** update the body content if the text is the result of a playground execution. There is any way to do this?
>
> Thanks,
>
> Offray
>
>

--
www.tudorgirba.com
www.feenk.com

"If you can't say why something is relevant,
it probably isn't."


Reply | Threaded
Open this post in threaded view
|

Re: Problems with auto-updating the text of a playground

Offray Vladimir Luna Cárdenas-2
Thanks Doru, That solves it! A quick and clean fix :-).

Cheers,

Offray


On 06/02/17 00:41, Tudor Girba wrote:

> Hi,
>
> I am not quite sure I understand your problem, but I believe what you want is to only react to a change in a text.
>
> This information is placed in the #text port. Here is a basic example of how to react to it:
> http://ws.stfx.eu/ETEC2JH7363M
>
> Cheers,
> Doru
>
>
>> On Feb 6, 2017, at 2:16 AM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:
>>
>> Hi,
>>
>> For my Grafoscopio notebooks,  I have implemented a way to auto-updating the content of a node, so it is automatically saved in the notebook when a node content is changed. The problem is that a node contains an embedded playground that produces text as output when executed (for example the playground reads a file or scraps HTML or calculates a hash), the text of the playground is replaced with the executed output. If the playground produces a visualization or non-textual output, this doesn't happen.
>>
>> I imagine that the source of the problem is here:
>>
>> =======
>>
>> GrafoscopioNotebook >> autoSaveBodyOf: aNode
>>     body body class = TextModel
>>         ifTrue: [ body body whenTextChanged: [ :arg | aNode body: arg ] ].
>>     body body class = GlamourPresentationModel
>>         ifTrue: [ | playground |
>>             playground := body body glmPres.
>>             playground
>>                 when: GLMContextChanged
>>                 do: [ :ann |
>>                     ann property = #text
>>                         ifTrue: [ | playgroundText |
>>                             playgroundText := (playground pane ports at: 2) value.
>>                             aNode body: playgroundText ]
>>                 ]
>>         ]
>>
>> =======
>>
>> as you can see the "when: GLMContextChanged" updates a node body with the playgroundText, as intended, so I can capture any change of the playground code, but I would like to add some condition to **not** update the body content if the text is the result of a playground execution. There is any way to do this?
>>
>> Thanks,
>>
>> Offray
>>
>>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "If you can't say why something is relevant,
> it probably isn't."
>
>
>