Questions about TextModel in Spec

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

Questions about TextModel in Spec

Uko2
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko
Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Nicolai Hess-3-2


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko

Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Nicolai Hess-3-2


2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko


But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)

Anyway, maybe we need a way to distinguish between
- get visible text (view get text?)
and
- get accepted text (model get text?)

nicolai

Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Uko2
Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?

Uko


On 24 Jul 2016, at 11:37, Nicolai Hess <[hidden email]> wrote:



2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko


But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)

Anyway, maybe we need a way to distinguish between
- get visible text (view get text?)
and
- get accepted text (model get text?)

nicolai


Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Uko2
There is #pendingText to access it, finally found that. Now I want to detect when someone starts typing and do actions (like disable something until the text is accepted). There is whenTextChanged: but it’s not that useful because it checks if the accepted text has changed. Is there a way to check if pendingCode has changed? Or if the model is entering “hasUnacceptedEdits”?

Uko

On 24 Jul 2016, at 12:48, Yuriy Tymchuk <[hidden email]> wrote:

Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?

Uko


On 24 Jul 2016, at 11:37, Nicolai Hess <[hidden email]> wrote:



2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko


But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)

Anyway, maybe we need a way to distinguish between
- get visible text (view get text?)
and
- get accepted text (model get text?)

nicolai



Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Nicolai Hess-3-2
In reply to this post by Uko2


2016-07-24 12:48 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?

I think MessageBrowser must set some handling for accepting modified code and react on compilation/parsing errors.
Look at caller for
#accept:notifying:

a simple example for reacting on parsing errors:



textmodel := TextModel new.
textmodel beForCode.
textmodel openWithSpec.
textmodel acceptBlock:[:text :notifier |
    [RBParser parseExpression:text] on:SyntaxErrorNotification do:[:ex |
    notifier notify: ex errorMessage at: ex location in: ex errorCode]
].


 

Uko


On 24 Jul 2016, at 11:37, Nicolai Hess <[hidden email]> wrote:



2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko


But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)

Anyway, maybe we need a way to distinguish between
- get visible text (view get text?)
and
- get accepted text (model get text?)

nicolai



Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Nicolai Hess-3-2
In reply to this post by Uko2


2016-07-24 13:45 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
There is #pendingText to access it, finally found that. Now I want to detect when someone starts typing and do actions (like disable something until the text is accepted). There is whenTextChanged: but it’s not that useful because it checks if the accepted text has changed. Is there a way to check if pendingCode has changed? Or if the model is entering “hasUnacceptedEdits”?

No :(

I don't think this is possible.
You could turn autoAccept to true and listen for set a whenTextChanged block, but of course, you can not display "unaccepted" text anymore, because all text is accepted.

Uko

On 24 Jul 2016, at 12:48, Yuriy Tymchuk <[hidden email]> wrote:

Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?

Uko


On 24 Jul 2016, at 11:37, Nicolai Hess <[hidden email]> wrote:



2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko


But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)

Anyway, maybe we need a way to distinguish between
- get visible text (view get text?)
and
- get accepted text (model get text?)

nicolai




Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Uko2
I’ve found a partial hack:

whenEdited: aBlock
"Set a block to perform when the text wasEddited & the widget entered hasUnacceptedEdits mode"
hasUnacceptedEdits whenChangedDo: [ :val |
val ifTrue: aBlock value ]

So now before the text is accepted I can block some other widgets

Uko

On 24 Jul 2016, at 14:17, Nicolai Hess <[hidden email]> wrote:



2016-07-24 13:45 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
There is #pendingText to access it, finally found that. Now I want to detect when someone starts typing and do actions (like disable something until the text is accepted). There is whenTextChanged: but it’s not that useful because it checks if the accepted text has changed. Is there a way to check if pendingCode has changed? Or if the model is entering “hasUnacceptedEdits”?

