Closed neeasade closed 4 years ago
This will be fun to solve.
I use the VT100/ANSI escape sequence method as it allows simple storage and printing of both the ASCII and information in a dynamic way. I really can't think of a way to implement the same behavior without the use of cursor movement.
ansi-term
work?Is there a list of supported escape sequences?
I can't find a definitive list. I think all the supported sequences are handled by ansi-color-for-comint-mode
(shell-mode derives from comint-mode). The regex it uses to look for supported esc codes can be found here [1]. Unsupported esc sequences that are not swallowed as SGR show in the output (eg [2], where I attempt to set window title). I'm actually a little confused as when I run through all the esc codes used in log
, they appear to be supported/not print the ^[
on the next line like my example. I wonder if the problem is the [%sA
code (move the cursor up, in get_ascii
) is just ignored.
Does ansi-term work?
I had assumed it would, but using emacs -Q
(vanilla/no config) on emacs 26.1 looks really :S [3]
[1] https://github.com/tomtt/tomtt_emacslisp/blob/63a7698a7e086aa0256e8ef4c5baf6327688cae9/ansi-color.el#L155 [2] https://0x0.st/zYpL.png [3] https://0x0.st/zYpQ.png
edit: confirmed that ansi-color-for-comint-mode does handle the lateral cursor moving escape codes used in log
by with M-x ansi-color-mode-for-comint-mode-off
was looking at very out of date ansi-color above, my bad. This is the current library and looks cleaner as well: https://github.com/emacs-mirror/emacs/blob/d0e2a341dd9a9a365fd311748df024ecb25b70ec/lisp/ansi-color.el#L153
I've got a patch that matches current behavior here [1] for this (I just make get_ascii special and loop over it, and have a function for padding with spaces) -- my implementation is pretty slow though (~4 times slower than original pfetch on my machine).
[1] https://github.com/neeasade/pfetch/commit/526087e4a5f9f5084d608439a1ebdef104eb5b31
edit: I commited again on that fork reducing subshell usage, now the speed is very comparable (from 0m0.231s to 0m0.285s in the 'real' section of time
).
Yeah, I've given up on this. I don't believe it's something I need to fix. If \r
isn't supported....
Hello,
emacs shell doesn't respect escape codes that manipulate the cursor position to different lines (it tries to be more shell than terminal), and as a result pfetch output looks like: https://0x0.st/zYpX.png (the same output if you
pfetch >./test.txt
) -- I have the same issue with neofetch. This is a feature request to investigate a simpler output resulting in line-by-line printing.Thanks, neeasade
edit: A humorous workaround: