diff options
author | ilyes-ced <109927235+ilyes-ced@users.noreply.github.com> | 2023-12-08 08:33:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-08 16:33:10 +0800 |
commit | 5648be6f11bd93a772cc6b4a04915c095577ea3d (patch) | |
tree | bc5e4ada9bb3ae9f3d07ea5f18e0c52e30383504 /src/display/ui.rs | |
parent | 0a89c5aba518294b1fdcaa77bdbc15c314b1651d (diff) |
Show interface names (#340)
* added interface names
* some fixes
* Set interface name in UI only once
* Code style
* Add changelog entry
---------
Co-authored-by: cyqsimon <28627918+cyqsimon@users.noreply.github.com>
Diffstat (limited to 'src/display/ui.rs')
-rw-r--r-- | src/display/ui.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/display/ui.rs b/src/display/ui.rs index df0978f..4b6d716 100644 --- a/src/display/ui.rs +++ b/src/display/ui.rs @@ -4,7 +4,7 @@ use chrono::prelude::*; use ratatui::{backend::Backend, Terminal}; use crate::{ - cli::RenderOpts, + cli::{Opt, RenderOpts}, display::{ components::{HeaderDetails, HelpText, Layout, Table}, UIState, @@ -26,21 +26,22 @@ impl<B> Ui<B> where B: Backend, { - pub fn new(terminal_backend: B, opts: RenderOpts) -> Self { + pub fn new(terminal_backend: B, opts: &Opt) -> Self { let mut terminal = Terminal::new(terminal_backend).unwrap(); terminal.clear().unwrap(); terminal.hide_cursor().unwrap(); let state = { let mut state = UIState::default(); - state.unit_family = opts.unit_family; - state.cumulative_mode = opts.total_utilization; + state.interface_name = opts.interface.clone(); + state.unit_family = opts.render_opts.unit_family; + state.cumulative_mode = opts.render_opts.total_utilization; state }; Ui { terminal, state, ip_to_host: Default::default(), - opts, + opts: opts.render_opts, } } pub fn output_text(&mut self, write_to_stdout: &mut (dyn FnMut(String) + Send)) { |