#[cfg(feature = "cursor-style")]
use crossterm::{cursor::SetCursorStyle, execute};
#[cfg(feature = "cursor-style")]
use std::io;
use crate::canvas::modes::AppMode;
pub struct CursorManager;
impl CursorManager {
#[cfg(feature = "cursor-style")]
pub fn update_for_mode(mode: AppMode) -> io::Result<()> {
#[cfg(feature = "textmode-normal")]
{
let style = SetCursorStyle::SteadyBar;
execute!(io::stdout(), style)
}
#[cfg(not(feature = "textmode-normal"))]
{
let style = match mode {
AppMode::Ins => SetCursorStyle::SteadyBar, AppMode::Nor => SetCursorStyle::SteadyBlock, AppMode::Sel => SetCursorStyle::BlinkingBlock, AppMode::General => SetCursorStyle::SteadyBlock, AppMode::Command => SetCursorStyle::SteadyUnderScore, };
return execute!(io::stdout(), style);
}
}
#[cfg(not(feature = "cursor-style"))]
pub fn update_for_mode(_mode: AppMode) -> io::Result<()> {
Ok(())
}
#[cfg(feature = "cursor-style")]
pub fn reset() -> io::Result<()> {
execute!(io::stdout(), SetCursorStyle::DefaultUserShape)
}
#[cfg(not(feature = "cursor-style"))]
pub fn reset() -> io::Result<()> {
Ok(())
}
}