fast-fs 0.2.1

High-speed async file system traversal library with batteries-included file browser component
Documentation
// <FILE>crates/fast-fs/src/nav/action.rs</FILE> - <DESC>User action enum</DESC>
// <VERS>VERSION: 0.2.0</VERS>
// <WCTX>Adding range selection and clipboard support</WCTX>
// <CLOG>Added MoveUpExtend, MoveDownExtend, Cut, Copy actions</CLOG>

//! User actions
//!
//! Actions are decoupled from keys, allowing configurable key bindings.
//! Each action represents a user intent that the browser can execute.

/// User actions that can be performed in the browser
///
/// Actions are mapped to keys via `KeyMap`. This decoupling allows
/// users to customize key bindings without modifying behavior.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Action {
    // Navigation
    /// Move cursor up one item
    MoveUp,
    /// Move cursor down one item
    MoveDown,
    /// Move cursor to first item
    MoveToTop,
    /// Move cursor to last item
    MoveToBottom,
    /// Move cursor up one page
    PageUp,
    /// Move cursor down one page
    PageDown,
    /// Enter directory or select file
    Enter,
    /// Go to parent directory
    GoParent,
    /// Navigate back in history
    GoBack,
    /// Navigate forward in history
    GoForward,

    // Selection
    /// Toggle selection of current item
    ToggleSelect,
    /// Select all visible items
    SelectAll,
    /// Clear all selections
    ClearSelection,
    /// Move up and extend selection (Shift+Up)
    MoveUpExtend,
    /// Move down and extend selection (Shift+Down)
    MoveDownExtend,

    // Clipboard (library tracks intent, caller handles actual clipboard)
    /// Cut selected items to clipboard
    Cut,
    /// Copy selected items to clipboard
    Copy,

    // Operations (ignored in readonly mode)
    /// Delete selected or current item(s)
    Delete,
    /// Rename current item
    Rename,
    /// Create new directory
    CreateDir,
    /// Create new file
    CreateFile,

    // View
    /// Toggle hidden file visibility
    ToggleHidden,
    /// Cycle through sort modes
    CycleSort,
    /// Reload current directory
    Refresh,

    // Search & Filter
    /// Enter filter mode
    StartFilter,
    /// Clear active filter
    ClearFilter,

    // Path Input
    /// Enter path input mode
    StartPathInput,
}

impl Action {
    /// Check if this action modifies the filesystem
    pub fn is_mutation(&self) -> bool {
        matches!(
            self,
            Action::Delete | Action::Rename | Action::CreateDir | Action::CreateFile
        )
    }

    /// Check if this action navigates to a different directory
    pub fn is_navigation(&self) -> bool {
        matches!(
            self,
            Action::Enter | Action::GoParent | Action::GoBack | Action::GoForward
        )
    }

    /// Check if this action modifies selection
    pub fn is_selection(&self) -> bool {
        matches!(
            self,
            Action::ToggleSelect
                | Action::SelectAll
                | Action::ClearSelection
                | Action::MoveUpExtend
                | Action::MoveDownExtend
        )
    }

    /// Check if this action is a clipboard operation
    pub fn is_clipboard(&self) -> bool {
        matches!(self, Action::Cut | Action::Copy)
    }

    /// Get a human-readable description of the action
    pub fn description(&self) -> &'static str {
        match self {
            Action::MoveUp => "Move up",
            Action::MoveDown => "Move down",
            Action::MoveToTop => "Move to top",
            Action::MoveToBottom => "Move to bottom",
            Action::PageUp => "Page up",
            Action::PageDown => "Page down",
            Action::Enter => "Enter/Select",
            Action::GoParent => "Go to parent",
            Action::GoBack => "Go back",
            Action::GoForward => "Go forward",
            Action::ToggleSelect => "Toggle selection",
            Action::SelectAll => "Select all",
            Action::ClearSelection => "Clear selection",
            Action::MoveUpExtend => "Extend selection up",
            Action::MoveDownExtend => "Extend selection down",
            Action::Cut => "Cut",
            Action::Copy => "Copy",
            Action::Delete => "Delete",
            Action::Rename => "Rename",
            Action::CreateDir => "Create directory",
            Action::CreateFile => "Create file",
            Action::ToggleHidden => "Toggle hidden files",
            Action::CycleSort => "Cycle sort mode",
            Action::Refresh => "Refresh",
            Action::StartFilter => "Start filter",
            Action::ClearFilter => "Clear filter",
            Action::StartPathInput => "Enter path",
        }
    }
}

// <FILE>crates/fast-fs/src/nav/action.rs</FILE>
// <VERS>END OF VERSION: 0.2.0</VERS>