Recent

Author Topic: How to control colors in cmd.exe with write?  (Read 1973 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
How to control colors in cmd.exe with write?
« on: October 15, 2018, 09:53:17 am »
How can i control the colors of my programs output (write)? Escape sequences do not work. Is there an other way?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Thaddy

  • Hero Member
  • *****
  • Posts: 14169
  • Probably until I exterminate Putin.
Re: How to control colors in cmd.exe with write?
« Reply #1 on: October 15, 2018, 11:34:47 am »
escape sequences should work when you include the crt unit.
Specialize a type, not a var.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to control colors in cmd.exe with write?
« Reply #2 on: October 15, 2018, 11:55:06 am »
No, doesn't work. The sequences are printed: ←[91m
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: How to control colors in cmd.exe with write?
« Reply #3 on: October 15, 2018, 12:09:22 pm »
In Windows 10, you need to enable processing of ansi escape control sequences programmatically by yourself. See this link how : https://github.com/php/php-src/pull/2103

EDIT : Call SetConsoleMode with flag ENABLE_VIRTUAL_TERMINAL_PROCESSING : https://docs.microsoft.com/en-us/windows/console/setconsolemode
« Last Edit: October 15, 2018, 12:12:51 pm by Cyrax »

 

TinyPortal © 2005-2018