mirror of
https://github.com/lotabout/skim.git
synced 2026-09-14 17:26:26 -04:00
1. add `as_any` for `SkimItem`
2. fix preview: deal with multi-lines prepared text
3. API for preview (non-)colored text
Skim will take trait object `Arc<dyn SkimItem>` and will return it back
in `SkimOutput`. Caller will need the concrete type reference to call
some type-specific methods. The `AsAny` trait is used for downcasting
`Arc<dyn SkimItem>` back to reference to its concrete type.
Q: Why not use associated type?
1. Associated type would pollute all the type signatures that deals with
`SkimItem`. Some traits could no longer be made into trait object
with generic type in their method signature.
```
pub trait MatchEngine: Sync + Send {
fn match_item<T: SkimItem>(&self, item: Arc<ItemWrapper<T>>) -> Option<MatchedItem<T>>;
}
```
To fix it would require much more work than I think.
2. Currently the support for "interaction mode" and "append-and-select"
action is done inside skim. That means some items added to skim could
not guaentee to be the associated type.
|
||
|---|---|---|
| .. | ||
| custom_item.rs | ||
| option_builder.rs | ||
| sample.rs | ||