diff --git a/Cargo.lock b/Cargo.lock index 0d1b05ce..a831e218 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -601,7 +601,6 @@ name = "skim" version = "0.10.4" dependencies = [ "beef", - "bitflags 1.3.2", "chrono", "clap", "crossbeam", diff --git a/Cargo.toml b/Cargo.toml index 54560823..06cfa617 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,6 @@ vte = "0.13.0" fuzzy-matcher = "0.3.7" rayon = "1.5.3" derive_builder = "0.20.2" -bitflags = "1.3.2" timer = "0.2.0" chrono = "0.4.22" crossbeam = "0.8.2" diff --git a/README.md b/README.md index 5497d1a0..aabf2033 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,16 @@ The skim project contains several components: ## Package Managers -| Distribution | Package Manager | Command | -| -------------- | ----------------- | ---------------------------- | -| macOS | Homebrew | `brew install sk` | -| macOS | MacPorts | `sudo port install skim` | -| Fedora | dnf | `dnf install skim` | -| Alpine | apk | `apk add skim` | -| Arch | pacman | `pacman -S skim` | +| Distribution | Package Manager | Command | +| -------------- | ----------------- | ------------------------- | +| macOS | Homebrew | `brew install sk` | +| macOS | MacPorts | `sudo port install skim` | +| Fedora | dnf | `dnf install skim` | +| Alpine | apk | `apk add skim` | +| Arch | pacman | `pacman -S skim` | | Gentoo | Portage | `emerge --ask app-misc/skim` | +| Guix | guix | `guix install skim` | +| Void | XBPS | `xbps-install -S skim` | See [repology](https://repology.org/project/skim/versions) for a comprehensive overview of package availability. diff --git a/src/bin/main.rs b/src/bin/main.rs index 21bdf96b..dcc1f4f7 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -168,22 +168,23 @@ fn real_main() -> Result { let opts = App::new("sk") .author("Jinzhou Zhang") .version(crate_version!()) + .args_override_self(true) .arg(Arg::with_name("help").long("help").short('h')) .arg(Arg::with_name("bind").long("bind").short('b').multiple(true).takes_value(true)) - .arg(Arg::with_name("multi").long("multi").short('m').multiple(true)) - .arg(Arg::with_name("no-multi").long("no-multi").multiple(true)) + .arg(Arg::with_name("multi").long("multi").short('m')) + .arg(Arg::with_name("no-multi").long("no-multi")) .arg(Arg::with_name("prompt").long("prompt").short('p').multiple(true).takes_value(true).default_value("> ")) .arg(Arg::with_name("cmd-prompt").long("cmd-prompt").multiple(true).takes_value(true).default_value("c> ")) .arg(Arg::with_name("expect").long("expect").multiple(true).takes_value(true)) - .arg(Arg::with_name("tac").long("tac").multiple(true)) + .arg(Arg::with_name("tac").long("tac")) .arg(Arg::with_name("tiebreak").long("tiebreak").short('t').multiple(true).takes_value(true)) - .arg(Arg::with_name("ansi").long("ansi").multiple(true)) - .arg(Arg::with_name("exact").long("exact").short('e').multiple(true)) + .arg(Arg::with_name("ansi").long("ansi")) + .arg(Arg::with_name("exact").long("exact").short('e')) .arg(Arg::with_name("cmd").long("cmd").short('c').multiple(true).takes_value(true)) - .arg(Arg::with_name("interactive").long("interactive").short('i').multiple(true)) + .arg(Arg::with_name("interactive").long("interactive").short('i')) .arg(Arg::with_name("query").long("query").short('q').multiple(true).takes_value(true)) .arg(Arg::with_name("cmd-query").long("cmd-query").multiple(true).takes_value(true)) - .arg(Arg::with_name("regex").long("regex").multiple(true)) + .arg(Arg::with_name("regex").long("regex")) .arg(Arg::with_name("delimiter").long("delimiter").short('d').multiple(true).takes_value(true)) .arg(Arg::with_name("nth").long("nth").short('n').multiple(true).takes_value(true)) .arg(Arg::with_name("with-nth").long("with-nth").multiple(true).takes_value(true)) @@ -192,52 +193,52 @@ fn real_main() -> Result { .arg(Arg::with_name("margin").long("margin").multiple(true).takes_value(true).default_value("0,0,0,0")) .arg(Arg::with_name("min-height").long("min-height").multiple(true).takes_value(true).default_value("10")) .arg(Arg::with_name("height").long("height").multiple(true).takes_value(true).default_value("100%")) - .arg(Arg::with_name("no-height").long("no-height").multiple(true)) - .arg(Arg::with_name("no-clear").long("no-clear").multiple(true)) - .arg(Arg::with_name("no-clear-start").long("no-clear-start").multiple(true)) - .arg(Arg::with_name("no-mouse").long("no-mouse").multiple(true)) + .arg(Arg::with_name("no-height").long("no-height")) + .arg(Arg::with_name("no-clear").long("no-clear")) + .arg(Arg::with_name("no-clear-start").long("no-clear-start")) + .arg(Arg::with_name("no-mouse").long("no-mouse")) .arg(Arg::with_name("preview").long("preview").multiple(true).takes_value(true)) .arg(Arg::with_name("preview-window").long("preview-window").multiple(true).takes_value(true).default_value("right:50%")) - .arg(Arg::with_name("reverse").long("reverse").multiple(true)) + .arg(Arg::with_name("reverse").long("reverse")) .arg(Arg::with_name("algorithm").long("algo").multiple(true).takes_value(true).default_value("skim_v2")) .arg(Arg::with_name("case").long("case").multiple(true).takes_value(true).default_value("smart")) - .arg(Arg::with_name("literal").long("literal").multiple(true)) - .arg(Arg::with_name("cycle").long("cycle").multiple(true)) - .arg(Arg::with_name("no-hscroll").long("no-hscroll").multiple(true)) + .arg(Arg::with_name("literal").long("literal")) + .arg(Arg::with_name("cycle").long("cycle")) + .arg(Arg::with_name("no-hscroll").long("no-hscroll")) .arg(Arg::with_name("hscroll-off").long("hscroll-off").multiple(true).takes_value(true).default_value("10")) - .arg(Arg::with_name("filepath-word").long("filepath-word").multiple(true)) + .arg(Arg::with_name("filepath-word").long("filepath-word")) .arg(Arg::with_name("jump-labels").long("jump-labels").multiple(true).takes_value(true).default_value("abcdefghijklmnopqrstuvwxyz")) - .arg(Arg::with_name("border").long("border").multiple(true)) - .arg(Arg::with_name("inline-info").long("inline-info").multiple(true)) + .arg(Arg::with_name("border").long("border")) + .arg(Arg::with_name("inline-info").long("inline-info")) .arg(Arg::with_name("header").long("header").multiple(true).takes_value(true).default_value("")) .arg(Arg::with_name("header-lines").long("header-lines").multiple(true).takes_value(true).default_value("0")) .arg(Arg::with_name("tabstop").long("tabstop").multiple(true).takes_value(true).default_value("8")) - .arg(Arg::with_name("no-bold").long("no-bold").multiple(true)) + .arg(Arg::with_name("no-bold").long("no-bold")) .arg(Arg::with_name("history").long("history").multiple(true).takes_value(true)) .arg(Arg::with_name("cmd-history").long("cmd-history").multiple(true).takes_value(true)) .arg(Arg::with_name("history-size").long("history-size").multiple(true).takes_value(true).default_value("1000")) .arg(Arg::with_name("cmd-history-size").long("cmd-history-size").multiple(true).takes_value(true).default_value("1000")) - .arg(Arg::with_name("print-query").long("print-query").multiple(true)) - .arg(Arg::with_name("print-cmd").long("print-cmd").multiple(true)) - .arg(Arg::with_name("print-score").long("print-score").multiple(true)) - .arg(Arg::with_name("read0").long("read0").multiple(true)) - .arg(Arg::with_name("print0").long("print0").multiple(true)) - .arg(Arg::with_name("sync").long("sync").multiple(true)) - .arg(Arg::with_name("extended").long("extended").short('x').multiple(true)) - .arg(Arg::with_name("no-sort").long("no-sort").multiple(true)) - .arg(Arg::with_name("select-1").long("select-1").short('1').multiple(true)) - .arg(Arg::with_name("exit-0").long("exit-0").short('0').multiple(true)) + .arg(Arg::with_name("print-query").long("print-query")) + .arg(Arg::with_name("print-cmd").long("print-cmd")) + .arg(Arg::with_name("print-score").long("print-score")) + .arg(Arg::with_name("read0").long("read0")) + .arg(Arg::with_name("print0").long("print0")) + .arg(Arg::with_name("sync").long("sync")) + .arg(Arg::with_name("extended").long("extended").short('x')) + .arg(Arg::with_name("no-sort").long("no-sort")) + .arg(Arg::with_name("select-1").long("select-1").short('1')) + .arg(Arg::with_name("exit-0").long("exit-0").short('0')) .arg(Arg::with_name("filter").long("filter").short('f').takes_value(true).multiple(true)) .arg(Arg::with_name("layout").long("layout").multiple(true).takes_value(true).default_value("default")) - .arg(Arg::with_name("keep-right").long("keep-right").multiple(true)) + .arg(Arg::with_name("keep-right").long("keep-right")) .arg(Arg::with_name("skip-to-pattern").long("skip-to-pattern").multiple(true).takes_value(true).default_value("")) .arg(Arg::with_name("pre-select-n").long("pre-select-n").multiple(true).takes_value(true).default_value("0")) .arg(Arg::with_name("pre-select-pat").long("pre-select-pat").multiple(true).takes_value(true).default_value("")) .arg(Arg::with_name("pre-select-items").long("pre-select-items").multiple(true).takes_value(true)) .arg(Arg::with_name("pre-select-file").long("pre-select-file").multiple(true).takes_value(true).default_value("")) - .arg(Arg::with_name("no-clear-if-empty").long("no-clear-if-empty").multiple(true)) - .arg(Arg::with_name("show-cmd-error").long("show-cmd-error").multiple(true)) + .arg(Arg::with_name("no-clear-if-empty").long("no-clear-if-empty")) + .arg(Arg::with_name("show-cmd-error").long("show-cmd-error")) .get_matches_from(args); if opts.is_present("help") { diff --git a/src/engine/fuzzy.rs b/src/engine/fuzzy.rs index 0c13ebc0..67117a56 100644 --- a/src/engine/fuzzy.rs +++ b/src/engine/fuzzy.rs @@ -1,3 +1,4 @@ +use std::cmp::min; use std::fmt::{Display, Error, Formatter}; use std::sync::Arc; @@ -8,7 +9,6 @@ use fuzzy_matcher::FuzzyMatcher; use crate::item::RankBuilder; use crate::{CaseMatching, MatchEngine}; use crate::{MatchRange, MatchResult, SkimItem}; -use bitflags::_core::cmp::min; //------------------------------------------------------------------------------ #[derive(Debug, Copy, Clone, Default)] diff --git a/src/event.rs b/src/event.rs index 45821bb8..c4825a1a 100644 --- a/src/event.rs +++ b/src/event.rs @@ -1,6 +1,5 @@ // All the events that will be used -use bitflags::bitflags; use std::sync::mpsc::{Receiver, Sender}; use tuikit::key::Key; @@ -77,12 +76,10 @@ pub enum Event { __Nonexhaustive, } -bitflags! { - /// `Effect` is the effect of a text - pub struct UpdateScreen: u8 { - const REDRAW = 0b0000_0001; - const DONT_REDRAW = 0b0000_0010; - } +/// `Effect` is the effect of a text +pub enum UpdateScreen { + Redraw, + DontRedraw, } pub trait EventHandler { diff --git a/src/header.rs b/src/header.rs index f22c3eb8..3394f78a 100644 --- a/src/header.rs +++ b/src/header.rs @@ -143,6 +143,6 @@ impl Widget for Header { impl EventHandler for Header { fn handle(&mut self, _event: &Event) -> UpdateScreen { - UpdateScreen::DONT_REDRAW + UpdateScreen::DontRedraw } } diff --git a/src/previewer.rs b/src/previewer.rs index 304cba40..1a08fe13 100644 --- a/src/previewer.rs +++ b/src/previewer.rs @@ -333,9 +333,9 @@ impl EventHandler for Previewer { EvActPreviewRight(diff) => self.act_scroll_right(*diff), EvActPreviewPageUp(diff) => self.act_scroll_down(-(height as i32 * *diff)), EvActPreviewPageDown(diff) => self.act_scroll_down(height as i32 * *diff), - _ => return UpdateScreen::DONT_REDRAW, + _ => return UpdateScreen::DontRedraw, } - UpdateScreen::REDRAW + UpdateScreen::Redraw } } diff --git a/src/query.rs b/src/query.rs index fd0a1bb0..6ee1fb8b 100644 --- a/src/query.rs +++ b/src/query.rs @@ -534,9 +534,9 @@ impl EventHandler for Query { } if self.query_changed(mode, query_before_len, query_after_len, cmd_before_len, cmd_after_len) { - UpdateScreen::REDRAW + UpdateScreen::Redraw } else { - UpdateScreen::DONT_REDRAW + UpdateScreen::DontRedraw } } } diff --git a/src/selection.rs b/src/selection.rs index 95d56909..a696547f 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -395,9 +395,9 @@ impl EventHandler for Selection { EvActScrollRight(diff) => { self.act_scroll(*diff); } - _ => return UpdateScreen::DONT_REDRAW, + _ => return UpdateScreen::DontRedraw, } - UpdateScreen::REDRAW + UpdateScreen::Redraw } } diff --git a/src/util.rs b/src/util.rs index a0aabf13..17f95380 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,6 +1,7 @@ use std::borrow::Cow; use std::cmp::{max, min}; use std::prelude::v1::*; +use std::str::FromStr; use regex::{Captures, Regex}; use tuikit::prelude::*; @@ -8,7 +9,6 @@ use unicode_width::UnicodeWidthChar; use crate::field::get_string_by_range; use crate::AnsiString; -use bitflags::_core::str::FromStr; lazy_static! { static ref RE_ESCAPE: Regex = Regex::new(r"['\U{00}]").unwrap();