No :(

I don't think this is possible.
You could turn autoAccept to true and listen for set a whenTextChanged block, but of course, you can not display "unaccepted" text anymore, because all text is accepted.

Uko

On 24 Jul 2016, at 12:48, Yuriy Tymchuk <[hidden email]> wrote:

Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?

Uko


On 24 Jul 2016, at 11:37, Nicolai Hess <[hidden email]> wrote:



2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko


But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)

Anyway, maybe we need a way to distinguish between
- get visible text (view get text?)
and
- get accepted text (model get text?)

nicolai





Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Peter Uhnak
On Sun, Jul 24, 2016 at 02:35:13PM +0200, Yuriy Tymchuk wrote:
> I’ve found a partial hack:
>
> whenEdited: aBlock
> "Set a block to perform when the text wasEddited & the widget entered hasUnacceptedEdits mode"
>
> hasUnacceptedEdits whenChangedDo: [ :val |
> val ifTrue: aBlock value ]
>
> So now before the text is accepted I can block some other widgets

wtf is whenEdited: :-o

There are couple of bugs I've reported last week in regards to this, because it's quite annoying.
https://pharo.fogbugz.com/f/cases/18799/TextModel-whenTextChanged-and-whenTextIsAccepted-should-behave-differently
https://pharo.fogbugz.com/f/cases/18800/TextModel-has-inconsistent-text-changed-API

I guess whenEdited: should be added to those issues.

Btw, what are you trying to do? Because I was playing around with custom styling for my DSL (parsed & highlighted by PetitParser),
but got stopped by this same issue.

Do you use a similar setup? Could we extrapolate something generically useful from this?

Peter


>
> Uko
>
> > On 24 Jul 2016, at 14:17, Nicolai Hess <[hidden email]> wrote:
> >
> >
> >
> > 2016-07-24 13:45 GMT+02:00 Yuriy Tymchuk <[hidden email] <mailto:[hidden email]>>:
> > There is #pendingText to access it, finally found that. Now I want to detect when someone starts typing and do actions (like disable something until the text is accepted). There is whenTextChanged: but it’s not that useful because it checks if the accepted text has changed. Is there a way to check if pendingCode has changed? Or if the model is entering “hasUnacceptedEdits”?
> >
> > No :(
> >
> > I don't think this is possible.
> > You could turn autoAccept to true and listen for set a whenTextChanged block, but of course, you can not display "unaccepted" text anymore, because all text is accepted.
> >
> > Uko
> >
> >> On 24 Jul 2016, at 12:48, Yuriy Tymchuk <[hidden email] <mailto:[hidden email]>> wrote:
> >>
> >> Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?
> >>
> >> Uko
> >>
> >>
> >>> On 24 Jul 2016, at 11:37, Nicolai Hess <[hidden email] <mailto:[hidden email]>> wrote:
> >>>
> >>>
> >>>
> >>> 2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email] <mailto:[hidden email]>>:
> >>>
> >>>
> >>> 2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email] <mailto:[hidden email]>>:
> >>> Hi,
> >>>
> >>> at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.
> >>>
> >>> And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.
> >>>
> >>> textmodel autoAccept: true.
> >>>  
> >>>
> >>> I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…
> >>>
> >>> Cheers.
> >>> Uko
> >>>
> >>>
> >>> But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)
> >>>
> >>> Anyway, maybe we need a way to distinguish between
> >>> - get visible text (view get text?)
> >>> and
> >>> - get accepted text (model get text?)
> >>>
> >>> nicolai
> >>>
> >>
> >
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

Uko2

> On 24 Jul 2016, at 15:55, Peter Uhnak <[hidden email]> wrote:
>
> On Sun, Jul 24, 2016 at 02:35:13PM +0200, Yuriy Tymchuk wrote:
>> I’ve found a partial hack:
>>
>> whenEdited: aBlock
>> "Set a block to perform when the text wasEddited & the widget entered hasUnacceptedEdits mode"
>>
>> hasUnacceptedEdits whenChangedDo: [ :val |
>> val ifTrue: aBlock value ]
>>
>> So now before the text is accepted I can block some other widgets
>
> wtf is whenEdited: :-o

