Commit Graph

651 Commits

Author SHA1 Message Date
ClementTsang 56bb3657a4 clippy: fix clippy eq warning 2022-08-13 11:34:17 -04:00
Wesley Moore 577fda96fc
Implement support for FreeBSD (#766)
* WIP FreeBSD support

* Implement get_cpu_data_list for FreeBSD

* Implement disks for FreeBSD

It doesn't work though as sysinfo doesn't make the device name available.

* Use libxo to read process cpu info on FreeBSD

* Populate get_io_usage with libxo too

Actual I/O stats still aren't populated though as there's not an
easy source for them.

* Share more processes code between macos and freebsd

* Extract function for deserializing libxo output on FreeBSD

* Implement filtering of disks in FreeBSD

* Clean up memory data collection

* Update module docs
2022-07-23 20:44:29 -04:00
Clement Tsang 121632760d
bug: fix total read/write units having /s (#763)
Fixes the total read/write columns in processes using the wrong unit (having /s).
2022-07-07 05:45:30 -04:00
Clement Tsang 04d1218f65
feature: add note on how to exit if running in non-terminal (#761)
Addition to #760, adds an extra message so users know how to exit in this scenario.
2022-06-29 01:15:37 -04:00
Clement Tsang baf844244d
feature: add check for whether the output is to a terminal (#760)
Adds a warning if the user is calling bottom from an environment where the output is not a terminal.
2022-06-28 23:00:52 -04:00
Clement Tsang c6f5d5488a
docs: re-enable lib docs for development purposes (#750)
Enables lib docs, primarily intended for dev use. Also change some existing documentation based on warnings (mainly broken/bare links).
2022-06-14 18:31:32 -04:00
Clement Tsang c1a7979be7
refactoring: Move around components and state (#746)
A small refactor to move some state/component files around in terms of file structure and code location. Should have no effect on logic.
2022-06-03 04:49:39 -04:00
Clement Tsang 8689492ae5
refactor: unify all mod.rs structure to 2018 style (#742)
This is a pretty small change, but at least _for now_, unifies all
`mod.rs` use cases to the 2018 style for consistency.

I personally don't mind going back to it on a case-by-case basis in the
future if it results in cleaner code, though.
2022-06-02 03:24:30 -04:00
Clement Tsang b986a259e1
other: make the graph legend the same color as the graph (#732)
This makes the graph legend the same color as the rest of the graph.
2022-05-17 05:42:48 -04:00
ClementTsang 01574c8afe bug: hide user column for non-unix 2022-05-16 15:08:46 -04:00
ClementTsang cc6d7b8ad7 bug: fix a variety of bugs
Bugs squashed:
- Incorrect column sizing for flex cases
- Case where the sort menu bounds were still existing despite being
  hidden
- Proc widget not actually taking into account the calculated row widths
  in some cases during data conversion.
2022-05-16 04:53:41 -04:00
ClementTsang 0831a56341 refactor: simplify partial ordering fn, clean up code 2022-05-15 21:02:33 -04:00
ClementTsang 1877ed5c88 refactor: remove redundant get_ordering fn, add tests 2022-05-15 21:02:33 -04:00
ClementTsang ba362f81c9 bug: fix issues with macos and windows during refactor 2022-05-15 21:02:33 -04:00
ClementTsang 05e9cd4d4d other: delete redundant code, run clippy and fmt 2022-05-15 21:02:33 -04:00
ClementTsang ed17264832 refactor: more work towards unifying process code
A bunch of work towards also refactoring how the process widget
gathers and converts data.
2022-05-15 21:02:33 -04:00
ClementTsang 7ee6f6a737 refactor: begin migration of process widget 2022-05-15 21:02:28 -04:00
ClementTsang 69ec526dc6 refactor: heavily simplify the old network legend 2022-05-15 05:03:42 -04:00
ClementTsang c97126df22 refactor: move CPU graph over to new system 2022-05-07 20:53:52 -04:00
ClementTsang 9e63642e9c refactor: fix off-by-one bug with getting start position 2022-05-07 20:53:52 -04:00
ClementTsang df1a418327 refactor: per-row styling, remove seemingly redundant table code 2022-05-07 20:53:52 -04:00
ClementTsang 2e51590bf5 refactor: don't draw header if too short 2022-05-07 20:53:52 -04:00
ClementTsang c296b8bf5a refactor: bind the start and end ranges for tables 2022-05-07 20:53:52 -04:00
ClementTsang 64ed45083e refactor: remove unneeded freeze param 2022-05-07 20:53:52 -04:00
ClementTsang 2a65bc95fe refactor: consolidate disk and temp table drawing, refactor state
Disk and temp tables now share the same drawing logic, as well as
consolidating the "text table" states into one single state, as opposed
to two separate states (one for scroll and one for width calculations).

BTW I know this is kinda an ugly design - creating a giant struct to
call a function - hopefully that's temporary, I want to do a bigger
refactor to consolidate more stuff together and therefore avoid this
problem, but baby steps, right?
2022-05-07 20:53:52 -04:00
Clement Tsang 4ceaf8d008
deps: migrate to starship-battery (#724)
Migrates the `battery` dependency to the more actively maintained
`starship-battery` fork, found at https://github.com/starship/rust-battery.
See https://github.com/svartalf/rust-battery/pull/92 for more information.
2022-05-06 17:16:57 -04:00
ClementTsang a92313a5be bug: fix panic if battery feature was disabled 2022-05-01 16:57:03 -04:00
Clement Tsang a516104dec
refactor: refactor some tests (#718)
Small PR to quickly refactor some recent tests to avoid too much duplication.
2022-04-29 16:02:34 -04:00
Clement Tsang cddee9d923
Merge pull request #710 from ClementTsang/consolidate_component_drawing
Cleans up some drawing code and unifies all time graph drawing.
2022-04-29 01:12:14 -04:00
ClementTsang 2401e583fb refactor: consolidate time graph components
This consolidates all the time graph drawing to one main location, as well
as some small improvements. This is helpful in that I don't have to
reimplement the same thing across three locations if I have to make one
change that in theory should affect them all. In particular, the CPU
graph, memory graph, and network graph are all now using the same,
generic implementation for drawing, which we call (for now) a component.

Note this only affects drawing - it accepts some parameters affecting style
and labels, as well as data points, and draw similarly to how it used to
before. Widget-specific actions, or things affecting widget state,
should all be handled by the widget-specific code instead. For example,
our current implementation of x-axis autohide is still controlled by the
widget, not the component, even if some of the code is shared. Components
are, again, only responsible for drawing (at least for now). For that
matter, the graph component does not have mutable access to any form of
state outside of tui-rs' `Frame`. Note this *might* change in the
future, where we might give the component state.

Note that while functionally, the graph behaviour for now is basically
the same, a few changes were made internally other than the move to
components. The big change is that rather than using tui-rs' `Chart`
for the underlying drawing, we now use a tweaked custom `TimeChart`
tui-rs widget, which also handles all interpolation steps and some extra
customization. Personally, I don't like having to deviate from the
library's implementation, but this gives us more flexibility and allows
greater control. For example, this allows me to move away from the old
hacks required to do interpolation (where I had to mutate the existing
list to avoid having to reallocate an extra vector just to insert one
extra interpolated point). I can also finally allow customizable
legends (which will be added in the future).
2022-04-28 23:36:53 -04:00
Clement Tsang e393078691
bug: fix choosing an out of list bounds selecting the last entry (#717)
This is a simple bug fix that changes the behaviour of a scroll select
(and column select) to only update if the updated position is _within_
the bounds of the list (0 to the max index, inclusive). Prior to this,
all the implementations but the disk implementation would just bound the
change. This was both inconsistent with the disk scroll state, but also
jarring since this meant a user could click on seemingly empty space but
it would somehow click on the very last entry.

This change also unifies the scroll calculation function between all the
scroll select functions. Ideally we get rid of the intermediary
functions but that might require more refactoring than I want for this
fairly simple bug fix.

The column select scroll calculation was also changed to fit this
behaviour, but it does not use the same logic as the other scroll
states. What could be done in the future is a generic implementation for
direction (or maybe just "increment vs. decrement") to share it all.
2022-04-28 22:39:33 -04:00
ClementTsang 1f731358ba refactor: remove dead config screen code
This code was never used and might as well be removed for clarity's
sake.
2022-04-28 01:40:10 -04:00
ClementTsang f68acc5c9d refactor: remove trait usage in component drawing
When I was newer to Rust, I got the weird impression that you couldn't
add functionality to a struct outside of the defining file without using
a trait.

That's obviously not true, so it's high time I got rid of it and just
made it part of the impl of the class itself, rather than declaring a
trait and then exporting/importing it.
2022-04-28 01:40:10 -04:00
Clement Tsang 476a4ad910
deps: update dependencies (#713)
Updates various dependencies in both Cargo.toml and Cargo.lock.
2022-04-27 19:23:34 -04:00
Clement Tsang d43bd6147d
bug: change as_ref() to build in Rust beta 1.61.0 (#711)
This changes various as_ref() calls as needed in order for bottom to successfully build in Rust beta 1.61, as they were causing type inference issues. These calls were either removed or changed to an alternative that does build (e.g. as_slice()).

Functionally, there should be no change.

For context, see:
- https://github.com/ClementTsang/bottom/issues/708
- https://github.com/rust-lang/rust/issues/96074
2022-04-27 18:34:49 -04:00
Clement Tsang d297ee4639
refactor: remove some simple as-casts (#697)
Remove some simple as casts that are easy to change to .into(), or easy to check.
2022-03-27 22:01:06 -04:00
ClementTsang 6fa04de2b7 docs: shorten some of the -h help dialog 2022-03-20 19:45:01 -04:00
Clement Tsang f2b8b4e842
other: add manpage file to cargo deb config, move back to build script (#693)
Adds the asset for the manpage to cargo deb config. Also moves the generated manpage file to a .1.gz file. Also, moves back to a build script since that was causing some issues for the automatic Cargo.toml fields detection for manpage and completion generation.

To prevent compilation from happening every time, and only in CI, we use an env var to avoid generation steps.
2022-03-11 06:45:05 -05:00
Clement Tsang 01f6bddab6
deps: update clap to 3.x (#690)
Updates bottom to use clap 3.x, along with some small refactoring changes.
2022-03-07 22:53:02 -05:00
Clement Tsang e682882aee
other: fix clippy lints on vector reference params (#689)
Fixes a few clippy lints around function parameters and using slices over vector references.
2022-03-07 18:44:45 -05:00
shurizzle c0feff3c01 Add support for nvidia GPUs 2022-02-13 00:07:44 +01:00
Frederick Zhang f54cc1a2cf
Refresh sysinfo CPU
Without this now sysinfo `sys.processors().len()` returns 0.
2022-02-02 11:41:38 +11:00
Clement Tsang 6c989785fb
bug: fix issues caused by having a width that is too small (#665)
Due to a missing check, you could resize the window to a width that was too small, and it would trigger an endless while-loop for any table while trying to redistribute remaining space. This has been rectified with an explicit check, as well as a smarter method of redistributing remaining space borrowed from the rewrite.

This also adds explicit width checks for widgets that have borders; if the width is <2, before, it would panic.

Note that the rewrite I have kinda fixes all these issues already, so I don't want to invest too hard into this, but this should be fine as a patch for now.

Also note that minimal heights don't seem to be causing any issues, it just seems to be minimal widths.
2022-01-27 19:16:27 -05:00
Guillaume Gomez e195b056b0 Update sysinfo version 2022-01-20 13:00:15 +01:00
Mateusz Mikuła 318fde3712 Remove unused constants 2021-12-31 00:41:01 +01:00
Mateusz Mikuła e33d6b5361 Replace statics with consts where possible 2021-12-30 21:29:57 +01:00
Mateusz Mikuła 72f2aeaab6
Fix Clippy warnings (#647) 2021-12-28 14:31:42 -05:00
Clement Tsang 9eabb061aa
feature: add basic page up/down scrolling (#646)
Adds page up/down scrolling support to respectively scroll up/down by a full page.

Note that this is mostly just to get the feature out for those interested, and is admittedly a bit rushed - I will be rewriting all logic involving event handling as part of state refactor anyways, so this will also get changed in the work done there, and therefore, I kinda just sped through this.
2021-12-27 18:23:11 -05:00
Clement Tsang cf08f935dc
deps: update time to 0.3.5 (#643)
Updates time to 0.3.5: https://github.com/time-rs/time/blob/main/CHANGELOG.md#035-2021-11-12
2021-12-23 17:31:41 -05:00
ClementTsang eaff52c8a4 docs: Add comment/changelog about not including guest twice 2021-12-22 14:57:15 -05:00