From b23063b856b35a27e403207b1137defc056530b6 Mon Sep 17 00:00:00 2001 From: Vonr Date: Thu, 24 Aug 2023 17:04:51 +0800 Subject: [PATCH] ver: 1.0.9 Updated dependencies, attempt to fix #4 by removing native-tls flag in ureq. --- Cargo.lock | 307 +++++++++++------------------------------------ Cargo.toml | 19 +-- src/interface.rs | 74 ++++-------- src/macros.rs | 51 ++++++++ src/main.rs | 50 +++++--- src/mode.rs | 5 +- 6 files changed, 195 insertions(+), 311 deletions(-) create mode 100644 src/macros.rs diff --git a/Cargo.lock b/Cargo.lock index 4a68144..2d858e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,12 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "atomic" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] [[package]] name = "autocfg" @@ -56,12 +59,38 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bumpalo" version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "bytes" version = "1.4.0" @@ -92,22 +121,6 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0c5685be29536b1c7f8251cbcad899f86134711da1fa0491c18fffef48c6788" -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - [[package]] name = "crc32fast" version = "1.3.2" @@ -123,7 +136,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossterm_winapi", "libc", "mio", @@ -133,6 +146,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "crossterm" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" +dependencies = [ + "bitflags 2.4.0", + "libc", + "mio", + "parking_lot", + "signal-hook", + "signal-hook-mio", +] + [[package]] name = "crossterm_winapi" version = "0.9.1" @@ -158,36 +185,6 @@ dependencies = [ "thousands", ] -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "flate2" version = "1.0.26" @@ -198,21 +195,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.0" @@ -245,24 +227,10 @@ dependencies = [ ] [[package]] -name = "instant" -version = "0.1.12" +name = "indoc" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] +checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" [[package]] name = "itoa" @@ -291,12 +259,6 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "lock_api" version = "0.4.10" @@ -350,24 +312,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nohash-hasher" version = "0.2.0" @@ -399,50 +343,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "openssl" -version = "0.10.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -468,11 +368,12 @@ dependencies = [ [[package]] name = "parui" -version = "1.0.8" +version = "1.0.9" dependencies = [ "atomic", + "bytemuck", "compact_strings", - "crossterm", + "crossterm 0.27.0", "dhat", "nohash-hasher", "parking_lot", @@ -481,6 +382,12 @@ dependencies = [ "ureq", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "percent-encoding" version = "2.3.0" @@ -489,15 +396,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" [[package]] name = "proc-macro2" @@ -519,13 +420,15 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce841e0486e7c2412c3740168ede33adeba8e154a15107b879d8162d77c7174e" +checksum = "8285baa38bdc9f879d92c0e37cb562ef38aa3aeefca22b3200186bc39242d3d5" dependencies = [ - "bitflags", + "bitflags 2.4.0", "cassowary", - "crossterm", + "crossterm 0.26.1", + "indoc", + "paste", "unicode-segmentation", "unicode-width", ] @@ -536,7 +439,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -566,20 +469,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "rustls" version = "0.21.5" @@ -618,15 +507,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" -[[package]] -name = "schannel" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" -dependencies = [ - "windows-sys", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -643,29 +523,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "security-framework" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "serde" version = "1.0.171" @@ -699,9 +556,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b824b6e687aff278cdbf3b36f07aa52d4bd4099699324d5da86a2ebce3aa00b3" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", @@ -760,20 +617,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tempfile" -version = "3.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" -dependencies = [ - "autocfg", - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys", -] - [[package]] name = "thousands" version = "0.2.0" @@ -797,11 +640,10 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", @@ -872,7 +714,6 @@ dependencies = [ "base64", "flate2", "log", - "native-tls", "once_cell", "rustls", "rustls-webpki 0.100.1", @@ -891,12 +732,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 2765f14..6a7351d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "parui" description = "Simple TUI frontend for paru or yay." -version = "1.0.8" +version = "1.0.9" edition = "2021" license = "MIT" readme = "README.md" @@ -24,29 +24,34 @@ debug = true strip = false [dependencies] -atomic = "0.5.3" +atomic = "0.6.0" parking_lot = "0.12.1" nohash-hasher = "0.2.0" compact_strings = "1.2.2" dhat = "0.3.2" [dependencies.crossterm] -version = "0.26.1" +version = "0.27.0" default-features = false +features = ["events"] [dependencies.tokio] -version = "1.28.2" +version = "1.32.0" features = ["process", "rt-multi-thread", "time", "macros", "sync"] [dependencies.tui] package = "ratatui" -version = "0.21.0" +version = "0.22.0" features = ["crossterm"] [dependencies.ureq] -version = "2.6.2" +version = "2.7.1" default-features = false -features = ["gzip", "tls", "native-tls"] +features = ["gzip", "tls"] + +[dependencies.bytemuck] +version = "1.13.1" +features = ["derive"] [features] dhat = [] diff --git a/src/interface.rs b/src/interface.rs index a4e52c4..d909505 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -92,7 +92,7 @@ pub fn search(shown: Arc>, query: &str, packages: &CompactStrings) } #[allow(clippy::too_many_arguments)] -pub async fn format_results<'a>( +pub fn format_results<'a>( packages: Arc>, shown: Arc>, current: usize, @@ -102,56 +102,29 @@ pub async fn format_results<'a>( skip: usize, installed: Arc>>, ) -> Vec> { - macro_rules! style { - ($fg:expr) => { - Style { - fg: Some(($fg)), - bg: None, - add_modifier: Modifier::empty(), - sub_modifier: Modifier::empty(), - } - }; - ($fg:expr, $mod:expr) => { - Style { - fg: Some(($fg)), - bg: None, - add_modifier: ($mod), - sub_modifier: Modifier::empty(), - } - }; - ($fg:expr, $bg:expr, $mod:expr) => { - Style { - fg: Some(($fg)), - bg: Some(($bg)), - add_modifier: ($mod), - sub_modifier: Modifier::empty(), - } - }; - } - - macro_rules! raws { - ($($str:literal),*) => { - [ - $(Span { - content: std::borrow::Cow::Borrowed($str), - style: DEFAULT_STYLE, - }),* - ] - }; - } + use crate::{raws, style}; const INDEX_STYLE: Style = style!(Color::Gray); - const INSTALLED_STYLE: Style = style!(Color::Green, Modifier::BOLD); - const INSTALLED_SELECTED_STYLE: Style = style!(Color::Yellow, Color::Red, Modifier::BOLD); - const UNINSTALLED_STYLE: Style = style!(Color::LightBlue, Modifier::BOLD); - const UNINSTALLED_SELECTED_STYLE: Style = style!(Color::Blue, Color::Red, Modifier::BOLD); - - const DEFAULT_STYLE: Style = Style { - fg: None, - bg: None, - add_modifier: Modifier::empty(), - sub_modifier: Modifier::empty(), + const INSTALLED_STYLE: Style = style! { + fg: Color::Green, + mod: Modifier::BOLD, }; + const INSTALLED_SELECTED_STYLE: Style = style! { + fg: Color::Yellow, + bg: Color::Red, + mod: Modifier::BOLD, + }; + const UNINSTALLED_STYLE: Style = style! { + fg: Color::LightBlue, + mod: Modifier::BOLD, + }; + const UNINSTALLED_SELECTED_STYLE: Style = style! { + fg: Color::Blue, + bg: Color::Red, + mod: Modifier::BOLD, + }; + const DEFAULT_STYLE: Style = style!(); + const PADDINGS: [Span; 16] = raws!( " ", " ", @@ -173,7 +146,7 @@ pub async fn format_results<'a>( const SELECTED: Span = Span { content: Cow::Borrowed("!"), - style: style!(Color::Yellow, Modifier::BOLD), + style: style! { fg: Color::Yellow, mod: Modifier::BOLD, }, }; let packages = packages.read(); @@ -268,6 +241,7 @@ pub async fn get_info<'a>( const KEY_STYLE: Style = Style { fg: None, bg: None, + underline_color: None, add_modifier: Modifier::BOLD, sub_modifier: Modifier::empty(), }; @@ -290,7 +264,7 @@ pub async fn get_info<'a>( info } -pub async fn is_installed( +pub async fn check_installed( packages: Arc>, installed: Arc>>, ) { diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..83f2793 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,51 @@ +#[macro_export] +macro_rules! style_inner { + {$(fg: $fg:expr,)? $(bg: $bg:expr,)? $(mod: $mod:expr,)? $(,)?} => {{ + macro_rules! opt { + () => { + None + }; + ($o:expr) => { + Some($o) + }; + } + + macro_rules! opt_mod { + () => { + ::tui::style::Modifier::empty() + }; + ($m:expr) => { + $m + }; + } + + Style { + fg: opt!($($fg)?), + bg: opt!($($bg)?), + underline_color: None, + add_modifier: opt_mod!($($mod)?), + sub_modifier: ::tui::style::Modifier::empty(), + } + }}; +} + +#[macro_export] +macro_rules! style { + ($fg:expr) => { $crate::style! { fg: $fg } }; + + {$($path:ident: $value:expr),*$(,)?} => { + $crate::style_inner!($($path: $value,)*) + }; +} + +#[macro_export] +macro_rules! raws { + ($($str:literal),*) => { + [ + $(Span { + content: std::borrow::Cow::Borrowed($str), + style: DEFAULT_STYLE, + }),* + ] + }; +} diff --git a/src/main.rs b/src/main.rs index b2087cf..9da7dd6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use crossterm::execute; use crossterm::terminal::{ disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen, }; -use interface::{format_results, get_info, is_installed, list, search}; +use interface::{check_installed, format_results, get_info, list, search}; use mode::Mode; use nohash_hasher::IntSet; use parking_lot::{Mutex, RwLock}; @@ -29,6 +29,7 @@ use tui::{ mod config; mod interface; +mod macros; mod mode; mod shown; @@ -95,7 +96,7 @@ async fn main() -> Result<(), io::Error> { } if installed.read().is_empty() { - is_installed(all_packages.clone(), installed.clone()).await; + check_installed(all_packages.clone(), installed.clone()).await; } search(shown.clone(), &query, &all_packages.read()); @@ -132,19 +133,16 @@ async fn main() -> Result<(), io::Error> { if redraw.swap(false, Ordering::SeqCst) { let shown_len_str_len = (shown_len() + 1).ilog10() as usize + 1; - let formatted_shown = { - format_results( - all_packages.clone(), - shown.clone(), - current, - &selected, - size.height as usize, - shown_len_str_len, - skipped, - installed.clone(), - ) - .await - }; + let formatted_shown = format_results( + all_packages.clone(), + shown.clone(), + current, + &selected, + size.height as usize, + shown_len_str_len, + skipped, + installed.clone(), + ); if info.lock().is_empty() && !shown.read().is_empty() { let shown = shown.clone(); @@ -347,7 +345,7 @@ async fn main() -> Result<(), io::Error> { if matches!(e, Event::Resize(..)) { redraw.store(true, Ordering::SeqCst); }; - continue + continue; }; match mode.load(Ordering::SeqCst) { @@ -403,6 +401,10 @@ async fn main() -> Result<(), io::Error> { terminal.clear()?; terminal.set_cursor(0, 0)?; + if let Some(search_thread) = _search_task { + search_thread.abort(); + } + return Ok(()); } 'w' if k.modifiers == KeyModifiers::CONTROL => { @@ -441,7 +443,7 @@ async fn main() -> Result<(), io::Error> { list(all_packages.clone(), command != "pacman").await; } - is_installed(all_packages.clone(), installed.clone()).await; + check_installed(all_packages.clone(), installed.clone()).await; search(shown.clone(), &query, &all_packages.read()); @@ -554,6 +556,10 @@ async fn main() -> Result<(), io::Error> { terminal.clear()?; terminal.set_cursor(0, 0)?; + if let Some(search_thread) = _search_task { + search_thread.abort(); + } + return Ok(()); } 'c' if k.modifiers.contains(KeyModifiers::CONTROL) => { @@ -562,6 +568,10 @@ async fn main() -> Result<(), io::Error> { terminal.clear()?; terminal.set_cursor(0, 0)?; + if let Some(search_thread) = _search_task { + search_thread.abort(); + } + return Ok(()); } 'R' => { @@ -606,6 +616,11 @@ async fn main() -> Result<(), io::Error> { terminal.clear()?; terminal.set_cursor(0, 0)?; terminal.show_cursor()?; + + if let Some(search_thread) = _search_task { + search_thread.abort(); + } + let mut cmd = std::process::Command::new(command); cmd.arg("-S"); if selected.is_empty() { @@ -615,6 +630,7 @@ async fn main() -> Result<(), io::Error> { cmd.arg(&(all_packages.read()[*i])); } } + cmd.exec(); return Ok(()); diff --git a/src/mode.rs b/src/mode.rs index c17384c..c780f4a 100644 --- a/src/mode.rs +++ b/src/mode.rs @@ -1,4 +1,7 @@ -#[derive(Clone, Copy)] +use bytemuck::NoUninit; + +#[derive(Clone, Copy, NoUninit)] +#[repr(u8)] pub enum Mode { Insert, Select,