PageRenderTime 62ms CodeModel.GetById 57ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 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
 8bsh.help.editor = "usage: editor()";
 9import java.awt.*;
10
11editor() 
12{
13	if ( bsh.system.desktop != void ) {
14		return workspaceEditor( this.interpreter );
15	}
16
17	this.ta = new TextArea(15,40);
18	this.frame = new Frame("Editor");
19	frame.add(ta, "Center");
20
21	this.p = new Panel();
22	this.b = new Button("Eval");
23	b.addActionListener(this);
24	p.add(b);
25	b = new Button("Clear");
26	b.addActionListener(this);
27	p.add(b);
28	b = new Button("Close");
29	b.addActionListener(this);
30	p.add(b);
31
32	frame.add(p, "South");
33	frame.pack();
34	frame.show();
35
36	actionPerformed(e) 
37	{
38		if ( e.getActionCommand().equals("Close") )
39			frame.dispose();
40		else if ( e.getActionCommand().equals("Clear") )
41			ta.setText("");
42		else
43			this.interpreter.eval( ta.getText() );
44	}
45
46	print("Editor started...");
47	return frame;
48}
49