Skip to content

Instantly share code, notes, and snippets.

@philippeback
Created September 22, 2018 08:06
Show Gist options
  • Save philippeback/2f36eb9bfceaac23986a87656139e9dd to your computer and use it in GitHub Desktop.
Save philippeback/2f36eb9bfceaac23986a87656139e9dd to your computer and use it in GitHub Desktop.
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.
~~~~~~~~~~~~~~~~~~~
Peter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment