Commit Graph
626 Commits
Author SHA1 Message Date
ClementTsang 7ee85a82f7 refactor: finish help menu 2021-09-22 01:16:33 -04:00
ClementTsang e7b9c72912 refactor: add general keybinds, fix buggy movement
Adds back some of the general program keybinds, and fixes both a bug causing
widget movement via keybinds to be incorrect, and not correcting the
last selected widget in the layout tree rows/cols after clicking/setting
the default widget!
2021-09-11 00:46:34 -04:00
ClementTsang 587987a2a5 refactor: add back original behaviour for closing search/sort in proc 2021-09-08 22:48:06 -04:00
ClementTsang 955840b412 refactor: Add back scroll position and expanded 2021-09-07 22:49:10 -04:00
ClementTsang d8a6a2344e refactor: use a builder for block building 2021-09-07 21:37:11 -04:00
ClementTsang 9ef38cbf1a refactor: add back widget titles
Also has a few clippy fixes and bug fixes:
- Fix redundant rerendering on scroll on time graphs.
- Fix being off by one cell during rendering for no-battery situation
  on the battery widget.
- Fix having empty columns for
  rtl column width calculations (as otherwise it goes to the wrong column).
- Fix rendering issue on small windows with text tables.

We also now ensure that the CPU legend has enough room to draw!
2021-09-07 01:13:17 -04:00
ClementTsang 18af6b01bf refactor: delete a bunch of old unused code 2021-09-05 19:09:11 -04:00
ClementTsang fa00dec146 refactor: move over battery widget 2021-09-05 19:09:11 -04:00
ClementTsang eddc9a16c7 refactor: move basic mode over
Because writing your own layout system and management is just *so much
fun*. Totally.

-------------------------------------------------------------------

Moves the basic mode system over to the new drawing/widget system. In
the process, it has forced me to completely redo how we do layouts...
again. This is because basic mode has widgets that control their own
height - this means the height of the columns and rows that wrap it
are also affected by the widget's height.

The previous system, using a constraint tree and splitting draw Rects
via tui-rs' built-in constraint solver, did not support this concept
very well. It was not simple to propagate up the widths/heights
towards parents while also using tui-rs' built-in constraint solver.
In the end, it was easier to just rewrite it using another algorithm.

We now follow a process very similar to Flutter's layout system.
Relevant links to the Flutter docs are found in the code or below:

- https://flutter.dev/docs/development/ui/layout/constraints
- https://flutter.dev/docs/resources/inside-flutter#sublinear-layouts

The gist of it, however, is that we now instead a few new options for
any element in the layout tree. A node can either:

- Grow to fill remaining space
- Take up as much room as its children
- Be a specific length

Technically right now, it's not perfect, in that leaf nodes can be as
large as their children (which makes no sense), though in that case it
just treats it as an expand.
2021-09-05 19:09:11 -04:00
ClementTsang 204b4dc351 refactor: add back grouping and command 2021-09-05 19:09:11 -04:00
ClementTsang b1889b0934 refactor: add text input 2021-09-05 19:09:11 -04:00
ClementTsang 27736b7fc0 refactor: Add sort capabilities to processes 2021-09-05 19:09:03 -04:00
ClementTsang 3fa50605b3 bug: fix bug causing click bounds to fail
There were three bugs:

1. The click bounds calculation was incorrect. I did the silly mistake
   of checking for <= bounds for the bottom and right sections of a
   Rect when checking if the mouse intersected - this is WRONG.

   For example, let's say you want to calculate if an x value of 5 falls
   between something that starts at 0 and is 5 long.  It shouldn't,
   right?  Because it draws from 0 to 4?  But if you just did <=
   Rect.right(), you would get a hit - because it just does (start +
   width), so you get 5, and 5 <= 5!

   So, easy fix, change all far bounds checks to <.

2. The second bug is a mistake where I accidentally did not include
   bounds sets for my memory and net widgets. Instead, they set their
   bounds to the underlying graph representation, which is WRONG, since
   that bound gets updated on draw, and gets set to a slightly smaller
   rect due to borders!

3. A slightly sneakier one. This broke my bounds checks for the CPU
   widget - and it would have broken my process widget too.

   The problem lies in the concept of widgets that handle multiple
   "sub"-blocks internally, and how I was doing click detection
   internally - I would check if the bounds of the internal Components
   were hit.  Say, the CPU, I would check if the internal graph was hit,
   then if the internal table was hit.

   But wait! I said in point 2 that a graph gets its borders updated on
   draw to something slightly smaller, due to borders!  And there's the
   problem - it affected tables too.  I was setting the bounds of
   components to that of the *internal* representation - without borders
   - but my click detection *needed* borders included!

   Solution?  Add another trait function to check bordered bounds, and
   make the default implementation just check the existing bounds. For
   cases like internal Components that may need it, I add a separate
   implementation.

   I also switched over all border bounds checks for Widgets to that,
   since it's a bit more consistent.
