Skip to content

Instantly share code, notes, and snippets.

@Geal
Geal / repl.st
Created May 24, 2011 09:04
A simple command line REPL (run it with a headless image)
OSProcess thisOSProcess stdOut
nextPutAll: 'Welcome to the simple Smalltalk REPL';
nextPut: Character lf; nextPut: $>; flush.
[ |input|
[ input := OSProcess readFromStdIn.
input size > 0 ifTrue: [
OSProcess thisOSProcess stdOut
nextPutAll: ((Compiler evaluate: input) asString;
nextPut: Character lf; nextPut: $>; flush
]
@Geal
Geal / reverse window title
Created February 4, 2011 09:28
Reverse all the window titles (except for PluggableSystemWindow)
SystemWindow allInstancesDo:[:win| win setLabel: (win labelString reverse)]
@Geal
Geal / get selected space in a workspace.st
Created February 3, 2011 16:36
Retrieve the text currently selected in a workspace
SHWorkspace allInstances first codeTextMorph textMorph selection asString
@Geal
Geal / dump content of method.st
Created February 2, 2011 10:31
Displays only the body of a method (without prototype and comments)
| scriptMethod sourceString sourceStringWithBracketsStripped |
scriptMethod := CLASS_HERE compiledMethodAt: #METHOD_HERE.
sourceString := scriptMethod methodNode body asString.
sourceStringWithBracketsStripped := sourceString copyFrom: 3 to: sourceString size - 2.
sourceStringWithBracketsStripped.
@Geal
Geal / set native window position.st
Created February 1, 2011 16:29
how to control the native window size and position
HostWindowProxy new
instVarNamed: #windowHandle put: 1;
windowPosition: 0 @ 0;
windowSize: 800 @ 600;
windowTitle: 'Screencast'