Method: rich.text.Text.stylize_before
Calls: 44, Exceptions: 0, Paths: 3Back
Path 1: 40 calls (0.91)
Style (40)
0 (40)
None (40)
1def stylize_before(
2 self,
3 style: Union[str, Style],
4 start: int = 0,
5 end: Optional[int] = None,
6 ) -> None:
7 """Apply a style to the text, or a portion of the text. Styles will be applied before other styles already present.
8
9 Args:
10 style (Union[str, Style]): Style instance or style definition to apply.
11 start (int): Start offset (negative indexing is supported). Defaults to 0.
12 end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
13 """
14 if style:
15 length = len(self)
16 if start < 0:
17 start = length + start
18 if end is None:
19 end = length
20 if end < 0:
21 end = length + end
22 if start >= length or end <= start:
23 # Span not in text or not valid
24 return
25 self._spans.insert(0, Span(start, min(length, end), style))
Path 2: 3 calls (0.07)
Style (3)
0 (3)
None (3)
1def stylize_before(
2 self,
3 style: Union[str, Style],
4 start: int = 0,
5 end: Optional[int] = None,
6 ) -> None:
7 """Apply a style to the text, or a portion of the text. Styles will be applied before other styles already present.
8
9 Args:
10 style (Union[str, Style]): Style instance or style definition to apply.
11 start (int): Start offset (negative indexing is supported). Defaults to 0.
12 end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
13 """
14 if style:
15 length = len(self)
16 if start < 0:
17 start = length + start
18 if end is None:
19 end = length
20 if end < 0:
21 end = length + end
22 if start >= length or end <= start:
23 # Span not in text or not valid
24 return
25 self._spans.insert(0, Span(start, min(length, end), style))
Path 3: 1 calls (0.02)
'italic' (1)
2 (1)
7 (1)
1def stylize_before(
2 self,
3 style: Union[str, Style],
4 start: int = 0,
5 end: Optional[int] = None,
6 ) -> None:
7 """Apply a style to the text, or a portion of the text. Styles will be applied before other styles already present.
8
9 Args:
10 style (Union[str, Style]): Style instance or style definition to apply.
11 start (int): Start offset (negative indexing is supported). Defaults to 0.
12 end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None.
13 """
14 if style:
15 length = len(self)
16 if start < 0:
17 start = length + start
18 if end is None:
19 end = length
20 if end < 0:
21 end = length + end
22 if start >= length or end <= start:
23 # Span not in text or not valid
24 return
25 self._spans.insert(0, Span(start, min(length, end), style))