on master help sign in
This term specific behavior really doesn't belong to compositor
00d7b18Blaž Hrastnik
helix-term/src/application.rs+14−2
@@ -395,7 +395,6 @@ impl Application {
395 use helix_view::graphics::Rect;
395 use helix_view::graphics::Rect;
396 match signal {
396 match signal {
397 signal::SIGTSTP => {
397 signal::SIGTSTP => {
398− self.compositor.save_cursor();
399 restore_term().unwrap();
398 restore_term().unwrap();
400 low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
399 low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
401 }
400 }
@@ -404,7 +403,6 @@ impl Application {
404 // redraw the terminal
403 // redraw the terminal
405 let Rect { width, height, .. } = self.compositor.size();
404 let Rect { width, height, .. } = self.compositor.size();
406 self.compositor.resize(width, height);
405 self.compositor.resize(width, height);
407− self.compositor.load_cursor();
408 self.render();
406 self.render();
409 }
407 }
410 signal::SIGUSR1 => {
408 signal::SIGUSR1 => {
@@ -924,7 +922,12 @@ impl Application {
924 }
922 }
925
923
926 async fn claim_term(&mut self) -> Result<(), Error> {
924 async fn claim_term(&mut self) -> Result<(), Error> {
925+ use helix_view::graphics::CursorKind;
926+ use tui::backend::Backend;
927 terminal::enable_raw_mode()?;
927 terminal::enable_raw_mode()?;
928+ if self.compositor.terminal.cursor_kind() == CursorKind::Hidden {
929+ self.compositor.terminal.backend_mut().hide_cursor().ok();
930+ }
928 let mut stdout = stdout();
931 let mut stdout = stdout();
929 execute!(
932 execute!(
930 stdout,
933 stdout,
@@ -958,6 +961,15 @@ impl Application {
958 self.event_loop(input_stream).await;
961 self.event_loop(input_stream).await;
959
962
960 let close_errs = self.close().await;
963 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+
961 restore_term()?;
973 restore_term()?;
962
974
963 for err in close_errs {
975 for err in close_errs {
helix-term/src/compositor.rs+1−17
@@ -76,7 +76,6 @@ pub trait Component: Any + AnyComponent {
76}
76}
77
77
78use anyhow::Context as AnyhowContext;
78use anyhow::Context as AnyhowContext;
79−use tui::backend::Backend;
80
79
81#[cfg(not(feature = "integration"))]
80#[cfg(not(feature = "integration"))]
82use tui::backend::CrosstermBackend;
81use tui::backend::CrosstermBackend;
@@ -92,7 +91,7 @@ type Terminal = tui::terminal::Terminal<TestBackend>;
92
91
93pub struct Compositor {
92pub struct Compositor {
94 layers: Vec<Box<dyn Component>>,
93 layers: Vec<Box<dyn Component>>,
95− terminal: Terminal,
94+ pub terminal: Terminal,
96 area: Rect,
95 area: Rect,
97
96
98 pub(crate) last_picker: Option<Box<dyn Component>>,
97 pub(crate) last_picker: Option<Box<dyn Component>>,
@@ -128,21 +127,6 @@ impl Compositor {
128 self.area = self.terminal.size().expect("couldn't get terminal size");
127 self.area = self.terminal.size().expect("couldn't get terminal size");
129 }
128 }
130
129
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−
146 pub fn push(&mut self, mut layer: Box<dyn Component>) {
130 pub fn push(&mut self, mut layer: Box<dyn Component>) {
147 let size = self.size();
131 let size = self.size();
148 // trigger required_size on init
132 // trigger required_size on init