mirror of
https://github.com/ClementTsang/bottom
synced 2025-02-16 21:28:26 +00:00
refactor: change name of some stuff, add some comments (#992)
* some quick refactoring first * add todo for bug report template
This commit is contained in:
parent
7f7a328977
commit
4870ff365a
7 changed files with 21 additions and 24 deletions
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
@ -88,6 +88,8 @@ body:
|
|||
**Note: if you installed from `bottom` from cargo, please ensure that you installed the right crate (https://crates.io/crates/bottom).**
|
||||
placeholder: Installed bottom through the Arch official repos.
|
||||
|
||||
# TODO: After some point also add in a `btm check` invocation
|
||||
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
validations:
|
||||
|
|
|
@ -41,7 +41,7 @@ doctest = true
|
|||
doc = true
|
||||
|
||||
[profile.release]
|
||||
# debug = true
|
||||
# debug = true # Might be nice to have a custom profile for flamegraphs.
|
||||
# strip = false
|
||||
debug = 0
|
||||
strip = "symbols"
|
||||
|
|
10
src/app.rs
10
src/app.rs
|
@ -12,7 +12,7 @@ pub use states::*;
|
|||
use typed_builder::*;
|
||||
use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
|
||||
|
||||
use crate::widgets::{ProcWidget, ProcWidgetMode};
|
||||
use crate::widgets::{ProcWidgetMode, ProcWidgetState};
|
||||
use crate::{
|
||||
constants,
|
||||
data_conversion::ConvertedData,
|
||||
|
@ -1190,7 +1190,7 @@ impl App {
|
|||
.proc_state
|
||||
.get_mut_widget_state(self.current_widget.widget_id)
|
||||
{
|
||||
proc_widget_state.select_column(ProcWidget::CPU);
|
||||
proc_widget_state.select_column(ProcWidgetState::CPU);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1200,7 +1200,7 @@ impl App {
|
|||
.proc_state
|
||||
.get_mut_widget_state(self.current_widget.widget_id)
|
||||
{
|
||||
proc_widget_state.select_column(ProcWidget::MEM);
|
||||
proc_widget_state.select_column(ProcWidgetState::MEM);
|
||||
}
|
||||
} else if let Some(disk) = self
|
||||
.disk_state
|
||||
|
@ -1215,7 +1215,7 @@ impl App {
|
|||
.proc_state
|
||||
.get_mut_widget_state(self.current_widget.widget_id)
|
||||
{
|
||||
proc_widget_state.select_column(ProcWidget::PID_OR_COUNT);
|
||||
proc_widget_state.select_column(ProcWidgetState::PID_OR_COUNT);
|
||||
}
|
||||
} else if let Some(disk) = self
|
||||
.disk_state
|
||||
|
@ -1240,7 +1240,7 @@ impl App {
|
|||
.proc_state
|
||||
.get_mut_widget_state(self.current_widget.widget_id)
|
||||
{
|
||||
proc_widget_state.select_column(ProcWidget::PROC_NAME_OR_CMD);
|
||||
proc_widget_state.select_column(ProcWidgetState::PROC_NAME_OR_CMD);
|
||||
}
|
||||
} else if let Some(disk) = self
|
||||
.disk_state
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
utils::gen_util::str_width,
|
||||
widgets::{
|
||||
BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
|
||||
ProcWidget, TempWidgetState,
|
||||
ProcWidgetState, TempWidgetState,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -251,19 +251,19 @@ impl AppSearchState {
|
|||
}
|
||||
|
||||
pub struct ProcState {
|
||||
pub widget_states: HashMap<u64, ProcWidget>,
|
||||
pub widget_states: HashMap<u64, ProcWidgetState>,
|
||||
}
|
||||
|
||||
impl ProcState {
|
||||
pub fn init(widget_states: HashMap<u64, ProcWidget>) -> Self {
|
||||
pub fn init(widget_states: HashMap<u64, ProcWidgetState>) -> Self {
|
||||
ProcState { widget_states }
|
||||
}
|
||||
|
||||
pub fn get_mut_widget_state(&mut self, widget_id: u64) -> Option<&mut ProcWidget> {
|
||||
pub fn get_mut_widget_state(&mut self, widget_id: u64) -> Option<&mut ProcWidgetState> {
|
||||
self.widget_states.get_mut(&widget_id)
|
||||
}
|
||||
|
||||
pub fn get_widget_state(&self, widget_id: u64) -> Option<&ProcWidget> {
|
||||
pub fn get_widget_state(&self, widget_id: u64) -> Option<&ProcWidgetState> {
|
||||
self.widget_states.get(&widget_id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,11 +113,6 @@ pub fn handle_key_event_or_break(
|
|||
) -> bool {
|
||||
// debug!("KeyEvent: {:?}", event);
|
||||
|
||||
// TODO: [PASTE] Note that this does NOT support some emojis like flags. This is due to us
|
||||
// catching PER CHARACTER right now WITH A forced throttle! This means multi-char will not work.
|
||||
// We can solve this (when we do paste probably) while keeping the throttle (mainly meant for movement)
|
||||
// by throttling after *bulk+singular* actions, not just singular ones.
|
||||
|
||||
if event.modifiers.is_empty() {
|
||||
// Required catch for searching - otherwise you couldn't search with q.
|
||||
if event.code == KeyCode::Char('q') && !app.is_in_search_widget() {
|
||||
|
|
|
@ -24,7 +24,7 @@ use crate::{
|
|||
utils::error::{self, BottomError},
|
||||
widgets::{
|
||||
BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
|
||||
ProcWidget, ProcWidgetMode, TempWidgetState,
|
||||
ProcWidgetMode, ProcWidgetState, TempWidgetState,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -198,7 +198,7 @@ pub fn build_app(
|
|||
let mut cpu_state_map: HashMap<u64, CpuWidgetState> = HashMap::new();
|
||||
let mut mem_state_map: HashMap<u64, MemWidgetState> = HashMap::new();
|
||||
let mut net_state_map: HashMap<u64, NetWidgetState> = HashMap::new();
|
||||
let mut proc_state_map: HashMap<u64, ProcWidget> = HashMap::new();
|
||||
let mut proc_state_map: HashMap<u64, ProcWidgetState> = HashMap::new();
|
||||
let mut temp_state_map: HashMap<u64, TempWidgetState> = HashMap::new();
|
||||
let mut disk_state_map: HashMap<u64, DiskTableWidget> = HashMap::new();
|
||||
let mut battery_state_map: HashMap<u64, BatteryWidgetState> = HashMap::new();
|
||||
|
@ -326,7 +326,7 @@ pub fn build_app(
|
|||
|
||||
proc_state_map.insert(
|
||||
widget.widget_id,
|
||||
ProcWidget::new(
|
||||
ProcWidgetState::new(
|
||||
&app_config_fields,
|
||||
mode,
|
||||
is_case_sensitive,
|
||||
|
|
|
@ -72,7 +72,7 @@ type ProcessTable = SortDataTable<ProcWidgetData, ProcColumn>;
|
|||
type SortTable = DataTable<Cow<'static, str>, SortTableColumn>;
|
||||
type StringPidMap = FxHashMap<String, Vec<Pid>>;
|
||||
|
||||
pub struct ProcWidget {
|
||||
pub struct ProcWidgetState {
|
||||
pub mode: ProcWidgetMode,
|
||||
|
||||
/// The state of the search box.
|
||||
|
@ -92,7 +92,7 @@ pub struct ProcWidget {
|
|||
pub force_update_data: bool,
|
||||
}
|
||||
|
||||
impl ProcWidget {
|
||||
impl ProcWidgetState {
|
||||
pub const PID_OR_COUNT: usize = 0;
|
||||
pub const PROC_NAME_OR_CMD: usize = 1;
|
||||
pub const CPU: usize = 2;
|
||||
|
@ -222,7 +222,7 @@ impl ProcWidget {
|
|||
|
||||
let id_pid_map = FxHashMap::default();
|
||||
|
||||
let mut table = ProcWidget {
|
||||
let mut table = ProcWidgetState {
|
||||
proc_search: process_search_state,
|
||||
table,
|
||||
sort_table,
|
||||
|
@ -240,7 +240,7 @@ impl ProcWidget {
|
|||
pub fn is_using_command(&self) -> bool {
|
||||
self.table
|
||||
.columns
|
||||
.get(ProcWidget::PROC_NAME_OR_CMD)
|
||||
.get(ProcWidgetState::PROC_NAME_OR_CMD)
|
||||
.map(|col| matches!(col.inner(), ProcColumn::Command))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ impl ProcWidget {
|
|||
pub fn is_mem_percent(&self) -> bool {
|
||||
self.table
|
||||
.columns
|
||||
.get(ProcWidget::MEM)
|
||||
.get(ProcWidgetState::MEM)
|
||||
.map(|col| matches!(col.inner(), ProcColumn::MemoryPercent))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue