如何将 Smalltalk 代码编辑器嵌入到我的应用程序中?

发布于 2024-10-19 15:53:35 字数 960 浏览 9 评论 0原文

我正在 Pharo 图像中构建博客条目查看器和编辑器应用程序,条目内容的格式为 Smalltalk 代码(Seaside 标记 API 非常好)。我对 Smalltalk 还很陌生,所以我使用了 这篇博文 为例。

我目前的 BlogEditor>>open 方法有这个:

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

我不知道用什么来代替 editor := builder newTextEditorFor:。我看到了 SmalltalkEditor 类,但我不知道如何将其放在我的 UI 上。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

知你几分 2024-10-26 15:53:35

将行放在

self halt.

下面

builder := UITheme builder.

运行代码 。当它停止时,调试并选择构建器。浏览它以查看还可以添加哪些内容。

您知道 Pharo 中的文本有格式吗?只需浏览文本即可。

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.

单身狗的梦 2024-10-26 15:53:35

可以使用的是 PluggableTextMorph,它引用 TextMorphForEditView,而 TextMorphForEditView 又为您提供了 SmalltalkEditor。

PluggableTextMorph 是一个 ScrollPane

您还可以查看 TextMorph,它会很方便。

UITheme 构建器隐藏了所有令人讨厌的细节,但它会让您回到上面提到的类。

祝你好运。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文