Skip to content

Tooltips (iTerm annotations) #3372

Answered by jace
jace asked this question in Ideas
Jun 5, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

A working solution! I'm calling it "hinted" instead of "annotated" because it's fewer chars in markup:

Markup: "[@hint='This is the hint']Hinted text[/]"

"""Add iTerm2 annotations to Rich."""

from collections.abc import Iterable
from typing import Optional

from rich import get_console
from rich import print as rprint
from rich.console import Console, ConsoleOptions, ConsoleRenderable, RenderHook
from rich.segment import Segment
from rich.style import Style
from rich.text import Text
from typing_extensions import Self


class HintedText(Text):
    """Text subclass that supports iTerm2 annotations."""

    @classmethod
    def recast(cls, text: Text) -> Self:
        """Recast from Text."""

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jace
Comment options

Answer selected by jace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant