/jEdit/tags/before-screen-line-refactoring/bsh/commands/editor.bsh
# · Unknown · 49 lines · 41 code · 8 blank · 0 comment · 0 complexity · 831206439aa8645712c9784139a8e1fa MD5 · raw file
- /**
- 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;
- }