/jEdit/tags/jedit-4-3-pre5/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
- /**
- Open a GUI editor from the command line or in the GUI desktop mode.
- When run from the command line the editor is a simple standalone
- frame. When run inside the GUI desktop it is a workspace editor.
- See workspaceEditor()
- */
- bsh.help.editor = "usage: editor()";
- import java.awt.*;
- editor()
- {
- if ( bsh.system.desktop != void ) {
- return workspaceEditor( this.interpreter );
- }
- this.ta = new TextArea(15,40);
- this.frame = new Frame("Editor");
- frame.add(ta, "Center");
- this.p = new Panel();
- this.b = new Button("Eval");
- b.addActionListener(this);
- p.add(b);
- b = new Button("Clear");
- b.addActionListener(this);
- p.add(b);
- b = new Button("Close");
- b.addActionListener(this);
- p.add(b);
- frame.add(p, "South");
- frame.pack();
- frame.show();
- actionPerformed(e)
- {
- if ( e.getActionCommand().equals("Close") )
- frame.dispose();
- else if ( e.getActionCommand().equals("Clear") )
- ta.setText("");
- else
- this.interpreter.eval( ta.getText() );
- }
- print("Editor started...");
- return frame;
- }