mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
Update network legend again
This commit is contained in:
parent
2365a58eff
commit
207444fbbf
@ -31,7 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Use custom legend-hiding to stop hiding legends for memory and network widgets.
|
- Use custom legend-hiding to stop hiding legends for memory and network widgets.
|
||||||
|
|
||||||
- In addition, changed to using only legends within the graph for network. The old legend style can still be used via the `--use_old_network_legend` flag or `use_old_network_legend = true` option.
|
- In addition, changed to using only legends within the graph for network, as well as redesigned the legend.
|
||||||
|
The old legend style can still be used via the `--use_old_network_legend` flag or `use_old_network_legend = true` option.
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
@ -35,14 +35,16 @@ impl Default for CanvasColours {
|
|||||||
CanvasColours {
|
CanvasColours {
|
||||||
currently_selected_text_colour: Color::Black,
|
currently_selected_text_colour: Color::Black,
|
||||||
currently_selected_bg_colour: Color::Cyan,
|
currently_selected_bg_colour: Color::Cyan,
|
||||||
currently_selected_text_style: Style::default().fg(Color::Black).bg(STANDARD_HIGHLIGHT_COLOUR),
|
currently_selected_text_style: Style::default()
|
||||||
|
.fg(Color::Black)
|
||||||
|
.bg(STANDARD_HIGHLIGHT_COLOUR),
|
||||||
table_header_style: Style::default().fg(STANDARD_HIGHLIGHT_COLOUR),
|
table_header_style: Style::default().fg(STANDARD_HIGHLIGHT_COLOUR),
|
||||||
ram_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
ram_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||||
swap_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
swap_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||||
rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||||
tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||||
total_rx_style: Style::default().fg(STANDARD_THIRD_COLOUR),
|
total_rx_style: Style::default().fg(STANDARD_FIRST_COLOUR),
|
||||||
total_tx_style: Style::default().fg(STANDARD_FOURTH_COLOUR),
|
total_tx_style: Style::default().fg(STANDARD_SECOND_COLOUR),
|
||||||
avg_colour_style: Style::default().fg(AVG_COLOUR),
|
avg_colour_style: Style::default().fg(AVG_COLOUR),
|
||||||
cpu_colour_styles: Vec::new(),
|
cpu_colour_styles: Vec::new(),
|
||||||
border_style: Style::default().fg(text_colour),
|
border_style: Style::default().fg(text_colour),
|
||||||
@ -103,15 +105,15 @@ impl CanvasColours {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_rx_total_colour(&mut self, colour: &str) -> error::Result<()> {
|
// pub fn set_rx_total_colour(&mut self, colour: &str) -> error::Result<()> {
|
||||||
self.total_rx_style = get_style_from_config(colour)?;
|
// self.total_rx_style = get_style_from_config(colour)?;
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn set_tx_total_colour(&mut self, colour: &str) -> error::Result<()> {
|
// pub fn set_tx_total_colour(&mut self, colour: &str) -> error::Result<()> {
|
||||||
self.total_tx_style = get_style_from_config(colour)?;
|
// self.total_tx_style = get_style_from_config(colour)?;
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn set_avg_cpu_colour(&mut self, colour: &str) -> error::Result<()> {
|
pub fn set_avg_cpu_colour(&mut self, colour: &str) -> error::Result<()> {
|
||||||
self.avg_colour_style = get_style_from_config(colour)?;
|
self.avg_colour_style = get_style_from_config(colour)?;
|
||||||
|
@ -150,7 +150,7 @@ impl NetworkGraphWidget for Painter {
|
|||||||
.y_axis(y_axis)
|
.y_axis(y_axis)
|
||||||
.datasets(&[
|
.datasets(&[
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(&format!("RX: {:7}", app_state.canvas_data.rx_display))
|
.name(&app_state.canvas_data.rx_display)
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
Marker::Dot
|
Marker::Dot
|
||||||
} else {
|
} else {
|
||||||
@ -159,7 +159,7 @@ impl NetworkGraphWidget for Painter {
|
|||||||
.style(self.colours.rx_style)
|
.style(self.colours.rx_style)
|
||||||
.data(&network_data_rx),
|
.data(&network_data_rx),
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(&format!("TX: {:7}", app_state.canvas_data.tx_display))
|
.name(&app_state.canvas_data.tx_display)
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
Marker::Dot
|
Marker::Dot
|
||||||
} else {
|
} else {
|
||||||
@ -167,18 +167,6 @@ impl NetworkGraphWidget for Painter {
|
|||||||
})
|
})
|
||||||
.style(self.colours.tx_style)
|
.style(self.colours.tx_style)
|
||||||
.data(&network_data_tx),
|
.data(&network_data_tx),
|
||||||
Dataset::default()
|
|
||||||
.name(&format!(
|
|
||||||
"Total RX: {:7}",
|
|
||||||
app_state.canvas_data.total_rx_display
|
|
||||||
))
|
|
||||||
.style(self.colours.total_rx_style),
|
|
||||||
Dataset::default()
|
|
||||||
.name(&format!(
|
|
||||||
"Total TX: {:7}",
|
|
||||||
app_state.canvas_data.total_tx_display
|
|
||||||
))
|
|
||||||
.style(self.colours.total_tx_style),
|
|
||||||
])
|
])
|
||||||
.hidden_legend_constraints(legend_constraints),
|
.hidden_legend_constraints(legend_constraints),
|
||||||
draw_loc,
|
draw_loc,
|
||||||
|
@ -29,8 +29,8 @@ pub struct ConvertedNetworkData {
|
|||||||
pub tx: Vec<Point>,
|
pub tx: Vec<Point>,
|
||||||
pub rx_display: String,
|
pub rx_display: String,
|
||||||
pub tx_display: String,
|
pub tx_display: String,
|
||||||
pub total_rx_display: String,
|
pub total_rx_display: Option<String>,
|
||||||
pub total_tx_display: String,
|
pub total_tx_display: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug)]
|
#[derive(Clone, Default, Debug)]
|
||||||
@ -324,7 +324,7 @@ pub fn get_rx_tx_data_points(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_network_data_points(
|
pub fn convert_network_data_points(
|
||||||
current_data: &data_farmer::DataCollection, is_frozen: bool,
|
current_data: &data_farmer::DataCollection, is_frozen: bool, need_four_points: bool,
|
||||||
) -> ConvertedNetworkData {
|
) -> ConvertedNetworkData {
|
||||||
let (rx, tx) = get_rx_tx_data_points(current_data, is_frozen);
|
let (rx, tx) = get_rx_tx_data_points(current_data, is_frozen);
|
||||||
|
|
||||||
@ -335,27 +335,55 @@ pub fn convert_network_data_points(
|
|||||||
|
|
||||||
rx_converted_result = get_exact_byte_values(current_data.network_harvest.rx, false);
|
rx_converted_result = get_exact_byte_values(current_data.network_harvest.rx, false);
|
||||||
total_rx_converted_result = get_exact_byte_values(current_data.network_harvest.total_rx, false);
|
total_rx_converted_result = get_exact_byte_values(current_data.network_harvest.total_rx, false);
|
||||||
let rx_display = format!("{:.*}{}", 1, rx_converted_result.0, rx_converted_result.1);
|
|
||||||
let total_rx_display = format!(
|
|
||||||
"{:.*}{}",
|
|
||||||
1, total_rx_converted_result.0, total_rx_converted_result.1
|
|
||||||
);
|
|
||||||
|
|
||||||
tx_converted_result = get_exact_byte_values(current_data.network_harvest.tx, false);
|
tx_converted_result = get_exact_byte_values(current_data.network_harvest.tx, false);
|
||||||
total_tx_converted_result = get_exact_byte_values(current_data.network_harvest.total_tx, false);
|
total_tx_converted_result = get_exact_byte_values(current_data.network_harvest.total_tx, false);
|
||||||
let tx_display = format!("{:.*}{}", 1, tx_converted_result.0, tx_converted_result.1);
|
|
||||||
let total_tx_display = format!(
|
|
||||||
"{:.*}{}",
|
|
||||||
1, total_tx_converted_result.0, total_tx_converted_result.1
|
|
||||||
);
|
|
||||||
|
|
||||||
ConvertedNetworkData {
|
if need_four_points {
|
||||||
rx,
|
let rx_display = format!("{:.*}{}", 1, rx_converted_result.0, rx_converted_result.1);
|
||||||
tx,
|
let total_rx_display = Some(format!(
|
||||||
rx_display,
|
"{:.*}{}",
|
||||||
tx_display,
|
1, total_rx_converted_result.0, total_rx_converted_result.1
|
||||||
total_rx_display,
|
));
|
||||||
total_tx_display,
|
let tx_display = format!("{:.*}{}", 1, tx_converted_result.0, tx_converted_result.1);
|
||||||
|
let total_tx_display = Some(format!(
|
||||||
|
"{:.*}{}",
|
||||||
|
1, total_tx_converted_result.0, total_tx_converted_result.1
|
||||||
|
));
|
||||||
|
ConvertedNetworkData {
|
||||||
|
rx,
|
||||||
|
tx,
|
||||||
|
rx_display,
|
||||||
|
tx_display,
|
||||||
|
total_rx_display,
|
||||||
|
total_tx_display,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let rx_display = format!(
|
||||||
|
"RX: {:<9} All: {:<9}",
|
||||||
|
format!("{:.1}{:3}", rx_converted_result.0, rx_converted_result.1),
|
||||||
|
format!(
|
||||||
|
"{:.1}{:3}",
|
||||||
|
total_rx_converted_result.0, total_rx_converted_result.1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
let tx_display = format!(
|
||||||
|
"TX: {:<9} All: {:<9}",
|
||||||
|
format!("{:.1}{:3}", tx_converted_result.0, tx_converted_result.1),
|
||||||
|
format!(
|
||||||
|
"{:.1}{:3}",
|
||||||
|
total_tx_converted_result.0, total_tx_converted_result.1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ConvertedNetworkData {
|
||||||
|
rx,
|
||||||
|
tx,
|
||||||
|
rx_display,
|
||||||
|
tx_display,
|
||||||
|
total_rx_display: None,
|
||||||
|
total_tx_display: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
src/main.rs
28
src/main.rs
@ -174,14 +174,22 @@ fn main() -> error::Result<()> {
|
|||||||
|
|
||||||
// Network
|
// Network
|
||||||
if app.used_widgets.use_net {
|
if app.used_widgets.use_net {
|
||||||
let network_data =
|
let network_data = convert_network_data_points(
|
||||||
convert_network_data_points(&app.data_collection, false);
|
&app.data_collection,
|
||||||
|
false,
|
||||||
|
app.app_config_fields.use_basic_mode
|
||||||
|
|| app.app_config_fields.use_old_network_legend,
|
||||||
|
);
|
||||||
app.canvas_data.network_data_rx = network_data.rx;
|
app.canvas_data.network_data_rx = network_data.rx;
|
||||||
app.canvas_data.network_data_tx = network_data.tx;
|
app.canvas_data.network_data_tx = network_data.tx;
|
||||||
app.canvas_data.rx_display = network_data.rx_display;
|
app.canvas_data.rx_display = network_data.rx_display;
|
||||||
app.canvas_data.tx_display = network_data.tx_display;
|
app.canvas_data.tx_display = network_data.tx_display;
|
||||||
app.canvas_data.total_rx_display = network_data.total_rx_display;
|
if let Some(total_rx_display) = network_data.total_rx_display {
|
||||||
app.canvas_data.total_tx_display = network_data.total_tx_display;
|
app.canvas_data.total_rx_display = total_rx_display;
|
||||||
|
}
|
||||||
|
if let Some(total_tx_display) = network_data.total_tx_display {
|
||||||
|
app.canvas_data.total_tx_display = total_tx_display;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disk
|
// Disk
|
||||||
@ -463,13 +471,13 @@ fn generate_config_colours(config: &Config, painter: &mut canvas::Painter) -> er
|
|||||||
painter.colours.set_tx_colour(tx_color)?;
|
painter.colours.set_tx_colour(tx_color)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(rx_total_color) = &colours.rx_total_color {
|
// if let Some(rx_total_color) = &colours.rx_total_color {
|
||||||
painter.colours.set_rx_total_colour(rx_total_color)?;
|
// painter.colours.set_rx_total_colour(rx_total_color)?;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if let Some(tx_total_color) = &colours.tx_total_color {
|
// if let Some(tx_total_color) = &colours.tx_total_color {
|
||||||
painter.colours.set_tx_total_colour(tx_total_color)?;
|
// painter.colours.set_tx_total_colour(tx_total_color)?;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if let Some(table_header_color) = &colours.table_header_color {
|
if let Some(table_header_color) = &colours.table_header_color {
|
||||||
painter
|
painter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user