From e10fae7255557df4e6c2b63a944357cae6b7d94f Mon Sep 17 00:00:00 2001 From: Jeff Zhao Date: Sun, 2 Jul 2023 11:20:37 -0400 Subject: migrate to rustyline v12 --- Cargo.lock | 300 ++++++++++++++++++------------------- Cargo.toml | 5 +- src/commands/command_line.rs | 5 +- src/commands/open_file.rs | 4 +- src/commands/set_mode.rs | 5 +- src/context/commandline_context.rs | 10 +- src/ui/views/tui_textfield.rs | 132 +++++++++++----- src/ui/widgets/tui_topbar.rs | 13 +- 8 files changed, 271 insertions(+), 203 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9799aa..cb17ea1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -43,9 +43,9 @@ dependencies = [ [[package]] name = "ansi-to-tui" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f3d156989cd98fb225b1a83e82e133e95a151774a420c884f6a65c5f6fb1ee2" +checksum = "0b0e348dcd256ba06d44d5deabc88a7c0e80ee7303158253ca069bcd9e9b7f57" dependencies = [ "nom", "ratatui", @@ -67,7 +67,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", "winapi", ] @@ -84,6 +84,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bstr" version = "1.5.0" @@ -122,9 +128,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbc37d37da9e5bce8173f3a41b71d9bf3c674deebbaceacd0ebdabde76efb03" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ "android-tzdata", "iana-time-zone", @@ -143,7 +149,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -185,18 +191,18 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] [[package]] name = "dirs" -version = "4.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] @@ -213,13 +219,14 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -239,6 +246,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "equivalent" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" + [[package]] name = "errno" version = "0.3.1" @@ -272,9 +285,9 @@ dependencies = [ [[package]] name = "fd-lock" -version = "3.0.12" +version = "3.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ae6b3d9530211fb3b12a95374b8b0823be812f53d09e18c5675c0146b09642" +checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", "rustix", @@ -301,9 +314,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -319,9 +332,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -343,9 +356,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] name = "heck" @@ -365,12 +378,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - [[package]] name = "home" version = "0.5.5" @@ -382,9 +389,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -405,9 +412,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -415,11 +422,11 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "autocfg", + "equivalent", "hashbrown", ] @@ -429,7 +436,7 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" dependencies = [ - "bitflags", + "bitflags 1.3.2", "inotify-sys", "libc", ] @@ -443,17 +450,6 @@ dependencies = [ "libc", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "is-docker" version = "0.2.0" @@ -512,9 +508,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -535,7 +531,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] @@ -547,21 +543,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "log" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "malloc_buf" @@ -578,15 +574,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -595,9 +582,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mio" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebffdb73fe72e917997fad08bdbf31ac50b0fa91cec93e69a0662e4264d454c" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "log", @@ -616,15 +603,14 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.2" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", - "cc", + "bitflags 1.3.2", "cfg-if", "libc", - "memoffset", + "static_assertions", ] [[package]] @@ -643,7 +629,7 @@ version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5738a2795d57ea20abec2d6d76c6081186709c0024187cd5977265eda6598b51" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossbeam-channel", "filetime", "fsevent-sys", @@ -681,9 +667,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.2" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "open" @@ -696,6 +682,12 @@ dependencies = [ "pathdiff", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "os_str_bytes" version = "6.5.1" @@ -713,15 +705,15 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "phf" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ "phf_macros", "phf_shared", @@ -729,9 +721,9 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared", "rand", @@ -739,22 +731,22 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92aacdc5f16768709a569e913f7451034034178b05bdc8acda226659a3dccc66" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" dependencies = [ "phf_generator", "phf_shared", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.22", ] [[package]] name = "phf_shared" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ "siphasher", ] @@ -791,18 +783,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -853,7 +845,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce841e0486e7c2412c3740168ede33adeba8e154a15107b879d8162d77c7174e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cassowary", "termion", "unicode-segmentation", @@ -866,7 +858,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -891,11 +883,11 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.3" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ - "aho-corasick 1.0.1", + "aho-corasick 1.0.2", "memchr", "regex-syntax", ] @@ -914,13 +906,12 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "rustix" -version = "0.37.19" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "fbc6396159432b5c8490d4e301d8c705f61860b8b6c863bf79942ce5401968f3" dependencies = [ - "bitflags", + "bitflags 2.3.3", "errno", - "io-lifetimes", "libc", "linux-raw-sys", "windows-sys 0.48.0", @@ -928,22 +919,21 @@ dependencies = [ [[package]] name = "rustyline" -version = "9.1.2" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7826789c0e25614b03e5a54a0717a86f9ff6e6e5247f92b369472869320039" +checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ - "bitflags", + "bitflags 2.3.3", "cfg-if", "clipboard-win", - "dirs-next", "fd-lock", + "home", "libc", "log", "memchr", "nix", "radix_trie", "scopeguard", - "smallvec", "unicode-segmentation", "unicode-width", "utf8parse", @@ -967,26 +957,26 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.22", ] [[package]] name = "serde_spanned" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -1039,6 +1029,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "str-buf" version = "1.0.6" @@ -1088,9 +1084,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.18" +version = "2.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" dependencies = [ "proc-macro2", "quote", @@ -1135,7 +1131,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.22", ] [[package]] @@ -1166,9 +1162,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +checksum = "1ebafdf5ad1220cb59e7d17cf4d2c72015297b75b19a10472f99b89225089240" dependencies = [ "serde", "serde_spanned", @@ -1178,18 +1174,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" dependencies = [ "indexmap", "serde", @@ -1200,9 +1196,9 @@ dependencies = [ [[package]] name = "trash" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d219a2989f6a23fd3a6599d733e03b524cc3c50feed539ea3a136ae7845fe83" +checksum = "eb060e46f3142e73342a48e30f31d24e6657bab2d7cc7b4b3afa213ea7a13b74" dependencies = [ "chrono", "libc", @@ -1249,9 +1245,9 @@ checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -1276,9 +1272,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" dependencies = [ "getrandom", "rand", @@ -1287,13 +1283,13 @@ dependencies = [ [[package]] name = "uuid-macro-internal" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f67b459f42af2e6e1ee213cb9da4dbd022d3320788c3fb3e1b893093f1e45da" +checksum = "8614dda80b9075fbca36bc31b58d1447715b1236af98dee21db521c47a0cc2c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.22", ] [[package]] @@ -1332,9 +1328,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1342,24 +1338,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.22", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1367,28 +1363,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.22", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -1396,9 +1392,9 @@ dependencies = [ [[package]] name = "whoami" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c70234412ca409cc04e864e89523cb0fc37f5e1344ebed5a3ebf4192b6b9f68" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" dependencies = [ "wasm-bindgen", "web-sys", @@ -1450,7 +1446,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -1468,7 +1464,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -1488,9 +1484,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", @@ -1587,9 +1583,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index d483cea..5c451a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,7 @@ notify = "^6" open = "^5" phf = { version = "^0", features = ["macros"], optional = true } rand = "^0" -# rustline latest is v12 migrate -rustyline = "^9" +rustyline = "^12" serde = "^1" serde_derive = "^1" shell-words = "^1" @@ -54,4 +53,4 @@ file_mimetype = [] mouse = [] recycle_bin = ["trash"] syntax_highlight = ["ansi-to-tui"] -default = ["devicons", "mouse", "recycle_bin", "syntax_highlight"] +default = ["devicons", "recycle_bin", "syntax_highlight"] diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs index 9c5aa70..608e5dd 100644 --- a/src/commands/command_line.rs +++ b/src/commands/command_line.rs @@ -4,7 +4,7 @@ use crate::config::AppKeyMapping; use crate::context::AppContext; use crate::error::JoshutoResult; use crate::key_command::{AppExecute, Command}; -use crate::ui::views::TuiTextField; +use crate::ui::views::{DummyListener, TuiTextField}; use crate::ui::AppBackend; pub fn read_and_execute( @@ -15,11 +15,12 @@ pub fn read_and_execute( suffix: &str, ) -> JoshutoResult { context.flush_event(); + let mut listener = DummyListener {}; let user_input: Option = TuiTextField::default() .prompt(":") .prefix(prefix) .suffix(suffix) - .get_input(backend, context); + .get_input(backend, context, &mut listener); if let Some(s) = user_input { let trimmed = s.trim_start(); diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs index eaa94ef..ba71b12 100644 --- a/src/commands/open_file.rs +++ b/src/commands/open_file.rs @@ -5,6 +5,7 @@ use crate::commands::{quit, reload}; use crate::config::ProgramEntry; use crate::context::AppContext; use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult}; +use crate::ui::views::DummyListener; use crate::ui::views::TuiTextField; use crate::ui::AppBackend; use crate::util::mimetype::get_mimetype; @@ -99,11 +100,12 @@ where .map(|(i, e)| format!(" {} | {}", i, e)) .collect(); + let mut listener = DummyListener {}; TuiTextField::default() .prompt(":") .prefix(PROMPT) .menu_items(menu_options.iter().map(|s| s.as_str())) - .get_input(backend, context) + .get_input(backend, context, &mut listener) }; match user_input.as_ref() { Some(user_input) if user_input.starts_with(PROMPT) => { diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs index 53c8740..1f11462 100644 --- a/src/commands/set_mode.rs +++ b/src/commands/set_mode.rs @@ -2,7 +2,7 @@ use std::fs; use crate::context::AppContext; use crate::error::JoshutoResult; -use crate::ui::views::TuiTextField; +use crate::ui::views::{DummyListener, TuiTextField}; use crate::ui::AppBackend; use crate::util::unix; @@ -51,13 +51,14 @@ pub fn set_mode(context: &mut AppContext, backend: &mut AppBackend) -> JoshutoRe Some(entry) => { let mode = entry.metadata.permissions_ref().mode(); let mode_string = unix::mode_to_string(mode); + let mut listener = DummyListener {}; context.flush_event(); TuiTextField::default() .prompt(":") .prefix(PREFIX) .suffix(&mode_string.as_str()[1..]) - .get_input(backend, context) + .get_input(backend, context, &mut listener) } None => None, }; diff --git a/src/context/commandline_context.rs b/src/context/commandline_context.rs index 5169029..f9d262d 100644 --- a/src/context/commandline_context.rs +++ b/src/context/commandline_context.rs @@ -1,13 +1,13 @@ -use rustyline::history; +use rustyline::history::{History, MemHistory}; pub struct CommandLineContext { - history: history::History, + history: MemHistory, } impl std::default::Default for CommandLineContext { fn default() -> Self { Self { - history: history::History::new(), + history: MemHistory::new(), } } } @@ -17,10 +17,10 @@ impl CommandLineContext { Self::default() } - pub fn history_ref(&self) -> &history::History { + pub fn history_ref(&self) -> &dyn History { &self.history } - pub fn history_mut(&mut self) -> &mut history::History { + pub fn history_mut(&mut self) -> &mut dyn History { &mut self.history } } diff --git a/src/ui/views/tui_textfield.rs b/src/ui/views/tui_textfield.rs index bc57138..ba783fd 100644 --- a/src/ui/views/tui_textfield.rs +++ b/src/ui/views/tui_textfield.rs @@ -1,10 +1,9 @@ use std::str::FromStr; use rustyline::completion::{Candidate, Completer, FilenameCompleter, Pair}; -use rustyline::{ - line_buffer::{self, LineBuffer}, - At, Word, -}; +use rustyline::history::{History, SearchDirection}; +use rustyline::line_buffer::{self, ChangeListener, DeleteListener, Direction, LineBuffer}; +use rustyline::{At, Changeset, Word}; use termion::event::{Event, Key}; use tui::layout::Rect; @@ -19,6 +18,22 @@ use crate::ui::views::TuiView; use crate::ui::widgets::{TuiMenu, TuiMultilineText}; use crate::ui::AppBackend; +// Might need to be implemented in the future +#[derive(Clone, Debug)] +pub struct DummyListener {} + +impl DeleteListener for DummyListener { + fn delete(&mut self, idx: usize, string: &str, dir: Direction) {} +} + +impl ChangeListener for DummyListener { + fn insert_char(&mut self, idx: usize, c: char) {} + + fn insert_str(&mut self, idx: usize, string: &str) {} + + fn replace(&mut self, idx: usize, old: &str, new: &str) {} +} + struct CompletionTracker { pub index: usize, pub pos: usize, @@ -78,6 +93,7 @@ impl<'a> TuiTextField<'a> { &mut self, backend: &mut AppBackend, context: &mut AppContext, + listener: &mut DummyListener, ) -> Option { let mut line_buffer = line_buffer::LineBuffer::with_capacity(255); let completer = FilenameCompleter::new(); @@ -86,8 +102,8 @@ impl<'a> TuiTextField<'a> { let char_idx = self._prefix.chars().map(|c| c.len_utf8()).sum(); - line_buffer.insert_str(0, self._prefix); - line_buffer.insert_str(line_buffer.len(), self._suffix); + line_buffer.insert_str(0, self._prefix, listener); + line_buffer.insert_str(line_buffer.len(), self._suffix, listener); line_buffer.set_pos(char_idx); let terminal = backend.terminal_mut(); @@ -169,26 +185,26 @@ impl<'a> TuiTextField<'a> { AppEvent::Termion(Event::Key(key)) => { let dirty = match key { Key::Backspace => { - let res = line_buffer.backspace(1); + let res = line_buffer.backspace(1, listener); if let Ok(command) = Command::from_str(line_buffer.as_str()) { command.interactive_execute(context) } res } - Key::Delete => line_buffer.delete(1).is_some(), + Key::Delete => line_buffer.delete(1, listener).is_some(), Key::Home => line_buffer.move_home(), Key::End => line_buffer.move_end(), Key::Up => { curr_history_index = curr_history_index.saturating_sub(1); line_buffer.move_home(); - line_buffer.kill_line(); - if let Some(s) = context + line_buffer.kill_line(listener); + if let Ok(Some(s)) = context .commandline_context_ref() .history_ref() - .get(curr_history_index) + .get(curr_history_index, SearchDirection::Forward) { - line_buffer.insert_str(0, s); + line_buffer.insert_str(0, &s.entry, listener); } true } @@ -201,13 +217,13 @@ impl<'a> TuiTextField<'a> { curr_history_index }; line_buffer.move_home(); - line_buffer.kill_line(); - if let Some(s) = context + line_buffer.kill_line(listener); + if let Ok(Some(s)) = context .commandline_context_ref() .history_ref() - .get(curr_history_index) + .get(curr_history_index, SearchDirection::Reverse) { - line_buffer.insert_str(0, s); + line_buffer.insert_str(0, &s.entry, listener); } true } @@ -215,17 +231,17 @@ impl<'a> TuiTextField<'a> { let _ = terminal.hide_cursor(); return None; } - Key::Char('\t') => autocomplete( + Key::Char('\t') => autocomplete_forward( &mut line_buffer, &mut completion_tracker, &completer, - false, + listener, ), - Key::BackTab => autocomplete( + Key::BackTab => autocomplete_backwards( &mut line_buffer, &mut completion_tracker, &completer, - true, + listener, ), // Current `completion_tracker` should be dropped @@ -261,14 +277,14 @@ impl<'a> TuiTextField<'a> { }) } - Key::Ctrl('w') => line_buffer.delete_prev_word(Word::Vi, 1), - Key::Ctrl('u') => line_buffer.discard_line(), - Key::Ctrl('d') => line_buffer.delete(1).is_some(), + Key::Ctrl('w') => line_buffer.delete_prev_word(Word::Vi, 1, listener), + Key::Ctrl('u') => line_buffer.discard_line(listener), + Key::Ctrl('d') => line_buffer.delete(1, listener).is_some(), Key::Char('\n') => { break; } Key::Char(c) => { - let dirty = line_buffer.insert(c, 1).is_some(); + let dirty = line_buffer.insert(c, 1, listener).is_some(); if let Ok(command) = Command::from_str(line_buffer.as_str()) { command.interactive_execute(context) @@ -300,27 +316,71 @@ impl<'a> TuiTextField<'a> { } } -fn autocomplete( +fn autocomplete_forward( line_buffer: &mut LineBuffer, completion_tracker: &mut Option, completer: &FilenameCompleter, - reversed: bool, + listener: &mut DummyListener, ) -> bool { // If we are in the middle of a word, move to the end of it, // so we don't split it with autocompletion. move_to_the_end(line_buffer); if let Some(ref mut ct) = completion_tracker { - ct.index = if reversed { - ct.index.checked_sub(1).unwrap_or(ct.candidates.len() - 1) - } else if ct.index + 1 < ct.candidates.len() { - ct.index + 1 - } else { - ct.index - }; + if ct.index + 1 >= ct.candidates.len() { + return false; + } + ct.index = ct.index + 1; + + let candidate = &ct.candidates[ct.index]; + + let pos = ct.pos; + let first = candidate.display(); + + line_buffer.set_pos(pos); + line_buffer.kill_buffer(listener); + line_buffer.insert_str(pos, &first, listener); + line_buffer.move_end(); + } else if let Some((pos, mut candidates)) = get_candidates(completer, line_buffer) { + if !candidates.is_empty() { + candidates.sort_by(|x, y| { + x.display() + .partial_cmp(y.display()) + .unwrap_or(std::cmp::Ordering::Less) + }); + + let first = candidates[0].display().to_string(); + let mut ct = + CompletionTracker::new(pos, candidates, String::from(line_buffer.as_str())); + ct.index = 0; + + *completion_tracker = Some(ct); + + line_buffer.set_pos(pos); + line_buffer.kill_buffer(listener); + line_buffer.insert_str(pos, &first, listener); + line_buffer.move_end(); + } + } + + false +} + +fn autocomplete_backwards( + line_buffer: &mut LineBuffer, + completion_tracker: &mut Option, + completer: &FilenameCompleter, + listener: &mut DummyListener, +) -> bool { + // If we are in the middle of a word, move to the end of it, + // so we don't split it with autocompletion. + move_to_the_end(line_buffer); + + if let Some(ref mut ct) = completion_tracker { + ct.index = ct.index.checked_sub(1).unwrap_or(ct.candidates.len() - 1); let candidate = &ct.candidates[ct.index]; - completer.update(line_buffer, ct.pos, candidate.display()); + line_buffer.update(candidate.display(), ct.pos, listener); } else if let Some((pos, mut candidates)) = get_candidates(completer, line_buffer) { if !candidates.is_empty() { candidates.sort_by(|x, y| { @@ -329,7 +389,7 @@ fn autocomplete( .unwrap_or(std::cmp::Ordering::Less) }); - let first_idx = if reversed { candidates.len() - 1 } else { 0 }; + let first_idx = candidates.len() - 1; let first = candidates[first_idx].display().to_string(); let mut ct = @@ -337,7 +397,7 @@ fn autocomplete( ct.index = first_idx; *completion_tracker = Some(ct); - completer.update(line_buffer, pos, &first); + line_buffer.update(&first, pos, listener); } } diff --git a/src/ui/widgets/tui_topbar.rs b/src/ui/widgets/tui_topbar.rs index 1f32ace..d98fd31 100644 --- a/src/ui/widgets/tui_topbar.rs +++ b/src/ui/widgets/tui_topbar.rs @@ -32,10 +32,19 @@ impl<'a> Widget for TuiTopBar<'a> { let mut ellipses = None; let mut curr_path_str = self.path.to_string_lossy().into_owned(); - if curr_path_str.width() > area.width as usize { + let num_tabs = self.context.tab_context_ref().len(); + let tab_width = num_tabs * 8; + let name_width = USERNAME.as_str().len() + HOSTNAME.as_str().len() + 2; + + if tab_width + name_width > area.width as usize { + curr_path_str = "".to_owned(); + } else if curr_path_str.width() > area.width as usize - tab_width - name_width { if let Some(s) = self.path.file_name() { let mut short_path = String::new(); - for component in self.path.components() { + let mut components: Vec = self.path.components().collect(); + components.pop(); + + for component in components { match component { Component::RootDir => short_path.push('/'), Component::Normal(s) => { -- cgit v1.2.3