-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
REPL doesn't interpret carriage return #1677
Comments
Seems you're right - this is a bug. I'm not sure what's causing it, though. The message we send to the nREPL server seems correct to me:
|
@dpsutton Maybe you'd like to investigate another REPL bug? :-) |
This appears to be a bug in the
in nrepl-client.el. I'm gonna go learn about platform specific newlines as I've never really understood the difference between \r and \r\n, etc. If i remove that line, i'm getting |
I guess I don't know if a
The following works, but I'm not sure if its hacky, nor if its correct. I'll play with this today and see what I can get
|
Guess there's not much more we can do about this now, so I'll close this. Thanks for fixing the handling for |
A CARRIAGE RETURN character moves the head of the teletype printer (the carriage) to the beginning of the line, without scrolling the paper (this is done by the LINE FEED "\n") In a contemporary terminal emulator this translates to moving the cursor to the beginning of the current line. Any subsequent output then overwrites what was already on that line. This is how terminal progress bars are implemented. The existing implementation incorrectly treated "\r" as "\n", thus inserting a newline, instead of moving to the beginning of the current line. Instead iterate over the output and deal with "\r" and "\n" the way terminals do, "\r" (ASCII 13) moves to the beginning of the line, "\n" (ASCII 10) moves to the beginning of the next line. Any output overwrites output on the same line after the cursor position. Sample code: ``` (println "aaaa\rbb\ncccc\rdd") ;; Outputs: ;; bbaa ;; ddcc (dotimes [i 20] (print "\r[" (inc i) "]") (flush) (Thread/sleep 500)) ;; prints a counter in place ``` Feedback welcome as I'm not sure of the performance impact of dealing with each character individually. Also not sure what the effect is of propertizing and running cider-repl-preoutput-hook per character. Fixes clojure-emacs#1677 (which was closed but not actually implemented, only worked around)
I entered
(println "foo\rbar")
in the Cider REPL, hoping to seeInstead I saw
This breaks progress bars among other things, as reported here: http://stackoverflow.com/questions/34649151/progress-indicator-bar-auto-changed-line-in-cider-nrepl-buffer/34651898#34651898.
For comparison,
(display "foo\rbar\n")
displaysbar
in the REPL started byrun-guile
.Environment & Version information
CIDER version information
Lein/Boot version
Leiningen 2.6.1 on Java 1.8.0_60 OpenJDK 64-Bit Server VM
Emacs version
GNU Emacs 24.5.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.28) of 2015-09-25 on machine
Operating system
NixOS 15.09
The text was updated successfully, but these errors were encountered: