Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
scala-swing-repl
package test
import scala.swing._
import scala.tools.nsc._
import scala.tools.nsc.interpreter._
import java.awt.Dimension
import java.io.{OutputStream, PrintStream}
/**
* scala-compiler.jar is required
*
* TODO: key bind
* TODO: output with UTF-8
* TODO: monospace font
* TODO: support undo
* TODO: use ScrollPane
*/
object ScalaREPL extends SimpleSwingApplication {
val settings = new Settings
settings.usejavacp.value = true
val input = new TextArea
val output = new TextArea {
editable = false
}
val main = new IMain(settings)
System.setOut(new PrintStream(new OutputStream {
def write(b: Int) {
// multi byte is not supported
output.text += String.valueOf(b.toChar)
}
}, true))
def top = new MainFrame { frame =>
title = "Scala REPL"
contents = new SplitPane {
dividerLocation = 300
topComponent = input
bottomComponent = output
}
menuBar = new MenuBar {
contents += new Button(Action("Eval") {
main.interpret(input.text)
})
contents += new Button(Action("Clear") {
output.text = ""
})
}
size = new Dimension(500, 600)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.