Commit graph

185 commits

Author SHA1 Message Date
Clement Tsang
76c3bc4254
refactor: clippy and small cleanup/comments (#865)
* refactor: small cleanup and comments in some code

* clippy

* more clippy

* fixes for macos/freebsd
2022-11-04 04:17:22 -04:00
Clement Tsang
064d740c6d
refactor: move data passing for table to another step (#863)
* refactor: remove redundant scroll direction enum

This was made redundant from the table refactor.

* add some todos/docs

* refactor: temp hack to pass in data on process
2022-11-02 00:36:55 -04:00
Clement Tsang
a949740c94
other: make gpu memory collection configurable (#835)
Follow-up to #794, this makes GPU memory collection toggleable.
2022-10-15 16:50:21 -04:00
Justin Martin
bd35bbdc9c
feature: add gpu ram collector for nvidia feature flag (#794)
* add gpu ram collector for nvidia feature flag

* add row for TX in basic layout

* size gpu point_vec

* use vec for mem basic widget drawing

* remove to_owned

* code review: change mem tuple to struct with cfg fields, rename mem_basic ratio and use vec macro for layout

* build on freebsd
2022-10-15 15:08:48 -04:00
Clement Tsang
8b72a33f40
refactor: move point definition to tui_rs widget (#832) 2022-10-13 15:40:19 -04:00
Clement Tsang
b6a75db1b4
refactor: switch to pipe gauge implementation for basic cpu + mem (#829)
* refactor: switch to pipe gauge implementation for basic cpu + mem

* fix incorrect new basic cpu chunking scheme, revert to old one
2022-10-13 10:17:26 -04:00
Clement Tsang
2a740f48f7
refactor: tables V2 (#749)
* refactor: move to new data table implementation

* more work towards refactor

* move disk and temp over, fix longstanding bug with disk and temp if removing the last value and selected

* work towards porting over CPU

work towards porting over CPU

fix typo

partially port over cpu, fix some potentially inefficient concat_string calls

more work towards cpu widget migration

some refactoring

* sortable data

sortable data

more refactoring

some sort refactoring

more refactoringgggg

column refactoring

renaming and reorganizing

more refactoring regarding column logic

add sort arrows again

* move over sort menu

* port over process

port over process

precommit

temp

temp two, remember to squash

work

fix broken ltr calculation and CPU hiding

add back row styling

temp

fix a bunch of issues, get proc working

more fixes around click

fix frozen issues

* fix dd process killing

* revert some of the persistent config changes from #257

* fix colouring for trees

* fix missing entries in tree

* keep columns if there is no data

* add and remove tests

* Fix ellipsis
2022-10-12 16:25:38 -04:00
Clement Tsang
46a2a3a52b
other: Clarify help menu (#800)
* other: clarify that numbers are for help menu

* bug: fix incorrect overscroll check, should be min
2022-09-03 04:04:03 -04:00
Justin Martin
6e0bc96093
feature: Add zfs feature flag for arc memory (#784)
* freebsd clippy

* add arc support

* Code Review: moved runtime cfg checks to compile time and formatting

* remove compile platform checks

* add zfs feature flag to get_arc_data
2022-08-22 02:47:22 -04:00
Clement Tsang
3016a3d6a2
refactor: change max_scroll_index usage to better reflect name (#783)
Tweaks `max_scroll_index` usage in the help menu to better reflect its name of being a max index, not a max index bound.

For example, before, the index could not be equal to or more than `max_scroll_index`, but the name would have implied that it should be less than or equal to it.
2022-08-14 18:21:48 -04:00
ViridiCanis
5da7411d3c
Feature: half page scrolling (#774)
* add ctrl-u/ctrl-d to process table

* add help text for ctrl-u/ctrl-d

* add ctrl-u/ctrl-d to help dialog

* store height of help menu, fix overscroll with half page down on help menu

Co-authored-by: ClementTsang <34804052+ClementTsang@users.noreply.github.com>
2022-08-14 17:47:03 -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
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
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
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
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
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
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
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
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
cb680dd12e
other: Add RISC-V to unofficially supported targets (#565)
Adds CI actions and documentation for RISC-V.
2021-07-31 16:24:16 -04:00
Clement Tsang
3313e88334
bug: Fix battery widget color and mouse (#504)
Fixes two bugs causing the battery widget colours and mouse events to be broken.
2021-06-20 20:28:44 -04:00
Clement Tsang
d4a18aea75
bug: Fix mouse hitboxes (#459)
Fixes the mouse hitbox checks overextending by 1. Also reverts the bandaid fix done for #458.
2021-04-23 23:13:42 -04:00
Clement Tsang
fcc478a1eb
bug: Fixes basic mode mouse hitboxes being broken (#458)
Fixes basic mode having broken click hitboxes (they were 1 unit too long in both directions). I'm pretty sure normal mode does too, but it's less noticeable due to bounding boxes.
2021-04-23 19:31:35 -04:00
Clement Tsang
0148432b15
refactor: Take clippy nightly suggestions into account (#456)
Refactor in regards to clippy nightly. Mostly deals with suggestions with duplicate code on multiple branches.
2021-04-23 00:06:07 -04:00
Clement Tsang
eb6a737d34
feature: Rework network y-axis, linear interpolation for off-screen data (#437)
Rewrite of the y-axis labeling and scaling for the network widget, along with more customization. This still has one step to be optimized (cache results so we don't have to recalculate the legend each time), but will be done in another PR for sake of this one being too large already.

Furthermore, this change adds linear interpolation at the 0 point in the case a data point shoots too far back - this seems to have lead to ugly gaps to the left of graphs in some cases, because the left hand limit was not big enough for the data point. We address this by grabbing values just outside the time range and linearly interpolating at the leftmost limit. This affects all graph widgets (CPU, mem, network).

This can be optimized, and will hopefully be prior to release in a separate change.
2021-04-04 05:38:57 -04:00
pvanheus
d8f8a92b55
feature: Add support for displaying load average (#392) 2021-03-12 20:03:25 -05:00
Clement Tsang
53d8bdae32
feature: User info in proc widget for Unix-based systems (#425)
Adds users into the process widget (for Unix-based systems).  This shows only in non-grouped modes, similar to state.  Search is also supported.

In addition, a quick fix to prevent users from being in grouped mode when they tried to enter tree mode while grouped.
2021-02-28 17:40:55 -05:00
Clement Tsang
cb1191ff35
deps: Update various deps as per 2021-02-19 (#420)
Major update is tui-rs from 0.13 to 0.14.  This change allows us to update our tables to make them look nicer!
2021-02-19 17:57:39 -05:00
Clement Tsang
e6230ef156
bug: fix inconsistent spacing with grouped vs non-grouped in the process widget (#416)
Fixes grouped mode having different spacing than non-grouped mode.
2021-02-18 19:15:07 -05:00
Clement Tsang
4db39da75e
feature: Add mouse support to sorting columns (#413)
Adds mouse support for sorting columns within the process widget. You can now click on the column header to sort (or invert the sort).
2021-02-18 17:10:51 -05:00