| NetRexxScript |
Version 0.1.3 (November 30 2009)
By Kermit Kiser (nrs@kermitkiser.com)
|
- The plugin writing guide in jEdit sucks - especially for
an amateur NetRexx progammer like me! There is no guide to writing a
macro handler as far as I can find. Many hours of wading through other
people's Java code resulted in this puny effort which I hope to
improve. Perhaps David and I can write a better guide for NetRexx
programmers at some time. As the release of NetRexx open source
approaches, it is becoming more important to have good tools and
documents. I hope these efforts can help bring NetRexx out of the dark
ages and give us some better tools!
- Can this plugin be integrated with the NetRexxJe plugin? Is
that even a good idea?
- Can I get trace output to the user? -sticking with activity
log for now
- Can
I pre-parse all NetRexx scripts at startup and cache them - perhaps as
an option? Will that allow one script to call another? (Yes - tested
it!)
- If
NetRexxC.jar is included in the NetRexxScript.jar file along with a
classpath in the manifest, will it fix the problem with jEdit startup
via "-jar"? (Nope - tried it.) Solved by dynamically modifying System
classpath variable - interpreter classloader uses it to override the
default classpath!
- Yes, I know about SuperScript and the "no -jar"
startup fix might make it work also but the BSF scriptengine code
comments make it clear that NetRexx script support would be highly
inefficient that way!
- I wonder if an efficient JSR 223 script
engine could be created for NetRexx? Then the ScriptEnginePlugin could
support NetRexx. And what about Eclipse integration?
- Perhaps
when NetRexx is open source, a different interpreter "proxy" class
loader could be made compatible with the plugin JAR classloader used by
jEdit. May not be needed with "dynamic" classpath technique. No longer
important - specification of user classpath is now allowed.
(Interpreter reads java.class.path variable at instantiation and
creates classloader.)
- *** When rerunning cached scripts, there are strange effects to
indexed variables with left over values. (if you set indexed variable
iv='x' then indexed values from last run when iv was 'x' will reappear!) See sample script "index" for an example. ***
- Can scripts use the package instruction?
- The "add jEdit variables" option adds a file called
"prefix.txt"
from the profile directory "NetRexx" to scripts before parsing them.
You can modify this file to add imports, etc., but if it contains any
new-line sequences, then error line numbers will no longer match the
original script file.
- The Preparse option makes an attempt to filter out
duplicate program names as they cause the NetRexx interpreter to fail,
but this only checks by file names, so watch out for duplication in
embedded utility classes! Hmm... Using minor classes may be the answer
here?
- The Runcurrent function will not work with an "untitled"
predefined classname script due to Java/NetRexx requirements for the
file name to match class name.
- Many
thanks to Mike Cowlishaw for NetRexx and to Satguru Srivastava and
David Requena for NetRexxJe all of which helped make this
plugin
possible!
- Guess I better document some of the things I had to figure out by trial and error:
The
NetRexx interpreter reads the current value of the Java system
classpath at the time instantiated and uses it to build a special
classloader - the interpreter must be recreated each time the classpath
needs to be altered.
The NetRexx "RexxIO" class obtains the Java
System.out printstream and saves it the first time you use a "say"
instruction - System.out must be changed before any "say" instruction
is executed in order to intercept output from "say" instructions!
The ASK interface is also part of RexxIO and uses the read to byte
array with offset+length which does not touch the read single byte
method.
- Can I instantiate multiple NetRexxA interpreters to get independent parse sets?
- Looks
like I will need one and possibly two custom classloaders to be able to
start arbitrary class files from the dynamic classpath (to allow
"promoting" script libs to jar files, etc.) - did it with one.
- Note
that the custom classloader does a recursive directory search for
classes, therefore if a class file is listed in the macro menu,
executing it may not find the one in the menu location (ie just don't
duplicate class names!)
- Test procedure is here
- Version Rollout Checklist
These are the additional things that are being considered or
planned plus outstanding bugs:
- Remove debugging output from activity log - removed display
of classpath on execute script, added df checks
- reorganize preparse to allow separate projects of related
scripts? *
- add an option to compile a script? macro might be better here? *
- classify option to convert script lib to classes? to jar? - better to do with a sample macro? *
- cache the directory search for command line entry somehow? *
- Scan std out for run time errors and post to ErrorList? *
- add
startup macros to preparse list? - advantage unknown - real goal is to
cache objects like beanshell does
- Make ErrorList use optional? *
- Add package support to class loader?
- allow scripts to run from jar files?
- Should mac dir vs script path search order be an option?
- make interpreter use my classloader as parent? *
- Can I add a plugin option to the file browser window to execute scripts from there?
- Add run selection option to execute a selected portion of a buffer?
Moving completed items here:
- Add caching for the executed scripts. This may require
reparsing them all each time a new script is called or an old one is
edited since Mike's userguide says that old classes become unusable
when parse is called again. - done
- Add editbus detection of save for NetRexx script files to
auto flush cache. - done
- Add plugin menu subitem flag for caching (to turn off when
debugging a new macro) and manual cache flushing. - done
- Add error message popups as needed. - added for missing
NetRexxC in classpath and for failure of script to parse
- Add mechanism to plugin setup script to pre parse all
available NetRexx scripts and cache them (optionally) - done
- Add a function to save and start the current nrx file as a
script - done but does not save current buffer - creates a temp copy of
the buffer and runs it
- Set compact parse option and reflect errors to the edit
buffer? done - requires ErrorList plugin.
- Add
setup scan to analyze all scripts and copy those with no
class name or method main or imports to a temp
directory with
a prefix that adds class/main/import/init of macro variables? - sorta
done - currently all or nothing though.
- Add an option to turn trace override off or on. - done
- Add a dockable output window for say/trace/parse output? done - still needs support for "ask" input - OK now - finally got it!
- Add
options screen to control all interpreter options - done - current
options = trace, cache, preparse and verbosity level + add jEdit
variables
- add popup screen to run a script with input parameters? not needed - dockable window handles it ok.
- test plugin under Linux -
done - tested via Ubuntu 9.04 in VMware
- add an option to include libraries of script functions in
the parse? done - see scriptpath option
- add option to specify a classpath for loading classes.
done - see classpath option
- Kill extra preparse at startup! done (setclasspath init)
- kill script option is not doing cleanup/flush - done
- mod teestream to route output directly to window? done - uses dynamic insertion of JTextArea into the PrintStream object!
- capture script error output to an error list? done - requires
ErrorList plugin installed. Still need change to make ErrorList
optional rather than required. **
- flush input buffer after ask/read. Done.
- check for executing script thread before parse/start new script? done.
- Make start button stop scripts started from the macro list. Done.
- Add popup message if attempt to start a second script while another is running. done.
- oops - testing V14 - after kill script button, next command line start failed - Fixed.
- allow "name.nrx" syntax on command line starts? done.
- if edit save .nrx to macros directory, autorun Macros.loadMacros to rescan macros - done.
- Add .class support to macro handler -- done.
- rebuild classloader when NetRexxA is reinstantiated - not needed - setPath method changes class loader path
- add command line search for class/main entry points ** - gonna need classloaders! done!
- Need an option/button to move command line/bar to top/bottom of window. done.
- change textareas to autoscroll to end of text added
- bug - attempt to run non nrx file does not reset command enter flags - fixed.
- Initial startup script is not finishing before initial preparse on
Linux - needs a check for active thread (restart of parse causes null
pointer exception) - fixed with 2 sec wait loop and kill check
- can I add NetRexx atOnce to the help? The NetRexx language def PDF? -
added edited copy of atOnce , help location for Mike's V2 NetRexx language doc.
- mod classloader to load a class from a specific address - done for macro menu call.
- rebuild class loader on flush to remove loaded classes from memory - done.
- need to test compiling nrx script to class to jar and executing from there - done.
- Add NetRexx builder system to replace Ant? - out of scope.
- add a script to flip the debug flag - done.
- Add erase/move file scripts? - out of scope.
- Figure out how to package for ant and distribution from the
jEdit plugin site. - done, I think!
- Include the NetRexxC.jar file with the plugin if not
conflicting with NetRexxJe which now includes it. - added it to
download site. don't want it in plugin jar, maybe a zip combo file like
David did for NetRexxJe? - dist build handles now.
- Add more sample scripts to the plugin jar. - added iosample
script and multi script which calls test script (requires preparse
option), asktest demos console IO
- add a script to generate ant build files? - out of scope.
- auto compile cache? - preparse handles it OK.
- ask request is not moving cursor to input line if focus elsewhere - fixed by adding requestFocus in read method.
- add clear output button to command bar - done.
- add option to not erase output window before script execution? - done.
- move macro directory search to after scriptpath search? - already done.
- need more tests with no command window - done - ask returns null if no window.
- zero length scripts may cause a problem - fixed (chk for len<3 bytes = nl cr)
- PO window is flashing before out window? fixed, I hope - skip PO display unless error
- George Hovey #1 - Shortcuts menu shows "No Label" error. fixed by adding props NetRexxScript.label=NetRexxScript
- George
Hovey #2 - If options panel too small in jEdit 4.2, the path fields
shrink to minimum size. fixed by killing gridbag and wrapping with
JScrollPane
- Document how to change prefix.txt? done.
- Document startup macro requirements. done.
- Reorg the prefix doc section. done.
- Document requirement to flush class files from memory after recompiling them and other class use items - done.
- make console window command line a history field? - done
- Add a flush button to the console window per George Hovey request - done
Version 0.1.3 (Nov 30, 2009)
- Fix codepage output problem reported by George Hovey
- Add flush button to console per George request
- Change command entry field to HistoryTextField to allow recording and reentering commands
- fix bug - runbysearch was not correctly searching scriptpath in non preparse mode
Version 0.1.2 (Nov 20, 2009)
- fixes to support restart via Plugin Manager:
- 1) check if macro handler already registered before adding it (no way to unload handler at shutdown)
2) change macro handler to call runmacro via reflection (because classloader changes)
3) unload NetRexxC.jar in plugin stop method to allow reinit if restarted (may cause probs with NetRexxJe plugin) - document direct class execution feature and related flush requirements per George Hovey request
Version 0.1.1a,b,c (Nov 18, 2009)
- changes for distribution via SourceForge and jEdit Plugin Central:
- a) modify build file for jEdit developer type builds per Eric Berry
b) fix build.xml for Unix system builds per Eric
c) document NetRexxC.jar requirements in build.xml file and add build tracking to activity log
Version 0.1.1 (Nov 07, 2009)
- First bug fix version - if passes tests and no more error reports promote to second beta. Changes and bugs fixed:
- zero length scripts may cause a problem .
- PO window is flashing before out window.
- George Hovey #1 - Shortcuts panel shows "No Label" errors.
- George
Hovey #2 - If options panel too small in jEdit 4.2, the path fields
shrink to minimum size.
- Add documentation for prefix changes and startup scripts.
Version 0.1.0 (Oct 31, 2009)
- First beta version finally!
- Added a modified copy of Leo's NetRexx at Once guide to help doc.
- Added a pointer to Mike's V2 NetRexx language def PDF in help doc.
- Mod classloader and runmacro entry to load macro classes without a classpath search
- Rebuild classloader in flush entry to unload any classes from memory
- Add copybin to copy sample classes to macro lib
- Modify error scan to reflect original file name rather than prefixed file in error lines
- Flag warnings separately from errors to errorlist plugin
- Fixed loop in flush with preparse on and classpath change in options
- Added button to clear output windows and option to auto clear output on script start
- Added icons for all buttons to match sizes plus code to change start icon to stop icon when a script is running
- Fixed prob where not able to set prefix option on Linux due to missing file sep char in check
Version 0.0.15 (Oct 22, 2009)
- Change to allow window to kill scripts started from menu runcurrent option
- Allow command.nrx syntax on window command line
- Added custom classloader to allow starting class files from command line
- Change output text areas to auto scroll to end of text
- This should be the last alpha for version 1, next posted build will be 0.1.0 beta
Version 0.0.14 (Oct 18, 2009)
- Add dockable window for script console output/input (final major feature!?)
Version 0.0.13 (Oct 14, 2009)
- Trap parse error output and scan to flag errors in file buffers. (This version requires the ErrorList plugin.)
Version 0.0.12 (Oct 11, 2009)
- Add options for
user specified classpath and scriptpath.
- Describe Trace option and other new options in this help doc.
Version 0.0.11 (Oct 07, 2009)
- Change to use File.separator and File.pathSeparator chars
for unix support
Version 0.0.10 (Oct 07, 2009)
- Added function to run currently open script buffer
Version 0.0.9 (Oct 05, 2009)
- Added code to change classpath system variable to
include NetRexxC.jar before calling parse
this seems
to fix the problems
with the missing netrexx.lang classes under the standard jEdit classpath
Version 0.0.8 (Oct 04, 2009)
- added plugin options panel for trace, verbosity,
cache, flush, and preparse options
- added trace/notrace and verbosity parse options
for user selection
- added code and option to prefix scripts with the
jedit variables
Version 0.0.7 (Sept. 29, 2009)
- added new menu options for cache, flush, and preparse
- changed plugin class to extend EBPlugin and add
handleMessage interface for editbus msgs to detect script changes
- added code to preserve parse results for cache flag and to
locate and parse all files for preparse flag
- added code to open log viewer and show an error dialog box
for parse errors
Version 0.0.6 (Sept. 25, 2009)
- restored
code to set scriptPath property as Macros.macro.getPath does not work
in jEdit 4.2 and NetRexx scripts cannot call plugin code due to the
different class loader structure
- added check for NetRexxC.jar in classpath and show error
message panel if not found at startup
Version 0.0.5 (Sept. 19, 2009)
- removed pathing from jarfile access to allow
placing in base jar directory
- updated startup code to copy all .nrx files in
jar to macros\NetRexx directory
- removed code to set scriptPath property and doc
Macros.macro.getPath as the way to set the scriptPath variable
Version 0.0.4 (Sept. 18, 2009) (First released alpha
version)
- created this html help file and added it to the
NetRexxScript.jar file.
Version 0.0.3 (Sept. 2009)
- created a macro.handler class and code to register it.
- deactivated code in setup script that creates beanshell
hooks.
Version 0.0.2 (Sept. 2009)
- added netrexxscript.nrx setup script to scan directories
and build beanshell invocation "hook" scripts for all NetRexx scripts.
- added code to create NetRexx macro subdirectory and copy
the setup script from the plugin jar to the subdirectory.
Version 0.0.1 (Sept. 2009)
- First version working - required hand coding of
beanshell "hook" macros to start the NetRexx scripts with the same
name. Solved the missing classpath problem!