/// This file is responsible for internal messages
/// Used to send internal flags and data transfer to trigger
/// Other instances of Message types.
use crate::features::search::SearchResult;
use iced_code_editor::LspOverlayMessage;
use iced_term::Event as TerminalEvent;
use std::path::PathBuf;

#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum Message {
    CodeEditorEvent(iced_code_editor::Message),

    LspOverlay(LspOverlayMessage),

    CodeEditorContentChanged,
    FileClicked(PathBuf),
    FileOpened(PathBuf, String),
    SensitiveFileOpenConfirm(bool),
    FolderToggled(PathBuf),

    FileTreeRefresh,
    ToggleSidebar,
    SetActivePanel(crate::app::ActivePanel),

    OpenFolderDialog,
    OpenFileOrFolder,
    FolderOpened(PathBuf),

    SaveFile,
    SaveCurrentFileAs(PathBuf),
    CurrentFileSavedAs(PathBuf),
    FileSaved(Result<(), String>),

    TabSelected(usize),
    TabClosed(usize),
    CloseActiveTab,

    SidebarResizeStart,
    SidebarResizing(f32),
    SidebarResizeEnd,

    PreviewMarkdown,
    MarkdownLinkClicked(iced::widget::markdown::Uri),

    ToggleSearch,
    SearchQueryChanged(String),
    SearchCompleted(Vec<SearchResult>),
    SearchResultClicked(PathBuf, usize),

    ToggleFileFinder,
    FileFinderQueryChanged(String),
    FileFinderSelect,
    FileFinderNavigate(i32),

    ToggleFuzzyFinder,
    FuzzyFinderQueryChanged(String),
    FuzzyFinderSelect,
    FuzzyFinderNavigate(i32),

    ToggleFullscreen(iced::window::Mode),
    EscapePressed,

    ToggleCommandPalette,
    CommandPaletteQueryChanged(String),
    CommandPaletteSelect(String),
    CommandPaletteNavigate(i32),

    TerminalEvent(TerminalEvent),
    ToggleTerminal,
    FocusEditor,
    FocusTerminal,

    ToggleFindReplace,
    FindQueryChanged(String),
    ReplaceQueryChanged(String),
    FindNext,
    FindPrev,
    ReplaceOne,
    ReplaceAll,
    ToggleCaseSensitive,

    ToggleSettings,
    SettingsNavigate(String),
    SettingsTabSizeChanged(String),
    SettingsToggleUseSpaces,
    SettingsToggleAutosave,
    SettingsAutosaveIntervalChanged(String),
    SettingsSavePreferences,
    SettingsSelectTheme(String),
    SettingsReloadTheme,
    SettingsLineNumberWidthChanged(String),
    SettingsToggleTabDragFloating,

    ToggleCommandInput,
    CommandInputChanged(String),
    CommandInputSubmit,
    WindowResized(u32, u32),

    NewFile,
    SaveAs,
    SelectTabByIndex(usize),
    TabHoverEnter(usize),
    TabHoverExit,
    TabDragInitiate,
    TabHoldTick,
    TabDragMove(f32),
    TabDragEnd,
    TabDragFloatMove(f32, f32),

    WakaTimeApiKeyChanged(String),
    WakaTimeApiKeyHoverStart,
    WakaTimeApiKeyHoverEnd,
    WakaTimeApiUrlChanged(String),
    SaveWakaTimeSettings,

    DismissNotification,
    ModifierStateChanged(iced::keyboard::Modifiers),
    LspTick,
    AutosaveTick,
    AutosaveFinished(PathBuf, String, Result<(), String>),

    #[cfg(feature = "unstable-comet")]
    ToggleDeveloperPanel,
    #[cfg(feature = "unstable-comet")]
    ClearDeveloperLogs,
    #[cfg(feature = "unstable-comet")]
    SettingsToggleDeveloperMode,
    ToggleLsp,

    StartupPageDone,
    StartupThemeSelected(String),
    StartupToggleVimMode,
    StartupToggleHelixMode,
    StartupToggleRunOnStartup,

    RefreshGitStatus,
    GitStatusLoaded(Vec<(String, String)>),

    CheckForUpdate,
    UpdateAvailable(crate::features::updater::UpdateInfo),
    DismissUpdateBanner,

    // all the ones below are related to media playback
    #[cfg(feature = "video")]
    VideoTogglePause,
    #[cfg(feature = "video")]
    VideoEndOfStream,
    #[cfg(feature = "video")]
    VideoNewFrame,
    AudioPlay,
    AudioPause,
    AudioStop,
    AudioSeek(f32),
    AudioTick,
}
