Closed zao111222333 closed 1 month ago
See #372 And https://github.com/gwenn/rustyline-notes/blob/master/src/design.md
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 Vec<(Range,Style)>
API is finished.
We might be able to fix the Highlighter
API like isocline.
And also check how isocline
handles continuation prompt:
Also I don't want you to waste your time. So maybe you should check if some alternatives already supports continuation prompt. For example: https://github.com/nushell/reedline/issues/112
Also I don't want you to waste your time. So maybe you should check if some alternatives already supports continuation prompt. For example: nushell/reedline#112
Thank you a lot for your time and information, I will have a try for those alternatives. Also I will still try to implement this feature for rustyline.
For the highlighting part, we might use this library: https://crates.io/crates/ansi-str
A library which provides a set of methods to work with ANSI strings It's an agnostic library in regard to different color libraries.
This method seems to do the job: https://docs.rs/ansi-str/latest/ansi_str/fn.get_blocks.html
Just in case if you are still interested, Could you please have a look at: https://github.com/kkawakam/rustyline/pull/795/commits/6b34d32cb43561856d538bc729ef8cfd0d7de5aa ? I guess it should be feasible like the Split iterator but I am not sure.
Just in case if you are still interested,
Could you please have a look at:
https://github.com/kkawakam/rustyline/pull/795/commits/6b34d32cb43561856d538bc729ef8cfd0d7de5aa
?
I guess it should be feasible like the Split iterator but I am not sure.
Thank you for informing, I will try it :)
Just in case if you are still interested, Could you please have a look at: 6b34d32 ? I guess it should be feasible like the Split iterator but I am not sure.
Thank you for informing, I will try it :)
Sorry I mean help me to fix it if you can... (you cannot give it a try because it doesn't type-check)
Just in case if you are still interested, Could you please have a look at: 6b34d32 ? I guess it should be feasible like the Split iterator but I am not sure.
Thank you for informing, I will try it :)
Sorry I mean help me to fix it if you can... (you cannot give it a try because it doesn't type-check)
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:
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!