(42 lines)
1 '\" t2 .\" Copyright (c) 2025 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH Text.slice 3 2025-11-29 "Tomo man-pages"6 .SH NAME7 Text.slice \- get a slice of a text8 .SH LIBRARY9 Tomo Standard Library10 .SH SYNOPSIS11 .nf12 .BI Text.slice\ :\ func(text:\ Text,\ from:\ Int\ =\ 1,\ to:\ Int\ =\ -1\ ->\ Text)13 .fi14 .SH DESCRIPTION15 Get a slice of the text.18 .SH ARGUMENTS20 .TS21 allbox;22 lb lb lbx lb23 l l l l.24 Name Type Description Default25 text Text The text to be sliced. -26 from Int The index of the first grapheme cluster to include (1-indexed). 127 to Int The index of the last grapheme cluster to include (1-indexed). -128 .TE29 .SH RETURN30 The text that spans the given grapheme cluster indices.32 .SH NOTES33 A negative index counts backwards from the end of the text, so `-1` refers to the last cluster, `-2` the second-to-last, etc. Slice ranges will be truncated to the length of the text.35 .SH EXAMPLES36 .EX37 assert "hello".slice(2, 3) == "el"38 assert "hello".slice(to=-2) == "hell"39 assert "hello".slice(from=2) == "ello"40 .EE41 .SH SEE ALSO42 .BR Tomo-Text (3)