Skip to content

Added some notes about Windows and colours. #2062

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

Closed
wants to merge 7 commits into from
Closed

Added some notes about Windows and colours. #2062

wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 25, 2012

Refs: symfony/symfony#6478

The motivation here is to stop repeated issues being reported to the Console tracker for this issue and provide a documented solution to the display of colours under Windows.

@@ -20,6 +20,12 @@ You can install the component in many different ways:
* Use the official Git repository (https://github.com/symfony/Console);
* :doc:`Install it via Composer</components/using_components>` (``symfony/console`` on `Packagist`_).

..note::

Windows does not support ANSI colours by default so you will experience problems
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, there is no "problems" when the console does not support colors. Colors are just disabled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the wording can be better, but they are disabled because Windows will not display ANSI colours unless Windows has an ANSI driver installed. It's not a problem for Console as it detects this, but anything you might invoke that does emit ANSI sequences is going to cause ANSI characters to be displayed. I think there needs to be some reference to this somewhere because it's a very common problem.

@ghost
Copy link
Author

ghost commented Dec 25, 2012

Reworded it taking comments into consideration.


Windows does not support ANSI colours by default so the Console Component detects and
disables colours where windows does not have support. However, if your console commands
invoke other scripts which emit ANSI colour sequences, they will be shown as raw escape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they "might" be show.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ANSICON is not installed, they will be shown for sure. E.g. if you have phpunit.xml.dist set to emit colours from the console, you will get raw ANSI sequences under Windows from a Console command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPUnit has nothing to do with the Console component. It does not use it

@ghost
Copy link
Author

ghost commented Dec 26, 2012

Reworded again taking into account feedback.


Windows does not support ANSI colors by default so the Console Component detects and
disables colors where Windows does not have support. However, if your console command
invokes other scripts which emit ANSI color sequences, they will be shown as raw escape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, should be "might". The Symfony console always behaves correctly. PHPUnit does, but we don't care about that; I mean, someone should probably report that to PHPUnit, but it has nothing to do with Symfony. I would even say that this sentence should be removed altogether.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an attempt to cover all bases. If your console commands running other php scripts that use emit colours and Windows is not setup for ANSI, you will get ugly ANSI escape characters displayed with 100% certainty. I use Windows as my development environment so I'm very familiar with this phenomenon:. There is no might, it's 100% sure you will get ugly characters displayed. The point of this note is make it clear that while the Console command has control over what it emits and can detect whether colours are available, it has no control over vendor PHP scripts you might run in the console and makes it crystal clear that Windows must be configured to use ANSI.

Without ANSICON, if you force --ansi for the Console, it will also display garbage ANSI escape sequences. It's up to you - this is about clearly documenting a phenomenon so you can refer to it when you inevitably get github issues being opened by those who do not know about the problem.

@weaverryan
Copy link
Member

Hi @Drak!

I've patched your commit into the 2.0 branch at sha: e2165a0 with no changes (the PR had somehow inherited some other recently-merged commits - probably a GH issue, hence the patch instead of a merge).

Thanks!

@weaverryan weaverryan closed this Dec 26, 2012
weaverryan added a commit that referenced this pull request Dec 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants