feat(api): implement stream-conditional colour API and runtime policy - #3
Open
synesissoftware wants to merge 2 commits into
Open
feat(api): implement stream-conditional colour API and runtime policy#3synesissoftware wants to merge 2 commits into
synesissoftware wants to merge 2 commits into
Conversation
Introduce a compiled runtime library component to complement the existing header-only SGR macros. The object-like colour macros remain unbound and require no linking; the compiled component adds stream-conditional colour sequences, environmental policy parsing, Windows console virtual-terminal gating, and runtime ABI version inspection. Key changes: - add runtime version functions woad_version() and woad_version_string() in src/api.c to provide an ABI probe; - implement stream-conditional colour selection and stream inspection for FILE*, file descriptor, and Windows console handles; - provide function-like conditional macros (WOAD_SEQ_FOR, WOAD_FG_FOR, WOAD_RESET_FOR, and colour-named variants) with type dispatch via _Generic in C11+ and overloading in C++; - evaluate environmental colour policy honouring WOAD_COLOUR / WOAD_COLOR, NO_COLOR, CLICOLOR_FORCE, CLICOLOR, and TERM=dumb; - support WOAD_SET_CONSOLE_MODE to withhold console modification while falling back to querying existing virtual-terminal capability; - gate Windows virtual-terminal processing via RtlGetVersion() and SetConsoleMode(), elected once per module/process via atomic CAS; - transition woad to a compiled library target in CMakeLists.txt and update woad.pc.in, while retaining unbound header-only SGR macros; - add section-3 manual page template man/woad.3.in, example colour_for.c, and unit tests in test.unit.gating.c and test.unit.version.c; - support --build-shared-libs in prepare_cmake.sh and unify options passed across MinGW and default CMake invocations; - smoke-test colour policy and precedence in CI across all matrix cells, and advance version to 0.0.1-beta1;
mwsis
approved these changes
Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a compiled runtime library component to complement the existing header-only SGR macros. The object-like colour macros remain unbound and require no linking; the compiled component adds stream-conditional colour sequences, environmental policy parsing, Windows console virtual-terminal gating, and runtime ABI version inspection.
Key changes:
woad_version()andwoad_version_string()in src/api.c to provide an ABI probe;FILE*, file descriptor, and Windows console handles;WOAD_SEQ_FOR,WOAD_FG_FOR,WOAD_RESET_FOR, and colour-named variants) with type dispatch via_Genericin C11+ and overloading in C++;WOAD_COLOUR/WOAD_COLOR,NO_COLOR,CLICOLOR_FORCE,CLICOLOR, andTERM=dumb;WOAD_SET_CONSOLE_MODEto withhold console modification while falling back to querying existing virtual-terminal capability;RtlGetVersion()andSetConsoleMode(), elected once per module/process via atomic CAS;--build-shared-libsin prepare_cmake.sh and unify options passed across MinGW and default CMake invocations;