mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
refactor: clean up some states and code
This commit is contained in:
parent
5749c32bd5
commit
fceae8d442
14
src/app.rs
14
src/app.rs
@ -4,7 +4,7 @@ pub mod filter;
|
|||||||
pub mod layout_manager;
|
pub mod layout_manager;
|
||||||
mod process_killer;
|
mod process_killer;
|
||||||
pub mod query;
|
pub mod query;
|
||||||
pub mod widget_states;
|
pub mod widgets;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{max, min},
|
cmp::{max, min},
|
||||||
@ -21,10 +21,11 @@ use data_farmer::*;
|
|||||||
use data_harvester::{processes, temperature};
|
use data_harvester::{processes, temperature};
|
||||||
pub use filter::*;
|
pub use filter::*;
|
||||||
use layout_manager::*;
|
use layout_manager::*;
|
||||||
pub use widget_states::*;
|
pub use widgets::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
canvas, constants,
|
canvas,
|
||||||
|
constants::{self, MAX_SIGNAL},
|
||||||
units::data_units::DataUnit,
|
units::data_units::DataUnit,
|
||||||
utils::error::{BottomError, Result},
|
utils::error::{BottomError, Result},
|
||||||
Pid,
|
Pid,
|
||||||
@ -128,13 +129,6 @@ pub struct AppState {
|
|||||||
pub filters: DataFilters,
|
pub filters: DataFilters,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
const MAX_SIGNAL: usize = 1;
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
const MAX_SIGNAL: usize = 64;
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
const MAX_SIGNAL: usize = 31;
|
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
// Reset multi
|
// Reset multi
|
||||||
|
@ -1 +0,0 @@
|
|||||||
//! States for a graph widget.
|
|
@ -1 +0,0 @@
|
|||||||
//! States for a table widget.
|
|
@ -4,26 +4,26 @@ use tui::widgets::TableState;
|
|||||||
|
|
||||||
use crate::{app::layout_manager::BottomWidgetType, constants};
|
use crate::{app::layout_manager::BottomWidgetType, constants};
|
||||||
|
|
||||||
pub mod process_state;
|
pub mod process;
|
||||||
pub use process_state::*;
|
pub use process::*;
|
||||||
|
|
||||||
pub mod net_state;
|
pub mod net;
|
||||||
pub use net_state::*;
|
pub use net::*;
|
||||||
|
|
||||||
pub mod mem_state;
|
pub mod mem;
|
||||||
pub use mem_state::*;
|
pub use mem::*;
|
||||||
|
|
||||||
pub mod cpu_state;
|
pub mod cpu;
|
||||||
pub use cpu_state::*;
|
pub use cpu::*;
|
||||||
|
|
||||||
pub mod disk_state;
|
pub mod disk;
|
||||||
pub use disk_state::*;
|
pub use disk::*;
|
||||||
|
|
||||||
pub mod battery_state;
|
pub mod battery;
|
||||||
pub use battery_state::*;
|
pub use self::battery::*;
|
||||||
|
|
||||||
pub mod temp_state;
|
pub mod temp;
|
||||||
pub use temp_state::*;
|
pub use temp::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ScrollDirection {
|
pub enum ScrollDirection {
|
@ -22,6 +22,14 @@ pub const MAX_KEY_TIMEOUT_IN_MILLISECONDS: u64 = 1000;
|
|||||||
pub const TABLE_GAP_HEIGHT_LIMIT: u16 = 7;
|
pub const TABLE_GAP_HEIGHT_LIMIT: u16 = 7;
|
||||||
pub const TIME_LABEL_HEIGHT_LIMIT: u16 = 7;
|
pub const TIME_LABEL_HEIGHT_LIMIT: u16 = 7;
|
||||||
|
|
||||||
|
// For kill signals
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
pub const MAX_SIGNAL: usize = 1;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub const MAX_SIGNAL: usize = 64;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub const MAX_SIGNAL: usize = 31;
|
||||||
|
|
||||||
// Side borders
|
// Side borders
|
||||||
pub static SIDE_BORDERS: Lazy<tui::widgets::Borders> =
|
pub static SIDE_BORDERS: Lazy<tui::widgets::Borders> =
|
||||||
Lazy::new(|| tui::widgets::Borders::from_bits_truncate(20));
|
Lazy::new(|| tui::widgets::Borders::from_bits_truncate(20));
|
||||||
|
@ -82,13 +82,10 @@ pub enum EventResult {
|
|||||||
|
|
||||||
pub fn handle_mouse_event(event: MouseEvent, app: &mut AppState) -> EventResult {
|
pub fn handle_mouse_event(event: MouseEvent, app: &mut AppState) -> EventResult {
|
||||||
match event.kind {
|
match event.kind {
|
||||||
MouseEventKind::Down(button) => match button {
|
MouseEventKind::Down(MouseButton::Left) => {
|
||||||
MouseButton::Left => {
|
|
||||||
app.on_left_mouse_up(event.column, event.row);
|
app.on_left_mouse_up(event.column, event.row);
|
||||||
EventResult::Redraw
|
EventResult::Redraw
|
||||||
}
|
}
|
||||||
_ => EventResult::Continue,
|
|
||||||
},
|
|
||||||
MouseEventKind::ScrollUp => {
|
MouseEventKind::ScrollUp => {
|
||||||
app.handle_scroll_up();
|
app.handle_scroll_up();
|
||||||
EventResult::Redraw
|
EventResult::Redraw
|
||||||
|
Loading…
x
Reference in New Issue
Block a user