Embed JRuby
if( ((String)langCombo.getSelectedItem()).equalsIgnoreCase("ruby") ) {
SwingUtilities.invokeLater(() -> {
try {
if( rubyScript == null ) {
rubyScript = new ScriptingContainer();
rubyWriter = new StringWriter();
rubyScript.setOutput(rubyWriter);
rubyScript.runScriptlet("def write(text) print(text) end\n");
rubyScript.runScriptlet("def writeln(text) print(text + \"\\n\") end\n");
}
outputPrintLn("<START Ruby>");
rubyScript.runScriptlet(textTab.getSelectedTextView().getText());
outputPrint(rubyWriter.toString());
rubyWriter.getBuffer().setLength(0);
rubyWriter.getBuffer().trimToSize();
outputPrintLn("<END Ruby>");
} catch (Exception e) {
e.printStackTrace();
outputPrintLn("error\n" + e.getMessage());
}
});
}
댓글 없음:
댓글 쓰기