code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(42 lines)
1 '\" t
2 .\" Copyright (c) 2025 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Text.slice 3 2025-11-29 "Tomo man-pages"
6 .SH NAME
7 Text.slice \- get a slice of a text
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Text.slice\ :\ func(text:\ Text,\ from:\ Int\ =\ 1,\ to:\ Int\ =\ -1\ ->\ Text)
13 .fi
14 .SH DESCRIPTION
15 Get a slice of the text.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx lb
23 l l l l.
24 Name Type Description Default
25 text Text The text to be sliced. -
26 from Int The index of the first grapheme cluster to include (1-indexed). 1
27 to Int The index of the last grapheme cluster to include (1-indexed). -1
28 .TE
29 .SH RETURN
30 The text that spans the given grapheme cluster indices.
32 .SH NOTES
33 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 EXAMPLES
36 .EX
37 assert "hello".slice(2, 3) == "el"
38 assert "hello".slice(to=-2) == "hell"
39 assert "hello".slice(from=2) == "ello"
40 .EE
41 .SH SEE ALSO
42 .BR Tomo-Text (3)