JShell: Request for ideas: Editing multiline snippets, adding lines
Jan Lahoda
jan.lahoda at oracle.com
Thu Dec 6 15:20:41 UTC 2018
On 6.12.2018 06:08, Michel Trudeau wrote:
> What about Ctrl-Enter ?
Actually, Alt-Enter turnes out to work on Linux (KDE Konsole) as a
shortcut to add a new line. The main issue here is that we can only use
shortcuts for which the terminal will produce an escape sequence, and
IIRC on Mac this was very troublesome (the shortcuts that produced
escape sequences and that we could use were severely limited). So the
Alt-Enter may not work on Mac (I believe we wanted to have the "add
import" bound to Alt-Enter and it was not possible on Mac). If someone
with Mac could try with this patch:
---
diff -r 183e274baccd
src/jdk.internal.le/share/classes/jdk/internal/org/jline/keymap/BindingReader.java
---
a/src/jdk.internal.le/share/classes/jdk/internal/org/jline/keymap/BindingReader.java
Thu Dec 06 15:05:31 2018 +0100
+++
b/src/jdk.internal.le/share/classes/jdk/internal/org/jline/keymap/BindingReader.java
Thu Dec 06 16:00:04 2018 +0100
@@ -11,7 +11,10 @@
import java.io.IOError;
import java.io.IOException;
import java.util.ArrayDeque;
+import java.util.Arrays;
import java.util.Deque;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import jdk.internal.org.jline.reader.EndOfFileException;
import jdk.internal.org.jline.utils.ClosedException;
@@ -112,6 +115,12 @@
return null;
}
opBuffer.appendCodePoint(c);
+ System.err.print("opBuffer='");
+ for (char cc : opBuffer.toString().toCharArray()) {
+ System.err.print(Integer.toHexString(cc));
+ System.err.print(" ");
+ }
+ System.err.println("'");
hasRead = true;
}
return null;
---
When a key or a combination of keys is pressed, it should print output like:
opBuffer='1b d '
(this is for Alt-Enter for me). If there's some useful combination on
Mac that prints something distinguishable, we can use that as a shortcut.
Thanks,
Jan
>
> On Dec 5, 2018, at 8:46 PM, Robert Field <robert.field at oracle.com> wrote:
>
> A fix about to go back to JDK 12 (see JLine 3 review discussion) provides a significant improvement when editing multiline snippets — they are treated as an integral unit — with WYSIWYG-ish interaction.
>
> There is however one limitation: Since <return> has its legacy action of accepting the input, there is no way with line editing to add a line within a multiline snippet.
>
> It would seem that a different input is needed to add a line (unless I’m missing something). Suggestions for that keystroke are herein solicited.
>
> Thanks,
> Robert
>
>
More information about the kulla-dev
mailing list