mirror of https://github.com/Textualize/rich.git
rename method
This commit is contained in:
parent
482dcee134
commit
96d61284ba
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
|
||||
- Added Text.extend_style method.
|
||||
- Added Span.extend method.
|
||||
|
||||
## [13.4.2] - 2023-06-12
|
||||
|
||||
|
|
12
rich/text.py
12
rich/text.py
|
@ -97,18 +97,18 @@ class Span(NamedTuple):
|
|||
return self
|
||||
return Span(start, min(offset, end), style)
|
||||
|
||||
def add_padding(self, padding: int) -> "Span":
|
||||
"""Add spaces the the end of a span.
|
||||
def extend(self, cells: int) -> "Span":
|
||||
"""Extend the span by the given number of cells.
|
||||
|
||||
Args:
|
||||
padding (int): Number of additional spaces.
|
||||
cells (int): Additional space to add to end of span.
|
||||
|
||||
Returns:
|
||||
Span: A span.
|
||||
"""
|
||||
if padding:
|
||||
if cells:
|
||||
start, end, style = self
|
||||
return Span(start, end + padding, style)
|
||||
return Span(start, end + cells, style)
|
||||
else:
|
||||
return self
|
||||
|
||||
|
@ -577,7 +577,7 @@ class Text(JupyterMixin):
|
|||
if spans:
|
||||
end_offset = len(self)
|
||||
self._spans[:] = [
|
||||
span.add_padding(spaces) if span.end >= end_offset else span
|
||||
span.extend(spaces) if span.end >= end_offset else span
|
||||
for span in spans
|
||||
]
|
||||
self._text.append(new_spaces)
|
||||
|
|
Loading…
Reference in New Issue