This term specific behavior really doesn't belong to compositor

pull/1/head
Blaž Hrastnik 2 years ago
parent b2e7171fed
commit 00d7b18097
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -395,7 +395,6 @@ impl Application {
use helix_view::graphics::Rect;
match signal {
signal::SIGTSTP => {
self.compositor.save_cursor();
restore_term().unwrap();
low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
}
@ -404,7 +403,6 @@ impl Application {
// redraw the terminal
let Rect { width, height, .. } = self.compositor.size();
self.compositor.resize(width, height);
self.compositor.load_cursor();
self.render();
}
signal::SIGUSR1 => {
@ -924,7 +922,12 @@ impl Application {
}
async fn claim_term(&mut self) -> Result<(), Error> {
use helix_view::graphics::CursorKind;
use tui::backend::Backend;
terminal::enable_raw_mode()?;
if self.compositor.terminal.cursor_kind() == CursorKind::Hidden {
self.compositor.terminal.backend_mut().hide_cursor().ok();
}
let mut stdout = stdout();
execute!(
stdout,
@ -958,6 +961,15 @@ impl Application {
self.event_loop(input_stream).await;
let close_errs = self.close().await;
use helix_view::graphics::CursorKind;
use tui::backend::Backend;
self.compositor
.terminal
.backend_mut()
.show_cursor(CursorKind::Block)
.ok();
restore_term()?;
for err in close_errs {

@ -76,7 +76,6 @@ pub trait Component: Any + AnyComponent {
}
use anyhow::Context as AnyhowContext;
use tui::backend::Backend;
#[cfg(not(feature = "integration"))]
use tui::backend::CrosstermBackend;
@ -92,7 +91,7 @@ type Terminal = tui::terminal::Terminal<TestBackend>;
pub struct Compositor {
layers: Vec<Box<dyn Component>>,
terminal: Terminal,
pub terminal: Terminal,
area: Rect,
pub(crate) last_picker: Option<Box<dyn Component>>,
@ -128,21 +127,6 @@ impl Compositor {
self.area = self.terminal.size().expect("couldn't get terminal size");
}
pub fn save_cursor(&mut self) {
if self.terminal.cursor_kind() == CursorKind::Hidden {
self.terminal
.backend_mut()
.show_cursor(CursorKind::Block)
.ok();
}
}
pub fn load_cursor(&mut self) {
if self.terminal.cursor_kind() == CursorKind::Hidden {
self.terminal.backend_mut().hide_cursor().ok();
}
}
pub fn push(&mut self, mut layer: Box<dyn Component>) {
let size = self.size();
// trigger required_size on init

Loading…
Cancel
Save