From 5ecd26fb10b2aa4dbe9a4fb0d592ab00ec5b79e8 Mon Sep 17 00:00:00 2001 From: etienne-k <2804556+etienne-k@users.noreply.github.com> Date: Mon, 9 May 2022 21:51:39 +0200 Subject: [PATCH] refactor(statusline): make clippy happy --- helix-term/src/ui/editor.rs | 27 +++++--- helix-term/src/ui/statusline.rs | 113 +++++++++++++------------------- helix-view/src/editor.rs | 4 +- 3 files changed, 68 insertions(+), 76 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f6f49d6be..6a6f1eac8 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -28,6 +28,8 @@ use std::borrow::Cow; use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind}; use tui::buffer::Buffer as Surface; +use super::statusline; + pub struct EditorView { pub keymaps: Keymaps, on_next_key: Option>, @@ -160,7 +162,16 @@ impl EditorView { .area .clip_top(view.area.height.saturating_sub(1)) .clip_bottom(1); // -1 from bottom to remove commandline - self.render_statusline(editor, doc, view, statusline_area, surface, is_focused); + + let context = statusline::RenderContext { + doc, + view, + theme, + focused: is_focused, + spinners: &self.spinners, + }; + + StatusLine::render(editor, &context, statusline_area, surface); } pub fn render_rulers( @@ -738,15 +749,15 @@ impl EditorView { surface: &mut Surface, is_focused: bool, ) { - StatusLine::render( - editor, + let context = statusline::RenderContext { doc, view, - viewport, - surface, - is_focused, - &self.spinners, - ); + theme: &editor.theme, + focused: is_focused, + spinners: &self.spinners, + }; + + StatusLine::render(editor, &context, viewport, surface); } /// Handle events by looking them up in `self.keymaps`. Returns None diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index d3e7d0093..c2bc260e3 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -22,8 +22,8 @@ struct StatusLineElement { pub style: Option