├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── flake.lock ├── flake.nix ├── rmenu └── rmenu └── src ├── app.rs ├── event.rs ├── handler.rs ├── lib.rs ├── main.rs ├── search_engine.rs ├── tui.rs └── ui.rs /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | # Cargo.lock 8 | *perf* 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | 12 | # MSVC Windows builds of rustc generate these, which store debugging information 13 | *.pdb 14 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.22.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "ahash" 22 | version = "0.8.11" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" 25 | dependencies = [ 26 | "cfg-if", 27 | "once_cell", 28 | "version_check", 29 | "zerocopy", 30 | ] 31 | 32 | [[package]] 33 | name = "aho-corasick" 34 | version = "1.1.3" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 37 | dependencies = [ 38 | "memchr", 39 | ] 40 | 41 | [[package]] 42 | name = "allocator-api2" 43 | version = "0.2.18" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" 46 | 47 | [[package]] 48 | name = "anstream" 49 | version = "0.6.14" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" 52 | dependencies = [ 53 | "anstyle", 54 | "anstyle-parse", 55 | "anstyle-query", 56 | "anstyle-wincon", 57 | "colorchoice", 58 | "is_terminal_polyfill", 59 | "utf8parse", 60 | ] 61 | 62 | [[package]] 63 | name = "anstyle" 64 | version = "1.0.7" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" 67 | 68 | [[package]] 69 | name = "anstyle-parse" 70 | version = "0.2.4" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" 73 | dependencies = [ 74 | "utf8parse", 75 | ] 76 | 77 | [[package]] 78 | name = "anstyle-query" 79 | version = "1.1.0" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" 82 | dependencies = [ 83 | "windows-sys 0.52.0", 84 | ] 85 | 86 | [[package]] 87 | name = "anstyle-wincon" 88 | version = "3.0.3" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" 91 | dependencies = [ 92 | "anstyle", 93 | "windows-sys 0.52.0", 94 | ] 95 | 96 | [[package]] 97 | name = "autocfg" 98 | version = "1.3.0" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" 101 | 102 | [[package]] 103 | name = "backtrace" 104 | version = "0.3.73" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" 107 | dependencies = [ 108 | "addr2line", 109 | "cc", 110 | "cfg-if", 111 | "libc", 112 | "miniz_oxide", 113 | "object", 114 | "rustc-demangle", 115 | ] 116 | 117 | [[package]] 118 | name = "bitflags" 119 | version = "2.6.0" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 122 | 123 | [[package]] 124 | name = "bytes" 125 | version = "1.6.1" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" 128 | 129 | [[package]] 130 | name = "cassowary" 131 | version = "0.3.0" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" 134 | 135 | [[package]] 136 | name = "castaway" 137 | version = "0.2.3" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5" 140 | dependencies = [ 141 | "rustversion", 142 | ] 143 | 144 | [[package]] 145 | name = "cc" 146 | version = "1.1.6" 147 | source = "registry+https://github.com/rust-lang/crates.io-index" 148 | checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" 149 | 150 | [[package]] 151 | name = "cfg-if" 152 | version = "1.0.0" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 155 | 156 | [[package]] 157 | name = "clap" 158 | version = "4.5.10" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "8f6b81fb3c84f5563d509c59b5a48d935f689e993afa90fe39047f05adef9142" 161 | dependencies = [ 162 | "clap_builder", 163 | ] 164 | 165 | [[package]] 166 | name = "clap_builder" 167 | version = "4.5.10" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "5ca6706fd5224857d9ac5eb9355f6683563cc0541c7cd9d014043b57cbec78ac" 170 | dependencies = [ 171 | "anstream", 172 | "anstyle", 173 | "clap_lex", 174 | "strsim", 175 | ] 176 | 177 | [[package]] 178 | name = "clap_lex" 179 | version = "0.7.1" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" 182 | 183 | [[package]] 184 | name = "colorchoice" 185 | version = "1.0.1" 186 | source = "registry+https://github.com/rust-lang/crates.io-index" 187 | checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" 188 | 189 | [[package]] 190 | name = "compact_str" 191 | version = "0.7.1" 192 | source = "registry+https://github.com/rust-lang/crates.io-index" 193 | checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" 194 | dependencies = [ 195 | "castaway", 196 | "cfg-if", 197 | "itoa", 198 | "ryu", 199 | "static_assertions", 200 | ] 201 | 202 | [[package]] 203 | name = "crossbeam" 204 | version = "0.8.4" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" 207 | dependencies = [ 208 | "crossbeam-channel", 209 | "crossbeam-deque", 210 | "crossbeam-epoch", 211 | "crossbeam-queue", 212 | "crossbeam-utils", 213 | ] 214 | 215 | [[package]] 216 | name = "crossbeam-channel" 217 | version = "0.5.13" 218 | source = "registry+https://github.com/rust-lang/crates.io-index" 219 | checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" 220 | dependencies = [ 221 | "crossbeam-utils", 222 | ] 223 | 224 | [[package]] 225 | name = "crossbeam-deque" 226 | version = "0.8.5" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" 229 | dependencies = [ 230 | "crossbeam-epoch", 231 | "crossbeam-utils", 232 | ] 233 | 234 | [[package]] 235 | name = "crossbeam-epoch" 236 | version = "0.9.18" 237 | source = "registry+https://github.com/rust-lang/crates.io-index" 238 | checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 239 | dependencies = [ 240 | "crossbeam-utils", 241 | ] 242 | 243 | [[package]] 244 | name = "crossbeam-queue" 245 | version = "0.3.11" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" 248 | dependencies = [ 249 | "crossbeam-utils", 250 | ] 251 | 252 | [[package]] 253 | name = "crossbeam-utils" 254 | version = "0.8.20" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" 257 | 258 | [[package]] 259 | name = "crossterm" 260 | version = "0.27.0" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" 263 | dependencies = [ 264 | "bitflags", 265 | "crossterm_winapi", 266 | "futures-core", 267 | "libc", 268 | "mio 0.8.11", 269 | "parking_lot", 270 | "signal-hook", 271 | "signal-hook-mio", 272 | "winapi", 273 | ] 274 | 275 | [[package]] 276 | name = "crossterm_winapi" 277 | version = "0.9.1" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" 280 | dependencies = [ 281 | "winapi", 282 | ] 283 | 284 | [[package]] 285 | name = "either" 286 | version = "1.13.0" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" 289 | 290 | [[package]] 291 | name = "futures" 292 | version = "0.3.30" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" 295 | dependencies = [ 296 | "futures-channel", 297 | "futures-core", 298 | "futures-executor", 299 | "futures-io", 300 | "futures-sink", 301 | "futures-task", 302 | "futures-util", 303 | ] 304 | 305 | [[package]] 306 | name = "futures-channel" 307 | version = "0.3.30" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 310 | dependencies = [ 311 | "futures-core", 312 | "futures-sink", 313 | ] 314 | 315 | [[package]] 316 | name = "futures-core" 317 | version = "0.3.30" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 320 | 321 | [[package]] 322 | name = "futures-executor" 323 | version = "0.3.30" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" 326 | dependencies = [ 327 | "futures-core", 328 | "futures-task", 329 | "futures-util", 330 | ] 331 | 332 | [[package]] 333 | name = "futures-io" 334 | version = "0.3.30" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 337 | 338 | [[package]] 339 | name = "futures-macro" 340 | version = "0.3.30" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" 343 | dependencies = [ 344 | "proc-macro2", 345 | "quote", 346 | "syn", 347 | ] 348 | 349 | [[package]] 350 | name = "futures-sink" 351 | version = "0.3.30" 352 | source = "registry+https://github.com/rust-lang/crates.io-index" 353 | checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" 354 | 355 | [[package]] 356 | name = "futures-task" 357 | version = "0.3.30" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" 360 | 361 | [[package]] 362 | name = "futures-util" 363 | version = "0.3.30" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" 366 | dependencies = [ 367 | "futures-channel", 368 | "futures-core", 369 | "futures-io", 370 | "futures-macro", 371 | "futures-sink", 372 | "futures-task", 373 | "memchr", 374 | "pin-project-lite", 375 | "pin-utils", 376 | "slab", 377 | ] 378 | 379 | [[package]] 380 | name = "gimli" 381 | version = "0.29.0" 382 | source = "registry+https://github.com/rust-lang/crates.io-index" 383 | checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" 384 | 385 | [[package]] 386 | name = "hashbrown" 387 | version = "0.14.5" 388 | source = "registry+https://github.com/rust-lang/crates.io-index" 389 | checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" 390 | dependencies = [ 391 | "ahash", 392 | "allocator-api2", 393 | ] 394 | 395 | [[package]] 396 | name = "heck" 397 | version = "0.5.0" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 400 | 401 | [[package]] 402 | name = "hermit-abi" 403 | version = "0.3.9" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" 406 | 407 | [[package]] 408 | name = "is_terminal_polyfill" 409 | version = "1.70.0" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" 412 | 413 | [[package]] 414 | name = "itertools" 415 | version = "0.13.0" 416 | source = "registry+https://github.com/rust-lang/crates.io-index" 417 | checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" 418 | dependencies = [ 419 | "either", 420 | ] 421 | 422 | [[package]] 423 | name = "itoa" 424 | version = "1.0.11" 425 | source = "registry+https://github.com/rust-lang/crates.io-index" 426 | checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" 427 | 428 | [[package]] 429 | name = "jwalk" 430 | version = "0.8.1" 431 | source = "registry+https://github.com/rust-lang/crates.io-index" 432 | checksum = "2735847566356cd2179a2a38264839308f7079fa96e6bd5a42d740460e003c56" 433 | dependencies = [ 434 | "crossbeam", 435 | "rayon", 436 | ] 437 | 438 | [[package]] 439 | name = "libc" 440 | version = "0.2.155" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" 443 | 444 | [[package]] 445 | name = "lock_api" 446 | version = "0.4.12" 447 | source = "registry+https://github.com/rust-lang/crates.io-index" 448 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" 449 | dependencies = [ 450 | "autocfg", 451 | "scopeguard", 452 | ] 453 | 454 | [[package]] 455 | name = "log" 456 | version = "0.4.22" 457 | source = "registry+https://github.com/rust-lang/crates.io-index" 458 | checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" 459 | 460 | [[package]] 461 | name = "lru" 462 | version = "0.12.3" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" 465 | dependencies = [ 466 | "hashbrown", 467 | ] 468 | 469 | [[package]] 470 | name = "memchr" 471 | version = "2.7.4" 472 | source = "registry+https://github.com/rust-lang/crates.io-index" 473 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 474 | 475 | [[package]] 476 | name = "miniz_oxide" 477 | version = "0.7.4" 478 | source = "registry+https://github.com/rust-lang/crates.io-index" 479 | checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" 480 | dependencies = [ 481 | "adler", 482 | ] 483 | 484 | [[package]] 485 | name = "mio" 486 | version = "0.8.11" 487 | source = "registry+https://github.com/rust-lang/crates.io-index" 488 | checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" 489 | dependencies = [ 490 | "libc", 491 | "log", 492 | "wasi", 493 | "windows-sys 0.48.0", 494 | ] 495 | 496 | [[package]] 497 | name = "mio" 498 | version = "1.0.1" 499 | source = "registry+https://github.com/rust-lang/crates.io-index" 500 | checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" 501 | dependencies = [ 502 | "hermit-abi", 503 | "libc", 504 | "wasi", 505 | "windows-sys 0.52.0", 506 | ] 507 | 508 | [[package]] 509 | name = "nucleo" 510 | version = "0.3.0" 511 | source = "registry+https://github.com/rust-lang/crates.io-index" 512 | checksum = "d9c28316df514918915799651c5a1cc8f1dd33a9294e1cc22f27fd19453fd62c" 513 | dependencies = [ 514 | "nucleo-matcher", 515 | "parking_lot", 516 | "rayon", 517 | ] 518 | 519 | [[package]] 520 | name = "nucleo-matcher" 521 | version = "0.3.1" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "bf33f538733d1a5a3494b836ba913207f14d9d4a1d3cd67030c5061bdd2cac85" 524 | dependencies = [ 525 | "memchr", 526 | "unicode-segmentation", 527 | ] 528 | 529 | [[package]] 530 | name = "object" 531 | version = "0.36.2" 532 | source = "registry+https://github.com/rust-lang/crates.io-index" 533 | checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" 534 | dependencies = [ 535 | "memchr", 536 | ] 537 | 538 | [[package]] 539 | name = "once_cell" 540 | version = "1.19.0" 541 | source = "registry+https://github.com/rust-lang/crates.io-index" 542 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 543 | 544 | [[package]] 545 | name = "parking_lot" 546 | version = "0.12.3" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" 549 | dependencies = [ 550 | "lock_api", 551 | "parking_lot_core", 552 | ] 553 | 554 | [[package]] 555 | name = "parking_lot_core" 556 | version = "0.9.10" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" 559 | dependencies = [ 560 | "cfg-if", 561 | "libc", 562 | "redox_syscall", 563 | "smallvec", 564 | "windows-targets 0.52.6", 565 | ] 566 | 567 | [[package]] 568 | name = "paste" 569 | version = "1.0.15" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 572 | 573 | [[package]] 574 | name = "pin-project-lite" 575 | version = "0.2.14" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" 578 | 579 | [[package]] 580 | name = "pin-utils" 581 | version = "0.1.0" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 584 | 585 | [[package]] 586 | name = "proc-macro2" 587 | version = "1.0.86" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" 590 | dependencies = [ 591 | "unicode-ident", 592 | ] 593 | 594 | [[package]] 595 | name = "quote" 596 | version = "1.0.36" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" 599 | dependencies = [ 600 | "proc-macro2", 601 | ] 602 | 603 | [[package]] 604 | name = "ratatui" 605 | version = "0.27.0" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "d16546c5b5962abf8ce6e2881e722b4e0ae3b6f1a08a26ae3573c55853ca68d3" 608 | dependencies = [ 609 | "bitflags", 610 | "cassowary", 611 | "compact_str", 612 | "crossterm", 613 | "itertools", 614 | "lru", 615 | "paste", 616 | "stability", 617 | "strum", 618 | "strum_macros", 619 | "unicode-segmentation", 620 | "unicode-truncate", 621 | "unicode-width", 622 | ] 623 | 624 | [[package]] 625 | name = "rayon" 626 | version = "1.10.0" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" 629 | dependencies = [ 630 | "either", 631 | "rayon-core", 632 | ] 633 | 634 | [[package]] 635 | name = "rayon-core" 636 | version = "1.12.1" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" 639 | dependencies = [ 640 | "crossbeam-deque", 641 | "crossbeam-utils", 642 | ] 643 | 644 | [[package]] 645 | name = "redox_syscall" 646 | version = "0.5.3" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" 649 | dependencies = [ 650 | "bitflags", 651 | ] 652 | 653 | [[package]] 654 | name = "regex" 655 | version = "1.10.5" 656 | source = "registry+https://github.com/rust-lang/crates.io-index" 657 | checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" 658 | dependencies = [ 659 | "aho-corasick", 660 | "memchr", 661 | "regex-automata", 662 | "regex-syntax", 663 | ] 664 | 665 | [[package]] 666 | name = "regex-automata" 667 | version = "0.4.7" 668 | source = "registry+https://github.com/rust-lang/crates.io-index" 669 | checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" 670 | dependencies = [ 671 | "aho-corasick", 672 | "memchr", 673 | "regex-syntax", 674 | ] 675 | 676 | [[package]] 677 | name = "regex-syntax" 678 | version = "0.8.4" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" 681 | 682 | [[package]] 683 | name = "rfz" 684 | version = "0.0.3" 685 | dependencies = [ 686 | "clap", 687 | "crossterm", 688 | "futures", 689 | "futures-util", 690 | "jwalk", 691 | "nucleo", 692 | "ratatui", 693 | "rayon", 694 | "tokio", 695 | "tui-textarea", 696 | ] 697 | 698 | [[package]] 699 | name = "rustc-demangle" 700 | version = "0.1.24" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" 703 | 704 | [[package]] 705 | name = "rustversion" 706 | version = "1.0.17" 707 | source = "registry+https://github.com/rust-lang/crates.io-index" 708 | checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" 709 | 710 | [[package]] 711 | name = "ryu" 712 | version = "1.0.18" 713 | source = "registry+https://github.com/rust-lang/crates.io-index" 714 | checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" 715 | 716 | [[package]] 717 | name = "scopeguard" 718 | version = "1.2.0" 719 | source = "registry+https://github.com/rust-lang/crates.io-index" 720 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 721 | 722 | [[package]] 723 | name = "signal-hook" 724 | version = "0.3.17" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" 727 | dependencies = [ 728 | "libc", 729 | "signal-hook-registry", 730 | ] 731 | 732 | [[package]] 733 | name = "signal-hook-mio" 734 | version = "0.2.3" 735 | source = "registry+https://github.com/rust-lang/crates.io-index" 736 | checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" 737 | dependencies = [ 738 | "libc", 739 | "mio 0.8.11", 740 | "signal-hook", 741 | ] 742 | 743 | [[package]] 744 | name = "signal-hook-registry" 745 | version = "1.4.2" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" 748 | dependencies = [ 749 | "libc", 750 | ] 751 | 752 | [[package]] 753 | name = "slab" 754 | version = "0.4.9" 755 | source = "registry+https://github.com/rust-lang/crates.io-index" 756 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 757 | dependencies = [ 758 | "autocfg", 759 | ] 760 | 761 | [[package]] 762 | name = "smallvec" 763 | version = "1.13.2" 764 | source = "registry+https://github.com/rust-lang/crates.io-index" 765 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 766 | 767 | [[package]] 768 | name = "socket2" 769 | version = "0.5.7" 770 | source = "registry+https://github.com/rust-lang/crates.io-index" 771 | checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" 772 | dependencies = [ 773 | "libc", 774 | "windows-sys 0.52.0", 775 | ] 776 | 777 | [[package]] 778 | name = "stability" 779 | version = "0.2.1" 780 | source = "registry+https://github.com/rust-lang/crates.io-index" 781 | checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" 782 | dependencies = [ 783 | "quote", 784 | "syn", 785 | ] 786 | 787 | [[package]] 788 | name = "static_assertions" 789 | version = "1.1.0" 790 | source = "registry+https://github.com/rust-lang/crates.io-index" 791 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 792 | 793 | [[package]] 794 | name = "strsim" 795 | version = "0.11.1" 796 | source = "registry+https://github.com/rust-lang/crates.io-index" 797 | checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 798 | 799 | [[package]] 800 | name = "strum" 801 | version = "0.26.3" 802 | source = "registry+https://github.com/rust-lang/crates.io-index" 803 | checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" 804 | dependencies = [ 805 | "strum_macros", 806 | ] 807 | 808 | [[package]] 809 | name = "strum_macros" 810 | version = "0.26.4" 811 | source = "registry+https://github.com/rust-lang/crates.io-index" 812 | checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" 813 | dependencies = [ 814 | "heck", 815 | "proc-macro2", 816 | "quote", 817 | "rustversion", 818 | "syn", 819 | ] 820 | 821 | [[package]] 822 | name = "syn" 823 | version = "2.0.72" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" 826 | dependencies = [ 827 | "proc-macro2", 828 | "quote", 829 | "unicode-ident", 830 | ] 831 | 832 | [[package]] 833 | name = "tokio" 834 | version = "1.39.1" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" 837 | dependencies = [ 838 | "backtrace", 839 | "bytes", 840 | "libc", 841 | "mio 1.0.1", 842 | "parking_lot", 843 | "pin-project-lite", 844 | "signal-hook-registry", 845 | "socket2", 846 | "tokio-macros", 847 | "windows-sys 0.52.0", 848 | ] 849 | 850 | [[package]] 851 | name = "tokio-macros" 852 | version = "2.4.0" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" 855 | dependencies = [ 856 | "proc-macro2", 857 | "quote", 858 | "syn", 859 | ] 860 | 861 | [[package]] 862 | name = "tui-textarea" 863 | version = "0.4.0" 864 | source = "registry+https://github.com/rust-lang/crates.io-index" 865 | checksum = "a3e38ced1f941a9cfc923fbf2fe6858443c42cc5220bfd35bdd3648371e7bd8e" 866 | dependencies = [ 867 | "crossterm", 868 | "ratatui", 869 | "regex", 870 | "unicode-width", 871 | ] 872 | 873 | [[package]] 874 | name = "unicode-ident" 875 | version = "1.0.12" 876 | source = "registry+https://github.com/rust-lang/crates.io-index" 877 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 878 | 879 | [[package]] 880 | name = "unicode-segmentation" 881 | version = "1.11.0" 882 | source = "registry+https://github.com/rust-lang/crates.io-index" 883 | checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" 884 | 885 | [[package]] 886 | name = "unicode-truncate" 887 | version = "1.1.0" 888 | source = "registry+https://github.com/rust-lang/crates.io-index" 889 | checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" 890 | dependencies = [ 891 | "itertools", 892 | "unicode-segmentation", 893 | "unicode-width", 894 | ] 895 | 896 | [[package]] 897 | name = "unicode-width" 898 | version = "0.1.13" 899 | source = "registry+https://github.com/rust-lang/crates.io-index" 900 | checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" 901 | 902 | [[package]] 903 | name = "utf8parse" 904 | version = "0.2.2" 905 | source = "registry+https://github.com/rust-lang/crates.io-index" 906 | checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" 907 | 908 | [[package]] 909 | name = "version_check" 910 | version = "0.9.4" 911 | source = "registry+https://github.com/rust-lang/crates.io-index" 912 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 913 | 914 | [[package]] 915 | name = "wasi" 916 | version = "0.11.0+wasi-snapshot-preview1" 917 | source = "registry+https://github.com/rust-lang/crates.io-index" 918 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 919 | 920 | [[package]] 921 | name = "winapi" 922 | version = "0.3.9" 923 | source = "registry+https://github.com/rust-lang/crates.io-index" 924 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 925 | dependencies = [ 926 | "winapi-i686-pc-windows-gnu", 927 | "winapi-x86_64-pc-windows-gnu", 928 | ] 929 | 930 | [[package]] 931 | name = "winapi-i686-pc-windows-gnu" 932 | version = "0.4.0" 933 | source = "registry+https://github.com/rust-lang/crates.io-index" 934 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 935 | 936 | [[package]] 937 | name = "winapi-x86_64-pc-windows-gnu" 938 | version = "0.4.0" 939 | source = "registry+https://github.com/rust-lang/crates.io-index" 940 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 941 | 942 | [[package]] 943 | name = "windows-sys" 944 | version = "0.48.0" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 947 | dependencies = [ 948 | "windows-targets 0.48.5", 949 | ] 950 | 951 | [[package]] 952 | name = "windows-sys" 953 | version = "0.52.0" 954 | source = "registry+https://github.com/rust-lang/crates.io-index" 955 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 956 | dependencies = [ 957 | "windows-targets 0.52.6", 958 | ] 959 | 960 | [[package]] 961 | name = "windows-targets" 962 | version = "0.48.5" 963 | source = "registry+https://github.com/rust-lang/crates.io-index" 964 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 965 | dependencies = [ 966 | "windows_aarch64_gnullvm 0.48.5", 967 | "windows_aarch64_msvc 0.48.5", 968 | "windows_i686_gnu 0.48.5", 969 | "windows_i686_msvc 0.48.5", 970 | "windows_x86_64_gnu 0.48.5", 971 | "windows_x86_64_gnullvm 0.48.5", 972 | "windows_x86_64_msvc 0.48.5", 973 | ] 974 | 975 | [[package]] 976 | name = "windows-targets" 977 | version = "0.52.6" 978 | source = "registry+https://github.com/rust-lang/crates.io-index" 979 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 980 | dependencies = [ 981 | "windows_aarch64_gnullvm 0.52.6", 982 | "windows_aarch64_msvc 0.52.6", 983 | "windows_i686_gnu 0.52.6", 984 | "windows_i686_gnullvm", 985 | "windows_i686_msvc 0.52.6", 986 | "windows_x86_64_gnu 0.52.6", 987 | "windows_x86_64_gnullvm 0.52.6", 988 | "windows_x86_64_msvc 0.52.6", 989 | ] 990 | 991 | [[package]] 992 | name = "windows_aarch64_gnullvm" 993 | version = "0.48.5" 994 | source = "registry+https://github.com/rust-lang/crates.io-index" 995 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 996 | 997 | [[package]] 998 | name = "windows_aarch64_gnullvm" 999 | version = "0.52.6" 1000 | source = "registry+https://github.com/rust-lang/crates.io-index" 1001 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1002 | 1003 | [[package]] 1004 | name = "windows_aarch64_msvc" 1005 | version = "0.48.5" 1006 | source = "registry+https://github.com/rust-lang/crates.io-index" 1007 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1008 | 1009 | [[package]] 1010 | name = "windows_aarch64_msvc" 1011 | version = "0.52.6" 1012 | source = "registry+https://github.com/rust-lang/crates.io-index" 1013 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1014 | 1015 | [[package]] 1016 | name = "windows_i686_gnu" 1017 | version = "0.48.5" 1018 | source = "registry+https://github.com/rust-lang/crates.io-index" 1019 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1020 | 1021 | [[package]] 1022 | name = "windows_i686_gnu" 1023 | version = "0.52.6" 1024 | source = "registry+https://github.com/rust-lang/crates.io-index" 1025 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1026 | 1027 | [[package]] 1028 | name = "windows_i686_gnullvm" 1029 | version = "0.52.6" 1030 | source = "registry+https://github.com/rust-lang/crates.io-index" 1031 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1032 | 1033 | [[package]] 1034 | name = "windows_i686_msvc" 1035 | version = "0.48.5" 1036 | source = "registry+https://github.com/rust-lang/crates.io-index" 1037 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1038 | 1039 | [[package]] 1040 | name = "windows_i686_msvc" 1041 | version = "0.52.6" 1042 | source = "registry+https://github.com/rust-lang/crates.io-index" 1043 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1044 | 1045 | [[package]] 1046 | name = "windows_x86_64_gnu" 1047 | version = "0.48.5" 1048 | source = "registry+https://github.com/rust-lang/crates.io-index" 1049 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1050 | 1051 | [[package]] 1052 | name = "windows_x86_64_gnu" 1053 | version = "0.52.6" 1054 | source = "registry+https://github.com/rust-lang/crates.io-index" 1055 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1056 | 1057 | [[package]] 1058 | name = "windows_x86_64_gnullvm" 1059 | version = "0.48.5" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1062 | 1063 | [[package]] 1064 | name = "windows_x86_64_gnullvm" 1065 | version = "0.52.6" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1068 | 1069 | [[package]] 1070 | name = "windows_x86_64_msvc" 1071 | version = "0.48.5" 1072 | source = "registry+https://github.com/rust-lang/crates.io-index" 1073 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1074 | 1075 | [[package]] 1076 | name = "windows_x86_64_msvc" 1077 | version = "0.52.6" 1078 | source = "registry+https://github.com/rust-lang/crates.io-index" 1079 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1080 | 1081 | [[package]] 1082 | name = "zerocopy" 1083 | version = "0.7.35" 1084 | source = "registry+https://github.com/rust-lang/crates.io-index" 1085 | checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" 1086 | dependencies = [ 1087 | "zerocopy-derive", 1088 | ] 1089 | 1090 | [[package]] 1091 | name = "zerocopy-derive" 1092 | version = "0.7.35" 1093 | source = "registry+https://github.com/rust-lang/crates.io-index" 1094 | checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" 1095 | dependencies = [ 1096 | "proc-macro2", 1097 | "quote", 1098 | "syn", 1099 | ] 1100 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [profile.release] 2 | lto = "fat" 3 | [build] 4 | rustflags = ["-Z", "threads=8","-C", "link-arg=-fuse-ld=lld","-C", "target-cpu=native" ] 5 | [package] 6 | name = "rfz" 7 | version = "0.0.6" 8 | authors = ["fede "] 9 | license = "MIT" 10 | edition = "2021" 11 | 12 | [dependencies] 13 | crossterm = { version = "0.27.0", features = ["event-stream"] } 14 | futures = "0.3.30" 15 | tokio = {version="1.35.1",features=["full"]} 16 | ratatui = "0.27.0" 17 | nucleo = "0.3.0" 18 | rayon = "1.8.1" 19 | clap = {version = "4.5.2", features = ["cargo"]} 20 | futures-util = "0.3.30" 21 | jwalk = "0.8.1" 22 | tui-textarea = { version = "0.4.0", features = ["search"] } 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rfz 2 | Kinda fzf but in Rust using the [Nucleo](https://github.com/helix-editor/nucleo) crate and other tomfooleries 3 | 4 | ## QA 5 | 6 | > Why it's better than using fzf? 7 | 8 | Simple, Nucleo is way faster than fzf and skim (at least on my machine, will provide benches as soon as possible). 9 | > All my homies hate find 10 | 11 | So we use [jwalk](https://docs.rs/jwalk/latest/jwalk/) to parallelize the search of the possible paths and cut the wait time (more time to touch grass) 12 | 13 | > Now with 100% of stdin more 14 | 15 | We implemented a fast way to get stdin 16 | 17 | > Why there isn't "insert stuff here" that fzf/skim/two_percent has? 18 | 19 | There are 2 good reason: 20 | 1) They are actually good developer (we are not) and have years of experience 21 | 2) K.I.S.S. 22 | 23 | ## Options: 24 | 25 | - `-f, --file `: Search files from the given PATH. 26 | - `-d, --directory `: Search directories from the given PATH. 27 | - `-w, --working-dir `: Search directories and files from the given PATH. 28 | - `-h, --help`: Print help. 29 | - `-V, --version`: Print version. 30 | 31 | ## Example Usage: 32 | - `File mode` 33 | 34 | ![rfz-filemode-2024-03-11_16 47 55](https://github.com/MangoTzara/rfz/assets/71153363/ae9b3944-3fe7-4a9a-b641-327c0510aa52) 35 | 36 | 37 | - `Directory mode` 38 | 39 | ![rfz-directorymode-2024-03-11_16 51 04](https://github.com/MangoTzara/rfz/assets/71153363/0974f1f8-d7f4-4224-8e52-2bb671594ec4) 40 | 41 | 42 | # rmenu 43 | Uses rfz as a [dmenu_run](https://manpages.debian.org/stretch/suckless-tools/dmenu_run.1.en.html) alternative 44 | 45 | ![rmenu-2024-03-10_20 05 46](https://github.com/MangoTzara/rfz/assets/71153363/c3031efb-c8e6-4af9-8fdb-3499162082e2) 46 | 47 | ### Default mappings (could change soon) 48 | 49 | Default key mappings are as follows: 50 | 51 | | Mappings | Description | 52 | |----------------------------------------------|-------------------------------------------| 53 | | `Ctrl+H`, `Backspace` | Delete one character before cursor | 54 | | `Ctrl+D`, `Delete` | Delete one character next to cursor | 55 | | `Ctrl+M`, `Enter` | Insert newline | 56 | | `Ctrl+K` | Delete from cursor until the end of line | 57 | | `Ctrl+J` | Delete from cursor until the head of line | 58 | | `Ctrl+W`, `Alt+H`, `Alt+Backspace` | Delete one word before cursor | 59 | | `Alt+D`, `Alt+Delete` | Delete one word next to cursor | 60 | | `Ctrl+U` | Undo | 61 | | `Ctrl+R` | Redo | 62 | | `Ctrl+C`, `Copy` | Copy selected text | 63 | | `Ctrl+X`, `Cut` | Cut selected text | 64 | | `Ctrl+Y`, `Paste` | Paste yanked text | 65 | | `Ctrl+F`, `→` | Move cursor forward by one character | 66 | | `Ctrl+B`, `←` | Move cursor backward by one character | 67 | | `Ctrl+P`, `↑` | Move cursor up by one line | 68 | | `Ctrl+N`, `↓` | Move cursor down by one line | 69 | | `Alt+F`, `Ctrl+→` | Move cursor forward by word | 70 | | `Atl+B`, `Ctrl+←` | Move cursor backward by word | 71 | | `Alt+]`, `Alt+P`, `Ctrl+↑` | Move cursor up by paragraph | 72 | | `Alt+[`, `Alt+N`, `Ctrl+↓` | Move cursor down by paragraph | 73 | | `Ctrl+E`, `End`, `Ctrl+Alt+F`, `Ctrl+Alt+→` | Move cursor to the end of line | 74 | | `Ctrl+A`, `Home`, `Ctrl+Alt+B`, `Ctrl+Alt+←` | Move cursor to the head of line | 75 | | `Alt+<`, `Ctrl+Alt+P`, `Ctrl+Alt+↑` | Move cursor to top of lines | 76 | | `Alt+>`, `Ctrl+Alt+N`, `Ctrl+Alt+↓` | Move cursor to bottom of lines | 77 | | `Ctrl+V`, `PageDown` | Scroll down by page | 78 | | `Alt+V`, `PageUp` | Scroll up by page | 79 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-utils": { 4 | "inputs": { 5 | "systems": "systems" 6 | }, 7 | "locked": { 8 | "lastModified": 1710146030, 9 | "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", 10 | "owner": "numtide", 11 | "repo": "flake-utils", 12 | "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", 13 | "type": "github" 14 | }, 15 | "original": { 16 | "owner": "numtide", 17 | "repo": "flake-utils", 18 | "type": "github" 19 | } 20 | }, 21 | "nixpkgs": { 22 | "locked": { 23 | "lastModified": 1721562059, 24 | "narHash": "sha256-Tybxt65eyOARf285hMHIJ2uul8SULjFZbT9ZaEeUnP8=", 25 | "owner": "nixos", 26 | "repo": "nixpkgs", 27 | "rev": "68c9ed8bbed9dfce253cc91560bf9043297ef2fe", 28 | "type": "github" 29 | }, 30 | "original": { 31 | "owner": "nixos", 32 | "ref": "nixos-unstable", 33 | "repo": "nixpkgs", 34 | "type": "github" 35 | } 36 | }, 37 | "root": { 38 | "inputs": { 39 | "flake-utils": "flake-utils", 40 | "nixpkgs": "nixpkgs" 41 | } 42 | }, 43 | "systems": { 44 | "locked": { 45 | "lastModified": 1681028828, 46 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 47 | "owner": "nix-systems", 48 | "repo": "default", 49 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 50 | "type": "github" 51 | }, 52 | "original": { 53 | "owner": "nix-systems", 54 | "repo": "default", 55 | "type": "github" 56 | } 57 | } 58 | }, 59 | "root": "root", 60 | "version": 7 61 | } 62 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "A Rust implementation of fzf using the Nucleo crate"; 3 | 4 | inputs = { 5 | nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; 6 | flake-utils.url = "github:numtide/flake-utils"; 7 | }; 8 | 9 | outputs = { self, nixpkgs, flake-utils }: 10 | let version = "0.0.6"; in 11 | flake-utils.lib.eachDefaultSystem (system: 12 | with import nixpkgs { system = system; }; 13 | rec { 14 | packages = { 15 | default = rustPlatform.buildRustPackage { 16 | pname = "rfz"; 17 | version = version; 18 | src = ./.; 19 | # cargoBuildFlags = "-p app"; 20 | cargoLock = { 21 | lockFile = ./Cargo.lock; 22 | }; 23 | nativeBuildInputs = [ pkg-config ]; 24 | PKG_CONFIG_PATH = "${openssl.dev}/lib/pkgconfig"; 25 | }; 26 | }; 27 | devShells = { 28 | default = mkShell { 29 | name = "rfz-dev"; 30 | 31 | packages = [ 32 | cargo 33 | clippy 34 | rustc 35 | ]; 36 | }; 37 | }; 38 | apps = { 39 | default = { 40 | type = "app"; 41 | program = "${packages.default}/bin/rfz"; 42 | }; 43 | }; 44 | } 45 | ); 46 | } 47 | -------------------------------------------------------------------------------- /rmenu/rmenu: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Create a temporary file 4 | temp_file=$(mktemp) 5 | 6 | # Run the command and write its output to the temporary file 7 | rfz -w /usr/bin > "$temp_file" 8 | 9 | # Read the output command from the temporary file and execute it in the background 10 | output=$(cat "$temp_file") 11 | setsid sh -c "$output" >/dev/null 2>&1 < /dev/null & 12 | 13 | # Clean up the temporary file 14 | rm "$temp_file" 15 | -------------------------------------------------------------------------------- /src/app.rs: -------------------------------------------------------------------------------- 1 | use crate::search_engine::SearchEngine; 2 | use crossterm::event::KeyEvent; 3 | use nucleo::{Config, Matcher, Utf32String}; 4 | use ratatui::{ 5 | style::Style, 6 | widgets::{Block, Borders, ListState, Widget}, 7 | }; 8 | use std::error; 9 | use tui_textarea::TextArea; 10 | /// Application result type. 11 | pub type AppResult = std::result::Result>; 12 | 13 | /// Application. 14 | pub struct App<'a> { 15 | /// Is the application running? 16 | pub running: bool, 17 | list_state: ListState, 18 | top: u32, 19 | matcher: SearchEngine, 20 | text_area: TextArea<'a>, 21 | } 22 | 23 | impl<'a> Default for App<'a> { 24 | fn default() -> Self { 25 | let mut text_area = TextArea::default(); 26 | 27 | text_area.set_style(Style::default()); 28 | text_area.set_block(Block::default().borders(Borders::ALL).title(">")); 29 | 30 | Self::new( 31 | ListState::default().with_selected(Some(0)), 32 | 1000, 33 | SearchEngine::default(), 34 | text_area, 35 | ) 36 | } 37 | } 38 | 39 | impl<'a> App<'a> { 40 | // Constructs a new instance of [`App`]. 41 | pub fn new( 42 | list_state: ListState, 43 | top: u32, 44 | matcher: SearchEngine, 45 | text_area: TextArea<'a>, 46 | ) -> App<'a> { 47 | Self { 48 | running: true, 49 | list_state, 50 | top, 51 | matcher, 52 | text_area, 53 | } 54 | } 55 | 56 | /// Handles the tick event of the terminal. 57 | pub fn tick(&mut self) { 58 | self.matcher.tick(10); 59 | } 60 | 61 | /// Set running to false to quit the application. 62 | /// * `esc` - Boolean representing if the application exit shouldn't print the selected value 63 | pub fn quit(&mut self, esc: bool) { 64 | if esc { 65 | self.list_state.select(None); 66 | } 67 | self.running = false; 68 | } 69 | pub fn get_matched_items(&self) -> u32 { 70 | self.snapshot().matched_item_count() 71 | } 72 | pub fn get_total_items(&self) -> u32 { 73 | self.snapshot().item_count() 74 | } 75 | 76 | pub fn get_list_state(&mut self) -> &mut ListState { 77 | &mut self.list_state 78 | } 79 | 80 | pub fn increment_counter(&mut self) { 81 | match self.list_state.selected() { 82 | Some(c) => { 83 | self.list_state.select(Some(c + 1)); 84 | if c + 100 > self.top as usize { 85 | self.top += 100; 86 | } 87 | } 88 | None => self.list_state.select(Some(0)), 89 | }; 90 | } 91 | 92 | pub fn decrement_counter(&mut self) { 93 | self.list_state 94 | .select(self.list_state.selected().unwrap_or(0).checked_sub(1)); 95 | } 96 | 97 | pub fn selected(&self) -> Option<&String> { 98 | match self.list_state.selected() { 99 | Some(selected) => Some( 100 | self.matcher 101 | .snapshot() 102 | .get_matched_item(selected.try_into().unwrap()) 103 | .unwrap() 104 | .data, 105 | ), 106 | None => None, 107 | } 108 | } 109 | 110 | pub fn paste(&mut self, to_paste: &str) { 111 | self.text_area.insert_str(to_paste); 112 | self.reparse(); 113 | self.matcher.tick(10); 114 | self.list_state.select(Some(0)); 115 | } 116 | 117 | pub fn update_query(&mut self, query: KeyEvent) { 118 | self.text_area.input(query); 119 | self.reparse(); 120 | self.matcher.tick(10); 121 | self.list_state.select(Some(0)); 122 | } 123 | 124 | fn reparse(&mut self) { 125 | let lines = self.text_area.lines(); 126 | self.matcher.reparse(match lines.len() { 127 | 1 => &lines[0], 128 | 0 => "", 129 | _ => "", 130 | }) 131 | } 132 | 133 | pub(crate) fn delete(&mut self) { 134 | if self.text_area.delete_char() { 135 | self.reparse(); 136 | self.matcher.tick(10); 137 | self.list_state.select(Some(0)); 138 | }; 139 | } 140 | 141 | pub fn injector(&self) -> nucleo::Injector { 142 | self.matcher.injector() 143 | } 144 | 145 | fn snapshot(&self) -> &nucleo::Snapshot { 146 | self.matcher.snapshot() 147 | } 148 | 149 | pub fn add_item(&mut self, to_push: String) { 150 | self.injector().push(to_push.clone(), |s| { 151 | s[0] = Utf32String::Ascii(to_push.into()); 152 | }); 153 | } 154 | 155 | pub fn get_items_with_indices(&mut self) -> Vec<(String, Vec)> { 156 | let mut vec: Vec<(String, Vec)> = Vec::new(); 157 | 158 | let mut matcher = Matcher::new(Config::DEFAULT); 159 | let matched_items = match self.snapshot().matched_item_count() < self.top { 160 | true => self 161 | .snapshot() 162 | .matched_items(0..self.snapshot().matched_item_count()), 163 | false => self.snapshot().matched_items(0..self.top), 164 | }; 165 | for c in matched_items { 166 | let mut indices: Vec = Vec::new(); 167 | self.snapshot().pattern().column_pattern(0).indices( 168 | c.matcher_columns[0].slice(..), 169 | &mut matcher, 170 | &mut indices, 171 | ); 172 | indices.sort_unstable(); 173 | indices.dedup(); 174 | vec.push((c.data.to_string(), indices)); 175 | } 176 | vec 177 | } 178 | 179 | pub(crate) fn get_state_area(&mut self) -> impl Widget + '_ { 180 | self.text_area.widget() 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /src/event.rs: -------------------------------------------------------------------------------- 1 | use crate::app::AppResult; 2 | use crossterm::event::{Event as CrosstermEvent, KeyEvent, MouseEvent}; 3 | use futures::{FutureExt, StreamExt}; 4 | use std::{process, time::Duration}; 5 | use tokio::sync::mpsc; 6 | 7 | /// Terminal events. 8 | #[derive(Clone, Debug)] 9 | pub enum Event { 10 | /// Terminal tick. 11 | Tick, 12 | /// Key press. 13 | Key(KeyEvent), 14 | /// Mouse click/scroll. 15 | Mouse(MouseEvent), 16 | /// Terminal resize. 17 | Resize(u16, u16), 18 | Paste(String), 19 | } 20 | 21 | /// Terminal event handler. 22 | #[allow(dead_code)] 23 | #[derive(Debug)] 24 | pub struct EventHandler { 25 | /// Event sender channel. 26 | sender: mpsc::UnboundedSender, 27 | /// Event receiver channel. 28 | receiver: mpsc::UnboundedReceiver, 29 | /// Event handler thread. 30 | handler: tokio::task::JoinHandle<()>, 31 | } 32 | 33 | impl EventHandler { 34 | /// Constructs a new instance of [`EventHandler`]. 35 | pub fn new(tick_rate: u64) -> Self { 36 | let tick_rate = Duration::from_millis(tick_rate); 37 | let (sender, receiver) = mpsc::unbounded_channel(); 38 | let _sender = sender.clone(); 39 | let handler = tokio::spawn(async move { 40 | let mut reader = crossterm::event::EventStream::new(); 41 | let mut tick = tokio::time::interval(tick_rate); 42 | loop { 43 | let tick_delay = tick.tick(); 44 | let crossterm_event = reader.next().fuse(); 45 | tokio::select! { 46 | _ = tick_delay => { 47 | if _sender.send(Event::Tick).is_err(){ 48 | process::exit(0); 49 | } 50 | } 51 | 52 | Some(Ok(evt)) = crossterm_event => { 53 | match evt { 54 | CrosstermEvent::Key(key) => { 55 | if key.kind == crossterm::event::KeyEventKind::Press { 56 | _sender.send(Event::Key(key)).unwrap(); 57 | } 58 | }, 59 | CrosstermEvent::Mouse(mouse) => { 60 | _sender.send(Event::Mouse(mouse)).unwrap(); 61 | }, 62 | CrosstermEvent::Resize(x, y) => { 63 | _sender.send(Event::Resize(x, y)).unwrap(); 64 | }, 65 | CrosstermEvent::FocusLost => { 66 | }, 67 | CrosstermEvent::FocusGained => { 68 | }, 69 | CrosstermEvent::Paste(c) => { 70 | _sender.send(Event::Paste(c)).unwrap(); 71 | }, 72 | 73 | } 74 | } 75 | }; 76 | } 77 | }); 78 | Self { 79 | sender, 80 | receiver, 81 | handler, 82 | } 83 | } 84 | 85 | /// Receive the next event from the handler thread. 86 | /// 87 | /// This function will always block the current thread if 88 | /// there is no data available and it's possible for more data to be sent. 89 | pub async fn next(&mut self) -> AppResult { 90 | self.receiver 91 | .recv() 92 | .await 93 | .ok_or(Box::new(std::io::Error::new( 94 | std::io::ErrorKind::Other, 95 | "This is an IO error", 96 | ))) 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/handler.rs: -------------------------------------------------------------------------------- 1 | use crate::app::{App, AppResult}; 2 | use crossterm::event::{KeyCode, KeyEvent}; 3 | 4 | /// Handles the key events and updates the state of [`App`]. 5 | pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { 6 | match key_event.code { 7 | // Exit application on `ESC` 8 | KeyCode::Esc => { 9 | app.quit(true); 10 | } 11 | // Counter handlers 12 | KeyCode::Up | KeyCode::BackTab => app.decrement_counter(), 13 | KeyCode::Down | KeyCode::Tab => app.increment_counter(), 14 | KeyCode::Enter => app.quit(false), 15 | KeyCode::Backspace => app.delete(), 16 | KeyCode::Char(_c) => app.update_query(key_event), 17 | _ => {} 18 | } 19 | Ok(()) 20 | } 21 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | /// Application. 2 | pub mod app; 3 | 4 | /// Terminal events handler. 5 | pub mod event; 6 | 7 | /// Widget renderer. 8 | pub mod ui; 9 | 10 | /// Terminal user interface. 11 | pub mod tui; 12 | 13 | /// Event handler. 14 | pub mod handler; 15 | pub mod search_engine; 16 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use clap::{arg, command}; 2 | use crossterm::ExecutableCommand; 3 | use nucleo::{Injector, Utf32String}; 4 | use ratatui::backend::CrosstermBackend; 5 | use ratatui::Terminal; 6 | use rfz::app::{App, AppResult}; 7 | use rfz::event::{Event, EventHandler}; 8 | use rfz::handler::handle_key_events; 9 | use rfz::tui::Tui; 10 | use std::fmt::Error; 11 | use std::fs::FileType; 12 | use std::io::{BufRead, IsTerminal, Stdin}; 13 | use std::path::Path; 14 | use std::process; 15 | use std::{env, io}; 16 | use tokio::main; 17 | 18 | fn get_os_path(injector: Injector) -> Result<(), Error> { 19 | let mut args = command!().args([ 20 | arg!(--file ) 21 | .short('f') 22 | .help("Search files from the given PATH") 23 | .exclusive(true), 24 | arg!(--directory ) 25 | .short('d') 26 | .help("Search directories from the given PATH ") 27 | .exclusive(true), 28 | arg!(--"working-dir" ) 29 | .short('w') 30 | .help("Search directories and files from the given PATH ") 31 | .exclusive(true), 32 | ]); 33 | let matches = args.clone().get_matches().clone(); 34 | if let Some(file) = matches.get_one::("file") { 35 | tokio::spawn(crawl_directory( 36 | file.clone(), 37 | injector, 38 | |entry: FileType| entry.is_file(), 39 | )); 40 | return Ok(()); 41 | } 42 | 43 | if let Some(directory) = matches.get_one::("directory") { 44 | tokio::spawn(crawl_directory( 45 | directory.clone(), 46 | injector, 47 | |entry: FileType| entry.is_dir(), 48 | )); 49 | return Ok(()); 50 | } 51 | 52 | if let Some(working_dir) = matches.get_one::("working-dir") { 53 | tokio::spawn(crawl_directory( 54 | working_dir.clone(), 55 | injector, 56 | |_: FileType| true, 57 | )); 58 | return Ok(()); 59 | } 60 | args.print_help().ok(); 61 | Err(std::fmt::Error) 62 | } 63 | 64 | async fn crawl_directory>( 65 | path: P, 66 | injector: Injector, 67 | predicate: fn(FileType) -> bool, 68 | ) { 69 | jwalk::WalkDir::new(path) 70 | .skip_hidden(false) 71 | .into_iter() 72 | .for_each(|entry| match entry { 73 | Ok(p) if predicate(p.file_type) => { 74 | let c = p.path().to_string_lossy().to_string(); 75 | injector.push(c.clone(), |s| { 76 | s[0] = Utf32String::Ascii(c.to_string().into()); 77 | }); 78 | } 79 | Ok(_) | Err(_) => {} 80 | }) 81 | } 82 | 83 | async fn async_stdin(stdin: Stdin, injector: Injector) { 84 | let mut lock = stdin.lock(); 85 | let mut line = String::new(); 86 | while lock.read_line(&mut line).expect("!!!") != 0 { 87 | injector.push(line.clone(), |s| { 88 | s[0] = Utf32String::Ascii(line.as_str().into()); 89 | }); 90 | 91 | line.clear(); 92 | } 93 | } 94 | 95 | #[main] 96 | async fn main() -> AppResult<()> { 97 | // Create an application. 98 | let mut app = App::default(); 99 | let injector = app.injector(); 100 | 101 | // Initialize the terminal user interface. 102 | let backend = CrosstermBackend::new(io::stderr()); 103 | let mut terminal = Terminal::new(backend)?; 104 | terminal 105 | .backend_mut() 106 | .execute(crossterm::terminal::SetTitle("rfz")) 107 | .expect("Couldn't change title"); 108 | let events = EventHandler::new(80); 109 | let mut tui = Tui::new(terminal, events); 110 | 111 | let input = io::stdin(); 112 | if input.is_terminal() { 113 | // no input available 114 | if get_os_path(injector).is_err() { 115 | process::exit(0); 116 | } 117 | } else { 118 | // input available 119 | tokio::spawn(async_stdin(input, injector)); 120 | } 121 | tui.init()?; 122 | 123 | // Start the main loop. 124 | while app.running { 125 | // Render the user interface. 126 | tui.draw(&mut app)?; 127 | // Handle events. 128 | match tui.events.next().await? { 129 | Event::Tick => app.tick(), 130 | Event::Key(key_event) => handle_key_events(key_event, &mut app)?, 131 | Event::Mouse(_) => {} 132 | Event::Resize(_, _) => {} 133 | Event::Paste(c) => app.paste(&c), 134 | } 135 | } 136 | 137 | // Exit the user interface. 138 | tui.exit()?; 139 | 140 | if let Some(selected) = app.selected() { 141 | println!("{}", selected) 142 | }; 143 | 144 | Ok(()) 145 | } 146 | -------------------------------------------------------------------------------- /src/search_engine.rs: -------------------------------------------------------------------------------- 1 | use std::{sync::Arc, thread::available_parallelism}; 2 | 3 | use nucleo::{ 4 | pattern::{CaseMatching, Normalization}, 5 | Config, Nucleo, 6 | }; 7 | 8 | pub struct SearchEngine { 9 | matcher: Nucleo, 10 | } 11 | 12 | impl SearchEngine { 13 | pub(crate) fn injector(&self) -> nucleo::Injector { 14 | self.matcher.injector() 15 | } 16 | 17 | /// Creates a new [`SearchEngine`]. 18 | pub fn new(matcher: Nucleo) -> Self { 19 | Self { matcher } 20 | } 21 | 22 | pub(crate) fn reparse(&mut self, query: &str) { 23 | self.matcher 24 | .pattern 25 | .reparse(0, query, CaseMatching::Ignore, Normalization::Never, false) 26 | } 27 | #[allow(dead_code)] 28 | pub(crate) fn restart(&mut self, clear_snapshot: bool) { 29 | self.matcher.restart(clear_snapshot) 30 | } 31 | 32 | pub(crate) fn snapshot(&self) -> &nucleo::Snapshot { 33 | self.matcher.snapshot() 34 | } 35 | #[inline] 36 | pub(crate) fn tick(&mut self, arg: u64) { 37 | self.matcher.tick(arg); 38 | } 39 | 40 | #[allow(dead_code)] 41 | pub(crate) fn update_config(&mut self, config: Config) { 42 | self.matcher.update_config(config) 43 | } 44 | } 45 | 46 | impl Default for SearchEngine { 47 | fn default() -> Self { 48 | let num_threads = Some(available_parallelism().unwrap().get()); 49 | Self::new(Nucleo::new( 50 | Config::DEFAULT, 51 | Arc::new(|| {}), 52 | num_threads, 53 | 1, 54 | )) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/tui.rs: -------------------------------------------------------------------------------- 1 | use crate::app::{App, AppResult}; 2 | use crate::event::EventHandler; 3 | use crate::ui; 4 | use crossterm::event::{DisableMouseCapture, EnableMouseCapture}; 5 | use crossterm::terminal::{self, EnterAlternateScreen, LeaveAlternateScreen}; 6 | use ratatui::backend::Backend; 7 | use ratatui::Terminal; 8 | use std::io; 9 | use std::panic; 10 | 11 | /// Representation of a terminal user interface. 12 | /// 13 | /// It is responsible for setting up the terminal, 14 | /// initializing the interface and handling the draw events. 15 | #[derive(Debug)] 16 | pub struct Tui { 17 | /// Interface to the Terminal. 18 | terminal: Terminal, 19 | /// Terminal event handler. 20 | pub events: EventHandler, 21 | } 22 | 23 | impl Tui { 24 | /// Constructs a new instance of [`Tui`]. 25 | pub fn new(terminal: Terminal, events: EventHandler) -> Self { 26 | Self { terminal, events } 27 | } 28 | 29 | /// Initializes the terminal interface. 30 | /// 31 | /// It enables the raw mode and sets terminal properties. 32 | pub fn init(&mut self) -> AppResult<()> { 33 | terminal::enable_raw_mode()?; 34 | crossterm::execute!(io::stderr(), EnterAlternateScreen, EnableMouseCapture)?; 35 | 36 | // Define a custom panic hook to reset the terminal properties. 37 | // This way, you won't have your terminal messed up if an unexpected error happens. 38 | let panic_hook = panic::take_hook(); 39 | panic::set_hook(Box::new(move |panic| { 40 | Self::reset().expect("failed to reset the terminal"); 41 | panic_hook(panic); 42 | })); 43 | 44 | self.terminal.hide_cursor()?; 45 | self.terminal.clear()?; 46 | Ok(()) 47 | } 48 | 49 | /// [`Draw`] the terminal interface by [`rendering`] the widgets. 50 | /// 51 | /// [`Draw`]: ratatui::Terminal::draw 52 | /// [`rendering`]: crate::ui:render 53 | pub fn draw(&mut self, app: &mut App) -> AppResult<()> { 54 | self.terminal.draw(|frame| ui::render(app, frame))?; 55 | Ok(()) 56 | } 57 | 58 | /// Resets the terminal interface. 59 | /// 60 | /// This function is also used for the panic hook to revert 61 | /// the terminal properties if unexpected errors occur. 62 | fn reset() -> AppResult<()> { 63 | terminal::disable_raw_mode()?; 64 | crossterm::execute!(io::stderr(), LeaveAlternateScreen, DisableMouseCapture)?; 65 | Ok(()) 66 | } 67 | 68 | /// Exits the terminal interface. 69 | /// 70 | /// It disables the raw mode and reverts back the terminal properties. 71 | pub fn exit(&mut self) -> AppResult<()> { 72 | Self::reset()?; 73 | self.terminal.show_cursor()?; 74 | Ok(()) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/ui.rs: -------------------------------------------------------------------------------- 1 | use crate::app::App; 2 | use ratatui::{ 3 | layout::{Constraint, Layout}, 4 | style::{Style, Stylize}, 5 | text::{Line, Span}, 6 | widgets::{Block, Borders, List}, 7 | Frame, 8 | }; 9 | 10 | /// Renders the user interface widgets. 11 | pub fn render(app: &mut App, frame: &mut Frame) { 12 | let layout = 13 | Layout::default().constraints([Constraint::Length(3), Constraint::Min(1)].as_slice()); 14 | let chunks = layout.split(frame.size()); 15 | 16 | // let widget = Paragraph::new(Span::styled(app.get_query(), Style::new())) 17 | // .block(Block::default().borders(Borders::ALL).title(">")); 18 | frame.render_widget(app.get_state_area(), chunks[0]); 19 | 20 | let binding = app.get_items_with_indices(); 21 | let list: List = binding 22 | .iter() 23 | .map(|(key, value)| format_line(key, value)) 24 | .collect::() 25 | .block(Block::default().borders(Borders::ALL)) 26 | .highlight_symbol(">>") 27 | .repeat_highlight_symbol(true); 28 | frame.render_stateful_widget(list, chunks[1], app.get_list_state()); 29 | 30 | frame.render_widget( 31 | Span::from(format!( 32 | "{}/{}", 33 | app.get_matched_items(), 34 | app.get_total_items() 35 | )), 36 | chunks[1], 37 | ); 38 | } 39 | 40 | ///Format the span corresponding to a line in the list, highlighting the letters matched 41 | /// 42 | /// # Arguments 43 | /// 44 | /// * `key` - The text of the line 45 | /// * `matched_indices` - The position of the matches 46 | fn format_line<'a>(line_text: &'a str, matched_indices: &'a [u32]) -> Line<'a> { 47 | Line::from( 48 | line_text 49 | .char_indices() 50 | .map(|(i, c)| match matched_indices.contains(&(i as u32)) { 51 | false => Span::raw(String::from(c)), 52 | true => Span::styled(String::from(c), Style::new().red()), 53 | }) 54 | .collect::>(), 55 | ) 56 | } 57 | --------------------------------------------------------------------------------