2021-08-30 00:51:09 -04:00
ClementTsang 48c572dbaf refactor: change up event handling logistics
Slightly move around the ideas of EventResult, ReturnSignalResult,
and how they all work.

The gist of it is that we now have widgets returning EventResults (and
renamed to WidgetEventResult), and the main app event handler returns
ReturnSignalResult (now named EventResult).

Also add a new signal to handle re-updating data inputs! This is needed
for the process, and any sortable/configurable widget.
2021-08-29 19:43:27 -04:00
ClementTsang 1ec203caa2 refactor: Add data updating to process widget 2021-08-29 19:33:13 -04:00
ClementTsang 74293aa243 refactor: another pass on sorting and columns 2021-08-29 01:19:34 -04:00
ClementTsang 64d47d54d3 refactor: add network drawing cache system 2021-08-28 22:11:35 -04:00
ClementTsang 2bff04d8a4 refactor: port over graph widgets
Things working as of now:
- Actually drawing
- Interpolation
- Styling
2021-08-28 20:09:00 -04:00
ClementTsang b72e76aa71 refactor: separate out sorted and non-sorted text tables 2021-08-28 04:16:32 -04:00
ClementTsang 6b69e373de refactor: start moving over the event system 2021-08-28 04:16:32 -04:00
ClementTsang 0afc371eaa refactor: start moving over drawing system
In particular, moving over table-style widgets
2021-08-28 04:16:12 -04:00
ClementTsang dd7e183ec8 refactor: rip out trait system for drawing widgets
This rips out this weird trait system I previously used for drawing
widgets, where I implemented a trait onto the Painter struct that did
the drawing.  I have no idea what I was thinking back then.
2021-08-24 22:49:06 -04:00
ClementTsang 189be96622 refactor: rename files from mod to their directory names 2021-08-24 22:11:06 -04:00
ClementTsang b5e6dea324 refactor: more glue code to build layout
Even more glue code to help glue together our layout options to our new
layout system!

Note that this PR will most likely likely break the two options:
- default_widget_type
- default_widget_count
and as such, they'll probably be deleted in a later commit.

