bpytop icon indicating copy to clipboard operation
bpytop copied to clipboard

[REQUEST] Low priority: Implement editable user input

Open RedBearAK opened this issue 4 years ago • 4 comments

This is a very low priority enhancement request. It would do nothing to change the essential functioning of bpytop. It would just make playing with the options more fun.

Currently, when editing options in the menu where the user can enter text, such as the clock config, the disk filter option, and the custom CPU name options, the UI doesn't respond to standard editing controls like moving left or right with the arrow/cursor keys. To edit the text it must be either appended or erased back to where you want to change something.

Desired functioning:

All text-based options that aren't simply True-False toggles or selectors should respond to the arrow/cursor keys to allow easier editing.

Bonus points if the up-arrow key (as well as the Home key) moves the cursor to the beginning of the text, and the down-arrow (as well as the End key) moves the cursor to the end. This is how things work in macOS with any single-line text input dialog, such as when renaming a file in the Finder, so Mac users would find that very intuitive.

It would be extra nice if hitting "enter" to edit these text options popped up a small "dialog" box, similar to the options menu itself, that allowed the entire length of the text to display while editing. Some of the inputs to text-based options can get pretty long. For instance the option for filtering disks. Editing inside the menu can feel pretty cramped and awkward.

RedBearAK avatar Oct 21 '20 03:10 RedBearAK

Everything else is easy to implement, but I can't figure out how to get a blinking cursor in front of text like this: 2021-01-05_12-34

I know it's very minor but I'd like to do this properly haha. I've looked through escape sequences but couldn't find anything.

UmarJ avatar Jan 05 '21 07:01 UmarJ

@UmarJ I was thinking something along the lines of creating a Inputting Class, and everytime text are to be edited create a Inputting object that keeps track of cursor placement and all that.

but I can't figure out how to get a blinking cursor in front of text

This could probably be done by having two versions of the text buffer, one where the cursor position has a black background and white text and one where the cursor position has a white background and black text. And then you switch them at every update. The "blinking" effect won't be that smooth though, since the time between updates aren't that consistent in the menus.

Will probably be fine though to just use the blinking block character that is used now, and just inserting it at the cursor position, displacing the characters around it instead.

aristocratos avatar Jan 05 '21 10:01 aristocratos

@aristocratos Yeah, an Input Class makes more sense, definitely better than updating the Input code in multiple places. I'll start working on it.

This could probably be done by having two versions of the text buffer, one where the cursor position has a black background and white text and one where the cursor position has a white background and black text. And then you switch them at every update. The "blinking" effect won't be that smooth though, since the time between updates aren't that consistent in the menus.

That's a neat idea! I'll see what I can do.

UmarJ avatar Jan 05 '21 11:01 UmarJ

@UmarJ

I'll start working on it.

Awesome! Thanks for taking the time and contributing :)

aristocratos avatar Jan 05 '21 11:01 aristocratos