mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-20 05:57:06 +04:00
This term specific behavior really doesn't belong to compositor
This commit is contained in:
parent
b2e7171fed
commit
00d7b18097
@ -395,7 +395,6 @@ pub async fn handle_signals(&mut self, signal: i32) {
|
|||||||
use helix_view::graphics::Rect;
|
use helix_view::graphics::Rect;
|
||||||
match signal {
|
match signal {
|
||||||
signal::SIGTSTP => {
|
signal::SIGTSTP => {
|
||||||
self.compositor.save_cursor();
|
|
||||||
restore_term().unwrap();
|
restore_term().unwrap();
|
||||||
low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
|
low_level::emulate_default_handler(signal::SIGTSTP).unwrap();
|
||||||
}
|
}
|
||||||
@ -404,7 +403,6 @@ pub async fn handle_signals(&mut self, signal: i32) {
|
|||||||
// redraw the terminal
|
// redraw the terminal
|
||||||
let Rect { width, height, .. } = self.compositor.size();
|
let Rect { width, height, .. } = self.compositor.size();
|
||||||
self.compositor.resize(width, height);
|
self.compositor.resize(width, height);
|
||||||
self.compositor.load_cursor();
|
|
||||||
self.render();
|
self.render();
|
||||||
}
|
}
|
||||||
signal::SIGUSR1 => {
|
signal::SIGUSR1 => {
|
||||||
@ -924,7 +922,12 @@ pub async fn handle_language_server_message(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn claim_term(&mut self) -> Result<(), Error> {
|
async fn claim_term(&mut self) -> Result<(), Error> {
|
||||||
|
use helix_view::graphics::CursorKind;
|
||||||
|
use tui::backend::Backend;
|
||||||
terminal::enable_raw_mode()?;
|
terminal::enable_raw_mode()?;
|
||||||
|
if self.compositor.terminal.cursor_kind() == CursorKind::Hidden {
|
||||||
|
self.compositor.terminal.backend_mut().hide_cursor().ok();
|
||||||
|
}
|
||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
execute!(
|
execute!(
|
||||||
stdout,
|
stdout,
|
||||||
@ -958,6 +961,15 @@ pub async fn run<S>(&mut self, input_stream: &mut S) -> Result<i32, Error>
|
|||||||
self.event_loop(input_stream).await;
|
self.event_loop(input_stream).await;
|
||||||
|
|
||||||
let close_errs = self.close().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()?;
|
restore_term()?;
|
||||||
|
|
||||||
for err in close_errs {
|
for err in close_errs {
|
||||||
|
@ -76,7 +76,6 @@ fn id(&self) -> Option<&'static str> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
use anyhow::Context as AnyhowContext;
|
use anyhow::Context as AnyhowContext;
|
||||||
use tui::backend::Backend;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "integration"))]
|
#[cfg(not(feature = "integration"))]
|
||||||
use tui::backend::CrosstermBackend;
|
use tui::backend::CrosstermBackend;
|
||||||
@ -92,7 +91,7 @@ fn id(&self) -> Option<&'static str> {
|
|||||||
|
|
||||||
pub struct Compositor {
|
pub struct Compositor {
|
||||||
layers: Vec<Box<dyn Component>>,
|
layers: Vec<Box<dyn Component>>,
|
||||||
terminal: Terminal,
|
pub terminal: Terminal,
|
||||||
area: Rect,
|
area: Rect,
|
||||||
|
|
||||||
pub(crate) last_picker: Option<Box<dyn Component>>,
|
pub(crate) last_picker: Option<Box<dyn Component>>,
|
||||||
@ -128,21 +127,6 @@ pub fn resize(&mut self, width: u16, height: u16) {
|
|||||||
self.area = self.terminal.size().expect("couldn't get terminal size");
|
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>) {
|
pub fn push(&mut self, mut layer: Box<dyn Component>) {
|
||||||
let size = self.size();
|
let size = self.size();
|
||||||
// trigger required_size on init
|
// trigger required_size on init
|
||||||
|
Loading…
Reference in New Issue
Block a user