As for why, it's since they're kinda a pain to support and don't work
well. Users can still enable default widget selection through the
layout system (which will also see a revamp in the future).
2021-08-24 22:10:46 -04:00
ClementTsang 88ebcab8f2 refactor: add glue to prep for the transition
Write some glue code to transition from the old code to the new one.
2021-08-24 16:03:23 -04:00
ClementTsang 64c6d0c898 refactor + change: write new movement logic 2021-08-23 17:34:52 -04:00
ClementTsang e657fec2c0 refactor: Create new main widgets 2021-08-23 16:55:32 -04:00
ClementTsang 4f0eb7b7eb refactor: Create basic widget system 2021-08-23 16:55:32 -04:00
ClementTsang fceae8d442 refactor: clean up some states and code 2021-08-23 16:55:32 -04:00
ClementTsang 5749c32bd5 deps: Update crossterm + tui-rs, along with event handling code 2021-08-23 16:55:32 -04:00
ClementTsang f73ea0da36 refactor: Start state refactor 2021-08-23 16:55:27 -04:00
Clement Tsang bacaca5548 change: add '/s' to network usage legend (#557)
Adds "/s" to the the network usage graph legend.
2021-07-23 19:51:45 -04:00
Clement Tsang 2736dc9b35 refactor: switch to manual implementation of meminfo parse (#548)
Manually parse `/proc/meminfo` for the purposes of memory usage.
2021-07-17 22:27:40 -04:00
Clement Tsang 7f24e62867 bug: switch over to procfs for linux mem usage (#547)
Swap to manually calculating the mem total and usage via procfs. The usage calculation is now:

total - (free + cached + buffers + slab_reclaimable - shmem)

This follows the same usage calculation as htop. See the PR for more details.
2021-07-17 21:25:05 -04:00
Clement Tsang 4e07a28e17 bug: Fix swap calculation for Linux (#546)
Workaround for Linux heim memory units not being correct for swap.
2021-07-16 01:16:18 -04:00
ClementTsang 847027182b bug: move linux mem used to kilobytes too as workaround 2021-07-15 22:03:54 -04:00
Clement Tsang 741054e84a bug: fix inaccuracy in memory usage/total on macOS and Linux (#545)
Fixes the accuracy of the memory widget for Linux and macOS, and uses binary prefixes instead to be more accurate.

Regarding the first part, it turns out that the way I was calculating memory usage was *slightly* incorrect for a few reasons:

- Regarding macOS, it seems like the way I was determining usage (`usage = total - available`) is not the most accurate.  The better way of doing this is apparently `usage = wire + active`, where `wire` is memory always marked to stay in RAM, and `active` is memory currently in RAM.  This seems to be much closer to other applications now.

- Regarding Linux, this was somewhat due to two issues - one was that I should have used heim's own built-in function call to get how much memory was *used*, and the other is that when heim reads info from `meminfo`, it reads it in *kilobytes* - however, the values are actually in *kibibytes*.  As such, to get the value in kibibytes, you want to actually take it in kilobytes.

  While I've filed an issue for the library, for now, I'll just manually bandaid over this.  See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-proc-meminfo for more info.

Both changes take more advantage of platform-specific methods, and as such, the change unfortunately adds some ugly platform-specific code blocks.

Side note, Windows Task Manager apparently (?) uses binary prefixes for the values behind the scenes, but displays decimal prefixes.  As such, now that we've switched to binary prefixes, it'll "seem" like the two aren't matching anymore since the units won't match, despite the values matching.
2021-07-15 18:28:41 -04:00
Clement Tsang b0199d4d1c bug: scaling -> scale in some docs, help, and config (#543)
Just fixing a few typos.
2021-07-14 19:30:32 -04:00
Clement Tsang 968b7bb2de bug: Fix missing config options in docs and default config (#542)
Adds the missing hide_time and battery config option to the default config and corresponding documentation.

Should probably automate the generation of this somehow tbh, though this might change when I add in-app config (soon™)
2021-07-14 19:08:54 -04:00
ClementTsang 70242bc2b2 refactor: remove beef dependency for now
This is just a temp change, I wanted to remove it just for clarity's
sake among dependencies, and will probably add it back in the future.

For now I'll just stick to std's beef.
2021-07-12 22:31:57 -04:00
Clement Tsang 1598654bef bug: Divide Windows process cpu usage by number of processors (#525)
Fixes a bug displaying the CPU usage of a process in Windows due to not dividing by the number of processors.
2021-06-26 02:34:32 -04:00
Clement Tsang 93b899e745 feature: add F9 as an alternative process kill key (#518)
Adds F9 as an alternative kill shortcut to dd.
2021-06-22 20:34:00 -04:00
Clement Tsang 06071d5abf docs: migrate documentation over to mkdocs (#506)
A large migration of documentation over to mkdocs, and some rewrites. Some stuff (install information, basic supported systems, contributors, thanks) are still staying in README.md, and CONTRIBUTING.md is essentially duplicated right now. However, stuff like configuration and key/mouse bindings are now moved to mkdocs.

Some parts are still a bit WIP - it is definitely not done (documentation never seems to be...). However, it should be "good enough" for now, and I'm much happier working with the documentation in this form than trying to scroll through a giant endless README.md file. It also works much better for adding new documentation.
2021-06-21 01:40:58 -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 e3ebc48ce8 refactor: Fix clippy lint for entry vacancy check (#503) 2021-06-18 18:35:19 -04:00
Clement Tsang 63f9ed6199 deps: Switch back from dirs-next to dirs (#492)
Since it's supported again, seems like a good time to switch back to
dirs.
2021-06-06 18:58:53 -04:00
Clement Tsang 733d0795db refactor: remove old traces (#486)
Removes some old trace lines for cleanup
2021-05-23 00:29:31 -04:00
Clement Tsang 6847f2ff0c refactor: split up data collection by OS (#482)
Refactor to split up data collection by OS and/or the backing library. The goal is to make it easier to work with and add new OS support, as opposed to how it was prior where we stored OS-independent implementations all in the same file.
2021-05-15 21:57:02 -04:00
Clement Tsang ee6228c2b6 refactor: switch to procfs library (#479)
Switch the Linux proc parts to the procfs library: https://crates.io/crates/procfs.
2021-05-13 23:41:43 -04:00
Clement Tsang 0ac449e573 bug: forgot to create memory usage string when collapsed (#473)
Adds a line to actually build the string of the summed memory usage. I forgot to make the string after summing the values.
2021-05-11 01:38:36 -04:00