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

Create a new row from raw text

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

Insert text at a position

Errors

Will return Err if start is out of range of the row

Remove text in a range

Errors

Will return Err if range is out of range of the row

Splits this row into two separate rows

Errors

Will return Err if idx is out of range of the row

Joins this row with another row

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

Find the character length of this row

Determine if the row is empty

Find the display width of this row

Calculate the character pointer from a display index

Retrieve the tab width from the document info

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.