mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-07 01:56:45 +01:00
emit tasks for columns
This commit is contained in:
parent
e16e8131aa
commit
59c2fdcbcd
6 changed files with 79 additions and 55 deletions
|
|
@ -38,14 +38,14 @@ macro_rules! setter {
|
|||
value: &str
|
||||
) {
|
||||
if let Some(entries) = entries_under(&mut state.entries, index) {
|
||||
for entry in entries.iter() {
|
||||
if let Some(task) = entry.write().unwrap().$name(&value) {
|
||||
state.tasks.push(task);
|
||||
for (path, entry) in entries.into_iter() {
|
||||
if let Some(item) = entry.write().unwrap().$name(&value) {
|
||||
state.tasks.push(Task { path, item, });
|
||||
};
|
||||
}
|
||||
} else if let Some(entry) = state.entries.get_mut(index) {
|
||||
if let Some(task) = entry.$name(&value) {
|
||||
state.tasks.push(task);
|
||||
if let Some(item) = entry.$name(&value) {
|
||||
state.tasks.push(Task { path: entry.path.clone(), item, });
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -53,8 +53,37 @@ macro_rules! setter {
|
|||
}}
|
||||
}
|
||||
|
||||
pub(crate) fn entries_under (
|
||||
entries: &mut [Entry],
|
||||
index: usize
|
||||
) -> Option<Vec<(Arc<PathBuf>, Arc<RwLock<Metadata>>)>> {
|
||||
let path = if let Some(Entry { path, info, .. }) = entries.get(index)
|
||||
&& let Metadata::Directory { .. } = &*info.read().unwrap()
|
||||
{
|
||||
Some(path.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some(path) = path {
|
||||
let mut others = vec![];
|
||||
for other in entries.iter_mut() {
|
||||
if other.path.starts_with(path.as_ref()) && !other.is_directory() {
|
||||
others.push((other.path.clone(), other.info.clone()));
|
||||
}
|
||||
}
|
||||
Some(others)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Columns<G, S>(pub Vec<Column<G, S>>);
|
||||
|
||||
impl<G, S> Columns<G, S> {
|
||||
const SCROLL_LEFT: &'static str = "❮";
|
||||
const SCROLL_RIGHT: &'static str = "❯";
|
||||
}
|
||||
|
||||
impl Default for Columns<fn(&Entry)->Option<Arc<str>>, fn(&mut Taggart, usize, &str)> {
|
||||
fn default () -> Self {
|
||||
Self(vec![
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue