Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dsherret/text_lines
Information about lines of text in a string.
https://github.com/dsherret/text_lines
Last synced: 13 days ago
JSON representation
Information about lines of text in a string.
- Host: GitHub
- URL: https://github.com/dsherret/text_lines
- Owner: dsherret
- License: mit
- Created: 2021-08-13T16:17:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-31T14:54:40.000Z (9 months ago)
- Last Synced: 2024-10-30T08:58:15.595Z (about 2 months ago)
- Language: Rust
- Size: 13.7 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# text_lines
[![](https://img.shields.io/crates/v/text_lines.svg)](https://crates.io/crates/text_lines)
Information about lines of text in a string.
```rust
use text_lines::TextLines;let text = "Line 1\n\tLine 2";
let info = TextLines::new(&text); // defaults to an indent width of 4let 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, 6let info = TextLines::with_indent_width(&text, 2);
let line_and_column_display = info.line_and_column_display(9); // 2, 4
```