on master help sign in
This term specific behavior really doesn't belong to compositor
commit00d7b1809714b82f24542f5b9099649e10d5a0b5 authorBlaž Hrastnik <blaz@mxxn.io> dateTue 29 Mar 2022, 10:01 (5 years ago) parentb2e7171
2 files changed+15−19
helix-term/src/application.rs+14−2 helix-term/src/compositor.rs+1−17
helix-term/src/application.rs+14−2
@@ -395,7 +395,6 @@ impl Application {
395395 use helix_view::graphics::Rect;
396396 match signal {
397397 signal::SIGTSTP => {
398− self.compositor.save_cursor();
399398 restore_term().unwrap();
400399 low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
401400 }
@@ -404,7 +403,6 @@ impl Application {
404403 // redraw the terminal
405404 let Rect { width, height, .. } = self.compositor.size();
406405 self.compositor.resize(width, height);
407− self.compositor.load_cursor();
408406 self.render();
409407 }
410408 signal::SIGUSR1 => {
@@ -924,7 +922,12 @@ impl Application {
924922 }
925923
926924 async fn claim_term(&mut self) -> Result<(), Error> {
925+ use helix_view::graphics::CursorKind;
926+ use tui::backend::Backend;
927927 terminal::enable_raw_mode()?;
928+ if self.compositor.terminal.cursor_kind() == CursorKind::Hidden {
929+ self.compositor.terminal.backend_mut().hide_cursor().ok();
930+ }
928931 let mut stdout = stdout();
929932 execute!(
930933 stdout,
@@ -958,6 +961,15 @@ impl Application {
958961 self.event_loop(input_stream).await;
959962
960963 let close_errs = self.close().await;
964+
965+ use helix_view::graphics::CursorKind;
966+ use tui::backend::Backend;
967+ self.compositor
968+ .terminal
969+ .backend_mut()
970+ .show_cursor(CursorKind::Block)
971+ .ok();
972+
961973 restore_term()?;
962974
963975 for err in close_errs {
helix-term/src/compositor.rs+1−17
@@ -76,7 +76,6 @@ pub trait Component: Any + AnyComponent {
7676}
7777
7878use anyhow::Context as AnyhowContext;
79−use tui::backend::Backend;
8079
8180#[cfg(not(feature = "integration"))]
8281use tui::backend::CrosstermBackend;
@@ -92,7 +91,7 @@ type Terminal = tui::terminal::Terminal<TestBackend>;
9291
9392pub struct Compositor {
9493 layers: Vec<Box<dyn Component>>,
95− terminal: Terminal,
94+ pub terminal: Terminal,
9695 area: Rect,
9796
9897 pub(crate) last_picker: Option<Box<dyn Component>>,
@@ -128,21 +127,6 @@ impl Compositor {
128127 self.area = self.terminal.size().expect("couldn't get terminal size");
129128 }
130129
131− pub fn save_cursor(&mut self) {
132− if self.terminal.cursor_kind() == CursorKind::Hidden {
133− self.terminal
134− .backend_mut()
135− .show_cursor(CursorKind::Block)
136− .ok();
137− }
138− }
139−
140− pub fn load_cursor(&mut self) {
141− if self.terminal.cursor_kind() == CursorKind::Hidden {
142− self.terminal.backend_mut().hide_cursor().ok();
143− }
144− }
145−
146130 pub fn push(&mut self, mut layer: Box<dyn Component>) {
147131 let size = self.size();
148132 // trigger required_size on init