Closed xixiaofinland closed 8 months ago
I figured out to use display
trait
fn display<'a>(&'a self, _context: DisplayContext<'a>) -> AnsiString<'a> {
if self.session_exists {
return AnsiString::from(format!("*{}", self.folder));
}
return AnsiString::from(self.folder.clone());
}
My original need and implementation
I have a list of items for the user to select in Skim. They are either
A
type orB
type, thus I use aProject
struct with a bool fieldtrue
orfalse
to differentiate them. code hereAnd I followed this sample.
The problem I encounter
Once the items are passed into
rx_item
, they are no moreProject
type butSkimItem
, i.e. thebool
field is gone. Do I need to cast it back? Why does Skim change the type?Alternatively, is there an easier way to achieve my goal (i.e. differentiate these two types of items in skim UI)? I considered using String with and without color, but can't figure out how.