mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-25 14:44:39 +02:00
Fix highlighting and cpu filtering when maximized
This commit is contained in:
parent
effd494683
commit
32ca9edf11
10
src/app.rs
10
src/app.rs
@ -375,6 +375,12 @@ impl App {
|
|||||||
self.dd_err = None;
|
self.dd_err = None;
|
||||||
} else if self.is_filtering_or_searching() {
|
} else if self.is_filtering_or_searching() {
|
||||||
match self.current_widget_selected {
|
match self.current_widget_selected {
|
||||||
|
WidgetPosition::Cpu
|
||||||
|
if self.is_expanded && self.app_config_fields.use_basic_mode =>
|
||||||
|
{
|
||||||
|
self.current_widget_selected = WidgetPosition::BasicCpu;
|
||||||
|
self.cpu_state.is_showing_tray = false;
|
||||||
|
}
|
||||||
WidgetPosition::Process | WidgetPosition::ProcessSearch => {
|
WidgetPosition::Process | WidgetPosition::ProcessSearch => {
|
||||||
if self.process_search_state.search_state.is_enabled {
|
if self.process_search_state.search_state.is_enabled {
|
||||||
self.current_widget_selected = WidgetPosition::Process;
|
self.current_widget_selected = WidgetPosition::Process;
|
||||||
@ -478,6 +484,10 @@ impl App {
|
|||||||
pub fn on_slash(&mut self) {
|
pub fn on_slash(&mut self) {
|
||||||
if !self.is_in_dialog() {
|
if !self.is_in_dialog() {
|
||||||
match self.current_widget_selected {
|
match self.current_widget_selected {
|
||||||
|
WidgetPosition::BasicCpu if self.is_expanded => {
|
||||||
|
self.current_widget_selected = WidgetPosition::Cpu;
|
||||||
|
self.cpu_state.is_showing_tray = true;
|
||||||
|
}
|
||||||
WidgetPosition::Process | WidgetPosition::ProcessSearch => {
|
WidgetPosition::Process | WidgetPosition::ProcessSearch => {
|
||||||
// Toggle on
|
// Toggle on
|
||||||
self.process_search_state.search_state.is_enabled = true;
|
self.process_search_state.search_state.is_enabled = true;
|
||||||
|
@ -375,7 +375,7 @@ impl Painter {
|
|||||||
.constraints([Constraint::Percentage(100)].as_ref())
|
.constraints([Constraint::Percentage(100)].as_ref())
|
||||||
.split(f.size());
|
.split(f.size());
|
||||||
match &app_state.current_widget_selected {
|
match &app_state.current_widget_selected {
|
||||||
WidgetPosition::Cpu | WidgetPosition::BasicCpu=> {
|
WidgetPosition::Cpu | WidgetPosition::BasicCpu => {
|
||||||
let cpu_chunk = Layout::default()
|
let cpu_chunk = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.margin(0)
|
.margin(0)
|
||||||
@ -637,7 +637,9 @@ impl Painter {
|
|||||||
})
|
})
|
||||||
.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,
|
WidgetPosition::Cpu | WidgetPosition::BasicCpu => {
|
||||||
|
self.colours.highlighted_border_style
|
||||||
|
}
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -699,7 +701,7 @@ impl Painter {
|
|||||||
Row::StyledData(
|
Row::StyledData(
|
||||||
cpu_string_row.iter(),
|
cpu_string_row.iter(),
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Cpu => {
|
WidgetPosition::Cpu => {
|
||||||
if itx as u64
|
if itx as u64
|
||||||
== app_state
|
== app_state
|
||||||
.app_scroll_positions
|
.app_scroll_positions
|
||||||
@ -774,13 +776,13 @@ impl Painter {
|
|||||||
self.colours.highlighted_border_style
|
self.colours.highlighted_border_style
|
||||||
} else {
|
} else {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Cpu => self.colours.highlighted_border_style,
|
WidgetPosition::Cpu => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_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,
|
WidgetPosition::Cpu => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -857,7 +859,9 @@ impl Painter {
|
|||||||
})
|
})
|
||||||
.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,
|
WidgetPosition::Mem | WidgetPosition::BasicMem => {
|
||||||
|
self.colours.highlighted_border_style
|
||||||
|
}
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -907,7 +911,9 @@ impl Painter {
|
|||||||
})
|
})
|
||||||
.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,
|
WidgetPosition::Network | WidgetPosition::BasicNet => {
|
||||||
|
self.colours.highlighted_border_style
|
||||||
|
}
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@ -980,7 +986,7 @@ impl Painter {
|
|||||||
Table::new(NETWORK_HEADERS.iter(), mapped_network)
|
Table::new(NETWORK_HEADERS.iter(), mapped_network)
|
||||||
.block(Block::default().borders(Borders::ALL).border_style(
|
.block(Block::default().borders(Borders::ALL).border_style(
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Network => self.colours.highlighted_border_style,
|
WidgetPosition::Network => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
@ -1022,7 +1028,7 @@ impl Painter {
|
|||||||
Row::StyledData(
|
Row::StyledData(
|
||||||
temp_row.iter(),
|
temp_row.iter(),
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Temp => {
|
WidgetPosition::Temp => {
|
||||||
if temp_row_counter as u64
|
if temp_row_counter as u64
|
||||||
== app_state
|
== app_state
|
||||||
.app_scroll_positions
|
.app_scroll_positions
|
||||||
@ -1074,7 +1080,7 @@ impl Painter {
|
|||||||
.title(&title)
|
.title(&title)
|
||||||
.title_style(if app_state.is_expanded {
|
.title_style(if app_state.is_expanded {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Temp => self.colours.highlighted_border_style,
|
WidgetPosition::Temp => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1082,12 +1088,12 @@ impl Painter {
|
|||||||
})
|
})
|
||||||
.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,
|
WidgetPosition::Temp => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Temp => Block::default()
|
WidgetPosition::Temp => Block::default()
|
||||||
.borders(*SIDE_BORDERS)
|
.borders(*SIDE_BORDERS)
|
||||||
.border_style(self.colours.highlighted_border_style),
|
.border_style(self.colours.highlighted_border_style),
|
||||||
_ => Block::default().borders(Borders::NONE),
|
_ => Block::default().borders(Borders::NONE),
|
||||||
@ -1097,7 +1103,7 @@ impl Painter {
|
|||||||
let margined_draw_loc = Layout::default()
|
let margined_draw_loc = Layout::default()
|
||||||
.constraints([Constraint::Percentage(100)].as_ref())
|
.constraints([Constraint::Percentage(100)].as_ref())
|
||||||
.horizontal_margin(match app_state.current_widget_selected {
|
.horizontal_margin(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Temp => 0,
|
WidgetPosition::Temp => 0,
|
||||||
_ if !draw_border => 1,
|
_ if !draw_border => 1,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
})
|
})
|
||||||
@ -1143,7 +1149,7 @@ impl Painter {
|
|||||||
Row::StyledData(
|
Row::StyledData(
|
||||||
disk.iter(),
|
disk.iter(),
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Disk => {
|
WidgetPosition::Disk => {
|
||||||
if disk_counter as u64
|
if disk_counter as u64
|
||||||
== app_state
|
== app_state
|
||||||
.app_scroll_positions
|
.app_scroll_positions
|
||||||
@ -1195,7 +1201,7 @@ impl Painter {
|
|||||||
.title(&title)
|
.title(&title)
|
||||||
.title_style(if app_state.is_expanded {
|
.title_style(if app_state.is_expanded {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Disk => self.colours.highlighted_border_style,
|
WidgetPosition::Disk => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1203,12 +1209,12 @@ impl Painter {
|
|||||||
})
|
})
|
||||||
.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,
|
WidgetPosition::Disk => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Disk => Block::default()
|
WidgetPosition::Disk => Block::default()
|
||||||
.borders(*SIDE_BORDERS)
|
.borders(*SIDE_BORDERS)
|
||||||
.border_style(self.colours.highlighted_border_style),
|
.border_style(self.colours.highlighted_border_style),
|
||||||
_ => Block::default().borders(Borders::NONE),
|
_ => Block::default().borders(Borders::NONE),
|
||||||
@ -1218,7 +1224,7 @@ impl Painter {
|
|||||||
let margined_draw_loc = Layout::default()
|
let margined_draw_loc = Layout::default()
|
||||||
.constraints([Constraint::Percentage(100)].as_ref())
|
.constraints([Constraint::Percentage(100)].as_ref())
|
||||||
.horizontal_margin(match app_state.current_widget_selected {
|
.horizontal_margin(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Disk => 0,
|
WidgetPosition::Disk => 0,
|
||||||
_ if !draw_border => 1,
|
_ if !draw_border => 1,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
})
|
})
|
||||||
@ -1257,7 +1263,7 @@ impl Painter {
|
|||||||
let grapheme_indices = UnicodeSegmentation::grapheme_indices(query, true);
|
let grapheme_indices = UnicodeSegmentation::grapheme_indices(query, true);
|
||||||
let mut current_grapheme_posn = 0;
|
let mut current_grapheme_posn = 0;
|
||||||
let query_with_cursor: Vec<Text<'_>> =
|
let query_with_cursor: Vec<Text<'_>> =
|
||||||
if let app::WidgetPosition::ProcessSearch = app_state.current_widget_selected {
|
if let WidgetPosition::ProcessSearch = app_state.current_widget_selected {
|
||||||
let mut res = grapheme_indices
|
let mut res = grapheme_indices
|
||||||
.filter_map(|grapheme| {
|
.filter_map(|grapheme| {
|
||||||
current_grapheme_posn += UnicodeWidthStr::width(grapheme.1);
|
current_grapheme_posn += UnicodeWidthStr::width(grapheme.1);
|
||||||
@ -1384,7 +1390,7 @@ impl Painter {
|
|||||||
Style::default().fg(Color::Rgb(255, 0, 0))
|
Style::default().fg(Color::Rgb(255, 0, 0))
|
||||||
} else {
|
} else {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::ProcessSearch => self.colours.highlighted_border_style,
|
WidgetPosition::ProcessSearch => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1409,7 +1415,7 @@ impl Painter {
|
|||||||
.border_style(current_border_style)
|
.border_style(current_border_style)
|
||||||
} else {
|
} else {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::ProcessSearch => Block::default()
|
WidgetPosition::ProcessSearch => Block::default()
|
||||||
.borders(*SIDE_BORDERS)
|
.borders(*SIDE_BORDERS)
|
||||||
.border_style(current_border_style),
|
.border_style(current_border_style),
|
||||||
_ => Block::default().borders(Borders::NONE),
|
_ => Block::default().borders(Borders::NONE),
|
||||||
@ -1419,7 +1425,7 @@ impl Painter {
|
|||||||
let margined_draw_loc = Layout::default()
|
let margined_draw_loc = Layout::default()
|
||||||
.constraints([Constraint::Percentage(100)].as_ref())
|
.constraints([Constraint::Percentage(100)].as_ref())
|
||||||
.horizontal_margin(match app_state.current_widget_selected {
|
.horizontal_margin(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::ProcessSearch => 0,
|
WidgetPosition::ProcessSearch => 0,
|
||||||
_ if !draw_border => 1,
|
_ if !draw_border => 1,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
})
|
})
|
||||||
@ -1488,7 +1494,7 @@ impl Painter {
|
|||||||
Row::StyledData(
|
Row::StyledData(
|
||||||
stringified_process_vec.into_iter(),
|
stringified_process_vec.into_iter(),
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Process => {
|
WidgetPosition::Process => {
|
||||||
if process_counter as u64
|
if process_counter as u64
|
||||||
== app_state
|
== app_state
|
||||||
.app_scroll_positions
|
.app_scroll_positions
|
||||||
@ -1572,7 +1578,7 @@ impl Painter {
|
|||||||
.title(&title)
|
.title(&title)
|
||||||
.title_style(if app_state.is_expanded {
|
.title_style(if app_state.is_expanded {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Process => self.colours.highlighted_border_style,
|
WidgetPosition::Process => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1580,12 +1586,12 @@ impl Painter {
|
|||||||
})
|
})
|
||||||
.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,
|
WidgetPosition::Process => self.colours.highlighted_border_style,
|
||||||
_ => self.colours.border_style,
|
_ => self.colours.border_style,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
match app_state.current_widget_selected {
|
match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Process => Block::default()
|
WidgetPosition::Process => Block::default()
|
||||||
.borders(*SIDE_BORDERS)
|
.borders(*SIDE_BORDERS)
|
||||||
.border_style(self.colours.highlighted_border_style),
|
.border_style(self.colours.highlighted_border_style),
|
||||||
_ => Block::default().borders(Borders::NONE),
|
_ => Block::default().borders(Borders::NONE),
|
||||||
@ -1595,7 +1601,7 @@ impl Painter {
|
|||||||
let margined_draw_loc = Layout::default()
|
let margined_draw_loc = Layout::default()
|
||||||
.constraints([Constraint::Percentage(100)].as_ref())
|
.constraints([Constraint::Percentage(100)].as_ref())
|
||||||
.horizontal_margin(match app_state.current_widget_selected {
|
.horizontal_margin(match app_state.current_widget_selected {
|
||||||
app::WidgetPosition::Process => 0,
|
WidgetPosition::Process => 0,
|
||||||
_ if !draw_border => 1,
|
_ if !draw_border => 1,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user