MCPcopy
hub / github.com/Textualize/rich / split

Method split

rich/text.py:63–74  ·  rich/text.py::Span.split

Split a span in to 2 from a given offset.

(self, offset: int)

Source from the content-addressed store, hash-verified

61 return self.end > self.start
62
63 def split(self, offset: int) -> Tuple[class="st">"Span", Optional[class="st">"Span"]]:
64 class="st">""class="st">"Split a span in to 2 from a given offset."class="st">""
65
66 if offset < self.start:
67 return self, None
68 if offset >= self.end:
69 return self, None
70
71 start, end, style = self
72 span1 = Span(start, min(end, offset), style)
73 span2 = Span(span1.end, end, style)
74 return span1, span2
75
76 def move(self, offset: int) -> class="st">"Span":
77 class="st">"""Move start and end by a given offset.

Callers 15

test_span_splitFunction · 0.45
test_splitFunction · 0.45
test_split_spansFunction · 0.45
test_brokenpipeerrorFunction · 0.45
layout.pyFile · 0.45
make_layoutFunction · 0.45
downloadFunction · 0.45
time_splitMethod · 0.45
parseMethod · 0.45
__rich_measure__Method · 0.45
expand_tabsMethod · 0.45

Calls 1

SpanClass · 0.85

Tested by 4

test_span_splitFunction · 0.36
test_splitFunction · 0.36
test_split_spansFunction · 0.36
test_brokenpipeerrorFunction · 0.36