Struct duat_core::file::File

source ·
pub struct File { /* private fields */ }
Expand description

The widget that is used to print and edit files.

Implementations§

source§

impl File

source

pub fn write(&self) -> Result<usize, String>

source

pub fn write_to(&self, path: impl AsRef<str>) -> Result<usize>

source

pub fn history_mut(&mut self) -> &mut History

source

pub fn text(&self) -> &Text

source§

impl File

§Querying functions

These functions serve the purpose of querying information from the File.

source

pub fn search(&self) -> Searcher<'_>

source

pub fn search_at(&self, point: Point) -> Searcher<'_>

source

pub fn rev_search_at(&self, point: Point) -> RevSearcher<'_>

source

pub fn path(&self) -> String

The full path of the file.

If there is no set path, returns "*scratch file*#{id}".

source

pub fn path_set(&self) -> Option<String>

The full path of the file.

Returns None if the path has not been set yet.

source

pub fn name(&self) -> String

The file’s name.

If there is no set path, returns "*scratch file #{id}*".

source

pub fn name_set(&self) -> Option<String>

The file’s name.

Returns None if the path has not been set yet.

source

pub fn len_bytes(&self) -> usize

The number of bytes in the file.

source

pub fn len_chars(&self) -> usize

The number of chars in the file.

source

pub fn len_lines(&self) -> usize

The number of lines in the file.

source

pub fn printed_lines(&self) -> &[(usize, bool)]

Returns the currently printed set of lines.

These are returned as a usize, showing the index of the line in the file, and a bool, which is true when the line is wrapped.

source§

impl File

These functions allow for the modification of the File’s Text by navigating through a History’s changes. For now, this is a linear history (i.e. modification removes all future changes), but the plan is to change it to a tree at some point.

source

pub fn add_moment(&mut self)

Begins a new moment in history.

A new moment makes it so that “undoing” or “redoing” will undo or redo all the changes in the moment. The previous moment can be undone, undoing multiple changes at once.

source

pub fn redo(&mut self, area: &impl Area, cursors: &mut Cursors)

Redoes the next moment, if there is one.

source

pub fn undo(&mut self, area: &impl Area, cursors: &mut Cursors)

Undoes the last moment, if there was one.

source

pub fn mut_text_and_history(&mut self) -> (&mut Text, &mut History)

Returns a mutable reference to the Text and History of the File.

Trait Implementations§

source§

impl<U> ActiveWidget<U> for File
where U: Ui,

source§

fn mut_text(&mut self) -> &mut Text

A mutable reference to the Text printed by this cursor.
source§

fn on_focus(&mut self, _area: &<U as Ui>::Area)

Actions to do whenever this [ActionableWidget] is focused.
source§

fn on_unfocus(&mut self, _area: &<U as Ui>::Area)

Actions to do whenever this [ActionableWidget] is unfocused.
source§

impl<U> PassiveWidget<U> for File
where U: Ui,

source§

fn build( _context: Context<U>, _: bool, ) -> (Widget<U>, impl Fn() -> bool, PushSpecs)
where Self: Sized,

source§

fn update(&mut self, _area: &U::Area)

Updates the widget, allowing the modification of its Area. Read more
source§

fn text(&self) -> &Text

The text that this widget prints out.
source§

fn print_cfg(&self) -> &PrintCfg

source§

fn once(_context: Context<U>)

source§

fn print(&mut self, area: &<U as Ui>::Area)

source§

fn name() -> &'static str
where Self: Sized,

source§

impl Send for File

source§

impl Sync for File

Auto Trait Implementations§

§

impl Freeze for File

§

impl !RefUnwindSafe for File

§

impl Unpin for File

§

impl !UnwindSafe for File

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.