Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AnnotatedString display interface (eliminate StyledStrings type-piracy) #56194

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

topolarity
Copy link
Member

@topolarity topolarity commented Oct 16, 2024

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.

This is required for downstream libraries (esp. StyledStrings)
to be able to influence the display of an AnnotatedString 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 leads to corner 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.
@tecosaur tecosaur added the display and printing Aesthetics and correctness of printed representations of objects. label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants