(&mut self, state: &AppState, f: &mut Frame, result: &mut EventResult)
| 40 | |
| 41 | impl UiView for FunctionDiffUi { |
| 42 | fn draw(&mut self, state: &AppState, f: &mut Frame, result: &mut EventResult) { |
| 43 | let chunks = Layout::vertical([Constraint::Length(1), Constraint::Fill(1)]).split(f.area()); |
| 44 | let header_chunks = Layout::horizontal([ |
| 45 | Constraint::Fill(1), |
| 46 | Constraint::Length(3), |
| 47 | Constraint::Fill(1), |
| 48 | Constraint::Length(2), |
| 49 | ]) |
| 50 | .split(chunks[0]); |
| 51 | let content_chunks = if self.three_way { |
| 52 | Layout::horizontal([ |
| 53 | Constraint::Fill(1), |
| 54 | Constraint::Length(3), |
| 55 | Constraint::Fill(1), |
| 56 | Constraint::Length(3), |
| 57 | Constraint::Fill(1), |
| 58 | Constraint::Length(2), |
| 59 | ]) |
| 60 | .split(chunks[1]) |
| 61 | } else { |
| 62 | Layout::horizontal([ |
| 63 | Constraint::Fill(1), |
| 64 | Constraint::Length(3), |
| 65 | Constraint::Fill(1), |
| 66 | Constraint::Length(2), |
| 67 | ]) |
| 68 | .split(chunks[1]) |
| 69 | }; |
| 70 | |
| 71 | self.per_page = chunks[1].height.saturating_sub(2) as usize; |
| 72 | let max_scroll_y = self.num_rows.saturating_sub(self.per_page); |
| 73 | if self.scroll_y > max_scroll_y { |
| 74 | self.scroll_y = max_scroll_y; |
| 75 | } |
| 76 | self.scroll_state_y = |
| 77 | self.scroll_state_y.content_length(max_scroll_y).position(self.scroll_y); |
| 78 | |
| 79 | let mut line_l = Line::default(); |
| 80 | line_l |
| 81 | .spans |
| 82 | .push(Span::styled(self.symbol_name.clone(), Style::new().fg(Color::White).bold())); |
| 83 | f.render_widget(line_l, header_chunks[0]); |
| 84 | |
| 85 | let mut line_r = Line::default(); |
| 86 | if let Some(percent) = get_symbol(state.right_obj.as_ref(), self.right_sym) |
| 87 | .and_then(|(_, _, d)| d.match_percent) |
| 88 | { |
| 89 | line_r.spans.push(Span::styled( |
| 90 | format!("{percent:.2}% "), |
| 91 | Style::new().fg(match_percent_color(percent)), |
| 92 | )); |
| 93 | } |
| 94 | let reload_time = state |
| 95 | .reload_time |
| 96 | .as_ref() |
| 97 | .and_then(|t| t.format(&state.time_format).ok()) |
| 98 | .unwrap_or_else(|| "N/A".to_string()); |
| 99 | line_r.spans.push(Span::styled( |
no test coverage detected