change: merge search and process widgets together
This commit is contained in:
parent
dacf8b1abb
commit
edd5cff12d
|
@ -1 +0,0 @@
|
|||
|
|
@ -44,11 +44,11 @@ impl ProcessTableWidget for Painter {
|
|||
widget_id: u64,
|
||||
) {
|
||||
if let Some(process_widget_state) = app_state.proc_state.widget_states.get(&widget_id) {
|
||||
let search_width = if draw_border { 5 } else { 3 };
|
||||
let search_height = if draw_border { 4 } else { 3 };
|
||||
if process_widget_state.is_search_enabled() {
|
||||
let processes_chunk = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Min(0), Constraint::Length(search_width)].as_ref())
|
||||
.constraints([Constraint::Min(0), Constraint::Length(search_height)].as_ref())
|
||||
.split(draw_loc);
|
||||
|
||||
self.draw_processes_table(f, app_state, processes_chunk[0], draw_border, widget_id);
|
||||
|
@ -85,6 +85,9 @@ impl ProcessTableWidget for Painter {
|
|||
// do so by hiding some elements!
|
||||
let num_rows = max(0, i64::from(draw_loc.height) - self.table_height_offset) as u64;
|
||||
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
||||
let is_on_processes =
|
||||
is_on_widget || (widget_id + 1 == app_state.current_widget.widget_id);
|
||||
let is_search_enabled = proc_widget_state.is_search_enabled();
|
||||
|
||||
let position = get_start_position(
|
||||
num_rows,
|
||||
|
@ -212,7 +215,7 @@ impl ProcessTableWidget for Painter {
|
|||
String::default()
|
||||
};
|
||||
|
||||
let (border_and_title_style, highlight_style) = if is_on_widget {
|
||||
let (border_and_title_style, highlight_style) = if is_on_processes {
|
||||
(
|
||||
self.colours.highlighted_border_style,
|
||||
self.colours.currently_selected_text_style,
|
||||
|
@ -229,7 +232,11 @@ impl ProcessTableWidget for Painter {
|
|||
} else {
|
||||
self.colours.widget_title_style
|
||||
})
|
||||
.borders(Borders::ALL)
|
||||
.borders(if is_search_enabled {
|
||||
*TOP_LEFT_RIGHT
|
||||
} else {
|
||||
Borders::ALL
|
||||
})
|
||||
.border_style(border_and_title_style)
|
||||
} else if is_on_widget {
|
||||
Block::default()
|
||||
|
@ -338,6 +345,8 @@ impl ProcessTableWidget for Painter {
|
|||
let chosen_text = get_prompt_text(&proc_widget_state);
|
||||
|
||||
let is_on_widget = widget_id == app_state.current_widget.widget_id;
|
||||
let is_on_processes =
|
||||
is_on_widget || (widget_id - 1 == app_state.current_widget.widget_id);
|
||||
let num_columns = draw_loc.width as usize;
|
||||
let small_mode = num_columns < 70;
|
||||
let search_title: &str = if !small_mode {
|
||||
|
@ -358,6 +367,7 @@ impl ProcessTableWidget for Painter {
|
|||
|
||||
let cursor_position = proc_widget_state.get_cursor_position();
|
||||
let current_cursor_position = proc_widget_state.get_char_cursor_position();
|
||||
let is_search_enabled = proc_widget_state.is_search_enabled();
|
||||
|
||||
let start_position: usize = get_search_start_position(
|
||||
num_columns - num_chars_for_text - 5,
|
||||
|
@ -452,29 +462,19 @@ impl ProcessTableWidget for Painter {
|
|||
.is_invalid_search
|
||||
{
|
||||
*INVALID_REGEX_STYLE
|
||||
} else if is_on_widget {
|
||||
} else if is_on_processes {
|
||||
self.colours.highlighted_border_style
|
||||
} else {
|
||||
self.colours.border_style
|
||||
};
|
||||
|
||||
let title = if draw_border {
|
||||
const TITLE_BASE: &str = " Esc to close ";
|
||||
|
||||
let repeat_num = max(
|
||||
0,
|
||||
draw_loc.width as i32 - TITLE_BASE.chars().count() as i32 - 2,
|
||||
);
|
||||
format!("{} Esc to close ", "─".repeat(repeat_num as usize))
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
let process_search_block = if draw_border {
|
||||
Block::default()
|
||||
.title(&title)
|
||||
.title_style(current_border_style)
|
||||
.borders(Borders::ALL)
|
||||
.borders(if is_search_enabled {
|
||||
*BOTTOM_LEFT_RIGHT
|
||||
} else {
|
||||
Borders::ALL
|
||||
})
|
||||
.border_style(current_border_style)
|
||||
} else if is_on_widget {
|
||||
Block::default()
|
||||
|
|
|
@ -27,6 +27,10 @@ pub const FORCE_MIN_THRESHOLD: usize = 5;
|
|||
lazy_static! {
|
||||
pub static ref SIDE_BORDERS: tui::widgets::Borders =
|
||||
tui::widgets::Borders::from_bits_truncate(20);
|
||||
pub static ref TOP_LEFT_RIGHT: tui::widgets::Borders =
|
||||
tui::widgets::Borders::from_bits_truncate(22);
|
||||
pub static ref BOTTOM_LEFT_RIGHT: tui::widgets::Borders =
|
||||
tui::widgets::Borders::from_bits_truncate(28);
|
||||
pub static ref DEFAULT_TEXT_STYLE: tui::style::Style =
|
||||
tui::style::Style::default().fg(tui::style::Color::Gray);
|
||||
pub static ref DEFAULT_HEADER_STYLE: tui::style::Style =
|
||||
|
|
Loading…
Reference in New Issue