You can do this using <code>crossterm</code>s <code>KeyEvent</code>, and then use the <code>KeyCode::Up</code>, <code>KeyCode::Down</code>, etc. enum variants. See for example the implementation in <code>ytop</code>, which doesn't use the arrow keys, but still demonstrates how to use KeyEvent
.
To be honest, for something like that I would have thought a more general purpose programming language would be a better idea - MATLAB is pretty heavily oriented towards data analysis type stuff. Maybe try python - it's very popular and the syntax for both languages is pretty similar, so you should find it's pretty easy to transfer.
I'm assuming you want something like ytop? https://github.com/cjbassi/ytop
There's an example on the tui-rs github for taking in user input text. If you clone the repo you can run the example with
cargo run --example user_input
For using crossterm
, and taking input from key events, there's a good example of this in the source code for <code>ytop</code>, which also uses tui
The most similar one I've used is ytop. You might be able to draw some inspiration from there.
Like many others, I think "better" is subjective. Make the tool that you personally would use.
WM: i3-gaps
Terminal: urxvt-patched
OS: Manjaro
Polybar: Polybar-4 Light Gray Theme
Wallpapers: https://imgur.com/a/SxVR7zH (Taken inside this games from cavesrd check out his work for real!)
Music Stuff: mpd and ncmpcpp
Info Tool: ytop
If you want to install it just type this from the terminal
cargo install -f --git https://github.com/cjbassi/ytop ytop
and then after its installed nano your .bashrc and at the bottom put
export PATH=$PATH:/home/yourusername/.cargo/bin
then just type source .bashrc then just type ytop in the terminal.
Hope thats helps you out
Ah ok. The debug symbols seem to be stripped from the executable. Maybe you should file an issue on the project's Github page (https://github.com/cjbassi/ytop/issues)
So there is some optimization we need to do still, but I think the main issue is just that ytop is over reporting its own CPU usage :) Check out this issue for more: https://github.com/cjbassi/ytop/issues/18