Struct kaolinite::row::Row [−][src]
pub struct Row { pub text: Vec<char>, pub indices: Vec<usize>, pub modified: bool, pub info: *mut FileInfo, }
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 mut row = Row::new("Hello"); assert_eq!(row.modified, false); row.insert(5, ", world!"); assert_eq!(row.modified, true); row.modified = false; assert_eq!(row.modified, false);
This is ideal for optimisation
info: *mut FileInfo
Holds a reference to file information
Implementations
This method provides a neat way to link a row to a file info
You usually don’t need to use this method yourself
It is used by Document to link it’s FileInfo
struct
to each Row for configuration purposes
Retrieve the indices of word boundaries
// Opening a file, use kaolinite::document::Document; let mut doc = Document::new(); // Imagine if test.txt were `The quick brown fox` doc.open("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).words());
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
Retrieve the tab width from the document info
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Row
impl UnwindSafe for Row
Blanket Implementations
Mutably borrows from an owned value. Read more