简体   繁体   中英

How to get color in Lua console/terminal

Is there a simple way to have the generic Lua console/terminal in windows display colors?

I am basically running the lua53.exe terminal in windows and want to display things with colors.

Mainly in my lua code, I'd like to display debug and error messages in a different color then the default text color. My default color is white in the lua terminal and I would like to output error messages that I print in red and debug in yellow.

I don't want to use other external applications/tools/etc to handle this. I've seen some links for using LOVE to create its own console to get color; and I've seen several ANSI code blocks that don't work natively in windows.

You cannot use colored output on Windows console cmd.exe. It's not Lua dependent.

Starting with Windows 10, you can use ANSI colors escape sequences on cmd.exe or with the Windows Terminal application (available on the Windows Store).

Another option is to use a Lua binary Module that deals with the Windows API to use colored output on the console.

如果您在 Windows 上,请使用os.execute('color')作为颜色命令阅读颜色命令 Microsoft docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM