Conversation
And their `ansi-str` implementations
Because ansi-str Style is immutable
As a return type for `highlight_line` * `Cow<'_, str>` -> `ansi_str::AnsiBlockIter<'_>` for compatibility with existing code * `Vec<(anstyle:Style, &str)>` for a default / test implementation But may be difficult to handle on our side or it's just me...
|
It seems that we can change the |
|
I find that once we define fn highlight_line<'l>(&self, line: &'l str, pos: usize) -> impl Iterator<Item = impl 'l+StyledBlock>The new And I have maked a pull request, see #799 |
|
Maybe we should not try to implement |
when "split-highlight" feature is activated but not "ansi-str" feature.
|
Looks good! And how do you think
cons:
|
We need to return a `Cow<str>` for `MaskingHighlighter`
|
|
`where Self: Sized` is not needed anymore And we don't really need `Cow<'l, str>` for MaskingHighlighter
|
Thanks a lot for your hard working, I believe |
See above: |
|
I seem to find a decent way to finish the task "Check that new API works with an hardcoded continuation prompt", |
|
After weeks of struggling, here is my solution, pls have a look at gwenn#3 |
|
Let me briefly summarize my commits
fn highlight<'b, 's: 'b, 'l: 'b>(
&'s mut self,
line: &'l str,
pos: usize,
) -> impl 'b + DisplayOnce;the back-compatiblity is that, the old highlight function even needn't to change their signatures, since we will auto-impl fn highlight<'b, 's: 'b, 'l: 'b>(
&'s mut self,
line: &'l str,
pos: usize,
) -> std::borrow::Cow<'b, str>And it also supports split-highlight, since we impl pub struct StyledBlocks<'l, B, I>
where
B: 'l + StyledBlock,
I: Iterator<Item = B>,
{
iter: I,
_marker: PhantomData<&'l ()>,
}
fn update_after_edit(&mut self, line: &str, pos: usize, forced_refresh: bool)And only one thing that user have to change is the let helper = MyHelper::new();
let mut rl = Editor::new()?;
rl.set_helper(helper);To let helper = MyHelper::new();
let mut rl = Editor::new(helper)?;And use let mut rl = Editor::new(())?;
|
Introduce
StyleandStyledBlocktraitsAnd their
ansi-strimplementationsansi-stroptionalHighlightertraitSee #793, #372
See https://github.com/gwenn/rustyline-notes/blob/master/src/design.md