From 3d6fda7b516c7bad95c7884e723d039ff2344fd3 Mon Sep 17 00:00:00 2001 From: Jengamon Date: Mon, 11 Sep 2023 11:15:01 -0700 Subject: [PATCH] update to 0.38.1 --- Cargo.lock | 154 ++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 4 +- src/backend_workers.rs | 24 +++---- src/main.rs | 58 +++++++++------- 4 files changed, 192 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d45e421..9840643 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -301,6 +301,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + [[package]] name = "cc" version = "1.0.79" @@ -336,7 +342,7 @@ dependencies = [ "bitflags", "clap_derive", "clap_lex", - "indexmap", + "indexmap 1.9.3", "once_cell", "strsim", "termcolor", @@ -600,6 +606,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.1" @@ -810,6 +828,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.3.2" @@ -905,7 +929,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", ] [[package]] @@ -992,6 +1026,15 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.7" @@ -1219,7 +1262,7 @@ dependencies = [ [[package]] name = "monocle" -version = "0.37.2" +version = "0.38.0" dependencies = [ "fuzzy-matcher", "ignore", @@ -1230,6 +1273,12 @@ dependencies = [ "zellij-tile", ] +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "nix" version = "0.23.2" @@ -1478,6 +1527,16 @@ dependencies = [ "sha2 0.10.6", ] +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.0.0", +] + [[package]] name = "phf" version = "0.10.1" @@ -1576,6 +1635,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -1609,6 +1678,60 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck 0.4.1", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 1.0.109", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost", +] + [[package]] name = "quote" version = "1.0.28" @@ -1822,7 +1945,7 @@ version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "ryu", "serde", "yaml-rust", @@ -2244,7 +2367,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" dependencies = [ - "hashbrown", + "hashbrown 0.12.3", "regex", ] @@ -2508,6 +2631,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2682,9 +2816,9 @@ dependencies = [ [[package]] name = "zellij-tile" -version = "0.37.2" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7c93e10683f2a81cfbbcfd005765c68eadc2b8d9aa24e091e71e03ce2a40d0" +checksum = "68b51700a828e8a2bf2eb82d62b260932576fa1882494c2af8395f5f4794a15f" dependencies = [ "clap", "serde", @@ -2696,9 +2830,9 @@ dependencies = [ [[package]] name = "zellij-utils" -version = "0.37.2" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c043465af8187811927bb5f4c2863aece71081a355e8616fa6d00892eedba2" +checksum = "60c68881b9892c36e90031e7deb36a4fc8e11f6f95c468e19e900f54b6ed94de" dependencies = [ "anyhow", "async-channel", @@ -2722,6 +2856,8 @@ dependencies = [ "notify-debouncer-full", "once_cell", "percent-encoding", + "prost", + "prost-build", "regex", "rmp-serde", "serde", diff --git a/Cargo.toml b/Cargo.toml index 6a1cc32..a2bc28f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "monocle" -version = "0.37.2" +version = "0.38.0" authors = ["Aram Drevekenin "] edition = "2018" [dependencies] -zellij-tile = "0.37.2" +zellij-tile = "0.38.1" ignore = "0.4.20" fuzzy-matcher = "0.3.7" serde = { version = "1.0", features = ["derive"] } diff --git a/src/backend_workers.rs b/src/backend_workers.rs index 94ec649..652350e 100644 --- a/src/backend_workers.rs +++ b/src/backend_workers.rs @@ -32,10 +32,10 @@ impl Search { match serde_json::from_str::(&message) { Ok(MessageToSearch::ScanFolder) => { self.scan_hd(); - post_message_to_plugin( - serde_json::to_string(&MessageToPlugin::DoneScanningFolder).unwrap(), - "".to_owned(), - ); + post_message_to_plugin(PluginMessage::new_to_plugin( + &serde_json::to_string(&MessageToPlugin::DoneScanningFolder).unwrap(), + "", + )); } Ok(MessageToSearch::Search) => { if let Some(current_search_term) = self.read_search_term_from_hd_cache() { @@ -105,16 +105,16 @@ impl Search { } } if let Some(file_names_search_results) = file_names_search_results { - post_message_to_plugin( - serde_json::to_string(&MessageToPlugin::UpdateFileNameSearchResults).unwrap(), - serde_json::to_string(&file_names_search_results).unwrap(), - ); + post_message_to_plugin(PluginMessage::new_to_plugin( + &serde_json::to_string(&MessageToPlugin::UpdateFileNameSearchResults).unwrap(), + &serde_json::to_string(&file_names_search_results).unwrap(), + )); } if let Some(file_contents_search_results) = file_contents_search_results { - post_message_to_plugin( - serde_json::to_string(&MessageToPlugin::UpdateFileContentsSearchResults).unwrap(), - serde_json::to_string(&file_contents_search_results).unwrap(), - ); + post_message_to_plugin(PluginMessage::new_to_plugin( + &serde_json::to_string(&MessageToPlugin::UpdateFileContentsSearchResults).unwrap(), + &serde_json::to_string(&file_contents_search_results).unwrap(), + )); } } pub fn rescan_files(&mut self, paths: String) { diff --git a/src/main.rs b/src/main.rs index 2a4240c..253a74f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ mod ui; use zellij_tile::prelude::*; use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; use std::path::PathBuf; use backend_workers::{FileContentsWorker, FileNameWorker, MessageToPlugin, MessageToSearch}; @@ -35,8 +36,13 @@ struct State { } impl ZellijPlugin for State { - fn load(&mut self) { + fn load(&mut self, _config: BTreeMap) { self.loading = true; + request_permission(&[ + PermissionType::OpenFiles, + PermissionType::ChangeApplicationState, + PermissionType::OpenTerminalsOrPlugins, + ]); subscribe(&[ EventType::Key, EventType::Mouse, @@ -46,16 +52,16 @@ impl ZellijPlugin for State { EventType::FileSystemUpdate, EventType::FileSystemDelete, ]); - post_message_to( + post_message_to(PluginMessage::new_to_worker( "file_name_search", &serde_json::to_string(&MessageToSearch::ScanFolder).unwrap(), "", - ); - post_message_to( + )); + post_message_to(PluginMessage::new_to_worker( "file_contents_search", &serde_json::to_string(&MessageToSearch::ScanFolder).unwrap(), "", - ); + )); self.loading = true; set_timeout(0.5); // for displaying loading animation } @@ -100,48 +106,48 @@ impl ZellijPlugin for State { .iter() .map(|p| p.to_string_lossy().to_string()) .collect(); - post_message_to( + post_message_to(PluginMessage::new_to_worker( "file_name_search", &serde_json::to_string(&MessageToSearch::FileSystemCreate).unwrap(), &serde_json::to_string(&paths).unwrap(), - ); - post_message_to( + )); + post_message_to(PluginMessage::new_to_worker( "file_contents_search", &serde_json::to_string(&MessageToSearch::FileSystemCreate).unwrap(), &serde_json::to_string(&paths).unwrap(), - ); + )); } Event::FileSystemUpdate(paths) => { let paths: Vec = paths .iter() .map(|p| p.to_string_lossy().to_string()) .collect(); - post_message_to( + post_message_to(PluginMessage::new_to_worker( "file_name_search", &serde_json::to_string(&MessageToSearch::FileSystemUpdate).unwrap(), &serde_json::to_string(&paths).unwrap(), - ); - post_message_to( + )); + post_message_to(PluginMessage::new_to_worker( "file_contents_search", &serde_json::to_string(&MessageToSearch::FileSystemUpdate).unwrap(), &serde_json::to_string(&paths).unwrap(), - ); + )); } Event::FileSystemDelete(paths) => { let paths: Vec = paths .iter() .map(|p| p.to_string_lossy().to_string()) .collect(); - post_message_to( + post_message_to(PluginMessage::new_to_worker( "file_name_search", &serde_json::to_string(&MessageToSearch::FileSystemDelete).unwrap(), &serde_json::to_string(&paths).unwrap(), - ); - post_message_to( + )); + post_message_to(PluginMessage::new_to_worker( "file_contents_search", &serde_json::to_string(&MessageToSearch::FileSystemDelete).unwrap(), &serde_json::to_string(&paths).unwrap(), - ); + )); } _ => { eprintln!("Unknown event: {}", event.to_string()); @@ -219,18 +225,20 @@ impl State { match self.selected_search_result_entry() { Some(SearchResult::File { path, .. }) => { if self.should_open_floating { - open_file_floating(&PathBuf::from(path)) + open_file_floating(FileToOpen::new(PathBuf::from(path))) } else { - open_file(&PathBuf::from(path)); + open_file(FileToOpen::new(PathBuf::from(path))); } } Some(SearchResult::LineInFile { path, line_number, .. }) => { if self.should_open_floating { - open_file_with_line_floating(&PathBuf::from(path), line_number); + open_file_floating( + FileToOpen::new(PathBuf::from(path)).with_line_number(line_number), + ); } else { - open_file_with_line(&PathBuf::from(path), line_number); + open_file(FileToOpen::new(PathBuf::from(path)).with_line_number(line_number)); } } None => eprintln!("Search results not found"), @@ -284,16 +292,16 @@ impl State { match std::fs::write(CURRENT_SEARCH_TERM, &self.search_term) { Ok(_) => { if !self.search_term.is_empty() { - post_message_to( + post_message_to(PluginMessage::new_to_worker( "file_name_search", &serde_json::to_string(&MessageToSearch::Search).unwrap(), "", - ); - post_message_to( + )); + post_message_to(PluginMessage::new_to_worker( "file_contents_search", &serde_json::to_string(&MessageToSearch::Search).unwrap(), "", - ); + )); self.file_name_search_results.clear(); self.file_contents_search_results.clear(); }