NotePad Solution in Pharo

a) Spec

tm := TextModel new.
tm autoAccept: true. “otherwise you would have to pres ctrl+s to ‘save’ the result in memory”
tm openWithSpec. “this will open text window
“and then you can do”
tm text. “retrieve current text from the TextModel (returns an instance of Text)”
tm text: ‘new content’ “set a new content”
b) Workspace
w := Workspace new.
w open.
w contents. “note that you must ctrl+s the content in the workspace for it to appear here (there’s a yellow triangle in top right corner if the content is not saved”
w contents: ‘123’.
Workspace can also be saved/loaded to disk.
c) Playground
(page := GTPlayPage new)
saveContent: ‘initial content’.
(playground := GTPlayground new)
openOn: page.
page content. “retrieve the content; just like with Workspace you must ctrl+s when editing in the Playground itself”
“updating is a bit more complex, but it still seems to work”
page saveContent: ‘new content’.
playground update.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: