#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

#391 in Text processing

Download history 2498/week @ 2022-12-07 2685/week @ 2022-12-14 1898/week @ 2022-12-21 1689/week @ 2022-12-28 3074/week @ 2023-01-04 3263/week @ 2023-01-11 3815/week @ 2023-01-18 3380/week @ 2023-01-25 4020/week @ 2023-02-01 3544/week @ 2023-02-08 4031/week @ 2023-02-15 4361/week @ 2023-02-22 3587/week @ 2023-03-01 4430/week @ 2023-03-08 4010/week @ 2023-03-15 2553/week @ 2023-03-22

15,002 downloads per month
Used in 35 crates (11 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

~220KB