tmux_styler.Statusbar.Segment

 1from enum import Enum
 2
 3from ..Colors import Color, NamedColor
 4from ..Style import Style
 5
 6
 7class SegmentType(Enum):
 8    """
 9    The type of segment.
10    """
11    FUNCTION = "function"
12    """
13    A segment that is a function and must be loaded from a module.
14    """
15    STRING = "str"
16    """
17    A segment that simply displays a static string.
18    """
19
20
21class Segment:
22    """
23    A segment is a part of the statusbar that displays some content.
24    """
25
26    def __init__(self, segment_type: SegmentType, content: str, bg: Color = NamedColor.DEFAULT, fg: Color = NamedColor.DEFAULT, separator: str | None = None, style: Style | None = None):
27        """
28        Creates a Segment object.
29
30        Parameters:
31        -----------
32        `segment_type`: SegmentType
33            The type of segment.
34
35        `content`: str
36            The content of the segment, if the segment type is a string than this is the string to display.
37            If the segment type is a function, then this is the function name. If the the function is
38            user defined then it must be in the format of {module}.{function name}. The module must be
39            in a path that tmux-styler will search for segments, or in your python path.
40
41        `bg`: Color
42            The background color of the segment. By default this will fallback to the default background color.
43
44        `fg`: Color
45            The foreground color of the segment. By default this will fallback to the default foreground color.
46
47        `separator`: str | None
48            Optionally specify a separator to use between this segment and the next segment, overrides the default separator.
49
50        `style`: Style
51            The style of the segment (optional). Specifying a style object that has colors will override the bg and fg parameters
52            with the colors from the style object.
53        """
54        self.type = segment_type
55        self.content = content
56        self.bg = bg
57        self.fg = fg
58        self.separator = separator
59
60        if style is not None and style.bg is not None:
61            self.bg = style.bg
62        if style is not None and style.fg is not None:
63            self.fg = style.fg
64        self.style = style
class SegmentType(enum.Enum):
 8class SegmentType(Enum):
 9    """
10    The type of segment.
11    """
12    FUNCTION = "function"
13    """
14    A segment that is a function and must be loaded from a module.
15    """
16    STRING = "str"
17    """
18    A segment that simply displays a static string.
19    """

The type of segment.

FUNCTION = <SegmentType.FUNCTION: 'function'>

A segment that is a function and must be loaded from a module.

STRING = <SegmentType.STRING: 'str'>

A segment that simply displays a static string.

Inherited Members
enum.Enum
name
value
class Segment:
22class Segment:
23    """
24    A segment is a part of the statusbar that displays some content.
25    """
26
27    def __init__(self, segment_type: SegmentType, content: str, bg: Color = NamedColor.DEFAULT, fg: Color = NamedColor.DEFAULT, separator: str | None = None, style: Style | None = None):
28        """
29        Creates a Segment object.
30
31        Parameters:
32        -----------
33        `segment_type`: SegmentType
34            The type of segment.
35
36        `content`: str
37            The content of the segment, if the segment type is a string than this is the string to display.
38            If the segment type is a function, then this is the function name. If the the function is
39            user defined then it must be in the format of {module}.{function name}. The module must be
40            in a path that tmux-styler will search for segments, or in your python path.
41
42        `bg`: Color
43            The background color of the segment. By default this will fallback to the default background color.
44
45        `fg`: Color
46            The foreground color of the segment. By default this will fallback to the default foreground color.
47
48        `separator`: str | None
49            Optionally specify a separator to use between this segment and the next segment, overrides the default separator.
50
51        `style`: Style
52            The style of the segment (optional). Specifying a style object that has colors will override the bg and fg parameters
53            with the colors from the style object.
54        """
55        self.type = segment_type
56        self.content = content
57        self.bg = bg
58        self.fg = fg
59        self.separator = separator
60
61        if style is not None and style.bg is not None:
62            self.bg = style.bg
63        if style is not None and style.fg is not None:
64            self.fg = style.fg
65        self.style = style

A segment is a part of the statusbar that displays some content.

Segment( segment_type: SegmentType, content: str, bg: tmux_styler.Colors.Color = <NamedColor.DEFAULT: 'default'>, fg: tmux_styler.Colors.Color = <NamedColor.DEFAULT: 'default'>, separator: str | None = None, style: tmux_styler.Style.Style | None = None)
27    def __init__(self, segment_type: SegmentType, content: str, bg: Color = NamedColor.DEFAULT, fg: Color = NamedColor.DEFAULT, separator: str | None = None, style: Style | None = None):
28        """
29        Creates a Segment object.
30
31        Parameters:
32        -----------
33        `segment_type`: SegmentType
34            The type of segment.
35
36        `content`: str
37            The content of the segment, if the segment type is a string than this is the string to display.
38            If the segment type is a function, then this is the function name. If the the function is
39            user defined then it must be in the format of {module}.{function name}. The module must be
40            in a path that tmux-styler will search for segments, or in your python path.
41
42        `bg`: Color
43            The background color of the segment. By default this will fallback to the default background color.
44
45        `fg`: Color
46            The foreground color of the segment. By default this will fallback to the default foreground color.
47
48        `separator`: str | None
49            Optionally specify a separator to use between this segment and the next segment, overrides the default separator.
50
51        `style`: Style
52            The style of the segment (optional). Specifying a style object that has colors will override the bg and fg parameters
53            with the colors from the style object.
54        """
55        self.type = segment_type
56        self.content = content
57        self.bg = bg
58        self.fg = fg
59        self.separator = separator
60
61        if style is not None and style.bg is not None:
62            self.bg = style.bg
63        if style is not None and style.fg is not None:
64            self.fg = style.fg
65        self.style = style

Creates a Segment object.

Parameters:

segment_type: SegmentType The type of segment.

content: str The content of the segment, if the segment type is a string than this is the string to display. If the segment type is a function, then this is the function name. If the the function is user defined then it must be in the format of {module}.{function name}. The module must be in a path that tmux-styler will search for segments, or in your python path.

bg: Color The background color of the segment. By default this will fallback to the default background color.

fg: Color The foreground color of the segment. By default this will fallback to the default foreground color.

separator: str | None Optionally specify a separator to use between this segment and the next segment, overrides the default separator.

style: Style The style of the segment (optional). Specifying a style object that has colors will override the bg and fg parameters with the colors from the style object.

type
content
bg
fg
separator
style