Skip to content

Commit

Permalink
chore: remove bitflags (#579)
Browse files Browse the repository at this point in the history
* chore: remove bitflags

* fix: add args-override-self to allow multiple args occurence

---------

Co-authored-by: LoricAndre <[email protected]>
  • Loading branch information
LoricAndre and LoricAndre authored Nov 18, 2024
1 parent 5ef1b59 commit c932a1f
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 304 deletions.
454 changes: 199 additions & 255 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
65 changes: 33 additions & 32 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,23 @@ fn real_main() -> Result<i32, std::io::Error> {
let opts = App::new("sk")
.author("Jinzhou Zhang<[email protected]>")
.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))
Expand All @@ -192,52 +193,52 @@ fn real_main() -> Result<i32, std::io::Error> {
.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") {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/fuzzy.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cmp::min;
use std::fmt::{Display, Error, Formatter};
use std::sync::Arc;

Expand All @@ -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)]
Expand Down
11 changes: 4 additions & 7 deletions src/event.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// All the events that will be used

use bitflags::bitflags;
use std::sync::mpsc::{Receiver, Sender};
use tuikit::key::Key;

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ impl Widget<Event> for Header {

impl EventHandler for Header {
fn handle(&mut self, _event: &Event) -> UpdateScreen {
UpdateScreen::DONT_REDRAW
UpdateScreen::DontRedraw
}
}
4 changes: 2 additions & 2 deletions src/previewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::borrow::Cow;
use std::cmp::{max, min};
use std::prelude::v1::*;
use std::str::FromStr;

use regex::{Captures, Regex};
use tuikit::prelude::*;
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();
Expand Down

0 comments on commit c932a1f

Please sign in to comment.