Text editor + morph

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

Text editor + morph

HilaireFernandes
Hi,

In Pharo, do we have a text editor where it is possible to embed
arbitrary Morph object?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: Text editor + morph

HilaireFernandes
If there are no such text editor, is there a best candidate to inherit
from and extend?

I have about no knowledge regarding the text editor implementations in
Pharo.

Hilaire


Le 03/10/2018 à 18:31, Hilaire a écrit :
> In Pharo, do we have a text editor where it is possible to embed
> arbitrary Morph object?

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: Text editor + morph

Hannes Hirzel
Hello Hilaire

Your question is
>> In Pharo, do we have a text editor where it is possible to embed
>> arbitrary Morph object?

I would put it differently:

Use  an object and embed Text editors and DrGeo canvas objects.
This idea is taken out of a paper about literate programming by
Trygver Reenskaug
I cc him, maybe he is  interested in answering.

http://folk.uio.no/trygver/1989/1989.10.1-LiterateProgrammingOOPSLA.pdf
An environment for literate Smalltalk programming

He implemented a 'Galley editor'. The following is a simplified
version of the idea.


A TextMorph actually can work as a text editor as the following
example will show.

It uses a AlignmentMorph (called 'column') which has three submorphs,
two of them being TextMorph objects:

1. aTextMorph
2. aDrGeoCanvas
    This is the result of
            DrGeoCanvas minimal
     which you implemented last week.
3. aTextMorph

The text morphs are editable. Some fine tuning of TextMorph editing
will be needed (pop-up menu, maybe keyboard shortcuts, alignment. But
as a whole following a Squeak implementation should do the job (
http://wiki.squeak.org/squeak/837 )



The code

| column box1 headingText box2 box3  ptA ptB ptC angle segA segB segC |


 column := AlignmentMorph newColumn cellPositioning: #topLeft.
 column  hResizing: #shrinkWrap.
 column  vResizing: #shrinkWrap.

 headingText := 'Right triangle (AE) / right-angled triangle (BE)'
asText allBold.
 box1 := TextMorph new leftFlush.
 box1 contents: headingText.
 box1 backgroundColor: Color white.
 column addMorphBack: box1.


 c := DrGeoCanvas minimal.
 ptA := c point: 0@0.
 ptA name: 'A'.
 ptB := c point: 4@3.
 ptB name: 'B'.
 ptC := c point: 4@0.
 ptC name: 'C'.
 angle  := c angle: ptB to: ptC to: ptA.
 angle show.
 c segment: ptC to: ptA.
 segA :=c segment: ptC to: ptB.
 segA name: 'a'.
 segB := c segment: ptC to: ptA.
 segB name: 'b'.
 segC := c segment: ptA to: ptB.
 segC name: 'c'.

 box2 := c.
 column addMorphBack: box2 view.


 box3 := TextMorph new leftFlush.
 box3 contents: 'a triangle in which one angle is a right angle'.
 box3 backgroundColor: Color lightGray.
 column addMorphBack: box3.


 column openInWorld.


I think this road can be extended for a nice extended Dynabook implementation

A stack of boxes or cells following the Jupyter notebook idea.
Later on put it into a window or  re-implementation of a BookMorph (a
'light version').
Maybe in Pharo there are also other TextEditors which are fine. But a
TextMorph seems to do the job.

Regards

Hannes



On 10/6/18, Hilaire <[hidden email]> wrote:

> If there are no such text editor, is there a best candidate to inherit
> from and extend?
>
> I have about no knowledge regarding the text editor implementations in
> Pharo.
>
> Hilaire
>
>
> Le 03/10/2018 à 18:31, Hilaire a écrit :
>> In Pharo, do we have a text editor where it is possible to embed
>> arbitrary Morph object?
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
>

Stacked_Morphs_with_editor_Screenshot_2018-10-07.png (146K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Text editor + morph

HilaireFernandes
Hi Hannes,

Thanks for the tips and the reference, which I did not know about until
now. I will take a close look to it.

Hilaire


Le 07/10/2018 à 09:04, H. Hirzel a écrit :
> I would put it differently:
>
> Use  an object and embed Text editors and DrGeo canvas objects.
> This idea is taken out of a paper about literate programming by
> Trygver Reenskaug
> I cc him, maybe he is  interested in answering.

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: Text editor + morph

Nicolai Hess-3-2
In reply to this post by HilaireFernandes
The "old" way, a Morph asText, still works. I don't know if this is still fully usable with normal text operations:

|text block|
block := [ Morph new asText, ' some text'].
text:=(Smalltalk ui theme builder newTextEditorFor: block  getText: #value setText: nil).
text openInWindow.



Am Mi., 3. Okt. 2018 um 18:32 Uhr schrieb Hilaire <[hidden email]>:
Hi,

In Pharo, do we have a text editor where it is possible to embed
arbitrary Morph object?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: Text editor + morph

HilaireFernandes
Hi Nicolai,

Thanks for the tips! I tried it out with DrGeo and it gives interesting
result (screenshot). Text can be edited and the DrGeo view is fully
interactive.

It is very close to what I am looking for.

Hilaire


PS: The used code was:

|text block c ptA ptB ptC angle segA segB segC|
    c := DrGeoCanvas minimal.
    ptA := c point: 0@0.
    ptA name: 'A'.
    ptB := c point: 4@3.
    ptB name: 'B'.
    ptC := c point: 4@0.
    ptC name: 'C'.
    angle  := c angle: ptB to: ptC to: ptA.
    angle show.
    c segment: ptC to: ptA.
    segA :=c segment: ptC to: ptB.
    segA name: 'a'.
    segB := c segment: ptC to: ptA.
    segB name: 'b'.
    segC := c segment: ptA to: ptB.
    segC name: 'c'.
    block := [ Morph new asText, ' some text'].
    text:=(Smalltalk ui theme builder newTextEditorFor: block  getText:
#value setText: nil).
    text openInWindow.

Le 07/10/2018 à 16:31, Nicolai Hess a écrit :
> The "old" way, a Morph asText, still works. I don't know if this is
> still fully usable with normal text operations:
>
> |text block|
> block := [ Morph new asText, ' some text'].
> text:=(Smalltalk ui theme builder newTextEditorFor: block  getText:
> #value setText: nil).
> text openInWindow.

--
Dr. Geo
http://drgeo.eu


DrGeoText.png (14K) Download Attachment