jEdit宏,使它像GroovyConsole一样

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jEdit宏,使它像GroovyConsole一样相关的知识,希望对你有一定的参考价值。

bind it to ctrl+enter and everything that GroovyConsole do jEdit will do too.
Uses groovy installation.
  1. buffer.setMode("groovy");
  2. buffers = jEdit.getBuffers();
  3. for(i = 0; i < buffers.length; i++) {
  4. gsh = buffers[i].getProperty("GroovyShell");
  5. if(gsh != null) { break; }
  6. }
  7. if(gsh == null) {
  8. libfiles = new File(System.getenv("GROOVY_HOME") + "/lib/").listFiles();
  9. cl = this.getClass().getClassLoader();
  10. for(i = 0; i < libfiles.length; i++)
  11. cl.addURL(new URL("jar:" + libfiles[i].toURL().toString() + "!/"));
  12. gsh = new groovy.lang.GroovyShell(cl);
  13. }
  14. for(i = 0; i < buffers.length; i++)
  15. buffers[i].setProperty("GroovyShell", gsh);
  16. outbuffer = buffer.getProperty("outbuffer");
  17. if((outbuffer == null) || outbuffer.isClosed()) {
  18. outbuffer = jEdit.newFile(view);
  19. buffer.setProperty("outbuffer", outbuffer);
  20. }
  21. out = new java.io.StringWriter();
  22. gsh.setProperty("out", out);
  23. String text() {
  24. view.showBuffer(buffer);
  25. res = textArea.getSelectedText();
  26. if(res == null || res.length() == 0) { res = buffer.getText(); }
  27. return res;
  28. }
  29. String cwd = System.getProperty("user.dir");
  30. System.setProperty("user.dir", buffer.getDirectory());
  31. result = gsh.evaluate(text());
  32. System.setProperty("user.dir", cwd);
  33. outbuffer.remove(0, outbuffer.getLength());
  34. outbuffer.insert(0, out.toString());
  35. outbuffer.insert(outbuffer.getLength()," Result: " + result);
  36. if(result != null) {
  37. view.showBuffer(outbuffer);
  38. }

以上是关于jEdit宏,使它像GroovyConsole一样的主要内容,如果未能解决你的问题,请参考以下文章

隐藏状态栏android时的白条一瞥(如何使它像Whatsapp状态)

从 GroovyConsole 执行 shell 命令时出错

GroovyConsole正在运行build.gradle

使用 jeditable 和 autogrow 的问题

为啥我不能让球跳起来?它像火箭一样飞起来

Django 和 JEditable:CSRF 错误