#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

#150 in #line

Download history 21779/week @ 2024-03-29 7756/week @ 2024-04-05 10573/week @ 2024-04-12 11388/week @ 2024-04-19 10548/week @ 2024-04-26 9788/week @ 2024-05-03 13395/week @ 2024-05-10 18874/week @ 2024-05-17 16547/week @ 2024-05-24 11438/week @ 2024-05-31 16906/week @ 2024-06-07 14703/week @ 2024-06-14 14362/week @ 2024-06-21 14598/week @ 2024-06-28 11321/week @ 2024-07-05 6534/week @ 2024-07-12

50,395 downloads per month
Used in 64 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

~180KB