mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-25 22:55:06 +02:00
Add debug flag
This commit is contained in:
parent
8cc66484a8
commit
b9b7d61a99
@ -75,7 +75,6 @@ impl DataState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_data(&mut self) {
|
pub async fn update_data(&mut self) {
|
||||||
//debug!("Start updating...");
|
|
||||||
self.sys.refresh_system();
|
self.sys.refresh_system();
|
||||||
self.sys.refresh_network();
|
self.sys.refresh_network();
|
||||||
|
|
||||||
@ -165,7 +164,5 @@ impl DataState {
|
|||||||
|
|
||||||
self.last_clean = current_instant;
|
self.last_clean = current_instant;
|
||||||
}
|
}
|
||||||
|
|
||||||
//debug!("End updating...");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,22 +41,20 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
|
|||||||
|
|
||||||
terminal.autoresize()?;
|
terminal.autoresize()?;
|
||||||
terminal.draw(|mut f| {
|
terminal.draw(|mut f| {
|
||||||
//debug!("Drawing!");
|
|
||||||
|
|
||||||
// Only for the "help" and "are you sure" menus
|
|
||||||
let vertical_dialog_chunk = Layout::default()
|
|
||||||
.direction(Direction::Vertical)
|
|
||||||
.margin(1)
|
|
||||||
.constraints([Constraint::Percentage(32), Constraint::Percentage(40), Constraint::Percentage(28)].as_ref())
|
|
||||||
.split(f.size());
|
|
||||||
|
|
||||||
let middle_dialog_chunk = Layout::default()
|
|
||||||
.direction(Direction::Horizontal)
|
|
||||||
.margin(0)
|
|
||||||
.constraints([Constraint::Percentage(30), Constraint::Percentage(40), Constraint::Percentage(30)].as_ref())
|
|
||||||
.split(vertical_dialog_chunk[1]);
|
|
||||||
|
|
||||||
if app_state.show_help {
|
if app_state.show_help {
|
||||||
|
// Only for the "help" and "are you sure" menus
|
||||||
|
let vertical_dialog_chunk = Layout::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.margin(1)
|
||||||
|
.constraints([Constraint::Percentage(32), Constraint::Percentage(40), Constraint::Percentage(28)].as_ref())
|
||||||
|
.split(f.size());
|
||||||
|
|
||||||
|
let middle_dialog_chunk = Layout::default()
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.margin(0)
|
||||||
|
.constraints([Constraint::Percentage(30), Constraint::Percentage(40), Constraint::Percentage(30)].as_ref())
|
||||||
|
.split(vertical_dialog_chunk[1]);
|
||||||
|
|
||||||
let text = [
|
let text = [
|
||||||
Text::raw("\nGeneral Keybinds\n"),
|
Text::raw("\nGeneral Keybinds\n"),
|
||||||
Text::raw("q, Ctrl-c to quit.\n"),
|
Text::raw("q, Ctrl-c to quit.\n"),
|
||||||
@ -375,11 +373,6 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
|
|||||||
&mut app_state.currently_selected_process_position,
|
&mut app_state.currently_selected_process_position,
|
||||||
);
|
);
|
||||||
|
|
||||||
/*debug!(
|
|
||||||
"START POSN: {}, PREV POSN: {}, CURRENT SELECTED POSN: {}, NUM ROWS: {}",
|
|
||||||
start_position, app_state.previous_process_position, app_state.currently_selected_process_position, num_rows
|
|
||||||
);*/
|
|
||||||
|
|
||||||
let sliced_vec: Vec<Vec<String>> = (&canvas_data.process_data[start_position as usize..]).to_vec();
|
let sliced_vec: Vec<Vec<String>> = (&canvas_data.process_data[start_position as usize..]).to_vec();
|
||||||
let mut process_counter = 0;
|
let mut process_counter = 0;
|
||||||
|
|
||||||
@ -441,8 +434,6 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
|
|||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
//debug!("Finished drawing.");
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
src/main.rs
43
src/main.rs
@ -44,8 +44,6 @@ enum ResetEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> error::Result<()> {
|
fn main() -> error::Result<()> {
|
||||||
utils::logging::init_logger()?;
|
|
||||||
|
|
||||||
// Parse command line options
|
// Parse command line options
|
||||||
let matches = clap_app!(app =>
|
let matches = clap_app!(app =>
|
||||||
(name: crate_name!())
|
(name: crate_name!())
|
||||||
@ -55,7 +53,7 @@ fn main() -> error::Result<()> {
|
|||||||
//(@arg THEME: -t --theme +takes_value "Sets a colour theme.")
|
//(@arg THEME: -t --theme +takes_value "Sets a colour theme.")
|
||||||
(@arg AVG_CPU: -a --avgcpu "Enables showing the average CPU usage.")
|
(@arg AVG_CPU: -a --avgcpu "Enables showing the average CPU usage.")
|
||||||
(@arg DOT_MARKER: -m --dot_marker "Use a dot marker instead of the default braille marker. May be needed in things like Powershell.")
|
(@arg DOT_MARKER: -m --dot_marker "Use a dot marker instead of the default braille marker. May be needed in things like Powershell.")
|
||||||
//(@arg DEBUG: -d --debug "Enables debug mode.") // TODO: This isn't done yet!
|
(@arg DEBUG: -d --debug "Enables debug mode.")
|
||||||
(@group TEMPERATURE_TYPE =>
|
(@group TEMPERATURE_TYPE =>
|
||||||
(@arg CELSIUS : -c --celsius "Sets the temperature type to Celsius. This is the default option.")
|
(@arg CELSIUS : -c --celsius "Sets the temperature type to Celsius. This is the default option.")
|
||||||
(@arg FAHRENHEIT : -f --fahrenheit "Sets the temperature type to Fahrenheit.")
|
(@arg FAHRENHEIT : -f --fahrenheit "Sets the temperature type to Fahrenheit.")
|
||||||
@ -94,6 +92,12 @@ fn main() -> error::Result<()> {
|
|||||||
};
|
};
|
||||||
let show_average_cpu = matches.is_present("AVG_CPU");
|
let show_average_cpu = matches.is_present("AVG_CPU");
|
||||||
let use_dot = matches.is_present("DOT_MARKER");
|
let use_dot = matches.is_present("DOT_MARKER");
|
||||||
|
let enable_debugging = matches.is_present("DEBUG");
|
||||||
|
|
||||||
|
// Attempt to create debugging...
|
||||||
|
if enable_debugging {
|
||||||
|
utils::logging::init_logger()?;
|
||||||
|
}
|
||||||
|
|
||||||
// Create "app" struct, which will control most of the program and store settings/state
|
// Create "app" struct, which will control most of the program and store settings/state
|
||||||
let mut app = app::App::new(show_average_cpu, temperature_type, update_rate_in_milliseconds as u64, use_dot);
|
let mut app = app::App::new(show_average_cpu, temperature_type, update_rate_in_milliseconds as u64, use_dot);
|
||||||
@ -208,7 +212,6 @@ fn main() -> error::Result<()> {
|
|||||||
if let Ok(recv) = rx.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
if let Ok(recv) = rx.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
||||||
match recv {
|
match recv {
|
||||||
Event::KeyInput(event) => {
|
Event::KeyInput(event) => {
|
||||||
// debug!("Keyboard event fired!");
|
|
||||||
match event {
|
match event {
|
||||||
KeyEvent::Ctrl('c') | KeyEvent::Char('q') => break,
|
KeyEvent::Ctrl('c') | KeyEvent::Char('q') => break,
|
||||||
KeyEvent::Char('h') | KeyEvent::Left => app.on_left(),
|
KeyEvent::Char('h') | KeyEvent::Left => app.on_left(),
|
||||||
@ -238,27 +241,22 @@ fn main() -> error::Result<()> {
|
|||||||
canvas_data.process_data = update_process_row(&app.data);
|
canvas_data.process_data = update_process_row(&app.data);
|
||||||
app.to_be_resorted = false;
|
app.to_be_resorted = false;
|
||||||
}
|
}
|
||||||
// debug!("Input event complete.");
|
|
||||||
}
|
}
|
||||||
Event::MouseInput(event) => {
|
Event::MouseInput(event) => match event {
|
||||||
// debug!("Mouse event fired!");
|
MouseEvent::Press(e, _x, _y) => match e {
|
||||||
match event {
|
MouseButton::WheelUp => {
|
||||||
MouseEvent::Press(e, _x, _y) => match e {
|
app.decrement_position_count();
|
||||||
MouseButton::WheelUp => {
|
}
|
||||||
app.decrement_position_count();
|
MouseButton::WheelDown => {
|
||||||
}
|
app.increment_position_count();
|
||||||
MouseButton::WheelDown => {
|
}
|
||||||
app.increment_position_count();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
MouseEvent::Hold(_x, _y) => {}
|
|
||||||
MouseEvent::Release(_x, _y) => {}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
},
|
||||||
}
|
MouseEvent::Hold(_x, _y) => {}
|
||||||
|
MouseEvent::Release(_x, _y) => {}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
Event::Update(data) => {
|
Event::Update(data) => {
|
||||||
// debug!("Update event fired!");
|
|
||||||
if !app.is_frozen {
|
if !app.is_frozen {
|
||||||
app.data = *data;
|
app.data = *data;
|
||||||
|
|
||||||
@ -296,6 +294,5 @@ fn main() -> error::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input().disable_mouse_mode().unwrap();
|
input().disable_mouse_mode().unwrap();
|
||||||
debug!("Terminating.");
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user