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
|
||||||
|
|
||||||
- Added Text.extend_style method.
|
- Added Text.extend_style method.
|
||||||
|
- Added Span.extend method.
|
||||||
|
|
||||||
## [13.4.2] - 2023-06-12
|
## [13.4.2] - 2023-06-12
|
||||||
|
|
||||||
|
|
12
rich/text.py
12
rich/text.py
|
@ -97,18 +97,18 @@ class Span(NamedTuple):
|
||||||
return self
|
return self
|
||||||
return Span(start, min(offset, end), style)
|
return Span(start, min(offset, end), style)
|
||||||
|
|
||||||
def add_padding(self, padding: int) -> "Span":
|
def extend(self, cells: int) -> "Span":
|
||||||
"""Add spaces the the end of a span.
|
"""Extend the span by the given number of cells.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
padding (int): Number of additional spaces.
|
cells (int): Additional space to add to end of span.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Span: A span.
|
Span: A span.
|
||||||
"""
|
"""
|
||||||
if padding:
|
if cells:
|
||||||
start, end, style = self
|
start, end, style = self
|
||||||
return Span(start, end + padding, style)
|
return Span(start, end + cells, style)
|
||||||
else:
|
else:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ class Text(JupyterMixin):
|
||||||
if spans:
|
if spans:
|
||||||
end_offset = len(self)
|
end_offset = len(self)
|
||||||
self._spans[:] = [
|
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
|
for span in spans
|
||||||
]
|
]
|
||||||
self._text.append(new_spaces)
|
self._text.append(new_spaces)
|
||||||
|
|
Loading…
Reference in New Issue