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

Make reedline handling cursor shapes more configurable #515

Merged
merged 5 commits into from
Dec 21, 2022
Merged

Make reedline handling cursor shapes more configurable #515

merged 5 commits into from
Dec 21, 2022

Conversation

cschierig
Copy link
Contributor

This pr is a follow-up to #494. There were various complaints about my implementation being to invasive, so for now I made it toggleable, but I would like not only be able to toggle this, but to actually make it configurable.

If merged, this should resolve #514.

@cschierig cschierig changed the title Make reedline handling cursor shapes more configurable Make reedline handle cursor shapes more configurable Nov 18, 2022
@cschierig cschierig changed the title Make reedline handle cursor shapes more configurable Make reedline handling cursor shapes more configurable Nov 18, 2022
examples/demo.rs Outdated Show resolved Hide resolved
@fdncred
Copy link
Collaborator

fdncred commented Nov 29, 2022

@CozyPenguin Any updates on this? Do you still plan to finish it or did you run out of time?

@cschierig
Copy link
Contributor Author

The current implementation already leaves unconfigured cursors untouched, so I don't think there is anything else to do.

If nothing else is missing, I think this is ready to merge.

@fdncred
Copy link
Collaborator

fdncred commented Nov 29, 2022

ok, thanks for the update @CozyPenguin. we'll need to land this and then update nushell. @sholderbach, thoughts on this pr?

@sholderbach
Copy link
Member

Sorry for not paying attention here. Thanks for your efforts @CozyPenguin.
Shoud be a simple way to get this more userfriendly on the nushell side.

Only thing that strikes me as overkill is using a hashmap for like 2 or 3 entries.(but we can fix that later if necessary)

@cschierig
Copy link
Contributor Author

Yeah the HashMap probably is overkill, I just didn't have a lot of time and that was the simplest solution. I can make this a simple disabled-by-default toggle for now and work on a better way to configure this later if that's ok for you. I think the most important thing is to correct my mistake (enabling it by default) as quickly as possible.

I personally would prefer a proper config implementation right away instead of taking something half-baked that you're not comfortable with long term. The first commit of the two implements the toggle, if you want a temporary solution to disable the cursors.

@cschierig
Copy link
Contributor Author

I should have some time to work on it this week. Are you fine with a struct containing a field for each mode? That would probably also represent nushells config structure more closely.

@dandavison
Copy link
Contributor

I'm not blocked by this -- I've reverted #494 locally. I just want to ask a question about cursor blinking:

I initially tried changing cursor::CursorShape::Block to cursor::CursorShape::Line as follows:

diff --git a/src/painting/painter.rs b/src/painting/painter.rs
index bace91d..1028916 100644
--- a/src/painting/painter.rs
+++ b/src/painting/painter.rs
@@ -179,7 +179,7 @@ impl Painter {
             .queue(RestorePosition)?
             .queue(cursor::SetCursorShape(match prompt_mode {
                 PromptEditMode::Vi(crate::PromptViMode::Insert) => cursor::CursorShape::Line,
-                _ => cursor::CursorShape::Block,
+                _ => cursor::CursorShape::Line,
             }))?
             .queue(cursor::Show)?;

However when I did that, I noticed that there was a blinking effect where the cursor would pulse for a few seconds after displaying the prompt.

Is that right, do you know the blinking/pulsing effect I'm referring to? Hopefully I didn't imagine it! Anyway, I just wanted to ask - could we have the option to not have the blinking effect, in addition to having the option to not change the cursor type?

@fdncred
Copy link
Collaborator

fdncred commented Dec 16, 2022

I had to revert this too. It's so aggravating to me. I'm currently using WezTerm on mac and don't see any unexpected blinking pulsing effect.

Actually, I didn't revert it, I just changed it to CursorShape::Line like the diff.

@cschierig
Copy link
Contributor Author

Anyway, I just wanted to ask - could we have the option to not have the blinking effect, in addition to having the option to not change the cursor type?

That should be possible, but I would like to leave that to another pr and finally get this merged.

@cschierig
Copy link
Contributor Author

I think this is ready now, but I'm happy to change anything if something's wrong/missing. Now, the behaviour is disabled by default, so it shouldn't bother anyone unless it is enabled in nushell. (and I've changed the config away from a hashmap to a struct). @fdncred @sholderbach

@fdncred
Copy link
Collaborator

fdncred commented Dec 19, 2022

Thanks @CozyPenguin. We have a nushell release coming up Dec 20th. I'd vote to land this soon after that release unless @sholderbach has objections/changes.

@sholderbach
Copy link
Member

Thank you very much for iterating on that. Looks good and tidy with the struct!

@sholderbach sholderbach merged commit 475495d into nushell:main Dec 21, 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.

Configurable cursor shape
4 participants