Replacing all text in a code pane

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

Replacing all text in a code pane

Sean P. DeNigris
Administrator
I'm writing a little debugger extension and I want to replace the entire method source with another string.

I thought of two ways:

aDebugger getTextMorph textMorph editor selectAll.
aDebugger getTextMorph textMorph editor zapSelectionWith: aString.

or

aDebugger getTextMorph textMorph contents: 'meaning: aString
        meaning := aString.'
aDebugger getTextMorph textMorph editor userHasEdited

They both work, but what is the best/correct way to do something like this?

Thanks!
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Replacing all text in a code pane

Igor Stasenko
On 10 April 2013 20:08, Sean P. DeNigris <[hidden email]> wrote:

> I'm writing a little debugger extension and I want to replace the entire
> method source with another string.
>
> I thought of two ways:
>
> aDebugger getTextMorph textMorph editor selectAll.
> aDebugger getTextMorph textMorph editor zapSelectionWith: aString.
>
> or
>
> aDebugger getTextMorph textMorph contents: 'meaning: aString
>         meaning := aString.'
> aDebugger getTextMorph textMorph editor userHasEdited
>
> They both work, but what is the best/correct way to do something like this?
>
> Thanks!
>

+ 1 i wanna know that too.
the problem with it, that the model is so diverse that you have no
clue, which object is actually
true holder (owner) of text, while others using it just for quick access.

and also i don't like the expression length:
aDebugger getTextMorph textMorph editor userHasEdited

(poor guy, Demeter, and his law ;) )
it should not be like that.. (maybe we need to think about proper api there?)


--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: Replacing all text in a code pane

Sean P. DeNigris
Administrator
In reply to this post by Sean P. DeNigris
Igor, couldn't agree more. Plus there are problems with both my approaches...

Sean P. DeNigris wrote
aDebugger getTextMorph textMorph editor selectAll.
aDebugger getTextMorph textMorph editor zapSelectionWith: aString.
"Works if wrapped in "sourcePane handleEdit: []", but warns that the method has been edited elsewhere. Without the wrapping, it looks like it has accepted, but keeps the old source (i.e. when I browse the method, the source was not accepted).

Sean P. DeNigris wrote
aDebugger getTextMorph textMorph contents: 'meaning: aString
        meaning := aString.'
aDebugger getTextMorph textMorph editor userHasEdited
Warns that the method has been edited elsewhere; if you click okay, it looks like it has accepted, but keeps the old source (i.e. when I browse the method, the source was not accepted).
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Replacing all text in a code pane

stephane ducasse
In reply to this post by Igor Stasenko
Alain is rewriting textMorph so it will get better.
Then sean did you look at the new debugger model?

Stef

On Apr 10, 2013, at 8:38 PM, Igor Stasenko <[hidden email]> wrote:

> On 10 April 2013 20:08, Sean P. DeNigris <[hidden email]> wrote:
>> I'm writing a little debugger extension and I want to replace the entire
>> method source with another string.
>>
>> I thought of two ways:
>>
>> aDebugger getTextMorph textMorph editor selectAll.
>> aDebugger getTextMorph textMorph editor zapSelectionWith: aString.
>>
>> or
>>
>> aDebugger getTextMorph textMorph contents: 'meaning: aString
>>        meaning := aString.'
>> aDebugger getTextMorph textMorph editor userHasEdited
>>
>> They both work, but what is the best/correct way to do something like this?
>>
>> Thanks!
>>
>
> + 1 i wanna know that too.
> the problem with it, that the model is so diverse that you have no
> clue, which object is actually
> true holder (owner) of text, while others using it just for quick access.
>
> and also i don't like the expression length:
> aDebugger getTextMorph textMorph editor userHasEdited
>
> (poor guy, Demeter, and his law ;) )
> it should not be like that.. (maybe we need to think about proper api there?)
>
>
> --
> Best regards,
> Igor Stasenko.
>


Reply | Threaded
Open this post in threaded view
|

Re: Replacing all text in a code pane

Andrei Chis
In reply to this post by Sean P. DeNigris
I've spent some time in the past in that part of the debugger but still can't say which approach is better.

Anyway, in the new debugger you can say:  
      aDebugger code pendingText: 'something'


Cheers,
Andrei


On Wed, Apr 10, 2013 at 9:24 PM, Sean P. DeNigris <[hidden email]> wrote:
Igor, couldn't agree more. Plus there are problems with both my approaches...


Sean P. DeNigris wrote
> aDebugger getTextMorph textMorph editor selectAll.
> aDebugger getTextMorph textMorph editor zapSelectionWith: aString.

"Works if wrapped in "sourcePane handleEdit: []", but warns that the method
has been edited elsewhere. Without the wrapping, it looks like it has
accepted, but keeps the old source (i.e. when I browse the method, the
source was not accepted).


Sean P. DeNigris wrote
> aDebugger getTextMorph textMorph contents: 'meaning: aString
>       meaning := aString.'
> aDebugger getTextMorph textMorph editor userHasEdited

Warns that the method has been edited elsewhere; if you click okay, it looks
like it has accepted, but keeps the old source (i.e. when I browse the
method, the source was not accepted).



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/Replacing-all-text-in-a-code-pane-tp4680669p4680679.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Replacing all text in a code pane

Sean P. DeNigris
Administrator
In reply to this post by stephane ducasse
stephane ducasse wrote
Then sean did you look at the new debugger model?
I want to use this in 2.0, so it seems I'm stuck with the old debugger for now.
Cheers,
Sean