Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/core/console/console.c
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

windows console only supports two-digit hexadecimal for FG and BG color. meaning the color is still limited to a set of colors made by microsoft/CMD
CMD Color Command

And powershell is restrictive but this would be something to consider since powershell does offer something better

[Enum]::GetValues([ConsoleColor])

Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,17 @@ LUA_METHOD(console, writecolor) {
return 0;
}

LUA_METHOD(console, writelncolor) {
int prev = color(L, 0, TRUE);
CONSOLE_SCREEN_BUFFER_INFO info;

color(L, 1, TRUE); //-- set color
con_write(L, File_writeln, 2);
GetConsoleScreenBufferInfo(std, &info);
SetConsoleTextAttribute(std, ((info.wAttributes & 0xFF) >> 4) * 16 + colors_values[prev]);
return 0;
}

LUA_METHOD(console, writeln) {
if (lua_gettop(L) == 0)
lua_pushstring(L, "\n");
Expand Down Expand Up @@ -515,6 +526,7 @@ MODULE_FUNCTIONS(console)
METHOD(console, write)
METHOD(console, writeln)
METHOD(console, writecolor)
METHOD(console, writelncolor)
METHOD(console, inverse)
METHOD(console, reset)
METHOD(console, locate)
Expand Down