feature: Add simple indicator for when data updating is frozen (#269)
This commit is contained in:
parent
b8606c41b9
commit
05b39d29ae
|
@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- [#223](https://github.com/ClementTsang/bottom/pull/223): Add tree mode for processes.
|
- [#223](https://github.com/ClementTsang/bottom/pull/223): Add tree mode for processes.
|
||||||
|
|
||||||
|
- [#269](https://github.com/ClementTsang/bottom/pull/269): Add simple indicator for when data updating is frozen.
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
- [#213](https://github.com/ClementTsang/bottom/pull/213), [#214](https://github.com/ClementTsang/bottom/pull/214): Updated help descriptions, added auto-complete generation.
|
- [#213](https://github.com/ClementTsang/bottom/pull/213), [#214](https://github.com/ClementTsang/bottom/pull/214): Updated help descriptions, added auto-complete generation.
|
||||||
|
|
|
@ -1229,7 +1229,6 @@ impl App {
|
||||||
'k' => self.on_up_key(),
|
'k' => self.on_up_key(),
|
||||||
'j' => self.on_down_key(),
|
'j' => self.on_down_key(),
|
||||||
'f' => {
|
'f' => {
|
||||||
// FIXME: [FROZEN] Add an indicator if frozen!
|
|
||||||
self.is_frozen = !self.is_frozen;
|
self.is_frozen = !self.is_frozen;
|
||||||
if self.is_frozen {
|
if self.is_frozen {
|
||||||
self.data_collection.set_frozen_time();
|
self.data_collection.set_frozen_time();
|
||||||
|
|
|
@ -6,6 +6,7 @@ use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
text::{Span, Spans},
|
text::{Span, Spans},
|
||||||
|
widgets::Paragraph,
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -315,13 +316,33 @@ impl Painter {
|
||||||
// FIXME: [CONFIG] write this, should call painter init and any changed colour functions...
|
// FIXME: [CONFIG] write this, should call painter init and any changed colour functions...
|
||||||
pub fn update_painter_colours(&mut self) {}
|
pub fn update_painter_colours(&mut self) {}
|
||||||
|
|
||||||
|
fn draw_frozen_indicator<B: Backend>(&self, f: &mut Frame<'_, B>, draw_loc: Rect) {
|
||||||
|
f.render_widget(
|
||||||
|
Paragraph::new(Span::styled(
|
||||||
|
"Frozen, press 'f' to unfreeze",
|
||||||
|
self.colours.currently_selected_text_style,
|
||||||
|
)),
|
||||||
|
Layout::default()
|
||||||
|
.horizontal_margin(1)
|
||||||
|
.constraints([Constraint::Length(1)])
|
||||||
|
.split(draw_loc)[0],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn draw_data<B: Backend>(
|
pub fn draw_data<B: Backend>(
|
||||||
&mut self, terminal: &mut Terminal<B>, app_state: &mut app::App,
|
&mut self, terminal: &mut Terminal<B>, app_state: &mut app::App,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
use BottomWidgetType::*;
|
use BottomWidgetType::*;
|
||||||
|
|
||||||
terminal.draw(|mut f| {
|
terminal.draw(|mut f| {
|
||||||
let terminal_size = f.size();
|
let (terminal_size, frozen_draw_loc) = if app_state.is_frozen {
|
||||||
|
let split_loc = Layout::default()
|
||||||
|
.constraints([Constraint::Min(0), Constraint::Length(1)])
|
||||||
|
.split(f.size());
|
||||||
|
(split_loc[0], Some(split_loc[1]))
|
||||||
|
} else {
|
||||||
|
(f.size(), None)
|
||||||
|
};
|
||||||
let terminal_height = terminal_size.height;
|
let terminal_height = terminal_size.height;
|
||||||
let terminal_width = terminal_size.width;
|
let terminal_width = terminal_size.width;
|
||||||
|
|
||||||
|
@ -455,6 +476,10 @@ impl Painter {
|
||||||
app_state.delete_dialog_state.is_showing_dd =
|
app_state.delete_dialog_state.is_showing_dd =
|
||||||
self.draw_dd_dialog(&mut f, dd_text, app_state, middle_dialog_chunk[1]);
|
self.draw_dd_dialog(&mut f, dd_text, app_state, middle_dialog_chunk[1]);
|
||||||
} else if app_state.is_expanded {
|
} else if app_state.is_expanded {
|
||||||
|
if let Some(frozen_draw_loc) = frozen_draw_loc {
|
||||||
|
self.draw_frozen_indicator(&mut f, frozen_draw_loc);
|
||||||
|
}
|
||||||
|
|
||||||
let rect = Layout::default()
|
let rect = Layout::default()
|
||||||
.margin(0)
|
.margin(0)
|
||||||
.constraints([Constraint::Percentage(100)])
|
.constraints([Constraint::Percentage(100)])
|
||||||
|
@ -528,6 +553,9 @@ impl Painter {
|
||||||
} else if app_state.app_config_fields.use_basic_mode {
|
} else if app_state.app_config_fields.use_basic_mode {
|
||||||
// Basic mode. This basically removes all graphs but otherwise
|
// Basic mode. This basically removes all graphs but otherwise
|
||||||
// the same info.
|
// the same info.
|
||||||
|
if let Some(frozen_draw_loc) = frozen_draw_loc {
|
||||||
|
self.draw_frozen_indicator(&mut f, frozen_draw_loc);
|
||||||
|
}
|
||||||
|
|
||||||
let vertical_chunks = Layout::default()
|
let vertical_chunks = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
|
@ -605,6 +633,10 @@ impl Painter {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Draws using the passed in (or default) layout.
|
// Draws using the passed in (or default) layout.
|
||||||
|
if let Some(frozen_draw_loc) = frozen_draw_loc {
|
||||||
|
self.draw_frozen_indicator(&mut f, frozen_draw_loc);
|
||||||
|
}
|
||||||
|
|
||||||
if self.derived_widget_draw_locs.is_empty() || app_state.is_force_redraw {
|
if self.derived_widget_draw_locs.is_empty() || app_state.is_force_redraw {
|
||||||
let row_draw_locs = Layout::default()
|
let row_draw_locs = Layout::default()
|
||||||
.margin(0)
|
.margin(0)
|
||||||
|
|
|
@ -29,30 +29,5 @@ impl ConfigScreen for Painter {
|
||||||
.border_style(self.colours.border_style);
|
.border_style(self.colours.border_style);
|
||||||
|
|
||||||
f.render_widget(config_block, draw_loc);
|
f.render_widget(config_block, draw_loc);
|
||||||
|
|
||||||
// let margined_draw_locs = Layout::default()
|
|
||||||
// .margin(2)
|
|
||||||
// .direction(Direction::Horizontal)
|
|
||||||
// .constraints(
|
|
||||||
// [
|
|
||||||
// Constraint::Percentage(33),
|
|
||||||
// Constraint::Percentage(34),
|
|
||||||
// Constraint::Percentage(33),
|
|
||||||
// ]
|
|
||||||
// )
|
|
||||||
// .split(draw_loc)
|
|
||||||
// .into_iter()
|
|
||||||
// .map(|loc| {
|
|
||||||
// // Required to properly margin in *between* the rectangles.
|
|
||||||
// Layout::default()
|
|
||||||
// .horizontal_margin(1)
|
|
||||||
// .constraints([Constraint::Percentage(100)])
|
|
||||||
// .split(loc)[0]
|
|
||||||
// })
|
|
||||||
// .collect::<Vec<Rect>>();
|
|
||||||
|
|
||||||
// for dl in margined_draw_locs {
|
|
||||||
// f.render_widget(Block::default().borders(Borders::ALL), dl);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue