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

top: implement TUI #292

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

top: implement TUI #292

wants to merge 1 commit into from

Conversation

r3yc0n1c
Copy link

@r3yc0n1c r3yc0n1c commented Dec 30, 2024

Resolves #191

Changes Made:

  • Dynamically pulled all other data from the main top.rs file
  • Added an exit feature by pressing 'q'
  • Implemented a static top block (pending implementation in top.rs)

To Do:

  • Implement data refresh functionality for the table and the top block
Screencast.2024-12-30.03.29.52.mp4

@Krysztal112233
Copy link
Collaborator

cool, that's very exciting!

@Krysztal112233 Krysztal112233 changed the title feat: tui for top command top: implement TUI Dec 30, 2024
@r3yc0n1c
Copy link
Author

Thank you, and I'm available for the discussion of the data refresh flow. Until then, I'm working on the row scrolling using the up and down arrow keys.

Comment on lines +35 to +43
fn render_top_info() -> Vec<String> {
let info = "top - 04:30:13 up 6:02, 3 users, load average: 0.40, 0.89, 1.24
Tasks: 260 total, 3 running, 257 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1.9 us, 0.3 sy, 0.0 ni, 97.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3911.6 total, 190.6 free, 2549.1 used, 1171.9 buff/cache
MiB Swap: 2048.0 total, 692.0 free, 1356.0 used. 1017.7 avail Mem";

info.lines().map(String::from).collect()
}
Copy link
Collaborator

@Krysztal112233 Krysztal112233 Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For refreshing, I think it can be done asynchronously? Like refreshing every 3 seconds in the background and then reading the refresh here? And all data can be refreshed in background too, I think this is the easiest way to implement it, via multithreading or smol(or tokio)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea! let me try this... will update the PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TUI for command top
2 participants