ratatui_toolkit/widgets/file_system_tree/
mod.rs

1//! File system tree browser component
2//!
3//! Provides a tree view for browsing file system directories.
4
5pub mod constructors;
6pub mod methods;
7pub mod traits;
8
9use std::path::PathBuf;
10
11use crate::primitives::tree_view::TreeNode;
12
13use ratatui::style::Style;
14use ratatui::widgets::Block;
15
16/// Represents a file system entry (file or directory)
17#[derive(Debug, Clone)]
18pub struct FileSystemEntry {
19    /// Name of the file/directory
20    pub name: String,
21    /// Full path
22    pub path: PathBuf,
23    /// Whether this is a directory
24    pub is_dir: bool,
25    /// Whether this entry is hidden (starts with .)
26    pub is_hidden: bool,
27}
28
29/// Configuration for the file system tree
30#[derive(Debug, Clone, Copy)]
31pub struct FileSystemTreeConfig {
32    /// Show hidden files (starting with .)
33    pub show_hidden: bool,
34    /// Use dark theme for icons (true = dark, false = light)
35    pub use_dark_theme: bool,
36    /// Style for directories
37    pub dir_style: Style,
38    /// Style for files
39    pub file_style: Style,
40    /// Style for selected items
41    pub selected_style: Style,
42}
43
44/// File system tree browser widget
45#[derive(Clone)]
46pub struct FileSystemTree<'a> {
47    /// Root directory to browse
48    pub root_path: PathBuf,
49    /// Tree nodes built from file system
50    pub nodes: Vec<TreeNode<FileSystemEntry>>,
51    /// Configuration
52    pub(crate) config: FileSystemTreeConfig,
53    /// Optional block wrapper
54    block: Option<Block<'a>>,
55}