Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I embed a Smalltalk code editor into my application?

I'm building a blog entry viewer and editor application in my Pharo image, and the entry content is formatted as Smalltalk code (the Seaside markup API is really nice). I'm pretty new to Smalltalk, so I was using this blog post as an example.

I currently have this for my BlogEditor>>open method:

open
| builder content |

builder := UITheme builder.
content := builder newColumn: {
    builder newRow: {
        builder newListFor: self
        list: #entries 
        selected: #entrySelectedIndex
        changeSelected: #entrySelectedIndex:
        help: 'Blog entries'.
    }.
    builder newRow: {
        editor := builder
            newTextEditorFor: self
            getText: #readSelectedEntry
            setText: #changeSelectedEntry:.
        editor minHeight: 400 } }.

(content openInWindowLabeled: 'Entries') extent: 800@700

I don't know what to put in place of editor := builder newTextEditorFor:. I saw the class SmalltalkEditor, but I don't know how to put one on my UI.

like image 778
xofz Avatar asked Nov 06 '22 02:11

xofz


2 Answers

Put the line

self halt.

below

builder := UITheme builder.

Run the code. When it halts, debug and select the builder. Browse it to see what else you can add.

You do know a Text in Pharo has formatting? Just browse Text.

like image 190
Stephan Eggermont Avatar answered Nov 16 '22 23:11

Stephan Eggermont


What can be used is a PluggableTextMorph, which refers to a TextMorphForEditView, which in turn gives you a SmalltalkEditor.

PluggableTextMorph is a ScrollPane

You can also look in the TextMorph which could come handy.

The UITheme builder hides all of the nasty details inside but it will bring you back to the classes mentioned above.

Good luck.

like image 39
philippeback Avatar answered Nov 17 '22 01:11

philippeback