New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emacs ANSI support #235
Comments
@fommil We need to keep track of this issue so that emacs-sbt-mode does not break when sbt and scala start using JLine3 |
Here are the changes
If the system is using termcap, the values are
(some versions have |
Starting with emacs 26.1 one can define the See https://github.com/emacs-mirror/emacs/blob/master/lisp/comint.el#L462 |
The code to look at would be in I'm not sure at this point which jline |
TL;DR of below is that emacs is like a dump terminal (no terminal emulation) that still can interpret some ANSI control codes, mostly the colors. The long version: In emacs all console interaction happens with the help of So to answer your question, no, there is no pty or even actual terminal emulation. Comint-mode just redirects the process output to the given editor buffer. However as emacs does support colors, there is support for interpreting some ANSI control sequences and turning them into emacs colors. Also some in-line movement may be supported, but things like movement between lines or relative to terminal screen is not supported and are not applicable. Furthermore, while the processes output comes to the end of the buffer, the user can move the cursor freely within the buffer. As said, input to the process is sent with a special command that sends either the input given to it as an argument, or alternatively it picks up the input from the cursor location (which again, can be anywhere) using special rules (such as sending everything on the line of the cursor, except maybe a prompt that is detected with a separate regexp). The use case for supporting emacs in JLine is that developers using emacs routinely run commands from within emacs. A trivial example is running a compilation command and getting back the compilation errors, which emacs can detect from the buffer using regular expressions and turn into links to the respective files. An other example is support for special programs, such as the scala REPL, which is supported by the |
The most important thing though is that while emacs |
Here's an experimental branch 1b10052. |
Added a few comments to the branch |
@gnodet awesome, thanks for looking into this. Do you think a backport to jline2 would be feasible? The entire scala tooling ecosystem is using jline2 and it would be years before they can migrate to jline3. They are also very unlikely to make patch releases to old versions of the core tools to facilitate this change, so we will have to document how users can use a binary-compatible jline2 locally. |
@gnodet Is your target for JLine3 Java8 or Java9? |
Java 8 for now. |
The https://github.com/jline/jline3/compare/issue-235-ansi branch contains a JDK 8 compatible fix I think. |
The branch looks good as far as ANSI. What about echo? Reading the code I gather that it should be disabled by default? |
Yes, there should be no echo for dumb terminals. |
Emacs comint announces it self as DUMP terminal, but it still support ANSI colors.
JLine Terminal should detect emacs based on the
INSIDE_EMACS
environment variable and turn on ANSI support for it.I could make a PR and test it if somebody gave me a few pointers where this would be best implemented in JLine.
The text was updated successfully, but these errors were encountered: