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

#620 in Text processing

Download history 7325/week @ 2024-07-27 6852/week @ 2024-08-03 10577/week @ 2024-08-10 11949/week @ 2024-08-17 18368/week @ 2024-08-24 11767/week @ 2024-08-31 15836/week @ 2024-09-07 11666/week @ 2024-09-14 13913/week @ 2024-09-21 21921/week @ 2024-09-28 9697/week @ 2024-10-05 17853/week @ 2024-10-12 12214/week @ 2024-10-19 16081/week @ 2024-10-26 6066/week @ 2024-11-02 26581/week @ 2024-11-09

64,512 downloads per month
Used in 76 crates (14 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

~165KB