2024-10-15 17:38:46 +01:00
|
|
|
mod config;
|
2024-09-06 00:39:10 +01:00
|
|
|
mod inner;
|
|
|
|
|
2024-09-30 22:48:22 +01:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
2024-09-06 00:39:10 +01:00
|
|
|
use ego_tree::Tree;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2024-10-15 17:38:46 +01:00
|
|
|
pub use config::Config;
|
2024-09-06 00:39:10 +01:00
|
|
|
pub use inner::get_tabs;
|
|
|
|
|
|
|
|
#[derive(Clone, Hash, Eq, PartialEq)]
|
|
|
|
pub enum Command {
|
|
|
|
Raw(String),
|
2024-09-22 17:50:43 +01:00
|
|
|
LocalFile {
|
|
|
|
executable: String,
|
|
|
|
args: Vec<String>,
|
|
|
|
// The file path is included within the arguments; don't pass this in addition
|
|
|
|
file: PathBuf,
|
|
|
|
},
|
2024-09-06 00:39:10 +01:00
|
|
|
None, // Directory
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Hash, Eq, PartialEq)]
|
|
|
|
pub struct Tab {
|
|
|
|
pub name: String,
|
2024-09-30 22:48:22 +01:00
|
|
|
pub tree: Tree<Rc<ListNode>>,
|
2024-09-19 19:15:30 +01:00
|
|
|
pub multi_selectable: bool,
|
2024-09-06 00:39:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Hash, Eq, PartialEq)]
|
|
|
|
pub struct ListNode {
|
|
|
|
pub name: String,
|
2024-09-19 01:17:08 +01:00
|
|
|
pub description: String,
|
2024-09-06 00:39:10 +01:00
|
|
|
pub command: Command,
|
2024-09-22 17:10:05 +01:00
|
|
|
pub task_list: String,
|
2024-09-06 00:39:10 +01:00
|
|
|
}
|
2024-10-15 17:38:46 +01:00
|
|
|
|
|
|
|
impl Tab {
|
|
|
|
pub fn find_command(&self, name: &str) -> Option<Rc<ListNode>> {
|
|
|
|
self.tree.root().descendants().find_map(|node| {
|
|
|
|
let value = node.value();
|
|
|
|
if value.name == name && !node.has_children() {
|
|
|
|
Some(value.clone())
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|