Color ascii sequences in stdout are not understood by Far3 Topic is solved

You have encountered a problem using Far macros? Here you can get help.
Post Reply
sh0375
Posts: 5
Joined: Mon 05 Jan, 2015 23:16
Has thanked: 1 time

Color ascii sequences in stdout are not understood by Far3

Post by sh0375 »

Hello,

Python script is sending to stdout ascii color sequences.
If I launch this script under ConEmu, then I see colored output.
If launch under Far3, then it prints all characters of ascii sequesce: ←[92m

How to tune Far3 so that it would print colored output of python script?
User avatar
DrKnS
Posts: 6114
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 12 times
Been thanked: 426 times

Color ascii sequences in stdout are not understood by Far3

Post by DrKnS »

Escape sequences are not enabled by default neither in cmd nor in python interpreter.
Conemu intercepts the output using some black magic and processes everything itself.

You can enable escape sequences from within your script with something like:

  1. import ctypes;
  2.  
  3.  
  4.  
  5. STD_OUTPUT_HANDLE = -11
  6.  
  7. ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
  8.  
  9.  
  10.  
  11. kernel32 = ctypes.WinDLL('kernel32');
  12.  
  13. hStdOut = kernel32.GetStdHandle(STD_OUTPUT_HANDLE);
  14.  
  15. mode = ctypes.c_ulong();
  16.  
  17. kernel32.GetConsoleMode(hStdOut, ctypes.byref(mode));
  18.  
  19. mode.value |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
  20.  
  21. kernel32.SetConsoleMode(hStdOut, mode)
sh0375
Posts: 5
Joined: Mon 05 Jan, 2015 23:16
Has thanked: 1 time

Color ascii sequences in stdout are not understood by Far3

Post by sh0375 »

DrKnS wrote: Mon 25 Jan, 2021 19:41 Escape sequences are not enabled by default neither in cmd nor in python interpreter.
Conemu intercepts the output using some black magic and processes everything itself.

You can enable escape sequences from within your script with something like:

Code: [Select all] [Expand/Collapse]
DrKnS, code example in your answer is empty.
python uses colorama and calls init(), so initialization is done already.
sh0375
Posts: 5
Joined: Mon 05 Jan, 2015 23:16
Has thanked: 1 time

Color ascii sequences in stdout are not understood by Far3

Post by sh0375 »

DrKnS, Thank you!
I found out that init was not called actually
Post Reply

Return to “Support and Troubleshooting”