(&mut self, terminal: &mut Terminal<B>)
| 93 | } |
| 94 | |
| 95 | pub async fn run<B: Backend>(&mut self, terminal: &mut Terminal<B>) -> Result<()> { |
| 96 | const STATUS_TIMEOUT: Duration = Duration::from_secs(4); |
| 97 | const FRAME_BUDGET: Duration = Duration::from_millis(16); |
| 98 | |
| 99 | loop { |
| 100 | if let Some(t) = self.status_msg_time { |
| 101 | if t.elapsed() >= STATUS_TIMEOUT { |
| 102 | self.status_msg.clear(); |
| 103 | self.status_msg_time = None; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | self.term.poll_completed(); |
| 108 | self.lsp.poll_messages(); |
| 109 | for d in self.lsp.diagnostic_strings() { |
| 110 | self.problems.insert(d); |
| 111 | } |
| 112 | |
| 113 | terminal.draw(|f| draw(f, self))?; |
| 114 | |
| 115 | if event::poll(FRAME_BUDGET)? { |
| 116 | match event::read()? { |
| 117 | Event::Key(key) => self.handle_key(key).await, |
| 118 | Event::Mouse(mouse) => self.handle_mouse(mouse), |
| 119 | _ => {} |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | if self.should_quit { |
| 124 | let _ = self.editor.save_all(); |
| 125 | self.snap.save_all_to_disk(); |
| 126 | self.save_session(); |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | Ok(()) |
| 132 | } |
| 133 | } |
no test coverage detected