On Wed, 26 Mar 2025 07:54:48 GMT, Jan Lahoda <[email protected]> wrote:
> The `java.io.Console` has several backends: a simple on in `java.base`, a
> more convenient one in `jdk.internal.le` (with line-reading based on JLine)
> and one for JShell.
>
> The backend based on JLine is proving to be a somewhat problematic - JLine is
> very powerful, possibly too powerful and complex for the simple task of
> editing a line with no completion, no history, no variables, no commands,
> etc. As a consequence, there are inevitable sharp edges in this backend.
>
> The idea in this PR is to replace the use of JLine in the `jdk.internal.le`
> backend with a simple escape code interpreter, that only handles a handful of
> keys/codes (left/right arrow, home, end, delete, backspace, enter), and
> ignores the rest. The goal is to have something simple with less surprising
> behavior.
I am not very familiar with those escape sequences/modes in the native console,
but looks good to me. Sharing the common part as the base looks reasonable.
src/jdk.internal.le/share/classes/jdk/internal/console/SimpleConsoleReader.java
line 69:
> 67: case 4: break READ; //EOF/Ctrl-D
> 68: case 127:
> 69: //backspace:
Is it `delete`?
src/jdk.internal.le/share/classes/jdk/internal/console/SimpleConsoleReader.java
line 198:
> 196:
> 197: if (it.hasNext()) {
> 198: out.append("\n\r");
I understand this is a simple console, but do we want to CR/LF/CRLF based on
the platform?
-------------
PR Review: https://git.openjdk.org/jdk/pull/24242#pullrequestreview-2723057740
PR Review Comment: https://git.openjdk.org/jdk/pull/24242#discussion_r2017409982
PR Review Comment: https://git.openjdk.org/jdk/pull/24242#discussion_r2017488129