jline / jline2

Jline 2.x
http://jline.github.com/jline2/
Other
712 stars 183 forks source link

IntelliJ Console doesn't seem to be supported on Windows. Pressing enter does not submit the value #185

Open yeison opened 9 years ago

yeison commented 9 years ago

If I run a ConsoleReader in IntelliJ, the input doesn't seem to end on new-line.

yeison commented 9 years ago

The same problem in Eclipse - note I believe it's only a problem in Windows.

yeison commented 9 years ago

Seem to have narrowed part of the problem to line 156 in WindowsTerminal.java - It just continues in an infinite loop even though I enter some input

gnodet commented 9 years ago

You could try forcing the use of the UnsupportedTerminal instead, or setting jline.WindowsTerminal.directConsole=false as a system property.

We may be able to improve the terminal factory detection code. If you want to give it a try, feel free to investigate.

westonal commented 9 years ago

I used this to force unsupported:

jline.TerminalFactory.registerFlavor(jline.TerminalFactory.Flavor.WINDOWS, UnsupportedTerminal.class);

And input works but completion does not. Is that expected behavior of Unsupported terminal?

Krasnyanskiy commented 9 years ago

The same for Mac OS. See my opened issue. Autocompletion does not work in IDEA terminal when you debugging the code.

westonal commented 9 years ago

@gnodet I've investigated and I understand why the same issue occurs on windows, the WindowsTerminal class is attempting to hook in to the command window with various dll calls that are obviously unsuitable for the kind of terminal IDEA is using. I imagine the issue is the same kind of problem in any other OS.

Detection would be nice, but it is not going to solve this issue, that you can't debug in IDEA.

I'm going to try and contact people who write IDEA and also look at the source for it here: https://github.com/JetBrains/intellij-community to try to work out what kind of terminal and how we can hook into it with a different Terminal implementation.

Vity01 commented 6 years ago

Any progress on this?

gnodet commented 6 years ago

THere's no way to have completion in the Intellij Console, mainly because Intellij will not transmet any character before hitting the key. Also, there's no real way to detect that the process is running in the Intellij Console using environment variables for example.

Workarounds include:

sbernard31 commented 3 years ago

If you are using picocli with jline2.

You can delegate the heuristic to picocli which seems better than the jline2 heuristic.

The code can looks like :

        // JLine 2 does not detect some terminal as not ANSI compatible, like Eclipse Console
        // see : https://github.com/jline/jline2/issues/185
        // So use picocli heuristic instead :
        if (!Help.Ansi.AUTO.enabled() && //
                Configuration.getString(TerminalFactory.JLINE_TERMINAL, TerminalFactory.AUTO).toLowerCase()
                        .equals(TerminalFactory.AUTO)) {
            TerminalFactory.configure(Type.NONE);
        }