/ Published in: Java
bind it to ctrl+enter and everything that GroovyConsole do jEdit will do too.
Uses groovy installation.
Uses groovy installation.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
buffer.setMode("groovy"); buffers = jEdit.getBuffers(); for(i = 0; i < buffers.length; i++) { gsh = buffers[i].getProperty("GroovyShell"); if(gsh != null) { break; } } if(gsh == null) { cl = this.getClass().getClassLoader(); for(i = 0; i < libfiles.length; i++) gsh = new groovy.lang.GroovyShell(cl); } for(i = 0; i < buffers.length; i++) buffers[i].setProperty("GroovyShell", gsh); outbuffer = buffer.getProperty("outbuffer"); if((outbuffer == null) || outbuffer.isClosed()) { outbuffer = jEdit.newFile(view); buffer.setProperty("outbuffer", outbuffer); } gsh.setProperty("out", out); view.showBuffer(buffer); res = textArea.getSelectedText(); if(res == null || res.length() == 0) { res = buffer.getText(); } return res; } result = gsh.evaluate(text()); outbuffer.remove(0, outbuffer.getLength()); outbuffer.insert(0, out.toString()); outbuffer.insert(outbuffer.getLength(),"\n\tResult: " + result); if(result != null) { view.showBuffer(outbuffer); }