Files
BitLogger/docs/api/set-global-style-tag-registry.md
Nanaloveyuki 25a6a973d2 πŸ“ Update More API Document
2026-05-20 11:37:49 +08:00

1.7 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
set-global-style-tag-registry api formatter 20260520 Replace the shared global style tag registry used by formatters without local overrides.
style
registry
global
public

Set-global-style-tag-registry

Replace the shared global StyleTagRegistry. This helper changes the default tag source used by formatters that do not define their own local registry.

Interface

pub fn set_global_style_tag_registry(registry : StyleTagRegistry) -> Unit {

input

  • registry : StyleTagRegistry - New shared global registry value.

Explanation

Detailed rules explaining key parameters and behaviors

  • This helper mutates process-wide shared formatter state.
  • Only formatters without local style tags read from the global registry.
  • It is useful for centralized theming or tests that need predictable tag behavior.

How to Use

Here are some specific examples provided.

When Need A Process-wide Custom Tag Default

When multiple formatters should share a custom default tag registry:

set_global_style_tag_registry(
  style_tag_registry().set_tag("accent", fg=Some("#102030"), dim=true),
)

In this example, subsequent formatters without local tag registries can resolve accent from the shared global registry.

Error Case

e.g.:

  • If local formatter tags are already present, those local tags still take priority.

  • Global mutation can affect later formatting broadly, so test code should usually restore or reset after temporary changes.

Notes

  1. Use global_style_tag_registry() to snapshot the previous value before replacement.

  2. Use reset_global_style_tag_registry() to restore the library default global registry.