pub struct Flagged {
pub content: Vec<PathBuf>,
pub index: usize,
}Expand description
The flagged files and an index, allowing navigation when the flagged files are displayed. We record here every flagged file by its path, allowing deletion, renaming, copying, moving and other actions.
Fields§
§content: Vec<PathBuf>Contains the different flagged files.
It’s basically a Set (of whatever kind) and insertion would be faster
using a set.
Iteration is faster with a vector and we need a vector to use the common trait
SelectableContent which can be implemented with a macro.
We use binary search in every non standard method (insertion, removal, search).
index: usizeThe index of the selected file. Used to jump.
Implementations§
Source§impl Flagged
impl Flagged
pub fn update(&mut self, content: Vec<PathBuf>)
pub fn extend(&mut self, content: Vec<PathBuf>)
pub fn clear(&mut self)
pub fn remove_selected(&mut self)
Sourcepub fn push(&mut self, path: PathBuf)
pub fn push(&mut self, path: PathBuf)
Push a new path into the content.
We maintain the content sorted and it’s used to make contains faster.
Sourcepub fn toggle(&mut self, path: &Path)
pub fn toggle(&mut self, path: &Path)
Toggle the flagged status of a path. Remove the path from the content if it’s flagged, flag it if it’s not. The implantation assumes the content to be sorted.
Sourcepub fn contains(&self, path: &Path) -> bool
pub fn contains(&self, path: &Path) -> bool
True if the path is flagged.
Since we maintain the content sorted, we can use a binary search and
compensate a little bit with using a vector instead of a set.
Sourcepub fn in_dir(&self, dir: &Path) -> Vec<PathBuf>
pub fn in_dir(&self, dir: &Path) -> Vec<PathBuf>
Returns a vector of path which are present in the current directory but ARE NOT the current dir. This prevents the current directory (or root path in tree display mode) to be altered by bulk.
Sourcepub fn content_to_string(&self) -> String
pub fn content_to_string(&self) -> String
Returns a string with every path in content on a separate line.
pub fn replace_by_string(&mut self, files: String)
Sourcepub fn as_strings(&self) -> Vec<String>
pub fn as_strings(&self) -> Vec<String>
Returns the flagged files as a vector of strings
pub fn should_all_be_opened_in_neovim(&self) -> bool
Sourcepub fn remove_non_existant(&mut self)
pub fn remove_non_existant(&mut self)
Remove all files from flagged which doesn’t exists.
Trait Implementations§
Source§impl Content<PathBuf> for Flagged
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: selected, content, push, style.
selected returns an optional reference to the value.
impl Content<PathBuf> for Flagged
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: selected, content, push, style.
selected returns an optional reference to the value.
Source§impl Selectable for Flagged
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: is_empty, len, next, prev, set_index and selected_is_last.
impl Selectable for Flagged
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: is_empty, len, next, prev, set_index and selected_is_last.
Auto Trait Implementations§
impl Freeze for Flagged
impl RefUnwindSafe for Flagged
impl Send for Flagged
impl Sync for Flagged
impl Unpin for Flagged
impl UnwindSafe for Flagged
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more