Add AnnotatedString display interface (eliminate StyledStrings type-piracy) #56194
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.
This implements a "rendering interface" for AnnotatedString, allowing StyledStrings to influence printing without type-piracy.
The idea here is to provide an
iterate
-like display protocol that passes style information into the implementing library, which takes that information (and a "state" from the last display update), and decides how it needs to update the output to render the string.Since AnnotatedStrings don't have a distinguished "owner" or "type" (only their annotations have types), this means we have to handle cases where the "laststate" you receive might be from another library. In that case, it's the responsibility of the downstream renderer to discard the laststate information and "reset" the display state as needed.
Dependent on #56192, and see JuliaLang/StyledStrings.jl#100 for the StyledStrings-side changes.
This should eliminate 100% of the StyledStrings type-piracy, once implemented.