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

Method split

src/textual/geometry.py:863–900  ·  view source on GitHub ↗

Split a region into 4 from given x and y offsets (cuts). ``` cut_x ↓ ┌────────┐ ┌───┐ │ │ │ │ │ 0 │ │ 1 │ │ │ │ │ cut_y → └────────┘ └───┘ ┌────────┐ ┌───┐

(self, cut_x: int, cut_y: int)

Source from the content-addressed store, hash-verified

861
862 @lru_cache(maxsize=1024)
863 def split(self, cut_x: int, cut_y: int) -> tuple[Region, Region, Region, Region]:
864 """Split a region into 4 from given x and y offsets (cuts).
865
866 ```
867 cut_x ↓
868 ┌────────┐ ┌───┐
869 │ │ │ │
870 │ 0 │ │ 1 │
871 │ │ │ │
872 cut_y → └────────┘ └───┘
873 ┌────────┐ ┌───┐
874 │ 2 │ │ 3 │
875 └────────┘ └───┘
876 ```
877
878 Args:
879 cut_x: Offset from self.x where the cut should be made. If negative, the cut
880 is taken from the right edge.
881 cut_y: Offset from self.y where the cut should be made. If negative, the cut
882 is taken from the lower edge.
883
884 Returns:
885 Four new regions which add up to the original (self).
886 """
887
888 x, y, width, height = self
889 if cut_x < 0:
890 cut_x = width + cut_x
891 if cut_y < 0:
892 cut_y = height + cut_y
893
894 _Region = Region
895 return (
896 _Region(x, y, cut_x, cut_y),
897 _Region(x + cut_x, y, width - cut_x, cut_y),
898 _Region(x, y + cut_y, cut_x, height - cut_y),
899 _Region(x + cut_x, y + cut_y, width - cut_x, height - cut_y),
900 )
901
902 @lru_cache(maxsize=1024)
903 def split_vertical(self, cut: int) -> tuple[Region, Region]:

Callers 15

parse_featuresFunction · 0.45
parseMethod · 0.45
__set__Method · 0.45
__init__Method · 0.45
_key_to_identifierFunction · 0.45
import_appFunction · 0.45
_parse_extended_keyMethod · 0.45
_initialize_reactiveMethod · 0.45
_setMethod · 0.45
parse_keyMethod · 0.45
make_bindingsMethod · 0.45

Calls

no outgoing calls

Tested by 6

composeMethod · 0.36
test_splitFunction · 0.36
test_split_negativeFunction · 0.36
test_move_cursorFunction · 0.36
test_index_from_locationFunction · 0.36
test_location_from_indexFunction · 0.36