Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Rework network y-axis, linear interpolation for off-screen data #437

Merged
merged 26 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1ba7bf1
feature: Add network y-axis scaling & unit options
ClementTsang Mar 13, 2021
863b3fa
Get most of it done...?
ClementTsang Mar 15, 2021
d8d1c0d
Some minor cometic things, want to do a cache as well
ClementTsang Mar 15, 2021
3fb6cc4
Add missing files
ClementTsang Mar 15, 2021
24419ea
Clippy fixes
ClementTsang Mar 15, 2021
270a884
Fix bugs with tx
ClementTsang Mar 23, 2021
f79b686
Add fixme
ClementTsang Mar 23, 2021
e29de6d
Fix clippy warnings about type names
ClementTsang Mar 27, 2021
2495ef0
More clippy fixes
ClementTsang Mar 27, 2021
4ea4bb6
Fix some macos lint warnings
ClementTsang Mar 27, 2021
5cc4438
Remove redundant push as per clippy
ClementTsang Mar 27, 2021
0142385
Fix os-specific refactor
ClementTsang Mar 28, 2021
f357954
Linear interpolation
ClementTsang Mar 28, 2021
ef2d8db
Update changelog
ClementTsang Apr 3, 2021
6d416b9
Change log scale system to be the same as existing, update docs
ClementTsang Apr 4, 2021
063a24f
Switch around starting default binary and dec prefixes, was bug
ClementTsang Apr 4, 2021
3485cd8
Drop empty default to kilo level
ClementTsang Apr 4, 2021
7b4e9b2
Remove ordered-float from deps for now
ClementTsang Apr 4, 2021
f022564
Expand todo for using bytes as default in harvesting phase
ClementTsang Apr 4, 2021
1dc43bb
Remove unused code for now
ClementTsang Apr 4, 2021
c955b04
Remove useless spacing param in prefix/byte/bit fn
ClementTsang Apr 4, 2021
f4477bf
Remove redundant file for now
ClementTsang Apr 4, 2021
1cdb62a
Add a comment on one area
ClementTsang Apr 4, 2021
a5d9605
Minor renaming
ClementTsang Apr 4, 2021
3274917
Another minor renaming + comment on a confusing function
ClementTsang Apr 4, 2021
57d2c98
Simplify a function a bit
ClementTsang Apr 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
override: true
components: clippy

# TODO: Can probably put cache here in the future; I'm worried if this will cause issues with clippy though since cargo check breaks it; maybe wait until 1.52, when fix lands.

- run: cargo clippy --all-targets --workspace -- -D warnings

# Compile/check test.
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"Mahmoud",
"Marcin",
"Mousebindings",
"NAS's",
"Nonexhaustive",
"PEBI",
"PETA",
"PKGBUILD",
"PKGBUILDs",
"Polishchuk",
Expand Down Expand Up @@ -90,6 +93,7 @@
"libc",
"markdownlint",
"memb",
"minmax",
"minwindef",
"musl",
"musleabihf",
Expand All @@ -102,14 +106,17 @@
"nvme",
"paren",
"pcpu",
"piasecki",
"pids",
"pmem",
"powerpc",
"powerpc le",
"ppid",
"prepush",
"processthreadsapi",
"pvanheus",
"regexes",
"rposition",
"rsplitn",
"runlevel",
"rustc",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#381](https://github.com/ClementTsang/bottom/pull/381): Added a filter in the config file for network interfaces.

