#string #line #information

text_lines

Information about lines of text in a string

9 releases (5 breaking)

0.6.0 Jul 11, 2022
0.5.0 Jul 11, 2022
0.4.1 Nov 25, 2021
0.3.0 Sep 3, 2021
0.1.2 Aug 13, 2021

#863 in Text processing

Download history 17007/week @ 2023-12-17 1471/week @ 2023-12-24 5614/week @ 2023-12-31 7217/week @ 2024-01-07 6246/week @ 2024-01-14 10989/week @ 2024-01-21 7828/week @ 2024-01-28 10221/week @ 2024-02-04 10786/week @ 2024-02-11 5317/week @ 2024-02-18 12506/week @ 2024-02-25 6816/week @ 2024-03-03 10611/week @ 2024-03-10 9777/week @ 2024-03-17 14772/week @ 2024-03-24 16634/week @ 2024-03-31

52,101 downloads per month
Used in 56 crates (12 directly)

MIT license

25KB
611 lines

text_lines

Information about lines of text in a string.

use text_lines::TextLines;

let text = "Line 1\n\tLine 2";
let info = TextLines::new(&text); // defaults to an indent width of 4

let line_index = info.line_index(9); // 1
let line_and_column = info.line_and_column_index(9); // 1, 2
let byte_index = info.byte_index(&line_and_column); // 9
let line_and_column_display = info.line_and_column_display(9); // 2, 6

let info = TextLines::with_indent_width(&text, 2);
let line_and_column_display = info.line_and_column_display(9); // 2, 4

Dependencies

~175KB