pub struct File<U: Ui> {
pub cfg: PrintCfg,
/* private fields */
}Expand description
The widget that is used to print and edit files
Fields§
§cfg: PrintCfgImplementations§
Source§impl<U: Ui> File<U>
impl<U: Ui> File<U>
Sourcepub fn save(&mut self) -> Result<Option<usize>, Text>
pub fn save(&mut self) -> Result<Option<usize>, Text>
Writes the file to the current PathBuf, if one was set
Sourcepub fn save_to(&self, path: impl AsRef<Path>) -> Result<Option<usize>>
pub fn save_to(&self, path: impl AsRef<Path>) -> Result<Option<usize>>
Writes the file to the given Path
Sourcepub fn path(&self) -> String
pub fn path(&self) -> String
The full path of the file.
If there is no set path, returns "*scratch file*#{id}".
Sourcepub fn path_set(&self) -> Option<String>
pub fn path_set(&self) -> Option<String>
The full path of the file.
Returns None if the path has not been set yet.
Sourcepub fn name(&self) -> String
pub fn name(&self) -> String
The file’s name.
If there is no set path, returns "*scratch file #{id}*".
Sourcepub fn name_set(&self) -> Option<String>
pub fn name_set(&self) -> Option<String>
The file’s name.
Returns None if the path has not been set yet.
Sourcepub fn printed_lines(&self) -> &[(usize, bool)]
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.
Sourcepub fn selections(&self) -> &Selections
pub fn selections(&self) -> &Selections
The Selections that are used on the Text, if they
exist
Sourcepub fn selections_mut(&mut self) -> &mut Selections
pub fn selections_mut(&mut self) -> &mut Selections
A mutable reference to the Selections, if they exist
Sourcepub fn read_parser<Rd: Parser<U>, Ret>(
&self,
read: impl FnOnce(&Rd) -> Ret,
) -> Option<Ret>
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.
Sourcepub fn try_read_parser<Rd: Parser<U>, Ret>(
&self,
read: impl FnOnce(&Rd) -> Ret,
) -> Option<Ret>
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.