Struct kaolinite::row::Row [−][src]
pub struct Row { pub text: Vec<char>, pub indices: Vec<usize>, pub modified: bool, pub tokens: Vec<Token>, pub needs_rerender: bool, }
Expand description
A struct that contains all the basic tools necessary to manage rows in a document
Fields
text: Vec<char>
All the characters within the row
indices: Vec<usize>
Corresponding display widths for each character
modified: bool
A tool for determining if the row has been edited
use kaolinite::row::Row; let tab_width = 4; let mut row = Row::new("Hello", tab_width); assert_eq!(row.modified, false); row.insert(5, ", world!", tab_width); assert_eq!(row.modified, true); row.modified = false; assert_eq!(row.modified, false);
This is ideal for optimisation
tokens: Vec<Token>
Tokens for this row
needs_rerender: bool
Implementations
Remove text in a range
This takes in an inclusive or exclusive range: ..
and ..=
only.
Errors
Will return Err
if range
is out of range of the row
Retrieve the indices of word boundaries
// Opening a file, use kaolinite::document::Document; let mut doc = Document::new((10, 10)); // Imagine if test.txt were `The quick brown fox` doc.open("examples/test.txt").expect("Failed to open file"); // This would get the word boundaries of the first row: [0, 4, 10, 16, 19] println!("{:?}", doc.row(0).unwrap().words());
Find the next word in this row from the character index
Find the previous word in this row from the character index
Render part of the row When trying to render X axis offset, this is the ideal function to use
"He好llo好" // 0.. "e好llo好" // 1.. "好llo好" // 2.. " llo好" // 3.. "llo好" // 4.. "lo好" // 5.. "o好" // 6.. "好" // 7.. " " // 8.. "" // 9..
This also handles double width characters by inserting whitespace when half of the character is off the screen
Render the entire row, with tabs converted into spaces
Render this row as is, with no tab interference
Calculate the character pointer from a display index
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Row
impl UnwindSafe for Row
Blanket Implementations
Mutably borrows from an owned value. Read more