--- skim-0.9.4/src/bin/main.rs 2021-02-15 18:15:27.000000000 +0800 +++ skim-0.9.4/src/bin/main.rs 2026-01-06 01:01:03.000000000 +0800 @@ -13,7 +13,28 @@ use std::io::{BufRead, BufReader, BufWriter, Write}; use clap::{App, Arg, ArgMatches}; -use skim::prelude::*; +use skim::{ + Skim, + SkimItemReceiver, + SkimItemSender, + CaseMatching, + MatchEngineFactory, + FuzzyAlgorithm, +}; +use skim::ansi::AnsiString; +use skim::event::Event; +use skim::helper::item_reader::{SkimItemReader, SkimItemReaderOption}; +use skim::helper::selector::DefaultSkimSelector; +use skim::options::{SkimOptions, SkimOptionsBuilder}; +use skim::output::SkimOutput; +use skim::engine::factory::{RegexEngineFactory, ExactOrFuzzyEngineFactory, AndOrEngineFactory}; +use crossbeam::channel::{bounded, unbounded, Receiver, Sender}; +use std::borrow::Cow; +use std::cell::RefCell; +use std::rc::Rc; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::Arc; +use tuikit::event::Key; const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -390,74 +411,81 @@ } fn parse_options<'a>(options: &'a ArgMatches) -> SkimOptions<'a> { - SkimOptionsBuilder::default() - .color(options.values_of("color").and_then(|vals| vals.last())) - .min_height(options.values_of("min-height").and_then(|vals| vals.last())) - .no_height(options.is_present("no-height")) - .height(options.values_of("height").and_then(|vals| vals.last())) - .margin(options.values_of("margin").and_then(|vals| vals.last())) - .preview(options.values_of("preview").and_then(|vals| vals.last())) - .cmd(options.values_of("cmd").and_then(|vals| vals.last())) - .query(options.values_of("query").and_then(|vals| vals.last())) - .cmd_query(options.values_of("cmd-query").and_then(|vals| vals.last())) - .interactive(options.is_present("interactive")) - .prompt(options.values_of("prompt").and_then(|vals| vals.last())) - .cmd_prompt(options.values_of("cmd-prompt").and_then(|vals| vals.last())) - .bind( - options - .values_of("bind") - .map(|x| x.collect::>()) - .unwrap_or_default(), - ) - .expect(options.values_of("expect").map(|x| x.collect::>().join(","))) - .multi(if options.is_present("no-multi") { + SkimOptions { + bind: options + .values_of("bind") + .map(|x| x.collect::>()) + .unwrap_or_default(), + multi: if options.is_present("no-multi") { false } else { options.is_present("multi") - }) - .layout(options.values_of("layout").and_then(|vals| vals.last()).unwrap_or("")) - .reverse(options.is_present("reverse")) - .no_hscroll(options.is_present("no-hscroll")) - .no_mouse(options.is_present("no-mouse")) - .no_clear(options.is_present("no-clear")) - .tabstop(options.values_of("tabstop").and_then(|vals| vals.last())) - .tiebreak(options.values_of("tiebreak").map(|x| x.collect::>().join(","))) - .tac(options.is_present("tac")) - .nosort(options.is_present("no-sort")) - .exact(options.is_present("exact")) - .regex(options.is_present("regex")) - .delimiter(options.values_of("delimiter").and_then(|vals| vals.last())) - .inline_info(options.is_present("inline-info")) - .header(options.values_of("header").and_then(|vals| vals.last())) - .header_lines( - options - .values_of("header-lines") - .and_then(|vals| vals.last()) - .map(|s| s.parse::().unwrap_or(0)) - .unwrap_or(0), - ) - .layout(options.values_of("layout").and_then(|vals| vals.last()).unwrap_or("")) - .algorithm(FuzzyAlgorithm::of( + }, + prompt: options.values_of("prompt").and_then(|vals| vals.last()), + cmd_prompt: options.values_of("cmd-prompt").and_then(|vals| vals.last()), + expect: options.values_of("expect").map(|x| x.collect::>().join(",")), + tac: options.is_present("tac"), + nosort: options.is_present("no-sort"), + tiebreak: options.values_of("tiebreak").map(|x| x.collect::>().join(",")), + exact: options.is_present("exact"), + cmd: options.values_of("cmd").and_then(|vals| vals.last()), + interactive: options.is_present("interactive"), + query: options.values_of("query").and_then(|vals| vals.last()), + cmd_query: options.values_of("cmd-query").and_then(|vals| vals.last()), + regex: options.is_present("regex"), + delimiter: options.values_of("delimiter").and_then(|vals| vals.last()), + replstr: None, + color: options.values_of("color").and_then(|vals| vals.last()), + margin: options.values_of("margin").and_then(|vals| vals.last()), + no_height: options.is_present("no-height"), + no_clear: options.is_present("no-clear"), + min_height: options.values_of("min-height").and_then(|vals| vals.last()), + height: if options.is_present("no-height") { + Some("100%") + } else { + options.values_of("height").and_then(|vals| vals.last()) + }, + preview: options.values_of("preview").and_then(|vals| vals.last()), + preview_window: None, + reverse: options.is_present("reverse"), + tabstop: options.values_of("tabstop").and_then(|vals| vals.last()), + no_hscroll: options.is_present("no-hscroll"), + no_mouse: options.is_present("no-mouse"), + inline_info: options.is_present("inline-info"), + header: options.values_of("header").and_then(|vals| vals.last()), + header_lines: options + .values_of("header-lines") + .and_then(|vals| vals.last()) + .map(|s| s.parse::().unwrap_or(0)) + .unwrap_or(0), + layout: if options.is_present("reverse") { + "reverse" + } else { + options.values_of("layout").and_then(|vals| vals.last()).unwrap_or("") + }, + algorithm: FuzzyAlgorithm::of( options.values_of("algorithm").and_then(|vals| vals.last()).unwrap(), - )) - .case(match options.value_of("case") { + ), + case: match options.value_of("case") { Some("smart") => CaseMatching::Smart, Some("ignore") => CaseMatching::Ignore, - _ => CaseMatching::Respect, - }) - .keep_right(options.is_present("keep-right")) - .skip_to_pattern( - options - .values_of("skip-to-pattern") - .and_then(|vals| vals.last()) - .unwrap_or(""), - ) - .select1(options.is_present("select-1")) - .exit0(options.is_present("exit-0")) - .sync(options.is_present("sync")) - .no_clear_if_empty(options.is_present("no-clear-if-empty")) - .build() - .unwrap() + _ => CaseMatching:: Respect, + }, + engine_factory: None, + query_history: &[], + cmd_history: &[], + cmd_collector: Rc::new(RefCell::new(SkimItemReader::new(Default::default()))), + keep_right: options.is_present("keep-right"), + skip_to_pattern: options + .values_of("skip-to-pattern") + .and_then(|vals| vals.last()) + .unwrap_or(""), + select1: options.is_present("select-1"), + exit0: options.is_present("exit-0"), + sync: options.is_present("sync"), + selector: None, + no_clear_if_empty: options.is_present("no-clear-if-empty"), + } } fn read_file_lines(filename: &str) -> Result, std::io::Error> { --- skim-0.9.4/src/options.rs 2021-02-15 18:15:27.000000000 +0800 +++ skim-0.9.4/src/options.rs 2026-01-06 00:35:45.000000000 +0800 @@ -8,7 +8,6 @@ use std::cell::RefCell; #[derive(Builder)] -#[builder(build_fn(name = "final_build"))] #[builder(default)] pub struct SkimOptions<'a> { pub bind: Vec<&'a str>, @@ -120,6 +119,54 @@ self.layout = Some("reverse"); } - self.final_build() + let result: SkimOptions<'a> = SkimOptions { + bind: self.bind.clone().unwrap_or_default(), + multi: self.multi.unwrap_or_default(), + prompt: self.prompt.unwrap_or(Some("> ")), + cmd_prompt: self.cmd_prompt.unwrap_or(Some("c> ")), + expect: self.expect.clone().unwrap_or_default(), + tac: self.tac.unwrap_or_default(), + nosort: self.nosort.unwrap_or_default(), + tiebreak: self.tiebreak.clone().unwrap_or_default(), + exact: self.exact.unwrap_or_default(), + cmd: self.cmd.unwrap_or_default(), + interactive: self.interactive.unwrap_or_default(), + query: self.query.unwrap_or_default(), + cmd_query: self.cmd_query.unwrap_or_default(), + regex: self.regex.unwrap_or_default(), + delimiter: self.delimiter.unwrap_or_default(), + replstr: self.replstr.unwrap_or(Some("{}")), + color: self.color.unwrap_or_default(), + margin: self.margin.unwrap_or(Some("0,0,0,0")), + no_height: self.no_height.unwrap_or_default(), + no_clear: self.no_clear.unwrap_or_default(), + min_height: self.min_height.unwrap_or(Some("10")), + height: self.height.unwrap_or(Some("100%")), + preview: self.preview.unwrap_or_default(), + preview_window: self.preview_window.unwrap_or(Some("right:50%")), + reverse: self.reverse.unwrap_or_default(), + tabstop: self.tabstop.unwrap_or_default(), + no_hscroll: self.no_hscroll.unwrap_or_default(), + no_mouse: self.no_mouse.unwrap_or_default(), + inline_info: self.inline_info.unwrap_or_default(), + header: self.header.unwrap_or_default(), + header_lines: self.header_lines.unwrap_or_default(), + layout: self.layout.unwrap_or(""), + algorithm: self.algorithm.unwrap_or_default(), + case: self.case.unwrap_or_default(), + engine_factory: self.engine_factory.clone().unwrap_or_default(), + query_history: self.query_history.unwrap_or(&[]), + cmd_history: self.cmd_history.unwrap_or(&[]), + cmd_collector: self.cmd_collector.clone().unwrap_or_else(|| Rc::new(RefCell:: new(SkimItemReader:: new(Default::default())))), + keep_right: self.keep_right.unwrap_or_default(), + skip_to_pattern: self.skip_to_pattern.unwrap_or(""), + select1: self.select1.unwrap_or_default(), + exit0: self.exit0.unwrap_or_default(), + sync: self.sync.unwrap_or_default(), + selector: self.selector.clone().unwrap_or_default(), + no_clear_if_empty: self.no_clear_if_empty.unwrap_or_default(), + }; + + Ok(result) } }