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

Implementation of preview callback #407

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alexxbb
Copy link

@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
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
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.

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.

None yet

2 participants