Thing that is called when the text is edited (when the orange triangle appears). I need a way to know that the text in the editor is different on from the excepted.

>
> There are couple of bugs I've reported last week in regards to this, because it's quite annoying.
> https://pharo.fogbugz.com/f/cases/18799/TextModel-whenTextChanged-and-whenTextIsAccepted-should-behave-differently
> https://pharo.fogbugz.com/f/cases/18800/TextModel-has-inconsistent-text-changed-API
>
> I guess whenEdited: should be added to those issues.
>
> Btw, what are you trying to do? Because I was playing around with custom styling for my DSL (parsed & highlighted by PetitParser),
> but got stopped by this same issue.

Just RB highlight, but I want it to be switchable i.e. #parseExpression:, #parseMethod:, #parseRewriteExpression:, #parseRewriteMethod:

Uko

>
> Do you use a similar setup? Could we extrapolate something generically useful from this?
>
> Peter
>
>
>>
>> Uko
>>
>>> On 24 Jul 2016, at 14:17, Nicolai Hess <[hidden email]> wrote:
>>>
>>>
>>>
>>> 2016-07-24 13:45 GMT+02:00 Yuriy Tymchuk <[hidden email] <mailto:[hidden email]>>:
>>> There is #pendingText to access it, finally found that. Now I want to detect when someone starts typing and do actions (like disable something until the text is accepted). There is whenTextChanged: but it’s not that useful because it checks if the accepted text has changed. Is there a way to check if pendingCode has changed? Or if the model is entering “hasUnacceptedEdits”?
>>>
>>> No :(
>>>
>>> I don't think this is possible.
>>> You could turn autoAccept to true and listen for set a whenTextChanged block, but of course, you can not display "unaccepted" text anymore, because all text is accepted.
>>>
>>> Uko
>>>
>>>> On 24 Jul 2016, at 12:48, Yuriy Tymchuk <[hidden email] <mailto:[hidden email]>> wrote:
>>>>
>>>> Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?
>>>>
>>>> Uko
>>>>
>>>>
>>>>> On 24 Jul 2016, at 11:37, Nicolai Hess <[hidden email] <mailto:[hidden email]>> wrote:
>>>>>
>>>>>
>>>>>
>>>>> 2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email] <mailto:[hidden email]>>:
>>>>>
>>>>>
>>>>> 2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email] <mailto:[hidden email]>>:
>>>>> Hi,
>>>>>
>>>>> at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.
>>>>>
>>>>> And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.
>>>>>
>>>>> textmodel autoAccept: true.
>>>>>
>>>>>
>>>>> I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…
>>>>>
>>>>> Cheers.
>>>>> Uko
>>>>>
>>>>>
>>>>> But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)
>>>>>
>>>>> Anyway, maybe we need a way to distinguish between
>>>>> - get visible text (view get text?)
>>>>> and
>>>>> - get accepted text (model get text?)
>>>>>
>>>>> nicolai
>>>>>
>>>>
>>>
>>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Questions about TextModel in Spec

stepharo
In reply to this post by Nicolai Hess-3-2



Le 24/7/16 à 11:37, Nicolai Hess a écrit :


2016-07-24 11:35 GMT+02:00 Nicolai Hess <[hidden email]>:


2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <[hidden email]>:
Hi,

at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework I’ve decided to give it another try.

And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no it’s much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted… Why in the first place a basic text model needs this “accept” stuff? What if I have just a dialog where someone types something and submits it? I don’t need accepts with orange corners for that.

textmodel autoAccept: true.
 

I think that you’ve got the idea. I just want to build a simple UI and it looks like it’s easier to do it with Morphic…

Cheers.
Uko


But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)

Anyway, maybe we need a way to distinguish between
- get visible text (view get text?)
and
- get accepted text (model get text?)

Yes we need that.