pub fn search_group(
        &self,
        annotations: &[Annotation],
        fuzzy: bool,
    ) -> color_eyre::Result<HashSet<String>> {
        let hbs = self.get_handlebars()?;
        let options = SkimOptionsBuilder::default()
            .height(Some("100%"))
            .preview(Some(""))
            .preview_window(Some("up:40%:wrap"))
            .bind(vec![
                "ctrl-a:select-all",
                "left:scroll-left",
                "right:scroll-right",
                "ctrl-c:abort",
                "Enter:accept"
            ])
            .exact(!fuzzy)
            .header(Some("Arrow keys to scroll, Tab to toggle selection, Ctrl-A to select all, Ctrl-C to abort\
            Enter to select"))
            .multi(true)
            .reverse(true)
            .build()
            .map_err(|_| Apologize::SearchError)?;

        let (tx_item, rx_item): (SkimItemSender, SkimItemReceiver) = unbounded();
        for annotation in annotations {
            let highlight = format!(
                "{} | {} |{}| {}",
                style(&utils::get_quotes(&annotation).join(" ").replace("\n", " ")),
                annotation.text.replace("\n", " "),
                style(&annotation.tags.join("|")).fg(dialoguer::console::Color::Red),
                style(&annotation.uri)
                    .fg(dialoguer::console::Color::Cyan)
                    .italic()
                    .underlined()
            );
            let _ = tx_item.send(Arc::new(SearchAnnotation {
                highlight,
                markdown: hbs.render(
                    "annotation",
                    &AnnotationTemplate::from_annotation(annotation.clone()),
                )?,
                id: annotation.id.to_owned(),
            }));
        }
        drop(tx_item); // so that skim could know when to stop waiting for more items.

        if let Some(output) = Skim::run_with(&options, Some(rx_item)) {
            let key = output.final_key;
            match key {
                Key::Enter => Ok(output
                    .selected_items
                    .into_iter()
                    .map(|s| {
                        s.as_any()
                            .downcast_ref::<SearchAnnotation>()
                            .unwrap()
                            .id
                            .to_string()
                    })
                    .collect()),
                _ => Ok(HashSet::new()),
            }
        } else {
            Err(Apologize::SearchError.into())
        }
    }
/// Makes a skim search window for given annotations from an external group
Makes a skim search window for given annotations from an external group
Makes a skim search window for given annotations from an external group
pub fn search_group(
        &self,
        annotations: &[Annotation],
        fuzzy: bool,
    ) -> color_eyre::Result<HashSet<String>> {
        let hbs = self.get_handlebars()?;
        let options = SkimOptionsBuilder::default()
            .height(Some("100%"))
            .preview(Some(""))
            .preview_window(Some("up:40%:wrap"))
            .bind(vec![
                "ctrl-a:select-all",
                "left:scroll-left",
                "right:scroll-right",
                "ctrl-c:abort",
                "Enter:accept"
            ])
            .exact(!fuzzy)
            .header(Some("Arrow keys to scroll, Tab to toggle selection, Ctrl-A to select all, Ctrl-C to abort\
            Enter to select"))
            .multi(true)
            .reverse(true)
            .build()
            .map_err(|_| Apologize::SearchError)?;
        let (tx_item, rx_item): (SkimItemSender, SkimItemReceiver) = unbounded();
        for annotation in annotations {
            let highlight = format!(
                "{} | {} |{}| {}",
                style(&utils::get_quotes(&annotation).join(" ").replace("\n", " ")),
                annotation.text.replace("\n", " "),
                style(&annotation.tags.join("|")).fg(dialoguer::console::Color::Red),
                style(&annotation.uri)
                    .fg(dialoguer::console::Color::Cyan)
                    .italic()
                    .underlined()
            );
            let _ = tx_item.send(Arc::new(SearchAnnotation {
                highlight,
                markdown: hbs.render(
                    "annotation",
                    &AnnotationTemplate::from_annotation(annotation.clone()),
                )?,
                id: annotation.id.to_owned(),
            }));
        }
        drop(tx_item); // so that skim could know when to stop waiting for more items.
        if let Some(output) = Skim::run_with(&options, Some(rx_item)) {
            let key = output.final_key;
            match key {
                Key::Enter => Ok(output
                    .selected_items
                    .into_iter()
                    .map(|s| {
                        s.as_any()
                            .downcast_ref::<SearchAnnotation>()
                            .unwrap()
                            .id
                            .to_string()
                    })
                    .collect()),
                _ => Ok(HashSet::new()),
            }
        } else {
            Err(Apologize::SearchError.into())
        }
    }
pub fn search_group ( & self , annotations : & [ Annotation ] , fuzzy : bool , ) -> color_eyre :: Result < HashSet < String > > { let hbs = self . get_handlebars ( ) ? ; let options = SkimOptionsBuilder :: default ( ) . height ( Some ( " " ) ) . preview ( Some ( " " ) ) . preview_window ( Some ( " " ) ) . bind ( vec ! [ " " " " " " " " " " ] ) . exact ( ! fuzzy ) . header ( Some ( " \
 " ) ) . multi ( true ) . reverse ( true ) . build ( ) . map_err ( | _ | Apologize :: SearchError ) ? ; let ( tx_item , rx_item ) : ( SkimItemSender , SkimItemReceiver ) = unbounded ( ) ; for annotation in annotations { let highlight = format ! ( " " style ( utils get_quotes ( annotation ) join ( " " ) replace ( " \n " " " ) ) annotation text replace ( " \n " " " ) style ( annotation tags join ( " " ) ) fg ( dialoguer console Color Red ) style ( annotation uri ) fg ( dialoguer console Color Cyan ) italic ( ) underlined ( ) ) ; let _ = tx_item . send ( Arc :: new ( SearchAnnotation { highlight , markdown : hbs . render ( " " , & AnnotationTemplate :: from_annotation ( annotation . clone ( ) ) , ) ? , id : annotation . id . to_owned ( ) , } ) ) ; } drop ( tx_item ) ; // so that skim could know when to stop waiting for more items. if let Some ( output ) = Skim :: run_with ( & options , Some ( rx_item ) ) { let key = output . final_key ; match key { Key :: Enter => Ok ( output . selected_items . into_iter ( ) . map ( | s | { s . as_any ( ) . downcast_ref :: < SearchAnnotation > ( ) . unwrap ( ) . id . to_string ( ) } ) . collect ( ) ) , _ => Ok ( HashSet :: new ( ) ) , } } else { Err ( Apologize :: SearchError . into ( ) ) } }
Makes a skim search window for given annotations from an external group
Makes a skim search window for given annotations from an external group
&self
annotations
&[Annotation]
fuzzy
bool
&self
annotations
&[Annotation]
fuzzy
bool