PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/bsh/commands/editor.bsh

#
Unknown | 49 lines | 41 code | 8 blank | 0 comment | 0 complexity | 831206439aa8645712c9784139a8e1fa MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /**
  2. Open a GUI editor from the command line or in the GUI desktop mode.
  3. When run from the command line the editor is a simple standalone
  4. frame. When run inside the GUI desktop it is a workspace editor.
  5. See workspaceEditor()
  6. */
  7. bsh.help.editor = "usage: editor()";
  8. import java.awt.*;
  9. editor()
  10. {
  11. if ( bsh.system.desktop != void ) {
  12. return workspaceEditor( this.interpreter );
  13. }
  14. this.ta = new TextArea(15,40);
  15. this.frame = new Frame("Editor");
  16. frame.add(ta, "Center");
  17. this.p = new Panel();
  18. this.b = new Button("Eval");
  19. b.addActionListener(this);
  20. p.add(b);
  21. b = new Button("Clear");
  22. b.addActionListener(this);
  23. p.add(b);
  24. b = new Button("Close");
  25. b.addActionListener(this);
  26. p.add(b);
  27. frame.add(p, "South");
  28. frame.pack();
  29. frame.show();
  30. actionPerformed(e)
  31. {
  32. if ( e.getActionCommand().equals("Close") )
  33. frame.dispose();
  34. else if ( e.getActionCommand().equals("Clear") )
  35. ta.setText("");
  36. else
  37. this.interpreter.eval( ta.getText() );
  38. }
  39. print("Editor started...");
  40. return frame;
  41. }