rename method

This commit is contained in:
Will McGugan 2023-07-28 22:04:01 +01:00
parent 482dcee134
commit 96d61284ba
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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)