cursor fixed

This commit is contained in:
filipriec
2025-04-07 23:39:27 +02:00
parent 75cd942f39
commit a8eef8107b
4 changed files with 25 additions and 10 deletions

6
Cargo.lock generated
View File

@@ -421,7 +421,7 @@ dependencies = [
[[package]] [[package]]
name = "client" name = "client"
version = "0.3.0" version = "0.3.3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"common", "common",
@@ -458,7 +458,7 @@ dependencies = [
[[package]] [[package]]
name = "common" name = "common"
version = "0.3.0" version = "0.3.3"
dependencies = [ dependencies = [
"prost", "prost",
"serde", "serde",
@@ -2589,7 +2589,7 @@ dependencies = [
[[package]] [[package]]
name = "server" name = "server"
version = "0.3.0" version = "0.3.3"
dependencies = [ dependencies = [
"bcrypt", "bcrypt",
"chrono", "chrono",

View File

@@ -5,7 +5,7 @@ resolver = "2"
[workspace.package] [workspace.package]
# TODO: idk how to do the name, fix later # TODO: idk how to do the name, fix later
# name = "Multieko2" # name = "Multieko2"
version = "0.3.0" version = "0.3.3"
edition = "2021" edition = "2021"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
authors = ["Filip Priečinský <filippriec@gmail.com>"] authors = ["Filip Priečinský <filippriec@gmail.com>"]

View File

@@ -3,7 +3,7 @@
use crossterm::{ use crossterm::{
execute, execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
cursor::{SetCursorStyle, EnableBlinking, Show, MoveTo}, cursor::{SetCursorStyle, EnableBlinking, Show, Hide, MoveTo},
}; };
use ratatui::{backend::CrosstermBackend, Terminal}; use ratatui::{backend::CrosstermBackend, Terminal};
use std::io::{self, stdout, Write}; use std::io::{self, stdout, Write};
@@ -72,6 +72,14 @@ impl TerminalCore {
)?; )?;
Ok(()) Ok(())
} }
pub fn hide_cursor(&mut self) -> Result<(), Box<dyn std::error::Error>> {
execute!(
self.terminal.backend_mut(),
Hide
)?;
Ok(())
}
} }
impl Drop for TerminalCore { impl Drop for TerminalCore {

View File

@@ -75,14 +75,21 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
if !app_state.ui.focus_outside_canvas { if !app_state.ui.focus_outside_canvas {
terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?; terminal.set_cursor_style(SetCursorStyle::SteadyBlock)?;
} else { } else {
terminal terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
} }
terminal.show_cursor()?; // Ensure visible terminal.show_cursor()?;
} }
AppMode::General | AppMode::Command => { AppMode::General => {
if app_state.ui.focus_outside_canvas {
terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
terminal.show_cursor()?;
} else {
terminal.hide_cursor()?;
}
}
AppMode::Command => {
terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?; terminal.set_cursor_style(SetCursorStyle::SteadyUnderScore)?;
terminal.show_cursor()?; // Ensure visible (though might not be positioned meaningfully) terminal.show_cursor()?;
} }
} }
// --- End Cursor Visibility Logic --- // --- End Cursor Visibility Logic ---