jEdit Community home jEdit Community Wiki > Main > BeanShell jEdit Community Wiki webs:
Main | Plugins | Know | TWiki | Sandbox
Main . { Whats New | Users | Groups | Changes | Index | Search | Go }

Bean Shell

Bean Shell is dialect of Java used for scripting. jEdit uses a tweaked version of Bean Shell as its macro language and also for Startup Scripts. More info about Bean Shell can be found at http://www.beanshell.org.

Example

The following Bean Shell code duplicates the current line in the current buffer:

void duplicateLine() {
/*
* Guard for readonly files because Buffer.insert()
* ignores the flag
*
*/
if (buffer.isReadOnly()) {
Macros.error(view, "This file is read only.");
return;
}
line = textArea.getCaretLine();
offset = textArea.getLineEndOffset(line);
// handle last line differently
if (line == textArea.getLineCount() - 1) {
text = "\n" + textArea.getLineText(line);
--offset;
} else {
text = textArea.getLineText(line) + "\n";
}
buffer.insert(offset, text);
textArea.goToNextLine(false);
}

duplicateLine();

Topic BeanShell . { Edit | Attach | Ref-By | Printable | Diffs | r1.4 | > | r1.3 | > | r1.2 | More }
Revision r1.4 - 10 Nov 2003 - 17:36 GMT - Brad Mace Copyright © 1999-2004 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding jEdit Community Wiki? Send feedback.