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

feat: add preview callback #407

Merged
merged 4 commits into from
Jan 23, 2025
Merged

Conversation

alexxbb
Copy link
Contributor

@alexxbb alexxbb commented Apr 19, 2021

The preview feature of skim is great, however when skim is used as a library, there's no way to render a preview from Rust code.

This PR adds a new option to SkimOptionsBuilder:

.preview_fn(| items: Vec<String> | -> Vec<AnsiString<'static>> {})

The closure will be called with the currently selected items to render.

@alexxbb alexxbb marked this pull request as ready for review April 20, 2021 04:41
@alexxbb alexxbb changed the title WIP: Draft implementation of preview callback Implementation of preview callback Apr 20, 2021
@alexxbb
Copy link
Contributor Author

alexxbb commented May 3, 2021

Hey @lotabout, could you please take a look at this PR and see if you want to merge it? I'm not sure why it's failing on one test, I'm happy to fix it if you could give me a hint.

Alex.

@kkharji
Copy link

kkharji commented Oct 26, 2021

Interesting, but does it allow for pre-processing of entry before handing it to preview command. In my case I have paths that I abbreviated and I have a rust function that perform some adjustment to make absolute path again. Then I'd pass it to bat

@alexxbb
Copy link
Contributor Author

alexxbb commented Oct 26, 2021

Interesting, but does it allow for pre-processing of entry before handing it to preview command. In my case I have paths that I abbreviated and I have a rust function that perform some adjustment to make absolute path again. Then I'd pass it to bat

If you want to pre-precess before sending to bat it could be possible to do with this PR, but you'd have to spawn bat yourself in this callback and returns its output. It would be nice to have a filtering function before sending to preview. Looks like there's no way to achive that atm.

@kkharji
Copy link

kkharji commented Oct 26, 2021

Interesting, but does it allow for pre-processing of entry before handing it to preview command. In my case I have paths that I abbreviated and I have a rust function that perform some adjustment to make absolute path again. Then I'd pass it to bat

If you want to pre-precess before sending to bat it could be possible to do with this PR, but you'd have to spawn bat yourself in this callback and returns its output. It would be nice to have a filtering function before sending to preview. Looks like there's no way to achive that atm.

Thanks @alexxbb I'll drop preview requirement for the moment.

@LoricAndre LoricAndre force-pushed the master branch 3 times, most recently from 6b0fab9 to e649d08 Compare November 26, 2024 17:01
@LoricAndre
Copy link
Contributor

This looks really interesting, I might try to pick it up and complete it.

@LoricAndre LoricAndre changed the title Implementation of preview callback feat: add preview callback Jan 23, 2025
@LoricAndre LoricAndre merged commit 226d995 into skim-rs:master Jan 23, 2025
9 of 10 checks passed
This was referenced Jan 22, 2025
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