Skip to content
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

Disable animations when terminal incapable of displaying #540

Open
zenspider opened this issue Jan 6, 2017 · 3 comments
Open

Disable animations when terminal incapable of displaying #540

zenspider opened this issue Jan 6, 2017 · 3 comments

Comments

@zenspider
Copy link
Contributor

@zenspider zenspider commented Jan 6, 2017

Checking .tty? isn't enough to determine whether you should do fancier terminal output and can result in output looking like:

�[1GRunning flog: |�[1GRunning flog: /�[1GRunning flog: -�[1GRunning flog: \�[1GRunning flog: |�[1G
Running flog: /�[1GRunning flog: -�[1GRunning flog: \�[1GRunning flog: |�[1GRunning flog: /�[1G
Running flog: -�[1GRunning flog: \�[1GRunning flog: |�[1GRunning flog: /�[1GRunning flog: -�[1G
Running flog: \�[1GRunning flog: Done!

In minitest, I use:

klass = ENV["TERM"] =~ /^xterm|-256color$/ ? PrideLOL : PrideIO
@pbrisbin
Copy link
Contributor

@pbrisbin pbrisbin commented Jan 9, 2017

I'm not sure the most robust way to do this, but just wanted to note that that regex is too restrictive IMO. Lots of terminals which are neither xterm nor 256color-capable should still be able to show our spinner and limited coloring. The most notable would be screen.

It might be more valuable to avoid certain "known-dumb" TERMs (like linux). @zenspider can you tell me what your TERM was when you uncovered this?

I think @wfleming mentioned matching tools like ls and grep which have an auto|always|off argument to their --color options. I'm 👍 on that, in addition to matching their implementation of "auto".

@zenspider
Copy link
Contributor Author

@zenspider zenspider commented Jan 9, 2017

In emacs' shell, TERM=dumb.

I have yet to have anyone complain about my choice for minitest's pride being too restrictive. In general, I much prefer whitelisting to blacklisting so I know what I am getting, but I'm fine with whatever as long as I don't have to remember a flag every time.

@zenspider
Copy link
Contributor Author

@zenspider zenspider commented Jan 9, 2017

Oh, and the "right" way of doing this would be to test capability via termcap. In the case of screen:

screen|VT 100/ANSI X3.64 virtual terminal:\
[...lots of crap]...:tc=ecma+color:

ETA:

1085 % infocmp -l1 dumb | grep "^\tcolor"
1086 % infocmp -l1 screen | grep "^\tcolor"
	colors#8,
1087 % infocmp -l1 xterm-256color | grep "^\tcolor"
	colors#256,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.