refactor: enable_mouse_capture() moved into Ui struct
This commit is contained in:
@@ -19,7 +19,7 @@ use crate::{
|
|||||||
app_data::{AppData, DockerControls, Header},
|
app_data::{AppData, DockerControls, Header},
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
docker_data::DockerMessage,
|
docker_data::DockerMessage,
|
||||||
ui::{enable_mouse_capture, GuiState, SelectablePanel, Status},
|
ui::{GuiState, SelectablePanel, Status, Ui},
|
||||||
};
|
};
|
||||||
pub use message::InputMessages;
|
pub use message::InputMessages;
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ impl InputHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
enable_mouse_capture();
|
Ui::enable_mouse_capture();
|
||||||
self.gui_state
|
self.gui_state
|
||||||
.lock()
|
.lock()
|
||||||
.set_info_box("✓ mouse capture enabled".to_owned());
|
.set_info_box("✓ mouse capture enabled".to_owned());
|
||||||
|
|||||||
+15
-15
@@ -41,21 +41,21 @@ pub struct Ui {
|
|||||||
terminal: Terminal<CrosstermBackend<Stdout>>,
|
terminal: Terminal<CrosstermBackend<Stdout>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enable mouse capture, but don't enable all the mouse movements, which improves performance, and is part of the fix for the weird mouse event output bug
|
|
||||||
pub fn enable_mouse_capture() {
|
|
||||||
io::stdout()
|
|
||||||
.write_all(
|
|
||||||
concat!(
|
|
||||||
crossterm::csi!("?1000h"),
|
|
||||||
crossterm::csi!("?1015h"),
|
|
||||||
crossterm::csi!("?1006h"),
|
|
||||||
)
|
|
||||||
.as_bytes(),
|
|
||||||
)
|
|
||||||
.unwrap_or(());
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Ui {
|
impl Ui {
|
||||||
|
/// Enable mouse capture, but don't enable all the mouse movements, which improves performance, and is part of the fix for the weird mouse event output bug
|
||||||
|
pub fn enable_mouse_capture() {
|
||||||
|
io::stdout()
|
||||||
|
.write_all(
|
||||||
|
concat!(
|
||||||
|
crossterm::csi!("?1000h"),
|
||||||
|
crossterm::csi!("?1015h"),
|
||||||
|
crossterm::csi!("?1006h"),
|
||||||
|
)
|
||||||
|
.as_bytes(),
|
||||||
|
)
|
||||||
|
.unwrap_or(());
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a new Ui struct, and execute the drawing loop
|
/// Create a new Ui struct, and execute the drawing loop
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
app_data: Arc<Mutex<AppData>>,
|
app_data: Arc<Mutex<AppData>>,
|
||||||
@@ -91,7 +91,7 @@ impl Ui {
|
|||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
execute!(stdout, EnterAlternateScreen)?;
|
execute!(stdout, EnterAlternateScreen)?;
|
||||||
enable_mouse_capture();
|
Self::enable_mouse_capture();
|
||||||
let backend = CrosstermBackend::new(stdout);
|
let backend = CrosstermBackend::new(stdout);
|
||||||
Terminal::new(backend)
|
Terminal::new(backend)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user