convert all def_command! to #[commands]
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
i do not exist 2026-08-10 12:11:17 +03:00
parent 7fcab73b04
commit 62f30daac6
6 changed files with 295 additions and 195 deletions

View file

@ -19,8 +19,8 @@ impl Browse {
todo!()
}
/// Set current directory
#[command(SetPath = "set-path")]
fn set_path (&mut self, _path: PathBuf) -> Perhaps<BrowseCommand> {
#[command(Chdir = "chdir")]
fn chdir (&mut self, _path: PathBuf) -> Perhaps<BrowseCommand> {
todo!()
}
/// Set current filter
@ -35,15 +35,6 @@ impl Browse {
}
}
def_command!(FileBrowserCommand: |_browse: Browse|{
//("begin" [] Some(Self::Begin))
//("cancel" [] Some(Self::Cancel))
//("confirm" [] Some(Self::Confirm))
//("select" [i: usize] Some(Self::Select(i.expect("no index"))))
//("chdir" [p: PathBuf] Some(Self::Chdir(p.expect("no path"))))
//("filter" [f: Arc<str>] Some(Self::Filter(f.expect("no filter")))))
});
/// Browses for files to load/save.
///
/// ```
@ -104,7 +95,7 @@ impl Browse {
}
Ok(Self { cwd, dirs, files, ..Default::default() })
}
pub fn chdir (&self) -> Usually<Self> { Self::new(Some(self.path())) }
pub fn to_chdir (&self) -> Usually<Self> { Self::new(Some(self.path())) }
pub fn len (&self) -> usize { self.dirs.len() + self.files.len() }
pub fn is_dir (&self) -> bool { self.index < self.dirs.len() }
pub fn is_file (&self) -> bool { self.index >= self.dirs.len() }