Used C preprocessor to define a macro depending on the OS used.
If you want true color support I can help you do it.
Do preprocessor commands work in newer versions of LuaJIT? My machines have 2.1b3 and it throws errors for them. Seems like that's the newest version?
This works on Linux and Mac at least:
if ffi then
ffi.cdef[[
int isatty(int); // Unix
int _isatty(int); // Windows
void free(void *ptr);
char *readline(const char *);
int add_history(const char *);
]]
local function get_func_or_nil(sym)
local success, func = pcall(function() return ffi.C[sym] end)
return success and func or nil
end
local isatty = get_func_or_nil("_isatty") or get_func_or_nil("isatty")
stdin_isatty = isatty(0)
stdout_isatty = isatty(1)
end
I'll push it to a branch if you are willing to test it. (https://github.com/slembcke/debugger.lua/tree/patch-59)
I was running Manjaro Linux with latest LuaJIT.
Hmm. The code in master works fine for me on Ubuntu and Mac (my main systems). I'm not really sure what to test on Windows since there are a bajillion combinations of Lua versions and installation methods.
CI: That would be great! I've never actually looked into how to set up any CI testing.
I will think about it.
@slembcke Your code works on windows! But ... ansi color support is off by default on Windows 😢.
Don't expect from powershell (or even worse cmd) to colorize text be default.
I used a third party console emulator called Cmder.
Colors show up correctly in Cmder!
Some other people have tried coloring text using lua and C bindings as well and they run into the same problem. Take a look at this project for example https://github.com/kikito/ansicolors.lua
I would say that you did the best you could.
Yeah... I'm don't really want to go down the rabbit hole of particularly robust color console support. I have a variable called color_maybe_supported that I enable it with. Hehe
This is still an active issue it seems
image
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?