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

Configurable spinners #2793

Closed
wants to merge 27 commits into from
Closed

Configurable spinners #2793

wants to merge 27 commits into from

Conversation

sbromberger
Copy link
Contributor

@sbromberger sbromberger commented Jun 16, 2022

This PR adds the ability to customize the progress spinners. It changes the way they are created, as well, but this is not a huge issue because they weren't user-customizable beforehand anyway.

In summary:

The spinner can be defined in the config file using two keys under [editor] - spinner and spinner-interval. The former is a Vec<String> whose elements represent frames. The latter is the maximum update time in ms (equivalent to the interval that already exists in the code). Both default to the existing spinner.

This required allowing EditorView to take a ProgressSpinners argument, so I've changed the calling convention for EditorView::new.

If the spinner is multi-frame, then the current behavior where Instant::now() is repeatedly called still applies. However, for lower-powered systems, if the spinner is a single frame, then we can elide all the calls (and resulting syscalls) and save some performance.

The spinner can now be styled using ui.spinner in the theme. This allows the use of rapid_blink, for example, to simulate motion. (However - If the statusbar is non-black, I don't know yet how to make the background persist when the blink state goes to black.)

Anyway - please let me know what you think. I'm still not sure why we're using ProgressSpinners as a collection when it appears there's only ever one spinner. Could we simplify this?

@the-mikedavis the-mikedavis changed the title Sbromberger/spinners Configurable spinners Jun 16, 2022
Copy link
Contributor

@bjorn-ove bjorn-ove left a comment

Choose a reason for hiding this comment

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

I added some comments, but they are without authority, and only my personal feedback.

helix-term/src/ui/spinner.rs Outdated Show resolved Hide resolved
helix-term/src/ui/spinner.rs Outdated Show resolved Hide resolved
helix-term/src/ui/spinner.rs Outdated Show resolved Hide resolved
helix-term/src/ui/spinner.rs Outdated Show resolved Hide resolved
@sbromberger
Copy link
Contributor Author

@BearOve - I think I addressed/resolved all your suggestions. Mind taking another look? Thanks!

@bjorn-ove
Copy link
Contributor

Yes you have. The only thing now is what happens if the frame specified is more than one visible character wide. However, it might even be a feature to have a 3 character spinner?

I will leave this for someone more familiar with the inner workings of Helix however.

Great work

@sbromberger
Copy link
Contributor Author

The only thing now is what happens if the frame specified is more than one visible character wide. However, it might even be a feature to have a 3 character spinner?

I tried this last night and it works up to 3-4 chars before it bumps into the filename.

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

I was curious what you would want to replace the current spinner with but it turns out there isn't a shortage of possible spinners 😄

Some of my favorites:

[editor]
spinner = ["", "", "", "", "", "", "", "", "", "", "", "", "", ""]
spinner = ["", "", "", "", "", "", "", "", "", "", "", "", ""]
spinner = ["", "", "", ""]
spinner = ["", "", "", ""]
spinner = ["◡◡", "⊙⊙", "◠◠"]

book/src/configuration.md Outdated Show resolved Hide resolved
helix-term/src/ui/spinner.rs Outdated Show resolved Hide resolved
helix-term/src/ui/spinner.rs Show resolved Hide resolved
@sbromberger
Copy link
Contributor Author

I was curious what you would want to replace the current spinner

Selfishly, I hate things that move erratically - I find them really distracting, and the LSP loading process stops and starts the spinner a few times (there's a CPU lag as well on my lower-performance VM). I replaced it with a single frame of a yellow dot. The single-frame notification also doesn't use Instant::now() so I save the syscalls.

But yes - I've been playing around with lots of alternate possibilities.

(Won't somebody think of the poor syscalls?)

@Woolworths
Copy link

Does it make sense for spinner-interval set to 0 to disable spinner display? We already have this functionality if spinner-frames is set to [].

Would it not make more sense to change this functionality to keep the previous logic (update when a key-press is made, instead of just removing the spinner)? I prefer this logic, because it prevents a render every time the spinner updates (which is 👍 if you're on a slow connection/ssh'd into a server).

@sbromberger
Copy link
Contributor Author

sbromberger commented Jun 19, 2022

Would it not make more sense to change this functionality to keep the previous logic (update when a key-press is made, instead of just removing the spinner)?

I'm not sure I understand. The current code doesn't allow you to configure the spinner interval at all, and if you manage to do it by editing the code, if you set it to zero, helix will panic on assert [1]. There's currently no logic that handles "update spinner on keypress".

Because the frame is empty, there will be no significant update - I run helix (and this proposed code) on a small VM over a slow SSH connection and haven't seen any issues. In fact, it's one of the primary reasons I'm submitting this PR, since the current behavior causes the spinner to move erratically.

[1]

assert!(interval > 0);

@Woolworths
Copy link

Ahhh yes, that makes sense. Thanks for the explanation 👍

@sbromberger sbromberger changed the title Configurable spinners WIP: Configurable spinners Jun 20, 2022
@sbromberger
Copy link
Contributor Author

sbromberger commented Jun 20, 2022

Changing this to WIP pending discussion of #2829
This was the wrong approach.

@sbromberger sbromberger marked this pull request as draft June 20, 2022 04:51
@sbromberger sbromberger changed the title WIP: Configurable spinners Configurable spinners Jun 20, 2022
@sbromberger sbromberger marked this pull request as ready for review June 20, 2022 06:22
@sbromberger
Copy link
Contributor Author

@Woolworths - just out of curiosity, are you using mosh?

@Woolworths
Copy link

@sbromberger I'm not, no 😄

@CptPotato
Copy link
Contributor

Does this PR affect how spinners work internally or just how they are displayed?
While testing this PR I just ran into the situation where the spinner would not disappear, even after rust-analyzer finished loading.

Though, I've also recently updated rust-analyzer (427061da1 2022-06-19) which may have introduced this problem.

@sbromberger
Copy link
Contributor Author

While testing this PR I just ran into the situation where the spinner would not disappear, even after rust-analyzer finished loading.

I've noticed this too, but I also noticed it without the PR, so I don't think it's the code here. The spinner indicator updated to the correct state (went away) when I pressed a key.

I didn't change any of the logic relating to spinner start/stop - just how it's displayed.

@sbromberger
Copy link
Contributor Author

Also, it's not consistent. Here's a screen recording I just made with a single-char (yellow dot) spinner:

https://asciinema.org/a/Tjuz8EWfpLZiDHd6A24K1l9sW

@CptPotato
Copy link
Contributor

I've noticed this too, but I also noticed it without the PR, so I don't think it's the code here. The spinner indicator updated to the correct state (went away) when I pressed a key.

I didn't change any of the logic relating to spinner start/stop - just how it's displayed.

Then it's probably an unrelated issue.
In my case it really never disappeared, even after half an hour while editing the file.

aaron404 and others added 3 commits June 22, 2022 21:48
simplify text and offset computation

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
@Woolworths
Copy link

This would be really awesome to see in helix!

@sbromberger
Copy link
Contributor Author

Refactored for new customizable statusline. Width of spinner is now handled appropriately by the statusline!

Ready for review.

sbromberger and others added 5 commits July 22, 2022 09:54
Updates documentation to reflect decision re: defaulting to never showing bufferline.
Update configuration.md to reflect new default.
@aikomastboom
Copy link
Contributor

Been using this branch for some time with a simple one character custom spinner and have seen no obvious glitches.

@sbromberger
Copy link
Contributor Author

Could I get a review on this, please? Thank you :)

@sbromberger
Copy link
Contributor Author

Merged with master - I think this is ready for review. Thank you.

@sbromberger sbromberger closed this by deleting the head repository Sep 3, 2022
@sbromberger sbromberger reopened this Sep 3, 2022
@sbromberger sbromberger closed this Sep 3, 2022
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.

7 participants