10from abc
import ABC, abstractmethod
35class Decorator(IRenderElement):
42 def __init__(self, element : IRenderElement) ->
None:
45 raise ValueError(
"The element being decorated cannot be null.")
71 def __init__(self, element: IRenderElement) ->
None:
82 return "\x1b[47m{0}\x1b[49m".format(super().
Render())
97 def __init__(self, element : IRenderElement) ->
None:
107 return "\x1b[4m{0}\x1b[24m".format(super().
Render())
123 def __init__(self, element : IRenderElement) ->
None:
133 return "\x1b[31m{0}\x1b[39m".format(super().
Render())
Represents the base class of all decorators and is responsible for handling the wrapped element being...
str Render(self)
Render the wrapped element with decorations.
None __init__(self, IRenderElement element)
Constructor.
_wrappedElement
Object being decorated by this class instance.
Represents an element that can be rendered in text.
str Render(self)
Render this element as a string.
Represents the RedForeground decorator, which renders the wrapped content as red text.
str Render(self)
Render the wrapped element with red text.
None __init__(self, IRenderElement element)
Constructor that wraps the specified element.
Represents the core element that can be decorated.
str Render(self)
Render this element as a string.
None __init__(self, str element)
Constructor.
_elementText
The raw text at the center of all decorators.
Represents the Underline decorator, which underlines the wrapped content.
str Render(self)
Render the wrapped element underlined.
None __init__(self, IRenderElement element)
Constructor that wraps the specified element.
Represents the WhiteBackground decorator, which changes the background color of the wrapped element t...
str Render(self)
Render the wrapped element with a white background.
None __init__(self, IRenderElement element)
Constructor that wraps the specified element.