From b2b3083a623ec3dc5e2d1ea9c6ba35970efe19a3 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 19 Oct 2020 16:20:59 +0900 Subject: Support multiple open views. --- helix-term/src/application.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 1e719f5f..9c90b6f3 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -354,7 +354,7 @@ impl Application { fn render(&mut self) { let viewport = Rect::new(OFFSET, 0, self.terminal.size.0, self.terminal.size.1 - 2); // - 2 for statusline and prompt - if let Some(view) = &mut self.editor.view { + if let Some(view) = self.editor.view_mut() { self.terminal.render_view(view, viewport); if let Some(prompt) = &self.prompt { if prompt.should_close { @@ -368,11 +368,8 @@ impl Application { self.terminal.draw(); // TODO: drop unwrap - self.terminal.render_cursor( - self.editor.view.as_ref().unwrap(), - self.prompt.as_ref(), - viewport, - ); + self.terminal + .render_cursor(self.editor.view().unwrap(), self.prompt.as_ref(), viewport); } pub async fn event_loop(&mut self) { @@ -392,7 +389,7 @@ impl Application { self.terminal.resize(width, height); // TODO: simplistic ensure cursor in view for now - if let Some(view) = &mut self.editor.view { + if let Some(view) = self.editor.view_mut() { view.size = self.terminal.size; view.ensure_cursor_in_view() }; @@ -408,7 +405,7 @@ impl Application { .handle_input(event, &mut self.editor); self.render(); - } else if let Some(view) = &mut self.editor.view { + } else if let Some(view) = self.editor.view_mut() { let keys = vec![event]; // TODO: sequences (`gg`) // TODO: handle count other than 1 -- cgit v1.2.3-70-g09d2