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

#618 in Text processing

Download history 14703/week @ 2024-06-14 14362/week @ 2024-06-21 14598/week @ 2024-06-28 11321/week @ 2024-07-05 7886/week @ 2024-07-12 9364/week @ 2024-07-19 7341/week @ 2024-07-26 6139/week @ 2024-08-02 11740/week @ 2024-08-09 8729/week @ 2024-08-16 18192/week @ 2024-08-23 12281/week @ 2024-08-30 18384/week @ 2024-09-06 7568/week @ 2024-09-13 17195/week @ 2024-09-20 19672/week @ 2024-09-27

65,243 downloads per month
Used in 68 crates (13 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