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

Support for line continuation #819

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

aljazerzen
Copy link

Adds support for line continuation in prompts, which can be used to achieve rectangular prompts.

Supersedes #338 & #372

image

Review notes:

  • I suggest reviewing commits separately,
  • To check the thing out, run input_multiline example,
  • The breaking: commit is the only breaking change that adds continuation param to fn readline. I'm not fully confident that this feature is worth breaking the API over, but it seems most reasonable public API to me. That's because the continuation is usually dependent on the prompt.
  • Alternative public API would fn Editor::set_continuation function. In that case, I can revert last two commits.

I'm very invested in landing this PR and I'm willing to make changes.

TODO:

  • windows support
  • documentation
  • tests

@gwenn
Copy link
Collaborator

gwenn commented Oct 21, 2024

This feature is a minefield...

@aljazerzen
Copy link
Author

Most likely a new Prompt trait with a default impl for &str.

I like this. It would also avoid the breaking change.


Thank you for the linked info. Given that I manage to solve/avoid these problems, is this a wanted feature?

I don't want to spend a lot of time working on a feature that would not be merged due to big-picture reasons.

@gwenn
Copy link
Collaborator

gwenn commented Oct 21, 2024

Thank you for the linked info. Given that I manage to solve/avoid these problems, is this a wanted feature?

I don't want to spend a lot of time working on a feature that would not be merged due to big-picture reasons.

This is definitely a wanted feature.
But that raises many issues on the current implementation (Highlighting / Layout / Moving cursor without repainting everything / ...).
So you should probably use reedline which already supports continuation prompt instead of rustyline.

@aljazerzen

This comment was marked as off-topic.

@gwenn
Copy link
Collaborator

gwenn commented Oct 22, 2024

I believe this needs to be fixed, right? And you've attempted to fix it in gwenn#2 ?

Current behavior might be buggy.
And gwenn#2 is just a draft to make this method work with continuation prompt.
We want something that can tell to the LineBuffer, the (line, column) associated to one byte / grapheme offset and vice-versa.

@zao111222333
Copy link

You can have a look at gwenn#3 (comment) , however it's mightly that the Layout requires reconstruction, and the continuation feature seems need to implement base on the new Layout.

@aljazerzen
Copy link
Author

I've opened a new PR that implements span tracking first: #820

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.

3 participants