User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b3pre) Gecko/2008020507 Firefox/3.0b3pre Build Identifier: This is the first version of a patch to improve the Rhino shell by adding line editing, history and completion. It relies on the JLine library to work but the dependency is optional at runtime. A bit more about the implementation itself. Instead of relying only on reflection, which worked but led to a rather ugly code, I've added a new file that includes all the JLine code. The classes contained in that file are only loaded if JLine is found in the classpath. The drawback is that JLine is required for compilation but I don't think it's a big problem, I've just modified a bit the Ant scripts. On the plus side it allowed me to implement a custom completor (the interface that handles completion in JLine) and add completion for all Rhino shell functions (load, print, spawn, ...). Let me know how it goes... Reproducible: Always
Created attachment 303815 [details] [diff] [review] Patch to rely on JLine for a better shell A separate file must be added in addition to this patch.
I finally got a chance to try this out. Works great from the command line on Unix and Windows. Doesn't work so well from the Eclipse console: on Unix the entered text is printed out when enter is pressed, so that the text is effectively repeated. And on Windows the shell terminates before accepting any input. Perhaps the thing to do is just provide a command-line switch to disable this that could be used from within Eclipse. It'd be better to detect if you're running in an Eclipse console, but I don't know if that's possible. Ideas?
Assignee: nobody → norrisboyd
Actually I was seeing it as an opt-in feature, if JLine is in your classpath then it uses it, otherwise just don't use Jline. I'd be surprised if folks who run this into an Eclipse console were using JLine already. Or you think that an additional option is necessary?
Well, the problem is that if you load all the source into Eclipse then you need JLine to compile. I suppose another option is to exclude JLine from the source list, or to make it so ShellLine will compile without JLine. I'll look at the latter on my flight Monday if I have a chance.
I changed ShellLine to just use reflection and I've now committed the changes. Thanks for contributing this; it makes the console much more pleasant to use! If I get more time to play with this I may explore completion for object/property chains starting with global variables (e.g. java.lang.Str^I)
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.