File

Struct File 

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

The widget that is used to print and edit files

Fields§

§cfg: PrintCfg

The PrintCfg of this File

Implementations§

Source§

impl<U: Ui> File<U>

Source

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

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

Source

pub fn save_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 bytes(&self) -> &Bytes

The Bytes of the File’s Text

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) -> &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 read_parser<Rd: Parser<U>, Ret>( &self, read: impl FnOnce(&Rd) -> Ret, ) -> Option<Ret>

Reads a specific Parser, if it was added

If the Parser was sent to another thread, this function will block until it returns to this thread. If you don’t wish for this behaviour, see File::try_read_parser.

This function will also update the Parsers with the latest changes that happened in the File, keeping state consistent even as you are actively updating it within the same scope. Do note that a Parser that was in this thread, could be sent to another thread because of this.

Source

pub fn try_read_parser<Rd: Parser<U>, Ret>( &self, read: impl FnOnce(&Rd) -> Ret, ) -> Option<Ret>

Tries tor read a specific Parser, if it was added

Not only does it not trigger if the Parser doesn’t exist, also will not trigger if it was sent to another thread, and isn’t ready to be brought back. If you wish to wait for the

This function will also update the Parsers with the latest changes that happened in the File, keeping state consistent even as you are actively updating it within the same scope. Do note that a Parser that was in this thread, could be sent to another thread because of this.

Trait Implementations§

Source§

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

Source§

type Cfg = FileCfg<U>

The configuration type Read more
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 Area Read more
Source§

fn needs_update(&self, _: &Pass) -> 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 Read more
Source§

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

Actions to do whenever this Widget is unfocused Read more

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.