- [#392](https://github.com/ClementTsang/bottom/pull/392): Added CPU load averages (1, 5, 15) for Unix-based systems.

- [#406](https://github.com/ClementTsang/bottom/pull/406): Added the Nord colour scheme, as well as a light variant.

- [#409](https://github.com/ClementTsang/bottom/pull/409): Added `Ctrl-w` and `Ctrl-h` shortcuts in search, to delete a word and delete a character respectively.
Expand All @@ -25,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#425](https://github.com/ClementTsang/bottom/pull/425): Added user into the process widget for Unix-based systems.

- [#437](https://github.com/ClementTsang/bottom/pull/437): Redo dynamic network y-axis, add linear scaling, unit type, and prefix options.

## Changes

- [#372](https://github.com/ClementTsang/bottom/pull/372): Hides the SWAP graph and legend in normal mode if SWAP is 0.
Expand All @@ -37,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#420](https://github.com/ClementTsang/bottom/pull/420): Updated tui-rs, allowing for prettier looking tables!

- [#437](https://github.com/ClementTsang/bottom/pull/437): Add linear interpolation step in drawing step to pr event missing entries on the right side of charts.

## Bug Fixes

- [#416](https://github.com/ClementTsang/bottom/pull/416): Fixes grouped vs ungrouped modes in the processes widget having inconsistent spacing.
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ futures = "0.3.12"
indexmap = "~1.6"
itertools = "0.10.0"
once_cell = "1.5.2"
# ordered-float = "2.1.1"
regex = "1.4.3"
serde = { version = "1.0.123", features = ["derive"] }
# Sysinfo is still used in Linux for the ProcessStatus
sysinfo = "0.16.4"
thiserror = "1.0.24"
toml = "0.5.8"
Expand Down
74 changes: 40 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Or, you can just download the binary from the [latest release](https://github.co

### Nightly

You can install pre-release nightly versions [here](https://github.com/ClementTsang/bottom/releases/tag/nightly). Builds are generated every day at 00:00 UTC, based on the most recent commit on the master branch.
You can install pre-release nightly versions [here](https://github.com/ClementTsang/bottom/releases/tag/nightly). Builds are generated every day at 00:00 UTC, based on the most recent commit on the master branch.

### Cargo

Expand Down Expand Up @@ -252,38 +252,41 @@ Run using `btm`.
Use `btm --help` for more information.

```
--advanced_kill Shows more options when killing a process on Unix-like systems.
--autohide_time Temporarily shows the time scale in graphs.
-b, --basic Hides graphs and uses a more basic look.
--battery Shows the battery widget.
-S, --case_sensitive Enables case sensitivity by default.
-c, --celsius Sets the temperature type to Celsius.
--color <COLOR SCHEME> Use a color scheme, use --help for supported values.
-C, --config <CONFIG PATH> Sets the location of the config file.
-u, --current_usage Sets process CPU% to be based on current CPU%.
-t, --default_time_value <MS> Default time value for graphs in ms.
--default_widget_count <INT> Sets the n'th selected widget type as the default.
--default_widget_type <WIDGET TYPE> Sets the default widget type, use --help for more info.
--disable_click Disables mouse clicks.
-m, --dot_marker Uses a dot marker for graphs.
-f, --fahrenheit Sets the temperature type to Fahrenheit.
-g, --group Groups processes with the same name by default.
-h, --help Prints help information. Use --help for more info.
-a, --hide_avg_cpu Hides the average CPU usage.
--hide_table_gap Hides the spacing between table headers and entries.
--hide_time Completely hides the time scaling.
-k, --kelvin Sets the temperature type to Kelvin.
-l, --left_legend Puts the CPU chart legend to the left side.
--mem_as_value Defaults to showing process memory usage by value.
--process_command Show processes as their commands by default.
-r, --rate <MS> Sets a refresh rate in ms.
-R, --regex Enables regex by default.
--show_table_scroll_position Shows the scroll position tracker in table widgets.
-d, --time_delta <MS> The amount in ms changed upon zooming.
-T, --tree Defaults to showing the process widget in tree mode.
--use_old_network_legend DEPRECATED - uses the older network legend.
-V, --version Prints version information.
-W, --whole_word Enables whole-word matching by default.
--advanced_kill Shows more options when killing a process on Unix-like systems.
--autohide_time Temporarily shows the time scale in graphs.
-b, --basic Hides graphs and uses a more basic look.
--battery Shows the battery widget.
-S, --case_sensitive Enables case sensitivity by default.
-c, --celsius Sets the temperature type to Celsius.
--color <COLOR SCHEME> Use a color scheme, use --help for supported values.
-C, --config <CONFIG PATH> Sets the location of the config file.
-u, --current_usage Sets process CPU% to be based on current CPU%.
-t, --default_time_value <MS> Default time value for graphs in ms.
--default_widget_count <INT> Sets the n'th selected widget type as the default.
--default_widget_type <WIDGET TYPE> Sets the default widget type, use --help for more info.
--disable_click Disables mouse clicks.
-m, --dot_marker Uses a dot marker for graphs.
-f, --fahrenheit Sets the temperature type to Fahrenheit.
-g, --group Groups processes with the same name by default.
-h, --help Prints help information. Use --help for more info.
-a, --hide_avg_cpu Hides the average CPU usage.
--hide_table_gap Hides the spacing between table headers and entries.
--hide_time Completely hides the time scaling.
-k, --kelvin Sets the temperature type to Kelvin.
-l, --left_legend Puts the CPU chart legend to the left side.
--mem_as_value Defaults to showing process memory usage by value.
--network_use_binary_prefix Displays the network widget with binary prefixes.
--network_use_bytes Displays the network widget using bytes.
--network_use_log Displays the network widget with a log scale.
--process_command Show processes as their commands by default.
-r, --rate <MS> Sets a refresh rate in ms.
-R, --regex Enables regex by default.
--show_table_scroll_position Shows the scroll position tracker in table widgets.
-d, --time_delta <MS> The amount in ms changed upon zooming.
-T, --tree Defaults to showing the process widget in tree mode.
--use_old_network_legend DEPRECATED - uses the older network legend.
-V, --version Prints version information.
-W, --whole_word Enables whole-word matching by default.
```

### Keybindings
Expand Down Expand Up @@ -464,7 +467,7 @@ As yet _another_ process/system visualization and management application, bottom

- RAM and swap usage visualization

- Network visualization for receiving and transmitting, on a log-graph scale
- Network visualization for receiving and transmitting

- Display information about disk capacity and I/O per second

Expand Down Expand Up @@ -599,6 +602,9 @@ These are the following supported flag config values, which correspond to the fl
| `show_table_scroll_position` | Boolean | Shows the scroll position tracker in table widgets. |
| `process_command` | Boolean | Show processes as their commands by default. |
| `advanced_kill` | Boolean | Shows more options when killing a process on Unix-like systems. |
| `network_use_binary_prefix` | Boolean | Displays the network widget with binary prefixes. |
| `network_use_bytes` | Boolean | Displays the network widget using bytes. |
| `network_use_log` | Boolean | Displays the network widget with a log scale. |

#### Theming

Expand Down
71 changes: 41 additions & 30 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::{
options::Config,
options::ConfigFlags,
options::WidgetIdEnabled,
units::data_units::DataUnit,
utils::error::{BottomError, Result},
Pid,
};
Expand All @@ -34,6 +35,12 @@ pub mod states;

const MAX_SEARCH_LENGTH: usize = 200;

#[derive(Debug, Clone)]
pub enum AxisScaling {
Log,
Linear,
}

/// AppConfigFields is meant to cover basic fields that would normally be set
/// by config files or launch options.
#[derive(Debug)]
Expand All @@ -55,6 +62,10 @@ pub struct AppConfigFields {
pub no_write: bool,
pub show_table_scroll_position: bool,
pub is_advanced_kill: bool,
// TODO: Remove these, move network details state-side.
pub network_unit_type: DataUnit,
pub network_scale_type: AxisScaling,
pub network_use_binary_prefix: bool,
}

/// For filtering out information
Expand Down Expand Up @@ -708,7 +719,7 @@ impl App {
if self.delete_dialog_state.is_showing_dd {
if self.dd_err.is_some() {
self.close_dd();
} else if self.delete_dialog_state.selected_signal != KillSignal::CANCEL {
} else if self.delete_dialog_state.selected_signal != KillSignal::Cancel {
// If within dd...
if self.dd_err.is_none() {
// Also ensure that we didn't just fail a dd...
Expand Down Expand Up @@ -886,7 +897,7 @@ impl App {
if kbd_signal > 31 {
kbd_signal %= 10;
}
self.delete_dialog_state.selected_signal = KillSignal::KILL(kbd_signal);
self.delete_dialog_state.selected_signal = KillSignal::Kill(kbd_signal);
if kbd_signal < 10 {
self.delete_dialog_state.keyboard_signal_select = kbd_signal;
} else {
Expand Down Expand Up @@ -991,23 +1002,23 @@ impl App {
{
if self.app_config_fields.is_advanced_kill {
match self.delete_dialog_state.selected_signal {
KillSignal::KILL(prev_signal) => {
KillSignal::Kill(prev_signal) => {
self.delete_dialog_state.selected_signal = match prev_signal - 1 {
0 => KillSignal::CANCEL,
0 => KillSignal::Cancel,
// 32+33 are skipped
33 => KillSignal::KILL(31),
signal => KillSignal::KILL(signal),
33 => KillSignal::Kill(31),
signal => KillSignal::Kill(signal),
};
}
KillSignal::CANCEL => {}
KillSignal::Cancel => {}
};
} else {
self.delete_dialog_state.selected_signal = KillSignal::default();
}
}
#[cfg(target_os = "windows")]
{
self.delete_dialog_state.selected_signal = KillSignal::KILL(1);
self.delete_dialog_state.selected_signal = KillSignal::Kill(1);
}
}
}
Expand Down Expand Up @@ -1067,53 +1078,53 @@ impl App {
{
if self.app_config_fields.is_advanced_kill {
let new_signal = match self.delete_dialog_state.selected_signal {
KillSignal::CANCEL => 1,
KillSignal::Cancel => 1,
// 32+33 are skipped
#[cfg(target_os = "linux")]
KillSignal::KILL(31) => 34,
KillSignal::Kill(31) => 34,
#[cfg(target_os = "macos")]
KillSignal::KILL(31) => 31,
KillSignal::KILL(64) => 64,
KillSignal::KILL(signal) => signal + 1,
KillSignal::Kill(31) => 31,
KillSignal::Kill(64) => 64,
KillSignal::Kill(signal) => signal + 1,
};
self.delete_dialog_state.selected_signal = KillSignal::KILL(new_signal);
self.delete_dialog_state.selected_signal = KillSignal::Kill(new_signal);
} else {
self.delete_dialog_state.selected_signal = KillSignal::CANCEL;
self.delete_dialog_state.selected_signal = KillSignal::Cancel;
}
}
#[cfg(target_os = "windows")]
{
self.delete_dialog_state.selected_signal = KillSignal::CANCEL;
self.delete_dialog_state.selected_signal = KillSignal::Cancel;
}
}
}

pub fn on_page_up(&mut self) {
if self.delete_dialog_state.is_showing_dd {
let mut new_signal = match self.delete_dialog_state.selected_signal {
KillSignal::CANCEL => 0,
KillSignal::KILL(signal) => max(signal, 8) - 8,
KillSignal::Cancel => 0,
KillSignal::Kill(signal) => max(signal, 8) - 8,
};
if new_signal > 23 && new_signal < 33 {
new_signal -= 2;
}
self.delete_dialog_state.selected_signal = match new_signal {
0 => KillSignal::CANCEL,
sig => KillSignal::KILL(sig),
0 => KillSignal::Cancel,
sig => KillSignal::Kill(sig),
};
}
}

pub fn on_page_down(&mut self) {
if self.delete_dialog_state.is_showing_dd {
let mut new_signal = match self.delete_dialog_state.selected_signal {
KillSignal::CANCEL => 8,
KillSignal::KILL(signal) => min(signal + 8, MAX_SIGNAL),
KillSignal::Cancel => 8,
KillSignal::Kill(signal) => min(signal + 8, MAX_SIGNAL),
};
if new_signal > 31 && new_signal < 42 {
new_signal += 2;
}
self.delete_dialog_state.selected_signal = KillSignal::KILL(new_signal);
self.delete_dialog_state.selected_signal = KillSignal::Kill(new_signal);
}
}

Expand Down Expand Up @@ -1672,8 +1683,8 @@ impl App {
if let Some(current_selected_processes) = &self.to_delete_process_list {
#[cfg(target_family = "unix")]
let signal = match self.delete_dialog_state.selected_signal {
KillSignal::KILL(sig) => sig,
KillSignal::CANCEL => 15, // should never happen, so just TERM
KillSignal::Kill(sig) => sig,
KillSignal::Cancel => 15, // should never happen, so just TERM
};
for pid in &current_selected_processes.1 {
#[cfg(target_family = "unix")]
Expand Down Expand Up @@ -2229,7 +2240,7 @@ impl App {
} else if self.help_dialog_state.is_showing_help {
self.help_dialog_state.scroll_state.current_scroll_index = 0;
} else if self.delete_dialog_state.is_showing_dd {
self.delete_dialog_state.selected_signal = KillSignal::CANCEL;
self.delete_dialog_state.selected_signal = KillSignal::Cancel;
}
}

Expand Down Expand Up @@ -2312,7 +2323,7 @@ impl App {
.max_scroll_index
.saturating_sub(1);
} else if self.delete_dialog_state.is_showing_dd {
self.delete_dialog_state.selected_signal = KillSignal::KILL(MAX_SIGNAL);
self.delete_dialog_state.selected_signal = KillSignal::Kill(MAX_SIGNAL);
}
}

Expand Down Expand Up @@ -2871,13 +2882,13 @@ impl App {
},
) {
Some((_, _, _, _, 0)) => {
self.delete_dialog_state.selected_signal = KillSignal::CANCEL
self.delete_dialog_state.selected_signal = KillSignal::Cancel
}
Some((_, _, _, _, idx)) => {
if *idx > 31 {
self.delete_dialog_state.selected_signal = KillSignal::KILL(*idx + 2)
self.delete_dialog_state.selected_signal = KillSignal::Kill(*idx + 2)
} else {
self.delete_dialog_state.selected_signal = KillSignal::KILL(*idx)
self.delete_dialog_state.selected_signal = KillSignal::Kill(*idx)
}
}
_ => {}
Expand Down
Loading