Clion 项目使用dbg-macro控制台输出ANSI转义,输出颜色文本。

2023-12-29 06:30:31

#Clion如何输出ANSI转义

首先源于,引入dbg-macro后,运行发现控制台全部是

C:\Users\WuXiangGuJun\CodeSpace\ClionCodeProjects\Tina\cmake-build-debug\tests\tests.exe
?[02m[..a\tests\src\main.cpp:16 (main)] ?[0m?[36mmessage?[0m = ?[01m"hello"?[0m (?[32mstd::string?[0m)
?[02m[..a\tests\src\main.cpp:19 (main)] ?[0m?[36m3 * a?[0m = ?[01m6?[0m (?[32mint32_t?[0m)
?[02m[..a\tests\src\main.cpp:22 (main)] ?[0m?[36mnumbers?[0m = ?[01m{7, 13, 42}?[0m (?[32mstd::vector<int32_t>?[0m)
?[02m[..a\tests\src\main.cpp:24 (main)] ?[0m?[01mthis line is executed?[0m
?[02m[..a\tests\src\main.cpp:7 (factorial)] ?[0m?[36mn <= 1?[0m = ?[01mfalse?[0m (?[32mbool?[0m)
?[02m[..a\tests\src\main.cpp:7 (factorial)] ?[0m?[36mn <= 1?[0m = ?[01mfalse?[0m (?[32mbool?[0m)
?[02m[..a\tests\src\main.cpp:7 (factorial)] ?[0m?[36mn <= 1?[0m = ?[01mfalse?[0m (?[32mbool?[0m)
?[02m[..a\tests\src\main.cpp:7 (factorial)] ?[0m?[36mn <= 1?[0m = ?[01mtrue?[0m (?[32mbool?[0m)
?[02m[..a\tests\src\main.cpp:8 (factorial)] ?[0m?[36m1?[0m = ?[01m1?[0m (?[32mint32_t?[0m)
?[02m[..a\tests\src\main.cpp:10 (factorial)] ?[0m?[36mn * factorial(n - 1)?[0m = ?[01m2?[0m (?[32mint32_t?[0m)
?[02m[..a\tests\src\main.cpp:10 (factorial)] ?[0m?[36mn * factorial(n - 1)?[0m = ?[01m6?[0m (?[32mint32_t?[0m)
?[02m[..a\tests\src\main.cpp:10 (factorial)] ?[0m?[36mn * factorial(n - 1)?[0m = ?[01m24?[0m (?[32mint32_t?[0m)

进程已结束,退出代码为 0

这些字符,没有颜色。于是经过修改终端为PowerShell等其他方式发现还是不行,才发现只需要勾选在输出控制台模拟终端既可。
在这里插入图片描述

文章来源:https://blog.csdn.net/qq_42282949/article/details/135281491
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。