Struct File

Source
pub struct File<U: Ui> { /* private fields */ }
Expand description

The widget that is used to print and edit files

Implementations§

Source§

impl<U: Ui> File<U>

Source

pub fn write(&mut self) -> Result<Option<usize>, Text>

Writes the file to the current PathBuf, if one was set

Source

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

Writes the file to the given Path

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 path_kind(&self) -> PathKind

The type of PathBuf

This represents the three possible states for a File’s PathBuf, as it could either represent a real File, not exist, or not have been defined yet.

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

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 selections(&self) -> &Selections

The Selections that are used on the Text, if they exist

Source

pub fn selections_mut(&mut self) -> Option<&mut Selections>

A mutable reference to the Selections, if they exist

Source

pub fn exists(&self) -> bool

Whether o not the File exists or not

Source

pub fn add_reader(&mut self, pa: &mut Pass, cfg: impl ReaderCfg<U>)

Adds a Reader to react to Text Changes

Source

pub fn get_reader<R: Reader<U>>(&self) -> Option<RwData<R>>

Gets a Reader

Trait Implementations§

Source§

impl<U: Ui> Widget<U> for File<U>

Source§

type Cfg = FileCfg

The configuration type
Source§

fn cfg() -> Self::Cfg

Returns a WidgetCfg, for use in layout construction Read more
Source§

fn update(pa: &mut Pass, handle: Handle<Self, U>)

Updates the widget, allowing the modification of its RawArea Read more
Source§

fn needs_update(&self) -> bool

Tells Duat that this Widget should be updated Read more
Source§

fn text(&self) -> &Text

The text that this widget prints out
Source§

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

A mutable reference to the Text that is printed
Source§

fn print_cfg(&self) -> PrintCfg

The configuration for how to print Text Read more
Source§

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

Prints the widget Read more
Source§

fn once() -> Result<(), Text>

Actions taken when this widget opens for the first time Read more
Source§

fn on_focus(pa: &mut Pass, handle: Handle<Self, U>)
where Self: Sized,

Actions to do whenever this Widget is focused
Source§

fn on_unfocus(pa: &mut Pass, handle: Handle<Self, U>)
where Self: Sized,

Actions to do whenever this Widget is unfocused

Auto Trait Implementations§

§

impl<U> Freeze for File<U>

§

impl<U> !RefUnwindSafe for File<U>

§

impl<U> !Send for File<U>

§

impl<U> !Sync for File<U>

§

impl<U> Unpin for File<U>
where U: Unpin,

§

impl<U> !UnwindSafe for File<U>

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>,

Source§

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>,

Source§

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.