Eclipse is a powerful framework for programming and developing tools. It's plugin programming is rather involved and occasionally distracted me from what I wanted to accomplish with the tool itself. jEdit is a matured editor which is simpler than eclipse both in layouts and programming. It has a macro feature which allows interactive programming to enhance the editor itself. I find the feature uniquely useful for text editing. This notes helps me to keep track of what gathered as I learn to use jEdit
Predefined Variables in BeanShell: http://www.jedit.org/users-guide/predefined-variables.html
buffer - a Buffer object represents the contents of the currently visible open text file. editPane - an EditPane object contains a text area and buffer switcher. This variable has the same value as the return value of: view.getEditPane(). textArea - a JEditTextArea is the visible component that displays the current buffer. wm - a DockableWindowManager is the visible component that manages dockable windows in the current view. This class is discussed in detail in Part IV, “Writing Plugins”.
Helpful Methods in the Macros Class: http://www.jedit.org/users-guide/helpful-methods.html
1 public static void message( Component comp, 2 String message); 3 public static void error( Component comp, 4 String message); 5 public static String input( Component comp, 6 String prompt); 7 public static String input( Component comp, 8 String prompt, 9 String defaultValue); 10 public static int confirm( Component comp, 11 String prompt, 12 int buttons);
BeanShell Dynamic Typing - http://www.jedit.org/users-guide/dynamic-typing.html Without an explicit type declaration like String result, BeanShell variables can change their type at runtime depending on the object or data assigned to it.
Now For Something Useful - http://www.jedit.org/users-guide/something-useful.html
1 // macro that inserts the path of the current buffer in the text: 2 String newText = buffer.getPath(); 3 textArea.setSelectedText(newText); 4 5 // the file name (without full path) 6 String newText = buffer.getName(); 7 8 // today's date 9 import java.text.DateFormat; 10 11 String newText = DateFormat.getDateInstance().format(new Date()); 12 13 // a line count for the current buffer 14 String newText = "This file contains " + textArea.getLineCount() + " lines."; 15
A Dialog-Based Macro - http://www.jedit.org/users-guide/dialog-macro.html This site points to the following topics:
Use of the Macro Listing of the Macro Analysis of the Macro Import Statements Create the Dialog Create the Text Fields Create the Buttons Register the Action Listeners Make the Dialog Visible The Action Listener Get the User's Input Call jEdit Methods to Manipulate Text The Main Routine
Insights of the past for the present
ON THE BOOK SHELF
May your insights be worthy.