Hi, Rainer
Sorry for the confusion. What I am talking about is not multiple-line
input support. Jaql shell already supports it. I am talking about
multiple-line input support in command history. The basic idea is as
this:
1 The following multiple-line input is fed in jaql shell:
jaql> $employees = [
{name: "Jon Doe", income: 20000, mgr: false},
{name: "Vince Wayne", income: 32500, mgr: false},
{name: "Jane Dean", income: 72000, mgr: true},
{name: "Alex Smith", income: 25000, mgr: false}
];
2. When UP arrow key is pressed, the current jaql shell will show
only
one line of the previous input:
jaql> $employees = [
{name: "Jon Doe", income: 20000, mgr: false},
{name: "Vince Wayne", income: 32500, mgr: false},
{name: "Jane Dean", income: 72000, mgr: true},
{name: "Alex Smith", income: 25000, mgr: false}
];
jaql> ];
Instead of one line of the previous input, we want all the lines of
the previous
input.
The java code take inputs from System.in and echoes the input. If &
is
inputted, the program will exit. If it is launched by issuing "java
Test" in windows command line console. And two inputs are fed. One
input is one line. The other input is longer than the windows console
width. So it is wrapped.
D:\>java Test
=>abc
abc
=>1111111111111111111111111111111111111111111111111111111111
22222222222222222
111111111111111111111111111111111111111111111111111111111122
222222222222222
=>
At this moment, if UP arrow key is pressed, the console is like this:
D:\>java Test
=>abc
abc
=>1111111111111111111111111111111111111111111111111111111111
22222222222222222
111111111111111111111111111111111111111111111111111111111122
222222222222222
=>1111111111111111111111111111111111111111111111111111111111
22222222222222222
If UP arrow key is pressed again, the console is like this:
D:\>java Test
=>abc
abc
=>1111111111111111111111111111111111111111111111111111111111
22222222222222222
111111111111111111111111111111111111111111111111111111111122
222222222222222
=>abc
You can see that the two-line history entry is replaced by the one-
lie
history entry. But if the JVM is launched by a shell script in
Cygwin.
For this little java program, the command history does not work. And
I
have tried the solution provided in
http://groovy.codehaus.org/Groovy+Shell. It also does not solve this
problem.
By multiline input, you mean to input multiple jaql expressions in
one
line. Among the two variants, I choose VARIANT 2. jaql shell already
supports this. For partial commands, I agree with you. The first
expression
should not be executed unitl the second expression is finished.
jaql> [1,2];[3,
4];
[UP]jaql>[1,2];[3,4]
I have done some experiments on top of jline command history
facility. If the
total length of the multiple line of one input is not longer than
the console
width, my approach works. Here is one example.
jaql>[1,
2,
3];
[UP]
jaql>[1, 2, 3]
My original post gives an example where this approach does not work
if
the total length of the multiple lines of one input is longer than
the
console width.