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

Refactor highlighting #799

Closed
wants to merge 9 commits into from
Closed

Refactor highlighting #799

wants to merge 9 commits into from

Conversation

zao111222333
Copy link

See #795

  1. Use ansi-str-fork to introduce
fn get_blocks<'a>(text: Cow<'a, str>) -> AnsiBlockIter<'a>

(see more at ansitok-fork)
2. Fix highlight_line function signature into:

fn highlight_line<'l>(&self, line: &'l str, pos: usize) -> impl Iterator<Item = impl 'l+StyledBlock>
  1. The new highlight_line function signature conflicts to the Option<&dyn Highligher> due to https://doc.rust-lang.org/reference/items/traits.html#object-safety . So use generic <H: Highligher> + Option<&H> to replace Option<&dyn Highligher>

gwenn and others added 7 commits August 15, 2024 12:54
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...
@zao111222333 zao111222333 mentioned this pull request Aug 23, 2024
4 tasks
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.

2 participants