diff --git a/prettypretty/color/style.pyi b/prettypretty/color/style/__init__.pyi similarity index 78% rename from prettypretty/color/style.pyi rename to prettypretty/color/style/__init__.pyi index 85e8077..2c2198a 100644 --- a/prettypretty/color/style.pyi +++ b/prettypretty/color/style/__init__.pyi @@ -1,7 +1,7 @@ -from collections.abc import Iterator from typing import Self -from . import Color +from .. import Color +from .format import Format class DefaultColor: """The default foreground or background color.""" @@ -208,91 +208,38 @@ class Layer: def __str__(self) -> str: ... -class Format: - """Text formats other than color.""" - Bold: Format = ... - Thin: Format = ... - Italic: Format = ... - Underlined: Format = ... - Blinking: Format = ... - Reversed: Format = ... - Hidden: Format = ... - Stricken: Format = ... - NotBoldOrThin: Format = ... - NotItalic: Format = ... - NotUnderlined: Format = ... - NotBlinking: Format = ... - NotReversed: Format = ... - NotHidden: Format = ... - NotStricken: Format = ... - - @staticmethod - def all() -> AllFormats: ... - - def __hash__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - - -class AllFormats: - """An iterator over all formats.""" - def drain(self) -> None: ... - def __iter__(self) -> Self: ... - def __next__(self) -> Format: ... - - -class Formatting: - """Terminal formatting.""" - def __new__(cls) -> Self: ... - def bold(self) -> Self: ... - def thin(self) -> Self: ... - def italic(self) -> Self: ... - def underlined(self) -> Self: ... - def blinking(self) -> Self: ... - def reversed(self) -> Self: ... - def hidden(self) -> Self: ... - def stricken(self) -> Self: ... - def has(self, format: Format) -> bool: ... - def formats(self) -> Iterator[Format]: ... - def __invert__(self) -> Self: ... - def __sub__(self, other: Self) -> Self: ... - def __hash__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - - -class Style_Reset(Style): +class StyleToken_Reset(StyleToken): def __new__(cls) -> Self: ... -class Style_Text(Style): - def __new__(cls, formatting: Formatting) -> Self: ... +class StyleToken_Format(StyleToken): + def __new__(cls, format: Format) -> Self: ... -class Style_Foreground(Style): +class StyleToken_Foreground(StyleToken): def __new__(cls, foreground: TerminalColor) -> Self: ... -class Style_Background(Style): +class StyleToken_Background(StyleToken): def __new__(cls, background: TerminalColor) -> Self: ... -class Style_HiResFore(Style): +class StyleToken_HiResForeground(StyleToken): def __new__(cls, foreground: Color) -> Self: ... -class Style_HiResBack(Style): +class StyleToken_HiResBackground(StyleToken): def __new__(cls, background: Color) -> Self: ... -class Style: - """The enum of all terminal styles.""" - Reset = Style_Reset - Text = Style_Text - Foreground = Style_Foreground - Background = Style_Background - HiResFore = Style_HiResFore - HiResBack = Style_HiResBack +class StyleToken: + """The enum of all terminal style tokens.""" + Reset = StyleToken_Reset + Format = StyleToken_Format + Foreground = StyleToken_Foreground + Background = StyleToken_Background + HiResForeground = StyleToken_HiResForeground + HiResBackground = StyleToken_HiResBackground def fidelity(self) -> Fidelity: ... def __hash__(self) -> int: ... @@ -300,24 +247,28 @@ class Style: def __ne__(self, other: object) -> bool: ... -def style() -> StyleCollection: ... - # Create a new, empty style collection. Idiomatic use starts with this - # method, followed by fluent style selections. +class TokenIterator: + """An iterator over style tokens.""" + def __iter__(self) -> Self: ... + def __next__(self) -> Format: ... + +def stylist() -> StyleBuilder: ... + # Create a new, empty style builder for assembling fluent styles. -class StyleCollection: - """A combination of styles.""" + +class StyleBuilder: + """A builder for fluently assembling styles.""" def __new__(cls) -> Self: ... - # FIXME: Enable fluent invocations! - def reset(self) -> None: ... - def bold(self) -> None: ... - def thin(self) -> None: ... - def italic(self) -> None: ... - def underlined(self) -> None: ... - def blinking(self) -> None: ... - def reversed(self) -> None: ... - def hidden(self) -> None: ... - def stricken(self) -> None: ... + def reset(self) -> Self: ... + def bold(self) -> Self: ... + def thin(self) -> Self: ... + def italic(self) -> Self: ... + def underlined(self) -> Self: ... + def blinking(self) -> Self: ... + def reversed(self) -> Self: ... + def hidden(self) -> Self: ... + def stricken(self) -> Self: ... def foreground( self, color: ( @@ -334,6 +285,12 @@ class StyleCollection: ) -> None: ... def hires_foreground(self, color: Color) -> None: ... def hires_background(self, color: Color) -> None: ... + def go(self) -> Style: ... + + +class Style: + """A style.""" + def tokens(self) -> TokenIterator: ... def fidelity(self) -> Fidelity: ... def __hash__(self) -> int: ... def __eq__(self, other: object) -> bool: ... diff --git a/prettypretty/color/style/format.pyi b/prettypretty/color/style/format.pyi new file mode 100644 index 0000000..e03ff50 --- /dev/null +++ b/prettypretty/color/style/format.pyi @@ -0,0 +1,54 @@ +from collections.abc import Iterator +from typing import Self + +class Attribute: + """Text attributes other than color.""" + Bold: Attribute = ... + Thin: Attribute = ... + Italic: Attribute = ... + Underlined: Attribute = ... + Blinking: Attribute = ... + Reversed: Attribute = ... + Hidden: Attribute = ... + Stricken: Attribute = ... + NotBoldOrThin: Attribute = ... + NotItalic: Attribute = ... + NotUnderlined: Attribute = ... + NotBlinking: Attribute = ... + NotReversed: Attribute = ... + NotHidden: Attribute = ... + NotStricken: Attribute = ... + + @staticmethod + def all() -> AllAttributes: ... + + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + + +class AllAttributes: + """An iterator over all attributes.""" + def drain(self) -> None: ... + def __iter__(self) -> Self: ... + def __next__(self) -> Attribute: ... + + +class Format: + """Terminal formatting.""" + def __new__(cls) -> Self: ... + def bold(self) -> Self: ... + def thin(self) -> Self: ... + def italic(self) -> Self: ... + def underlined(self) -> Self: ... + def blinking(self) -> Self: ... + def reversed(self) -> Self: ... + def hidden(self) -> Self: ... + def stricken(self) -> Self: ... + def has(self, format: Format) -> bool: ... + def formats(self) -> Iterator[Format]: ... + def __invert__(self) -> Self: ... + def __sub__(self, other: Self) -> Self: ... + def __hash__(self) -> int: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ...