mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-22 13:14:40 +02:00
Added more options and removed cursor (merged with overall text highlighting)
This commit is contained in:
parent
13d3e76dc6
commit
f3a70fbf6d
@ -13,6 +13,7 @@ regex = true
|
|||||||
[colors]
|
[colors]
|
||||||
# Based on gruvbox: https://github.com/morhetz/gruvbox
|
# Based on gruvbox: https://github.com/morhetz/gruvbox
|
||||||
table_header_color="#458588"
|
table_header_color="#458588"
|
||||||
|
widget_title_color="#076678"
|
||||||
cpu_core_colors=["#cc241d", "#98971a", "#d79921", "#458588", "#b16286", "#689d6a", "#fb4934", "#b8bb26", "#fabd2f", "#83a598"]
|
cpu_core_colors=["#cc241d", "#98971a", "#d79921", "#458588", "#b16286", "#689d6a", "#fb4934", "#b8bb26", "#fabd2f", "#83a598"]
|
||||||
ram_color="#fb4934"
|
ram_color="#fb4934"
|
||||||
swap_color="#fabd2f"
|
swap_color="#fabd2f"
|
||||||
@ -21,6 +22,6 @@ tx_color="#689d6a"
|
|||||||
border_color="#ebdbb2"
|
border_color="#ebdbb2"
|
||||||
highlighted_border_color="#fe8019"
|
highlighted_border_color="#fe8019"
|
||||||
text_color="#ebdbb2"
|
text_color="#ebdbb2"
|
||||||
cursor_color="#8ec07c"
|
graph_color="#076678"
|
||||||
scroll_entry_text_color="#282828"
|
selected_text_color="#282828"
|
||||||
scroll_entry_bg_color="#458588"
|
selected_bg_color="#458588"
|
245
src/canvas.rs
245
src/canvas.rs
@ -103,7 +103,7 @@ pub struct DisplayableData {
|
|||||||
|
|
||||||
/// Generates random colours. Strategy found from
|
/// Generates random colours. Strategy found from
|
||||||
/// https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
|
/// https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
|
||||||
fn gen_n_colours(num_to_gen: i32) -> Vec<Color> {
|
fn gen_n_styles(num_to_gen: i32) -> Vec<Style> {
|
||||||
fn gen_hsv(h: f32) -> f32 {
|
fn gen_hsv(h: f32) -> f32 {
|
||||||
let new_val = h + GOLDEN_RATIO;
|
let new_val = h + GOLDEN_RATIO;
|
||||||
if new_val > 1.0 {
|
if new_val > 1.0 {
|
||||||
@ -129,20 +129,20 @@ fn gen_n_colours(num_to_gen: i32) -> Vec<Color> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate colours
|
// Generate colours
|
||||||
let mut colour_vec: Vec<Color> = vec![
|
let mut colour_vec: Vec<Style> = vec![
|
||||||
Color::Rgb(150, 106, 253),
|
Style::default().fg(Color::Rgb(150, 106, 253)),
|
||||||
Color::LightYellow,
|
Style::default().fg(Color::LightYellow),
|
||||||
Color::LightMagenta,
|
Style::default().fg(Color::LightMagenta),
|
||||||
Color::LightCyan,
|
Style::default().fg(Color::LightCyan),
|
||||||
Color::Green,
|
Style::default().fg(Color::Green),
|
||||||
Color::Red,
|
Style::default().fg(Color::Red),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut h: f32 = 0.4; // We don't need random colours... right?
|
let mut h: f32 = 0.4; // We don't need random colours... right?
|
||||||
for _i in 0..(num_to_gen - 6) {
|
for _i in 0..(num_to_gen - 6) {
|
||||||
h = gen_hsv(h);
|
h = gen_hsv(h);
|
||||||
let result = hsv_to_rgb(h, 0.5, 0.95);
|
let result = hsv_to_rgb(h, 0.5, 0.95);
|
||||||
colour_vec.push(Color::Rgb(result.0, result.1, result.2));
|
colour_vec.push(Style::default().fg(Color::Rgb(result.0, result.1, result.2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
colour_vec
|
colour_vec
|
||||||
@ -191,19 +191,18 @@ pub struct CanvasColours {
|
|||||||
text_colour: Color,
|
text_colour: Color,
|
||||||
scroll_text_colour: Color,
|
scroll_text_colour: Color,
|
||||||
scroll_bg_colour: Color,
|
scroll_bg_colour: Color,
|
||||||
scroll_entry_style: Style,
|
currently_selected_text_style: Style,
|
||||||
border_colour: Color,
|
table_header_style: Style,
|
||||||
highlighted_border_colour: Color,
|
|
||||||
table_header_colour: Color,
|
|
||||||
ram_colour: Color,
|
ram_colour: Color,
|
||||||
swap_colour: Color,
|
swap_colour: Color,
|
||||||
rx_colour: Color,
|
rx_colour: Color,
|
||||||
tx_colour: Color,
|
tx_colour: Color,
|
||||||
cpu_colours: Vec<Color>,
|
cpu_colour_styles: Vec<Style>,
|
||||||
cursor_colour: Color,
|
|
||||||
border_style: Style,
|
border_style: Style,
|
||||||
highlighted_border_style: Style,
|
highlighted_border_style: Style,
|
||||||
text_style: Style,
|
text_style: Style,
|
||||||
|
widget_title_style: Style,
|
||||||
|
graph_style: Style,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CanvasColours {
|
impl Default for CanvasColours {
|
||||||
@ -212,19 +211,18 @@ impl Default for CanvasColours {
|
|||||||
text_colour: Color::Gray,
|
text_colour: Color::Gray,
|
||||||
scroll_text_colour: Color::Black,
|
scroll_text_colour: Color::Black,
|
||||||
scroll_bg_colour: Color::Cyan,
|
scroll_bg_colour: Color::Cyan,
|
||||||
scroll_entry_style: Style::default().fg(Color::Black).bg(Color::Cyan),
|
currently_selected_text_style: Style::default().fg(Color::Black).bg(Color::Cyan),
|
||||||
border_colour: Color::Gray,
|
table_header_style: Style::default().fg(Color::LightBlue),
|
||||||
highlighted_border_colour: Color::LightBlue,
|
|
||||||
table_header_colour: Color::LightBlue,
|
|
||||||
ram_colour: STANDARD_FIRST_COLOUR,
|
ram_colour: STANDARD_FIRST_COLOUR,
|
||||||
swap_colour: STANDARD_SECOND_COLOUR,
|
swap_colour: STANDARD_SECOND_COLOUR,
|
||||||
rx_colour: STANDARD_FIRST_COLOUR,
|
rx_colour: STANDARD_FIRST_COLOUR,
|
||||||
tx_colour: STANDARD_SECOND_COLOUR,
|
tx_colour: STANDARD_SECOND_COLOUR,
|
||||||
cpu_colours: Vec::new(),
|
cpu_colour_styles: Vec::new(),
|
||||||
cursor_colour: Color::Cyan,
|
|
||||||
border_style: Style::default().fg(Color::Gray),
|
border_style: Style::default().fg(Color::Gray),
|
||||||
highlighted_border_style: Style::default().fg(Color::LightBlue),
|
highlighted_border_style: Style::default().fg(Color::LightBlue),
|
||||||
text_style: Style::default().fg(Color::Gray),
|
text_style: Style::default().fg(Color::Gray),
|
||||||
|
widget_title_style: Style::default().fg(Color::Gray),
|
||||||
|
graph_style: Style::default().fg(Color::Gray),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,17 +234,15 @@ impl CanvasColours {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn set_border_colour(&mut self, hex: &str) -> error::Result<()> {
|
pub fn set_border_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||||
self.border_colour = convert_hex_to_color(hex)?;
|
self.border_style = Style::default().fg(convert_hex_to_color(hex)?);
|
||||||
self.border_style = Style::default().fg(self.border_colour);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn set_highlighted_border_colour(&mut self, hex: &str) -> error::Result<()> {
|
pub fn set_highlighted_border_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||||
self.highlighted_border_colour = convert_hex_to_color(hex)?;
|
self.highlighted_border_style = Style::default().fg(convert_hex_to_color(hex)?);
|
||||||
self.highlighted_border_style = Style::default().fg(self.highlighted_border_colour);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn set_table_header_colour(&mut self, hex: &str) -> error::Result<()> {
|
pub fn set_table_header_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||||
self.table_header_colour = convert_hex_to_color(hex)?;
|
self.table_header_style = Style::default().fg(convert_hex_to_color(hex)?);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn set_ram_colour(&mut self, hex: &str) -> error::Result<()> {
|
pub fn set_ram_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||||
@ -268,34 +264,41 @@ impl CanvasColours {
|
|||||||
pub fn set_cpu_colours(&mut self, hex_colours: &Vec<String>) -> error::Result<()> {
|
pub fn set_cpu_colours(&mut self, hex_colours: &Vec<String>) -> error::Result<()> {
|
||||||
let max_amount = std::cmp::min(hex_colours.len(), NUM_COLOURS as usize);
|
let max_amount = std::cmp::min(hex_colours.len(), NUM_COLOURS as usize);
|
||||||
for i in 0..max_amount {
|
for i in 0..max_amount {
|
||||||
self.cpu_colours
|
self.cpu_colour_styles
|
||||||
.push(convert_hex_to_color(&hex_colours[i])?);
|
.push(Style::default().fg(convert_hex_to_color(&hex_colours[i])?));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn generate_remaining_cpu_colours(&mut self) {
|
pub fn generate_remaining_cpu_colours(&mut self) {
|
||||||
let remaining_num_colours = NUM_COLOURS - self.cpu_colours.len() as i32;
|
let remaining_num_colours = NUM_COLOURS - self.cpu_colour_styles.len() as i32;
|
||||||
self.cpu_colours
|
self.cpu_colour_styles
|
||||||
.extend(gen_n_colours(remaining_num_colours));
|
.extend(gen_n_styles(remaining_num_colours));
|
||||||
}
|
|
||||||
pub fn set_cursor_colour(&mut self, hex: &str) -> error::Result<()> {
|
|
||||||
self.cursor_colour = convert_hex_to_color(hex)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_scroll_entry_text_color(&mut self, hex: &str) -> error::Result<()> {
|
pub fn set_scroll_entry_text_color(&mut self, hex: &str) -> error::Result<()> {
|
||||||
self.scroll_text_colour = convert_hex_to_color(hex)?;
|
self.scroll_text_colour = convert_hex_to_color(hex)?;
|
||||||
self.scroll_entry_style = Style::default()
|
self.currently_selected_text_style = Style::default()
|
||||||
.fg(self.scroll_text_colour)
|
.fg(self.scroll_text_colour)
|
||||||
.bg(self.scroll_bg_colour);
|
.bg(self.scroll_bg_colour);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn set_scroll_entry_bg_color(&mut self, hex: &str) -> error::Result<()> {
|
pub fn set_scroll_entry_bg_color(&mut self, hex: &str) -> error::Result<()> {
|
||||||
self.scroll_bg_colour = convert_hex_to_color(hex)?;
|
self.scroll_bg_colour = convert_hex_to_color(hex)?;
|
||||||
self.scroll_entry_style = Style::default()
|
self.currently_selected_text_style = Style::default()
|
||||||
.fg(self.scroll_text_colour)
|
.fg(self.scroll_text_colour)
|
||||||
.bg(self.scroll_bg_colour);
|
.bg(self.scroll_bg_colour);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_widget_title_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||||
|
self.widget_title_style = Style::default().fg(convert_hex_to_color(hex)?);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_graph_colour(&mut self, hex: &str) -> error::Result<()> {
|
||||||
|
self.graph_style = Style::default().fg(convert_hex_to_color(hex)?);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Painter {
|
impl Painter {
|
||||||
@ -336,7 +339,7 @@ impl Painter {
|
|||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" Help (Press Esc to close) ")
|
.title(" Help (Press Esc to close) ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.style(self.colours.border_style)
|
.style(self.colours.border_style)
|
||||||
.borders(Borders::ALL),
|
.borders(Borders::ALL),
|
||||||
)
|
)
|
||||||
@ -411,7 +414,7 @@ impl Painter {
|
|||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" Kill Process Confirmation (Press Esc to close) ")
|
.title(" Kill Process Confirmation (Press Esc to close) ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.style(self.colours.border_style)
|
.style(self.colours.border_style)
|
||||||
.borders(Borders::ALL),
|
.borders(Borders::ALL),
|
||||||
)
|
)
|
||||||
@ -558,8 +561,8 @@ impl Painter {
|
|||||||
// CPU usage graph
|
// CPU usage graph
|
||||||
let x_axis: Axis<String> = Axis::default().bounds([0.0, TIME_STARTS_FROM as f64]);
|
let x_axis: Axis<String> = Axis::default().bounds([0.0, TIME_STARTS_FROM as f64]);
|
||||||
let y_axis = Axis::default()
|
let y_axis = Axis::default()
|
||||||
.style(self.colours.text_style)
|
.style(self.colours.graph_style)
|
||||||
.labels_style(self.colours.text_style)
|
.labels_style(self.colours.graph_style)
|
||||||
.bounds([-0.5, 100.5])
|
.bounds([-0.5, 100.5])
|
||||||
.labels(&["0%", "100%"]);
|
.labels(&["0%", "100%"]);
|
||||||
|
|
||||||
@ -568,7 +571,7 @@ impl Painter {
|
|||||||
|
|
||||||
for (i, cpu) in cpu_data.iter().enumerate() {
|
for (i, cpu) in cpu_data.iter().enumerate() {
|
||||||
cpu_entries_vec.push((
|
cpu_entries_vec.push((
|
||||||
Style::default().fg(self.colours.cpu_colours[(i) % self.colours.cpu_colours.len()]),
|
self.colours.cpu_colour_styles[(i) % self.colours.cpu_colour_styles.len()],
|
||||||
cpu.cpu_data
|
cpu.cpu_data
|
||||||
.iter()
|
.iter()
|
||||||
.map(<(f64, f64)>::from)
|
.map(<(f64, f64)>::from)
|
||||||
@ -579,7 +582,7 @@ impl Painter {
|
|||||||
if app_state.show_average_cpu {
|
if app_state.show_average_cpu {
|
||||||
if let Some(avg_cpu_entry) = cpu_data.first() {
|
if let Some(avg_cpu_entry) = cpu_data.first() {
|
||||||
cpu_entries_vec.push((
|
cpu_entries_vec.push((
|
||||||
Style::default().fg(self.colours.cpu_colours[0]),
|
self.colours.cpu_colour_styles[0],
|
||||||
avg_cpu_entry
|
avg_cpu_entry
|
||||||
.cpu_data
|
.cpu_data
|
||||||
.iter()
|
.iter()
|
||||||
@ -606,7 +609,7 @@ impl Painter {
|
|||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" CPU ")
|
.title(" CPU ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_style(match app_state.current_widget_selected {
|
.border_style(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Cpu => self.colours.highlighted_border_style,
|
app::WidgetPosition::Cpu => self.colours.highlighted_border_style,
|
||||||
@ -658,18 +661,19 @@ impl Painter {
|
|||||||
== app_state.currently_selected_cpu_table_position - start_position
|
== app_state.currently_selected_cpu_table_position - start_position
|
||||||
{
|
{
|
||||||
cpu_row_counter = -1;
|
cpu_row_counter = -1;
|
||||||
self.colours.scroll_entry_style
|
self.colours.currently_selected_text_style
|
||||||
} else {
|
} else {
|
||||||
if cpu_row_counter >= 0 {
|
if cpu_row_counter >= 0 {
|
||||||
cpu_row_counter += 1;
|
cpu_row_counter += 1;
|
||||||
}
|
}
|
||||||
Style::default()
|
self.colours.cpu_colour_styles
|
||||||
.fg(self.colours.cpu_colours
|
[itx % self.colours.cpu_colour_styles.len()]
|
||||||
[itx % self.colours.cpu_colours.len()])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => Style::default()
|
_ => {
|
||||||
.fg(self.colours.cpu_colours[itx % self.colours.cpu_colours.len()]),
|
self.colours.cpu_colour_styles
|
||||||
|
[itx % self.colours.cpu_colour_styles.len()]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@ -683,13 +687,16 @@ impl Painter {
|
|||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
Table::new(CPU_LEGEND_HEADER.iter(), cpu_rows)
|
Table::new(CPU_LEGEND_HEADER.iter(), cpu_rows)
|
||||||
.block(Block::default().borders(Borders::ALL).border_style(
|
.block(
|
||||||
match app_state.current_widget_selected {
|
Block::default()
|
||||||
app::WidgetPosition::Cpu => self.colours.highlighted_border_style,
|
.borders(Borders::ALL)
|
||||||
_ => self.colours.border_style,
|
.title_style(self.colours.widget_title_style)
|
||||||
},
|
.border_style(match app_state.current_widget_selected {
|
||||||
))
|
app::WidgetPosition::Cpu => self.colours.highlighted_border_style,
|
||||||
.header_style(Style::default().fg(self.colours.table_header_colour))
|
_ => self.colours.border_style,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.header_style(self.colours.table_header_style)
|
||||||
.widths(
|
.widths(
|
||||||
&(intrinsic_widths
|
&(intrinsic_widths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -709,8 +716,8 @@ impl Painter {
|
|||||||
|
|
||||||
// Offset as the zero value isn't drawn otherwise...
|
// Offset as the zero value isn't drawn otherwise...
|
||||||
let y_axis: Axis<&str> = Axis::default()
|
let y_axis: Axis<&str> = Axis::default()
|
||||||
.style(self.colours.text_style)
|
.style(self.colours.graph_style)
|
||||||
.labels_style(self.colours.text_style)
|
.labels_style(self.colours.graph_style)
|
||||||
.bounds([-0.5, 100.5])
|
.bounds([-0.5, 100.5])
|
||||||
.labels(&["0%", "100%"]);
|
.labels(&["0%", "100%"]);
|
||||||
|
|
||||||
@ -742,7 +749,7 @@ impl Painter {
|
|||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" Memory ")
|
.title(" Memory ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_style(match app_state.current_widget_selected {
|
.border_style(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Mem => self.colours.highlighted_border_style,
|
app::WidgetPosition::Mem => self.colours.highlighted_border_style,
|
||||||
@ -763,15 +770,15 @@ impl Painter {
|
|||||||
|
|
||||||
let x_axis: Axis<String> = Axis::default().bounds([0.0, 60_000.0]);
|
let x_axis: Axis<String> = Axis::default().bounds([0.0, 60_000.0]);
|
||||||
let y_axis = Axis::default()
|
let y_axis = Axis::default()
|
||||||
.style(self.colours.text_style)
|
.style(self.colours.graph_style)
|
||||||
.labels_style(self.colours.text_style)
|
.labels_style(self.colours.graph_style)
|
||||||
.bounds([-0.5, 30_f64])
|
.bounds([-0.5, 30_f64])
|
||||||
.labels(&["0B", "1KiB", "1MiB", "1GiB"]);
|
.labels(&["0B", "1KiB", "1MiB", "1GiB"]);
|
||||||
Chart::default()
|
Chart::default()
|
||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" Network ")
|
.title(" Network ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_style(match app_state.current_widget_selected {
|
.border_style(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Network => self.colours.highlighted_border_style,
|
app::WidgetPosition::Network => self.colours.highlighted_border_style,
|
||||||
@ -852,13 +859,16 @@ impl Painter {
|
|||||||
.iter(),
|
.iter(),
|
||||||
mapped_network,
|
mapped_network,
|
||||||
)
|
)
|
||||||
.block(Block::default().borders(Borders::ALL).border_style(
|
.block(
|
||||||
match app_state.current_widget_selected {
|
Block::default()
|
||||||
app::WidgetPosition::Network => self.colours.highlighted_border_style,
|
.borders(Borders::ALL)
|
||||||
_ => self.colours.border_style,
|
.title_style(self.colours.widget_title_style)
|
||||||
},
|
.border_style(match app_state.current_widget_selected {
|
||||||
))
|
app::WidgetPosition::Network => self.colours.highlighted_border_style,
|
||||||
.header_style(Style::default().fg(self.colours.table_header_colour))
|
_ => self.colours.border_style,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.header_style(self.colours.table_header_style)
|
||||||
.style(Style::default().fg(self.colours.text_colour))
|
.style(Style::default().fg(self.colours.text_colour))
|
||||||
.widths(
|
.widths(
|
||||||
&(intrinsic_widths
|
&(intrinsic_widths
|
||||||
@ -894,7 +904,7 @@ impl Painter {
|
|||||||
== app_state.currently_selected_temperature_position - start_position
|
== app_state.currently_selected_temperature_position - start_position
|
||||||
{
|
{
|
||||||
temp_row_counter = -1;
|
temp_row_counter = -1;
|
||||||
self.colours.scroll_entry_style
|
self.colours.currently_selected_text_style
|
||||||
} else {
|
} else {
|
||||||
if temp_row_counter >= 0 {
|
if temp_row_counter >= 0 {
|
||||||
temp_row_counter += 1;
|
temp_row_counter += 1;
|
||||||
@ -919,14 +929,14 @@ impl Painter {
|
|||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" Temperatures ")
|
.title(" Temperatures ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_style(match app_state.current_widget_selected {
|
.border_style(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Temp => self.colours.highlighted_border_style,
|
app::WidgetPosition::Temp => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.header_style(Style::default().fg(self.colours.table_header_colour))
|
.header_style(self.colours.table_header_style)
|
||||||
.widths(
|
.widths(
|
||||||
&(intrinsic_widths
|
&(intrinsic_widths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -960,7 +970,7 @@ impl Painter {
|
|||||||
== app_state.currently_selected_disk_position - start_position
|
== app_state.currently_selected_disk_position - start_position
|
||||||
{
|
{
|
||||||
disk_counter = -1;
|
disk_counter = -1;
|
||||||
self.colours.scroll_entry_style
|
self.colours.currently_selected_text_style
|
||||||
} else {
|
} else {
|
||||||
if disk_counter >= 0 {
|
if disk_counter >= 0 {
|
||||||
disk_counter += 1;
|
disk_counter += 1;
|
||||||
@ -986,14 +996,14 @@ impl Painter {
|
|||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" Disk ")
|
.title(" Disk ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_style(match app_state.current_widget_selected {
|
.border_style(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Disk => self.colours.highlighted_border_style,
|
app::WidgetPosition::Disk => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.header_style(Style::default().fg(self.colours.table_header_colour))
|
.header_style(self.colours.table_header_style)
|
||||||
.widths(
|
.widths(
|
||||||
&(intrinsic_widths
|
&(intrinsic_widths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -1027,7 +1037,7 @@ impl Painter {
|
|||||||
|
|
||||||
q.push(Text::styled(
|
q.push(Text::styled(
|
||||||
" ".to_string(),
|
" ".to_string(),
|
||||||
Style::default().bg(self.colours.cursor_colour),
|
self.colours.currently_selected_text_style,
|
||||||
));
|
));
|
||||||
|
|
||||||
q
|
q
|
||||||
@ -1042,9 +1052,7 @@ impl Painter {
|
|||||||
if itx == cursor_position {
|
if itx == cursor_position {
|
||||||
return Text::styled(
|
return Text::styled(
|
||||||
c.to_string(),
|
c.to_string(),
|
||||||
Style::default()
|
self.colours.currently_selected_text_style,
|
||||||
.fg(self.colours.text_colour)
|
|
||||||
.bg(self.colours.table_header_colour),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1062,55 +1070,37 @@ impl Painter {
|
|||||||
let mut search_text = vec![if app_state.search_state.is_searching_with_pid() {
|
let mut search_text = vec![if app_state.search_state.is_searching_with_pid() {
|
||||||
Text::styled(
|
Text::styled(
|
||||||
"Search by PID (Tab for Name): ",
|
"Search by PID (Tab for Name): ",
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
self.colours.table_header_style,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Text::styled(
|
Text::styled(
|
||||||
"Search by Name (Tab for PID): ",
|
"Search by Name (Tab for PID): ",
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
self.colours.table_header_style,
|
||||||
)
|
)
|
||||||
}];
|
}];
|
||||||
|
|
||||||
// Text options shamelessly stolen from VS Code.
|
// Text options shamelessly stolen from VS Code.
|
||||||
let option_text = vec![
|
let option_text = vec![
|
||||||
Text::styled(
|
Text::styled("\n\n", self.colours.table_header_style),
|
||||||
"\n\n",
|
Text::styled("Match Case (Alt+C)", self.colours.table_header_style),
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
|
||||||
),
|
|
||||||
Text::styled(
|
|
||||||
"Match Case (Alt+C)",
|
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
|
||||||
),
|
|
||||||
if !app_state.search_state.is_ignoring_case() {
|
if !app_state.search_state.is_ignoring_case() {
|
||||||
Text::styled("[*]", Style::default().fg(self.colours.table_header_colour))
|
Text::styled("[*]", self.colours.table_header_style)
|
||||||
} else {
|
} else {
|
||||||
Text::styled("[ ]", Style::default().fg(self.colours.table_header_colour))
|
Text::styled("[ ]", self.colours.table_header_style)
|
||||||
},
|
},
|
||||||
Text::styled(
|
Text::styled(" ", self.colours.table_header_style),
|
||||||
" ",
|
Text::styled("Match Whole Word (Alt+W)", self.colours.table_header_style),
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
|
||||||
),
|
|
||||||
Text::styled(
|
|
||||||
"Match Whole Word (Alt+W)",
|
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
|
||||||
),
|
|
||||||
if app_state.search_state.is_searching_whole_word() {
|
if app_state.search_state.is_searching_whole_word() {
|
||||||
Text::styled("[*]", Style::default().fg(self.colours.table_header_colour))
|
Text::styled("[*]", self.colours.table_header_style)
|
||||||
} else {
|
} else {
|
||||||
Text::styled("[ ]", Style::default().fg(self.colours.table_header_colour))
|
Text::styled("[ ]", self.colours.table_header_style)
|
||||||
},
|
},
|
||||||
Text::styled(
|
Text::styled(" ", self.colours.table_header_style),
|
||||||
" ",
|
Text::styled("Use Regex (Alt+R)", self.colours.table_header_style),
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
|
||||||
),
|
|
||||||
Text::styled(
|
|
||||||
"Use Regex (Alt+R)",
|
|
||||||
Style::default().fg(self.colours.table_header_colour),
|
|
||||||
),
|
|
||||||
if app_state.search_state.is_searching_with_regex() {
|
if app_state.search_state.is_searching_with_regex() {
|
||||||
Text::styled("[*]", Style::default().fg(self.colours.table_header_colour))
|
Text::styled("[*]", self.colours.table_header_style)
|
||||||
} else {
|
} else {
|
||||||
Text::styled("[ ]", Style::default().fg(self.colours.table_header_colour))
|
Text::styled("[ ]", self.colours.table_header_style)
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -1118,16 +1108,21 @@ impl Painter {
|
|||||||
search_text.extend(option_text);
|
search_text.extend(option_text);
|
||||||
|
|
||||||
Paragraph::new(search_text.iter())
|
Paragraph::new(search_text.iter())
|
||||||
.block(Block::default().borders(Borders::ALL).border_style(
|
.block(
|
||||||
if app_state.get_current_regex_matcher().is_err() {
|
Block::default()
|
||||||
Style::default().fg(Color::Red)
|
.borders(Borders::ALL)
|
||||||
} else {
|
.title_style(self.colours.widget_title_style)
|
||||||
match app_state.current_widget_selected {
|
.border_style(if app_state.get_current_regex_matcher().is_err() {
|
||||||
app::WidgetPosition::ProcessSearch => self.colours.highlighted_border_style,
|
Style::default().fg(Color::Red)
|
||||||
_ => self.colours.border_style,
|
} else {
|
||||||
}
|
match app_state.current_widget_selected {
|
||||||
},
|
app::WidgetPosition::ProcessSearch => {
|
||||||
))
|
self.colours.highlighted_border_style
|
||||||
|
}
|
||||||
|
_ => self.colours.border_style,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
.style(Style::default().fg(self.colours.text_colour))
|
.style(Style::default().fg(self.colours.text_colour))
|
||||||
.alignment(Alignment::Left)
|
.alignment(Alignment::Left)
|
||||||
.wrap(false)
|
.wrap(false)
|
||||||
@ -1186,7 +1181,7 @@ impl Painter {
|
|||||||
== app_state.currently_selected_process_position - start_position
|
== app_state.currently_selected_process_position - start_position
|
||||||
{
|
{
|
||||||
process_counter = -1;
|
process_counter = -1;
|
||||||
self.colours.scroll_entry_style
|
self.colours.currently_selected_text_style
|
||||||
} else {
|
} else {
|
||||||
if process_counter >= 0 {
|
if process_counter >= 0 {
|
||||||
process_counter += 1;
|
process_counter += 1;
|
||||||
@ -1240,14 +1235,14 @@ impl Painter {
|
|||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(" Processes ")
|
.title(" Processes ")
|
||||||
.title_style(self.colours.text_style)
|
.title_style(self.colours.widget_title_style)
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_style(match app_state.current_widget_selected {
|
.border_style(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Process => self.colours.highlighted_border_style,
|
app::WidgetPosition::Process => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.header_style(Style::default().fg(self.colours.table_header_colour))
|
.header_style(self.colours.table_header_style)
|
||||||
.widths(
|
.widths(
|
||||||
&(intrinsic_widths
|
&(intrinsic_widths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
25
src/main.rs
25
src/main.rs
@ -86,9 +86,10 @@ struct ConfigColours {
|
|||||||
border_color: Option<String>,
|
border_color: Option<String>,
|
||||||
highlighted_border_color: Option<String>,
|
highlighted_border_color: Option<String>,
|
||||||
text_color: Option<String>,
|
text_color: Option<String>,
|
||||||
cursor_color: Option<String>,
|
selected_text_color: Option<String>,
|
||||||
scroll_entry_text_color: Option<String>,
|
selected_bg_color: Option<String>,
|
||||||
scroll_entry_bg_color: Option<String>,
|
widget_title_color: Option<String>,
|
||||||
|
graph_color: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> error::Result<()> {
|
fn main() -> error::Result<()> {
|
||||||
@ -584,27 +585,33 @@ fn generate_config_colours(
|
|||||||
painter.colours.set_tx_colour(tx_color)?;
|
painter.colours.set_tx_colour(tx_color)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(cursor_color) = &colours.cursor_color {
|
|
||||||
painter.colours.set_cursor_colour(cursor_color)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(table_header_color) = &colours.table_header_color {
|
if let Some(table_header_color) = &colours.table_header_color {
|
||||||
painter
|
painter
|
||||||
.colours
|
.colours
|
||||||
.set_table_header_colour(table_header_color)?;
|
.set_table_header_colour(table_header_color)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(scroll_entry_text_color) = &colours.scroll_entry_text_color {
|
if let Some(scroll_entry_text_color) = &colours.selected_text_color {
|
||||||
painter
|
painter
|
||||||
.colours
|
.colours
|
||||||
.set_scroll_entry_text_color(scroll_entry_text_color)?;
|
.set_scroll_entry_text_color(scroll_entry_text_color)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(scroll_entry_bg_color) = &colours.scroll_entry_bg_color {
|
if let Some(scroll_entry_bg_color) = &colours.selected_bg_color {
|
||||||
painter
|
painter
|
||||||
.colours
|
.colours
|
||||||
.set_scroll_entry_bg_color(scroll_entry_bg_color)?;
|
.set_scroll_entry_bg_color(scroll_entry_bg_color)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(widget_title_color) = &colours.widget_title_color {
|
||||||
|
painter
|
||||||
|
.colours
|
||||||
|
.set_widget_title_colour(widget_title_color)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(graph_color) = &colours.graph_color {
|
||||||
|
painter.colours.set_graph_colour(graph_color)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user