# Not getting expected colors with ansi\_format/3 on Windows

**URL:** <https://swi-prolog.discourse.group/t/not-getting-expected-colors-with-ansi-format-3-on-windows/3431>\
**Category:** Help!\
**Created:** [December 28, 2020, 9:41am UTC](https://swi-prolog.discourse.group/t/not-getting-expected-colors-with-ansi-format-3-on-windows/3431 "2020-12-28T09:41:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JCR](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@JCR](https://swi-prolog.discourse.group/u/JCR)\
**Post date:** [December 28, 2020, 9:41am UTC](https://swi-prolog.discourse.group/t/not-getting-expected-colors-with-ansi-format-3-on-windows/3431/1 "2020-12-28T09:41:16Z")

</div>

With SWI-Prolog (threaded, 64 bits, version 8.2.3) in the terminal on Microsoft Windows [Version 10.0.17134.1902] this:

`?-ansi_format([fg(1,249, 1)],'~w',['green text']), nl, ansi_format([fg(200,1, 1)],'~w',['red text']).`

just results in `green text` and `red text` both printed in blue. Other examples also generate unexpected output. This works on MacOS though.

Any suggestions?

Kind regards, JCR

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [December 28, 2020, 11:23am UTC](https://swi-prolog.discourse.group/t/not-getting-expected-colors-with-ansi-format-3-on-windows/3431/2 "2020-12-28T11:23:48Z")

</div>

The swipl-win.exe console doesn’t support 24-bit direct color. Seems it neither supports the 8-bit color model, so you only have the classical 16 ANSI colors.

To get more, some hacking is required in `src/win32/console/console.c` 🙂

---

<div class="post-metadata">

**Author:** ![JCR](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@JCR](https://swi-prolog.discourse.group/u/JCR)\
**Post date:** [December 28, 2020, 3:33pm UTC](https://swi-prolog.discourse.group/t/not-getting-expected-colors-with-ansi-format-3-on-windows/3431/3 "2020-12-28T15:33:50Z")

</div>

Thanks Jan!

This works as expected:  
`?- ansi_format([fg(yellow)], '~w', ['bananas']), nl, ansi_format([fg(blue)], '~w', ['blue berries']).`

Looking at the code in ansi\_term.pl i see that the color options in this case seem to be black, red, green, yellow, blue, magenta, cyan and white. Or are there additional colors?

Cheers/JCR

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [December 28, 2020, 4:32pm UTC](https://swi-prolog.discourse.group/t/not-getting-expected-colors-with-ansi-format-3-on-windows/3431/4 "2020-12-28T16:32:44Z")

</div>

> [@JCR](#):
>
> Or are there additional colors?

Nope. These are the good old 16 color ansi palette (8 colors in normal and _high intensity_ mode). Since then there is the 256 model and the direct color model, but neither is implemented in the swipl-win.exe console. It shouldn’t be rocket science to do so …
