#text #lines #string #information #line

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

#180 in Text processing

Download history 2715/week @ 2022-08-09 3250/week @ 2022-08-16 3491/week @ 2022-08-23 3159/week @ 2022-08-30 3417/week @ 2022-09-06 2605/week @ 2022-09-13 2763/week @ 2022-09-20 2873/week @ 2022-09-27 3363/week @ 2022-10-04 3090/week @ 2022-10-11 2548/week @ 2022-10-18 2334/week @ 2022-10-25 1934/week @ 2022-11-01 2758/week @ 2022-11-08 2499/week @ 2022-11-15 2325/week @ 2022-11-22

9,894 downloads per month
Used in 26 crates (8 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

~160KB