Skip to content

Conversation

@chqrlie
Copy link
Contributor

@chqrlie chqrlie commented Mar 8, 2025

  • use style names instead of hard-coded color names
  • customize color output via environment variable C2_COLORS: eg: C2_COLORS=none, C2_COLORS="error:bright-blue, C2_COLORS="error:#d0d0d0
  • use cache to multiple calls to unix.isatty() and stdib.getenv()
  • simplify error formating in source_mgr.c2

@chqrlie chqrlie force-pushed the nocolor branch 3 times, most recently from ee5cef6 to bdbd6c8 Compare March 10, 2025 10:05
@bvdberg
Copy link
Member

bvdberg commented Mar 10, 2025

Please be Very careful with globals in combination with plugins. Since the plugins will have a different set of them. Please see the ast.setGlobals() function. It's a bit of a hack, but it's the only way to have access to the same globals atm..

@chqrlie
Copy link
Contributor Author

chqrlie commented Mar 10, 2025

Please be Very careful with globals in combination with plugins. Since the plugins will have a different set of them. Please see the ast.setGlobals() function. It's a bit of a hack, but it's the only way to have access to the same globals atm..

Yes, I am aware of this problem. As long as we call color.useColor() in both c2c and in all plugins, the global color variables should be initialized and cached with the same values.

Alternately, we could make these variables members of the diagnostics or globals or another appropriate structure to ensure encapsulation and dynamic sharing with the plugins.

The globals variable in ast/utils.c2 is definitely a hack.

@chqrlie chqrlie force-pushed the nocolor branch 4 times, most recently from 9242087 to a8f79c0 Compare March 17, 2025 19:16
@bvdberg
Copy link
Member

bvdberg commented Mar 18, 2025

To keep the plugins working, all AST globals need to be moved to the Globals struct)

@chqrlie chqrlie marked this pull request as draft March 23, 2025 19:17
@chqrlie chqrlie force-pushed the nocolor branch 2 times, most recently from f4b6725 to 52b2b9d Compare March 25, 2025 14:57
@bvdberg
Copy link
Member

bvdberg commented Mar 25, 2025

We need to discuss this on the phone, there are also some regressions

@chqrlie
Copy link
Contributor Author

chqrlie commented Mar 25, 2025

This PR is flagged as a draft for now. Work in progress

@chqrlie chqrlie force-pushed the nocolor branch 6 times, most recently from 651d347 to adfc6c3 Compare April 1, 2025 17:50
@chqrlie chqrlie force-pushed the nocolor branch 4 times, most recently from f984be8 to 0a6c2ed Compare April 6, 2025 14:32
@chqrlie chqrlie force-pushed the nocolor branch 4 times, most recently from 442c0ac to 8bae15c Compare April 14, 2025 20:26
@chqrlie chqrlie force-pushed the nocolor branch 3 times, most recently from 1e286e2 to 0b23c8b Compare August 29, 2025 12:23
@chqrlie chqrlie force-pushed the nocolor branch 4 times, most recently from 620bb23 to 65c4ec4 Compare September 3, 2025 08:58
@chqrlie chqrlie force-pushed the nocolor branch 3 times, most recently from 54e6f49 to eac2139 Compare September 14, 2025 20:42
@chqrlie chqrlie force-pushed the nocolor branch 2 times, most recently from a24e26d to 7cb8a85 Compare September 28, 2025 16:29
@chqrlie chqrlie force-pushed the nocolor branch 7 times, most recently from e24f77a to 0753858 Compare October 8, 2025 09:40
@chqrlie chqrlie force-pushed the nocolor branch 4 times, most recently from a4f80d0 to 390c483 Compare October 18, 2025 20:12
@chqrlie chqrlie force-pushed the nocolor branch 3 times, most recently from a1c2653 to c50fcc7 Compare October 20, 2025 20:58
@chqrlie chqrlie force-pushed the nocolor branch 2 times, most recently from 2499c4b to 6028f25 Compare November 2, 2025 14:53
* use style names instead of hard-coded color names
* customize color output via environment variable `C2_COLORS`:
  eg: `C2_COLORS=none`, `C2_COLORS="error:bright-blue"`, `C2_COLORS="error:#d0d0d0"`
* use console to output error messages in source_mgr and c2recipe_parser.
* use cache to avoid multiple calls to `unix.isatty()` and `stdlib.getenv()`
* share global colors with plugins
* simplify error formating in **source_mgr.c2**
* add c2cat color customisation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants