-
Notifications
You must be signed in to change notification settings - Fork 182
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
User-specified continuation prompt #793
Conversation
Hi, I agree with "split the input by line" mentioned in design.md, the implementation here is essentially split the input in renderer (soft wrapped), and then re-align cursor. And I'd like to contribute for continuation prompt if the new |
We might be able to fix the |
Also I don't want you to waste your time. |
Thank you a lot for your time and information, I will have a try for those alternatives. |
For the highlighting part, we might use this library:
This method seems to do the job: |
Sorry I mean help me to fix it if you can... |
Oh I see, sure I can help to try how to fix it (might be this weekend). Thanks! |
I believe the user-specified continuation prompt is a crucial feature, especially in scenarios where indentation is important (such as Python shell). I have implemented this feature by replacing the '\n' character in multi-line input with
\n
+continuation_prompt
in display phase (inRenderer::refresh_line
). This approach can cause a misalignment between the displayed cursor position and the actual editing position. To address this, I usedState::continuation_prompt_move_cursor
to correct these misalignments.Additionally, I have added an example. You can run it with the following command:
cargo run --release --example continuation_prompt --features="custom-bindings derive"
And the demo results:
However, the current implementation only meets the minimum use case (i.e., continuation prompt works when pasting multi-line text into rustyline), but I have still encountered some bugs:
Cmd::Newline
.Since I'm not very familiar with rustyline, I want to share my current implementation and seek help and suggestions here. Thank you!