CPU title bar and esc sequencing.

This commit is contained in:
ClementTsang 2020-02-16 19:32:21 -05:00
parent 8856ea152e
commit 32e8be93b7
2 changed files with 41 additions and 10 deletions

View File

@ -301,7 +301,7 @@ impl App {
self.delete_dialog_state.is_on_yes = false; self.delete_dialog_state.is_on_yes = false;
self.to_delete_process_list = None; self.to_delete_process_list = None;
self.dd_err = None; self.dd_err = None;
} else if !self.is_expanded { } else if self.is_filtering_or_searching() {
match self.current_widget_selected { match self.current_widget_selected {
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 {
@ -320,11 +320,18 @@ impl App {
} }
_ => {} _ => {}
} }
} else { } else if self.is_expanded {
self.is_expanded = false; self.is_expanded = false;
} }
} }
fn is_filtering_or_searching(&self) -> bool {
self.cpu_state.is_showing_tray
|| self.mem_state.is_showing_tray
|| self.net_state.is_showing_tray
|| self.process_search_state.search_state.is_enabled
}
fn reset_multi_tap_keys(&mut self) { fn reset_multi_tap_keys(&mut self) {
self.awaiting_second_char = false; self.awaiting_second_char = false;
self.second_char = None; self.second_char = None;

View File

@ -563,7 +563,7 @@ impl Painter {
); );
} }
let title = if app_state.is_expanded { let title = if app_state.is_expanded && !app_state.cpu_state.is_showing_tray {
const TITLE_BASE: &str = " CPU ── Esc to go back "; const TITLE_BASE: &str = " CPU ── Esc to go back ";
let repeat_num = max( let repeat_num = max(
0, 0,
@ -644,7 +644,7 @@ impl Painter {
let cpu_rows = stringified_cpu_data let cpu_rows = stringified_cpu_data
.iter() .iter()
.enumerate() .enumerate()
.filter(|(itx, _cpu_string_row)| { .filter(|(itx, _)| {
if app_state.cpu_state.is_showing_tray { if app_state.cpu_state.is_showing_tray {
true true
} else { } else {
@ -695,6 +695,19 @@ impl Painter {
); );
let intrinsic_widths = &(variable_intrinsic_results.0)[0..variable_intrinsic_results.1]; let intrinsic_widths = &(variable_intrinsic_results.0)[0..variable_intrinsic_results.1];
let title = if app_state.cpu_state.is_showing_tray {
const TITLE_BASE: &str = " Esc to go close ";
let repeat_num = max(
0,
draw_loc.width as i32 - TITLE_BASE.chars().count() as i32 - 2,
);
let result_title = format!("{} Esc to go close ", "".repeat(repeat_num as usize));
result_title
} else {
"".to_string()
};
// Draw // Draw
Table::new( Table::new(
if app_state.cpu_state.is_showing_tray { if app_state.cpu_state.is_showing_tray {
@ -705,12 +718,23 @@ impl Painter {
.iter(), .iter(),
cpu_rows, 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, .title(&title)
_ => self.colours.border_style, .title_style(if app_state.is_expanded {
}, self.colours.highlighted_border_style
)) } else {
match app_state.current_widget_selected {
app::WidgetPosition::Cpu => self.colours.highlighted_border_style,
_ => self.colours.border_style,
}
})
.borders(Borders::ALL)
.border_style(match app_state.current_widget_selected {
app::WidgetPosition::Cpu => self.colours.highlighted_border_style,
_ => self.colours.border_style,
}),
)
.header_style(self.colours.table_header_style) .header_style(self.colours.table_header_style)
.widths( .widths(
&(intrinsic_widths &(intrinsic_widths