powered by Slim Framework
Follow @NesbittBrian rss

ANSI colour support in Windows for the Play! Framework 2.0 preview

Sep 9, 2011

This is a follow up to Adding initial Windows support for the Play! Framework 2.0 preview... you may want to go and read that first.

As pointed out today the Windows version outputs various ANSI color codes rather than changing the color of the text. There aren't many so they don't really get in the way, we just don't get color.

For example when creating a new project in a directory that contains files you should get an error message in red:

The directory is not empty, cannot create a new application here.

Well on windows at the moment you get:

[31mThe directory is not empty, cannot create a new application here.[0m

The fix comes via Ansicon, a clever C app that "provides ANSI escape sequence recognition for Windows console programs (both 32- (x86) and 64-bit (x64)). It is basically the Windows equivalent of ANSI.SYS".

Here we go with the instructions. First, you are going to have to re-download the play.bat file as I have pushed an update to integrate Ansicon. I augmented the batch file with a registry check to see which OS bitness is installed which is needed later.

Download play.bat and put it in c:\play-2.0

Now for Ansicon. They provide seperate binaries for 32 and 64 bit.

Download playAnsicon.zip and unzip it to c:\play-2.0. This should give you the following directories c:\play-2.0\ansicon\x86 and c:\play-2.0\ansicon\x64 each with some dll's and their respective ansicon.exe.

That should be it. Now when you run the play.bat script you should see some glorious colour!

Someone on the playframework group mentioned that the same issue occurs with Jenkins. This fix should be able to work with it as well. Basically I found you can ansicon 2 ways. If you run ansicon.exe -p from the cmd prompt, then any commands after that should interpret ANSI colour. I use console2 as a Windows console replacement, mostly for the tabs, and I found this initial method didn't work because of the way cmd gets wrapped by the parent application. The other way you can run ansicon is by piping output to it and have it echo it while interpreting ANSI escape commands along the way, myFunCommandThatDoesSomething | ansicon.exe -t.

I hope at some point this can get pulled into the master trunk for us Windows folk.

Adding initial Windows support for the Play! Framework 2.0 preview  Home Tricks for using the cobertura module with the Play Framework  
blog comments powered by Disqus