mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
wip: basic editing
This commit is contained in:
parent
b13ce4f0d0
commit
5336ee358a
4 changed files with 90 additions and 57 deletions
34
src/main.rs
34
src/main.rs
|
|
@ -41,37 +41,3 @@ fn main () -> Usually<()> {
|
|||
let state = Arc::new(RwLock::new(Taggart::new(&path)?));
|
||||
Tui::new()?.run(&state)
|
||||
}
|
||||
|
||||
impl Taggart {
|
||||
|
||||
fn new (root: &impl AsRef<Path>) -> Usually<Self> {
|
||||
Ok(Self {
|
||||
_root: root.as_ref().into(),
|
||||
paths: Self::collect(root)?,
|
||||
cursor: 0,
|
||||
offset: 0,
|
||||
column: 0,
|
||||
size: Measure::new(),
|
||||
editing: None,
|
||||
columns: Columns::default(),
|
||||
})
|
||||
}
|
||||
|
||||
fn collect (root: &impl AsRef<Path>) -> Usually<Vec<Entry>> {
|
||||
let mut paths = vec![];
|
||||
for entry in WalkDir::new(&root).into_iter()
|
||||
.filter_entry(|e|!e.file_name().to_str().map(|s|s.starts_with(".")).unwrap_or(false))
|
||||
{
|
||||
let entry = entry?;
|
||||
if entry.depth() == 0 {
|
||||
continue
|
||||
}
|
||||
if let Some(entry) = Entry::new(root, &entry)? {
|
||||
paths.push(entry);
|
||||
}
|
||||
}
|
||||
paths.sort();
|
||||
Ok(paths)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue