From 0d94f2bf2e9e0ff14301382228b27828030085e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Molin?= Date: Wed, 21 Oct 2026 08:52:46 +0200 Subject: [PATCH] Initial commit --- .github/workflows/ci.yml | 62 + .gitignore | 1 + Cargo.lock | 5003 +++++++++++++++++++++++++++++ Cargo.toml | 40 + README.md | 50 + benches/passes.rs | 79 + examples/gen_fixture.rs | 102 + log-reader-implementation-plan.md | 249 ++ rustfmt.toml | 2 + src/grep.rs | 282 ++ src/index.rs | 246 ++ src/job.rs | 93 + src/lib.rs | 16 + src/main.rs | 16 + src/passes.rs | 268 ++ src/pattern.rs | 362 +++ src/rowmap.rs | 217 ++ src/rules.rs | 324 ++ src/settings.rs | 196 ++ src/source.rs | 67 + src/ui/debug.rs | 71 + src/ui/grep_tab.rs | 327 ++ src/ui/log_tab.rs | 1654 ++++++++++ src/ui/mod.rs | 455 +++ src/ui/palette.rs | 63 + src/ui/panels.rs | 501 +++ src/ui/text.rs | 160 + tests/detection.rs | 170 + 28 files changed, 11076 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 benches/passes.rs create mode 100644 examples/gen_fixture.rs create mode 100644 log-reader-implementation-plan.md create mode 100644 rustfmt.toml create mode 100644 src/grep.rs create mode 100644 src/index.rs create mode 100644 src/job.rs create mode 100644 src/lib.rs create mode 100644 src/main.rs create mode 100644 src/passes.rs create mode 100644 src/pattern.rs create mode 100644 src/rowmap.rs create mode 100644 src/rules.rs create mode 100644 src/settings.rs create mode 100644 src/source.rs create mode 100644 src/ui/debug.rs create mode 100644 src/ui/grep_tab.rs create mode 100644 src/ui/log_tab.rs create mode 100644 src/ui/mod.rs create mode 100644 src/ui/palette.rs create mode 100644 src/ui/panels.rs create mode 100644 src/ui/text.rs create mode 100644 tests/detection.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a31f229 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: + push: + branches: [main] + tags: ["v*"] + pull_request: + +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + - name: Linux GUI dependencies + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libxkbcommon-dev libgtk-3-dev + - run: cargo fmt --check + - run: cargo clippy --all-targets -- -D warnings + - run: cargo test --release + + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: test + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + - os: windows-latest + target: x86_64-pc-windows-msvc + - os: macos-latest + target: aarch64-apple-darwin + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Linux GUI dependencies + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libxkbcommon-dev libgtk-3-dev + - run: cargo build --release --target ${{ matrix.target }} + - name: Package + shell: bash + run: | + name=logreadlite-${GITHUB_REF_NAME}-${{ matrix.target }} + mkdir "$name" + cp README.md "$name/" + if [ "$RUNNER_OS" = "Windows" ]; then + cp target/${{ matrix.target }}/release/logreadlite.exe "$name/" + 7z a "$name.zip" "$name" + else + cp target/${{ matrix.target }}/release/logreadlite "$name/" + tar czf "$name.tar.gz" "$name" + fi + - uses: softprops/action-gh-release@v2 + with: + files: logreadlite-*.* diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..3ae59ef --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,5003 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ab_glyph" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" + +[[package]] +name = "accesskit" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad442f58ee04714aaa0ba0a2768c1ea1935b29507bb22ddece8cbbc76db02932" +dependencies = [ + "uuid", +] + +[[package]] +name = "accesskit_atspi_common" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52c182f9c282ac9c5638d876d551d15e5f7d397ec263349a0c6a2b61595dd5e4" +dependencies = [ + "accesskit", + "accesskit_consumer", + "atspi-common", + "phf", + "serde", + "zvariant", +] + +[[package]] +name = "accesskit_consumer" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a45e2bb300bea6d5f33a82c3e051c3ddc6f41c209750f68a0acbe991a284344" +dependencies = [ + "accesskit", + "hashbrown 0.17.1", +] + +[[package]] +name = "accesskit_ios" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e539d64b27fd4c14de8f78ada8f7c944c092f52f7e49fb63316507a57f6937" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.17.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-ui-kit 0.2.2", +] + +[[package]] +name = "accesskit_macos" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5701624bf6a11efb6d4c8e922bf44126ed96250e5faa9a7a0468c979635839a4" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.17.1", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "accesskit_unix" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "202f24df034a7476d07b7f74284de84f6d62aabd858dbe7ee9cad3b7ad6f8f9d" +dependencies = [ + "accesskit", + "accesskit_atspi_common", + "async-channel", + "async-executor", + "async-task", + "atspi", + "futures-lite", + "futures-util", + "serde", + "zbus", +] + +[[package]] +name = "accesskit_windows" +version = "0.35.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce63f35d6bdcf59f26b76b3379063f738e6412cef46999cc772d46aa3de35adb" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.17.1", + "static_assertions", + "windows", + "windows-core", +] + +[[package]] +name = "accesskit_winit" +version = "0.34.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee96dd150375c05912d8a473f98c2fb155fb3234fac88292d396548a2460fa77" +dependencies = [ + "accesskit", + "accesskit_ios", + "accesskit_macos", + "accesskit_unix", + "accesskit_windows", + "raw-window-handle", + "winit", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloca" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7d05ea6aea7e9e64d25b9156ba2fee3fdd659e34e41063cd2fc7cd020d7f4" +dependencies = [ + "cc", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android-activity" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" +dependencies = [ + "android-properties", + "bitflags 2.13.2", + "cc", + "jni", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror 2.0.21", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arboard" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" +dependencies = [ + "clipboard-win", + "image", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "wl-clipboard-rs", + "x11rb", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + +[[package]] +name = "ash" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" +dependencies = [ + "libloading", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96bf972d85afc50bf5ab8fe2d54d1586b4e0b46c97c50a0c9e71e2f7bcd812a" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix 1.1.5", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix 1.1.5", +] + +[[package]] +name = "async-recursion" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "async-signal" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 1.1.5", + "signal-hook-registry", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "atspi" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77886257be21c9cd89a4ae7e64860c6f0eefca799bb79127913052bd0eefb3d" +dependencies = [ + "atspi-common", + "atspi-proxies", +] + +[[package]] +name = "atspi-common" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20c5617155740c98003016429ad13fe43ce7a77b007479350a9f8bf95a29f63d" +dependencies = [ + "enumflags2", + "serde", + "static_assertions", + "zbus", + "zbus-lockstep", + "zbus-lockstep-macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "atspi-proxies" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2230e48787ed3eb4088996eab66a32ca20c0b67bbd4fd6cdfe79f04f1f04c9fc" +dependencies = [ + "atspi-common", + "serde", + "zbus", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bit-set" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2 0.5.3", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2 0.6.5", +] + +[[package]] +name = "blocking" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "bstr" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f" +dependencies = [ + "memchr", + "regex-automata", + "serde_core", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "calloop" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" +dependencies = [ + "bitflags 2.13.2", + "log", + "polling", + "rustix 0.38.44", + "slab", + "thiserror 1.0.69", +] + +[[package]] +name = "calloop" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" +dependencies = [ + "bitflags 2.13.2", + "polling", + "rustix 1.1.5", + "tracing", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" +dependencies = [ + "calloop 0.13.0", + "rustix 0.38.44", + "wayland-backend", + "wayland-client", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" +dependencies = [ + "calloop 0.14.5", + "rustix 1.1.5", + "wayland-backend", + "wayland-client", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877bf67ac8e52449eb2f9e98a344ea163beb70dd1f9eebe3cc5357dcfeaee4df" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clap" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_lex" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486" + +[[package]] +name = "clipboard-win" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4" +dependencies = [ + "error-code", +] + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "color" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec7c5eb7a16992b1904d76c517d170ab353b0e0b3d5a0c81a8a0cd1037893cf" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core-graphics" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "libc", +] + +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "crc32fast" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "criterion" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "950046b2aa2492f9a536f5f4f9a3de7b9e2476e575e05bd6c333371add4d98f3" +dependencies = [ + "alloca", + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "itertools 0.13.0", + "num-traits", + "oorandom", + "page_size", + "plotters", + "rayon", + "regex", + "serde", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8d80a2f4f5b554395e47b5d8305bc3d27813bacb73493eb1001e8f76dae29ea" +dependencies = [ + "cast", + "itertools 0.13.0", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "cursor-icon" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" + +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "libc", + "objc2 0.6.5", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "dlib" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" +dependencies = [ + "libloading", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dpi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" + +[[package]] +name = "ecolor" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31bcbef0d4263a63eb32c4834e5d711613035ce1333468e107d928923e21e6e2" +dependencies = [ + "bytemuck", + "emath", +] + +[[package]] +name = "eframe" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c5642501a65ca657d05f00c643a5c14ff2346cb3818032bfe23d58e1f8e5f84" +dependencies = [ + "ahash", + "bytemuck", + "document-features", + "egui", + "egui-wgpu", + "egui-winit", + "egui_glow", + "egui_system_font_provider", + "glutin", + "glutin-winit", + "image", + "js-sys", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "pollster 1.0.1", + "profiling", + "raw-window-handle", + "send_wrapper", + "static_assertions", + "wasm-bindgen", + "web-sys", + "web-time", + "wgpu", + "windows-sys 0.61.2", + "winit", +] + +[[package]] +name = "egui" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec9144f49b7a28b5f395d3147e325b4fe3e77ba686eac11d1bdf0a7da3f375f" +dependencies = [ + "accesskit", + "ahash", + "bitflags 2.13.2", + "emath", + "epaint", + "itertools 0.15.0", + "log", + "nohash-hasher", + "profiling", + "smallvec", + "unicode-segmentation", + "web-sys", +] + +[[package]] +name = "egui-wgpu" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0309cbe1febed48af5b974e4bcc424b35e9664863a4d402697147b57a488c864" +dependencies = [ + "ahash", + "bytemuck", + "document-features", + "egui", + "epaint", + "log", + "profiling", + "thiserror 2.0.21", + "type-map", + "web-time", + "wgpu", + "winit", +] + +[[package]] +name = "egui-winit" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e449f4c4a2a60c7ccb4ba7fa4078417bfe1f9ddc03b5e05ce75748e33a70de" +dependencies = [ + "accesskit_winit", + "arboard", + "block2 0.6.2", + "bytemuck", + "egui", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "objc2-ui-kit 0.3.2", + "profiling", + "raw-window-handle", + "smithay-clipboard", + "web-time", + "webbrowser", + "windows-sys 0.61.2", + "winit", +] + +[[package]] +name = "egui_glow" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9275ca5cc35a6b7c94e0e8cedf22542f66cb0cf45ed8ab2657c78ff49fec7268" +dependencies = [ + "bytemuck", + "egui", + "glow", + "log", + "profiling", + "winit", +] + +[[package]] +name = "egui_system_font_provider" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f2a2fdfe3c05dd9f691d2b1388b2312d6dce1af502f217c22136d22d9bd76f6" +dependencies = [ + "epaint", + "fontique", + "log", + "poll-promise", + "skrifa", + "sys-locale", + "unicode-script", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "emath" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e73ce90f54750be8672c02be0743fe47530e6f251e066f0ee2869b59eb297af5" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "encoding_rs" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "encoding_rs_io" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba3fe847045ecff794b9c138293a80db914678c453ad63fbf0c6a9eb6e00b22" +dependencies = [ + "encoding_rs", +] + +[[package]] +name = "endi" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" + +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "epaint" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97bac86ae3dde93fc3951e790951caea739ff39a6c89d909cdaf1d9278dbb1bd" +dependencies = [ + "ahash", + "bytemuck", + "ecolor", + "emath", + "epaint_default_fonts", + "font-types", + "harfrust", + "log", + "nohash-hasher", + "parking_lot", + "profiling", + "self_cell", + "skrifa", + "smallvec", + "unicode-general-category", + "unicode-properties", + "unicode-segmentation", + "vello_cpu", +] + +[[package]] +name = "epaint_default_fonts" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfc1cc505827f4c23eedc297975a0fd038268d41293f389dd8ff3b574aefab19" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "error-code" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" + +[[package]] +name = "euclid" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06" +dependencies = [ + "num-traits", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "fearless_simd" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97b65636e5b9ef369943878ac74335ba1c55c1cb6adbf1e2c293c624248d693" + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "flate2" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "font-types" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "fontique" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6688bc1294fe7117d788937b6c53480169b29c566954af490830d4c09da9516a" +dependencies = [ + "hashbrown 0.17.1", + "linebender_resource_handle", + "memmap2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-text", + "objc2-foundation 0.3.2", + "parlance", + "read-fonts", + "roxmltree", + "smallvec", + "windows", + "windows-core", + "yeslogic-fontconfig-sys", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "gethostname" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" +dependencies = [ + "rustix 1.1.5", + "windows-link", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glifo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a26c1e23de04bdab3e34a21b6f877a479b96737792516b9b8b8f69b6661be" +dependencies = [ + "bytemuck", + "foldhash 0.2.0", + "hashbrown 0.17.1", + "log", + "peniko", + "png", + "skrifa", + "smallvec", + "vello_common", +] + +[[package]] +name = "globset" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c34a9410465b45bd9787443bc7370f37735bad04b0f0cd57ff1a3186c98988" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "glow" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" +dependencies = [ + "bitflags 2.13.2", + "cfg_aliases", + "cgl", + "dispatch2", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "libloading", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "raw-window-handle", + "wayland-sys", + "windows-sys 0.52.0", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85edca7075f8fc728f28cb8fbb111a96c3b89e930574369e3e9c27eb75d3788f" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2" +dependencies = [ + "gl_generator", + "windows-sys 0.52.0", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gpu-allocator" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795" +dependencies = [ + "ash", + "hashbrown 0.16.1", + "log", + "presser", + "thiserror 2.0.21", + "windows", +] + +[[package]] +name = "grep-matcher" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9417543f4870fc8f1c8e1af870afae2431007626d9e703fce6471c468d33847" +dependencies = [ + "memchr", +] + +[[package]] +name = "grep-regex" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce0c256c3ad82bcc07b812c15a45ec1d398122e8e15124f96695234db7112ef" +dependencies = [ + "bstr", + "grep-matcher", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "grep-searcher" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72348823a0eafc4bc2e9051064f28b5b42cc100b571b3a35d67918d711efcbc6" +dependencies = [ + "bstr", + "encoding_rs", + "encoding_rs_io", + "grep-matcher", + "log", + "memchr", + "memmap2", +] + +[[package]] +name = "guillotiere" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b17e70c989c36bad147b27a58d148c0741c51448aa5653436547323e524d0ab" +dependencies = [ + "euclid", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "harfrust" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "read-fonts", + "smallvec", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "foldhash 0.2.0", +] + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "icu_collections" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" + +[[package]] +name = "icu_properties" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" + +[[package]] +name = "icu_provider" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "ignore" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b69833ed729dc5aa7d19541d96d6cf8e9137194207a04916d658e43168402f" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "png", + "tiff", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "khronos-egl" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" +dependencies = [ + "libc", + "libloading", + "pkg-config", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "kurbo" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b60dfc32f652b926df6192e55525b16d186c69d47876c3ead4da5cc9f8450e2" +dependencies = [ + "arrayvec", + "euclid", + "polycool", + "smallvec", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags 2.13.2", + "libc", + "plain", + "redox_syscall 0.9.5", +] + +[[package]] +name = "linebender_resource_handle" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "logreadlite" +version = "0.1.0" +dependencies = [ + "aho-corasick", + "anyhow", + "criterion", + "directories", + "eframe", + "egui", + "globset", + "grep-regex", + "grep-searcher", + "ignore", + "lru", + "memchr", + "memmap2", + "rayon", + "regex", + "rfd", + "serde", + "tempfile", + "toml", +] + +[[package]] +name = "lru" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9f71e3591c7ec44d3e563e87bf14ddc2bada8519dca046e5b0e560cd004e2d" +dependencies = [ + "hashbrown 0.17.1", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "naga" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a616d2fb8c89516ac2723a581f69d6c18576046bed761bd6b305e5618e6ae130" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.1", + "indexmap", + "libm", + "log", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "spirv", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "naga-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590afbf58a6f4f62873cd5cff4468061844bafa1cdf399cc954537c22d768d49" +dependencies = [ + "hashbrown 0.17.1", + "indexmap", + "rustc-hash 1.1.0", + "thiserror 2.0.21", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "libc", + "objc2 0.5.3", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation 0.2.2", + "objc2-quartz-core 0.2.2", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-contacts", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.13.2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "dispatch", + "libc", + "objc2 0.5.3", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", +] + +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", + "objc2-core-location", + "objc2-foundation 0.2.2", + "objc2-link-presentation", + "objc2-quartz-core 0.2.2", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "orbclient" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df339f526ea9a60e371768d50efc2f2508c7203290731565d1f7a6f71d21747" +dependencies = [ + "libc", + "libredox", +] + +[[package]] +name = "ordered-float" +version = "5.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c7c9e0d9b23589f26070720bac724174bfec1083e82f7854cdd0267518343c0" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "os_pipe" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "page_size" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "parlance" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73072a9470554c8e794778acece2312661218aaabb635600957d952cf01c716e" + +[[package]] +name = "peniko" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839c8299360d2e998bdb106dc0a6cd71dcc5f4df51df1b620361bf50e283cca6" +dependencies = [ + "bytemuck", + "color", + "kurbo", + "linebender_resource_handle", + "smallvec", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[package]] +name = "phf" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" +dependencies = [ + "phf_macros", + "phf_shared", + "serde", +] + +[[package]] +name = "phf_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" +dependencies = [ + "fastrand", + "phf_shared", +] + +[[package]] +name = "phf_macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_shared" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "poll-promise" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6a58fecbf9da8965bcdb20ce4fd29788d1acee68ddbb64f0ba1b81bccdb7df" +dependencies = [ + "document-features", + "static_assertions", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.1.5", + "windows-sys 0.61.2", +] + +[[package]] +name = "pollster" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" + +[[package]] +name = "pollster" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6355899e1c9462875b6757c79f3caa011a1fdae12bbb1a2e72dd1f234f8336" + +[[package]] +name = "polycool" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50596ddc09eb5ad5f75cacd40209568e66df71baf86e1499a0e99c4cff12a5a6" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "range-alloc" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "raw-window-metal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" +dependencies = [ + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "read-fonts" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror 2.0.21", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "rfd" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20dafead71c16a34e1ff357ddefc8afc11e7d51d6d2b9fbd07eaa48e3e540220" +dependencies = [ + "block2 0.6.2", + "dispatch2", + "js-sys", + "libc", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "percent-encoding", + "pollster 0.4.0", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "web-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "roxmltree" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1964b10c76125c36f8afe190065a4bf9a87bf324842c05701330bba9f1cacbb" +dependencies = [ + "memchr", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sctk-adwaita" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit 0.19.2", + "tiny-skia", +] + +[[package]] +name = "self_cell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_spanned" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +dependencies = [ + "serde_core", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "skrifa" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" +dependencies = [ + "bytemuck", + "read-fonts", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" + +[[package]] +name = "smithay-client-toolkit" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" +dependencies = [ + "bitflags 2.13.2", + "calloop 0.13.0", + "calloop-wayland-source 0.3.0", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 0.38.44", + "thiserror 1.0.69", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-client-toolkit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" +dependencies = [ + "bitflags 2.13.2", + "calloop 0.14.5", + "calloop-wayland-source 0.4.1", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 1.1.5", + "thiserror 2.0.21", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-experimental", + "wayland-protocols-misc", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-clipboard" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71704c03f739f7745053bde45fa203a46c58d25bc5c4efba1d9a60e9dba81226" +dependencies = [ + "libc", + "smithay-client-toolkit 0.20.0", + "wayland-backend", +] + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "spirv" +version = "0.4.0+sdk-1.4.341.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "sys-locale" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" +dependencies = [ + "libc", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix 1.1.5", + "windows-sys 0.61.2", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[package]] +name = "tinystr" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "tokio" +version = "1.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c168a474b95bfecfe908a65d4bdffc523144b649a74c09c286afb35d53e0bc" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml" +version = "1.1.8+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.17+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tree_magic_mini" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" +dependencies = [ + "memchr", + "nom", + "petgraph", +] + +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" + +[[package]] +name = "type-map" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90" +dependencies = [ + "rustc-hash 2.1.3", +] + +[[package]] +name = "uds_windows" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys 0.61.2", +] + +[[package]] +name = "unicode-general-category" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b993bddc193ae5bd0d623b49ec06ac3e9312875fdae725a975c51db1cc1677f" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" + +[[package]] +name = "unicode-script" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383ad40bb927465ec0ce7720e033cb4ca06912855fc35db31b5755d0de75b1ee" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cc1186384beb7dd8eedea376413fd654937285ea6c9cfbb928dc3043ea4b606" +dependencies = [ + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "vello_common" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb2141a2bca6e6d598e471fd4d1d7eed8e020aad6a28187edda07f091a325dd" +dependencies = [ + "bytemuck", + "fearless_simd", + "guillotiere", + "log", + "peniko", + "png", + "smallvec", + "thiserror 2.0.21", +] + +[[package]] +name = "vello_cpu" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace506ca414548966fcf3c283be94eb1cad8254de488791ee698bf438b0890a9" +dependencies = [ + "bytemuck", + "glifo", + "hashbrown 0.17.1", + "png", + "vello_common", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wayland-backend" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" +dependencies = [ + "cc", + "downcast-rs", + "rustix 1.1.5", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" +dependencies = [ + "bitflags 2.13.2", + "rustix 1.1.5", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.13.2", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" +dependencies = [ + "rustix 1.1.5", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-experimental" +version = "20250721.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-misc" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62c35be770821a214dbc362fc26908c853e776c0004294d0b10b8a6bad582f94" +dependencies = [ + "jni", + "log", + "ndk-context", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "url", + "web-sys", +] + +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "wgpu" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527ccdf43dd5b2e8676eed9984ce00e2bbb0a1b85b70c1969dcb6cd2eb55ab9e" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "js-sys", + "log", + "naga", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c018fce9b6270aa203c2fdd56f3cce996713534bd757e4ea58c8560b121f14" +dependencies = [ + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "indexmap", + "log", + "naga", + "naga-types", + "once_cell", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.21", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-wasm", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-naga-bridge", + "wgpu-types", +] + +[[package]] +name = "wgpu-core-deps-apple" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061f3d319a40d39d00b1ecc2c33b89fe21d4e6fe01859df3500a3a8ecccd6b68" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-emscripten" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98b86cf4abf524a902dd35f18ca6a3f08fc2ae9847c8f10b48e30491b1f0b86" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-wasm" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d260ca2ca8adc654f513a869bf3cac0b47f5b8d3f87803d6942015f8de597aae" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7586165fd5f6d881cb9ce4bb71f40d6caab2c0f1837e3fc1d9788a197fb6004f" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-hal" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b7fb58561a792bc237628ba0792e332de418fefe145f13b5ed8201e6d52f58" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.13.2", + "block2 0.6.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "glow", + "glutin_wgl_sys", + "gpu-allocator", + "hashbrown 0.17.1", + "js-sys", + "khronos-egl", + "libc", + "libloading", + "log", + "naga", + "naga-types", + "ndk-sys", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "once_cell", + "ordered-float", + "parking_lot", + "portable-atomic", + "portable-atomic-util", + "profiling", + "range-alloc", + "raw-window-handle", + "raw-window-metal", + "renderdoc-sys", + "smallvec", + "static_assertions", + "thiserror 2.0.21", + "wasm-bindgen", + "wayland-sys", + "web-sys", + "wgpu-naga-bridge", + "wgpu-types", + "windows", + "windows-core", + "windows-result", +] + +[[package]] +name = "wgpu-naga-bridge" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f62e73117bb7a62bfd9c5a5841438a823f6566c6442a808ee269d2d055c081" +dependencies = [ + "naga", + "wgpu-types", +] + +[[package]] +name = "wgpu-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99dad6f1fbdbbdb4c278a6508b059d44688f5cebddf78d005a46a31340269286" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "js-sys", + "log", + "naga-types", + "raw-window-handle", + "static_assertions", + "web-sys", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core", + "windows-link", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core", + "windows-link", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winit" +version = "0.30.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.13.2", + "block2 0.5.1", + "bytemuck", + "calloop 0.13.0", + "cfg_aliases", + "concurrent-queue", + "core-foundation", + "core-graphics", + "cursor-icon", + "dpi", + "js-sys", + "libc", + "memmap2", + "ndk", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", + "objc2-ui-kit 0.2.2", + "orbclient", + "percent-encoding", + "pin-project", + "raw-window-handle", + "redox_syscall 0.4.1", + "rustix 0.38.44", + "sctk-adwaita", + "smithay-client-toolkit 0.19.2", + "smol_str", + "tracing", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.52.0", + "x11-dl", + "x11rb", + "xkbcommon-dl", +] + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wl-clipboard-rs" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d7888ccd4896447b2d14d3a9350a85df2aeb6f181e2e7a31349d104ac46cac1" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix 1.1.5", + "thiserror 2.0.21", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "x11rb" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" +dependencies = [ + "as-raw-xcb-connection", + "gethostname", + "libc", + "libloading", + "once_cell", + "rustix 1.1.5", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + +[[package]] +name = "xcursor" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" + +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.13.2", + "dlib", + "log", + "once_cell", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "yeslogic-fontconfig-sys" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8b8abf912b9a29ff112e1671c97c33636903d13a69712037190e6805af4f76" +dependencies = [ + "dlib", + "once_cell", + "pkg-config", +] + +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "libc", + "ordered-stream", + "rustix 1.1.5", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus-lockstep" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863" +dependencies = [ + "zbus_xml", + "zvariant", +] + +[[package]] +name = "zbus-lockstep-macros" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10da05367f3a7b7553c8cdf8fa91aee6b64afebe32b51c95177957efc47ca3a0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "zbus-lockstep", + "zbus_xml", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.9", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd" +dependencies = [ + "serde", + "winnow", + "zvariant", +] + +[[package]] +name = "zbus_xml" +version = "5.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1586c021a01ca0a9216dcd874e546382e156a5cbab5fab6cb5f10087e22682a" +dependencies = [ + "serde", + "winnow", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zcheapstr" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1afec51604565183aeb5c54c20aeab286120d4e4460f7f76e3e8bb8c0d99473" +dependencies = [ + "serde", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] + +[[package]] +name = "zvariant" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow", + "zcheapstr", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.9", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 3.0.9", + "winnow", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..93db99f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "logreadlite" +version = "0.1.0" +edition = "2024" + +[dependencies] +aho-corasick = "1.1.5" +anyhow = "1.0.104" +directories = "6.0.0" +eframe = "0.37.0" +egui = "0.37.0" +globset = "0.4.20" +grep-regex = "0.1.14" +grep-searcher = "0.1.17" +ignore = "0.4.33" +lru = "0.19.0" +memchr = "2.8.3" +memmap2 = "0.9.11" +rayon = "1.12.0" +regex = "1.13.1" +rfd = "0.17.2" +serde = { version = "1.0.229", features = ["derive"] } +toml = "1.1.8" + +[dev-dependencies] +criterion = "0.8.2" +tempfile = "3.27.0" + +[profile.release] +opt-level = 3 +lto = "thin" +codegen-units = 4 + +# Keep debug builds usable on big files. +[profile.dev.package."*"] +opt-level = 2 + +[[bench]] +name = "passes" +harness = false diff --git a/README.md b/README.md new file mode 100644 index 0000000..9619dac --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# logreadlite + +A fast desktop viewer for large log files, built in Rust with egui/eframe. It +opens files of hundreds of MB or more right away, groups multi-line records +(stack traces, JSON dumps) into entries, and indexes, filters and searches in +the background so the UI never blocks. + +See `log-reader-implementation-plan.md` for the design. + +## Run + +```sh +cargo run --release -- [FILE|FOLDER]... +``` + +A file opens in a viewer tab and a folder opens a "Find in files" tab. You can +also drop files, folders or `.logrules.toml` rule files on the window. + +## Features + +- Memory-mapped, read-only access; a parallel background indexer (about 4–5 GB/s from a warm cache). +- Detects the entry-start pattern automatically, with an editor that shows a live preview. + The pattern you pick is saved per file or per file-name glob. +- Multi-line entries are collapsed with a "+N lines" badge. Expand one, or all. +- Line wrap toggle (Alt+Z), saved per file. +- Keyword filter chips (Exclude / Only, regex and case toggles), applied to whole entries. +- Highlight rules (row tint or matched text) with light and dark palettes. +- Regex search with next/previous and a match count. A match on a continuation line expands its entry. +- Import and export rule files (`.logrules.toml`), and named rule sets. +- Folder grep built on ripgrep's `ignore` and `grep-searcher` crates. Open any hit in the viewer. + +Help → Keyboard shortcuts lists the keys. + +## Develop + +```sh +cargo test # unit tests and format-detection tests +cargo bench --bench passes # index/filter/search throughput (100 MB fixture) +cargo run --release --example gen_fixture -- big.log 1024 traces +cargo run --release --example gen_fixture -- --folder logs/ 1000 2 +``` + +Two environment variables help with UI checks that have no input injection: +`LOGREADLITE_SCREENSHOT=out.ppm` saves a screenshot after +`LOGREADLITE_SCREENSHOT_DELAY` seconds and then quits. +`LOGREADLITE_DEBUG_SCRIPT="search:foo;next;exclude:DEBUG;wrap"` replays +actions on the active tab (see `src/ui/debug.rs`). + +Settings and named rule sets are stored in the OS config folder +(`~/.config/logreadlite` on Linux). diff --git a/benches/passes.rs b/benches/passes.rs new file mode 100644 index 0000000..82d70fd --- /dev/null +++ b/benches/passes.rs @@ -0,0 +1,79 @@ +//! Index, filter and search throughput on generated fixtures. +//! Set LOGREADLITE_BENCH_FILE to benchmark a real file instead. + +use std::path::PathBuf; +use std::sync::Arc; + +use criterion::{Criterion, Throughput, criterion_group, criterion_main}; +use logreadlite::index::{self, SharedIndex}; +use logreadlite::job::{Token, no_notify}; +use logreadlite::passes::{self, SearchQuery, SharedSearch}; +use logreadlite::pattern; +use logreadlite::rules::{CompiledFilter, Rule, RuleKind}; +use logreadlite::source::{ByteSource, MmapSource}; + +#[path = "../examples/gen_fixture.rs"] +#[allow(dead_code)] +mod gen_fixture; + +fn fixture() -> (PathBuf, Option) { + if let Ok(p) = std::env::var("LOGREADLITE_BENCH_FILE") { + return (p.into(), None); + } + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("bench.log"); + gen_fixture::write_log(&path, 100 << 20, "traces", 7).unwrap(); + (path, Some(dir)) +} + +fn bench(c: &mut Criterion) { + let (path, _dir) = fixture(); + let src: Arc = Arc::new(MmapSource::open(&path).unwrap()); + let mut g = c.benchmark_group("passes"); + g.sample_size(10); + g.throughput(Throughput::Bytes(src.len())); + + let det = pattern::detect(src.bytes(), &[]); + let re = det.chosen.compile().unwrap(); + g.bench_function("detect", |b| b.iter(|| pattern::detect(src.bytes(), &[]))); + g.bench_function("index", |b| { + b.iter(|| { + let shared = SharedIndex::new(src.len()); + index::build(&*src, &re, &shared, &Token::detached(), &no_notify()); + shared + }) + }); + + let shared = Arc::new(SharedIndex::new(src.len())); + index::build(&*src, &re, &shared, &Token::detached(), &no_notify()); + let rules = vec![Rule::filter(RuleKind::Exclude, "DEBUG"), Rule::filter(RuleKind::Exclude, "health")]; + g.bench_function("filter", |b| { + b.iter(|| { + let out = passes::SharedFilter { + visible: Default::default(), + entries_done: Default::default(), + total_entries: 0, + done: Default::default(), + }; + passes::run_filter(&*src, &shared, &CompiledFilter::new(&rules), &out, &Token::detached(), &no_notify()); + }) + }); + let q = SearchQuery { text: r"Handler1\d\.handle".into(), regex: true, ..Default::default() }; + let sre = q.compile().unwrap(); + g.bench_function("search", |b| { + b.iter(|| { + let out = SharedSearch { + matches: Default::default(), + bytes_done: Default::default(), + total_bytes: src.len(), + done: Default::default(), + capped: Default::default(), + }; + passes::run_search(&*src, &sre, &out, &Token::detached(), &no_notify()); + }) + }); + g.finish(); +} + +criterion_group!(benches, bench); +criterion_main!(benches); diff --git a/examples/gen_fixture.rs b/examples/gen_fixture.rs new file mode 100644 index 0000000..64be1ba --- /dev/null +++ b/examples/gen_fixture.rs @@ -0,0 +1,102 @@ +//! Generates fixture log files for manual testing and benchmarks. +//! +//! cargo run --release --example gen_fixture -- [short|long|traces] +//! cargo run --release --example gen_fixture -- --folder + +use std::fs::File; +use std::io::{BufWriter, Write}; +use std::path::Path; + +struct Rng(u64); + +impl Rng { + fn next(&mut self) -> u64 { + self.0 ^= self.0 << 13; + self.0 ^= self.0 >> 7; + self.0 ^= self.0 << 17; + self.0 + } + + fn below(&mut self, n: u64) -> u64 { + self.next() % n + } +} + +const LEVELS: [&str; 5] = ["DEBUG", "INFO", "INFO", "WARN", "ERROR"]; +const THREADS: [&str; 4] = ["main", "worker-1", "worker-2", "http-nio-8080-exec-3"]; +const WORDS: [&str; 16] = [ + "request", + "user", + "session", + "cache", + "db", + "timeout", + "connected", + "retry", + "payload", + "order", + "invoice", + "queue", + "health", + "check", + "shutdown", + "started", +]; + +pub fn write_log(path: &Path, size: u64, kind: &str, seed: u64) -> std::io::Result<()> { + let mut w = BufWriter::with_capacity(1 << 20, File::create(path)?); + let mut rng = Rng(seed.max(1)); + let mut written = 0u64; + let mut t = 0u64; + let mut n = 0u64; + while written < size { + t += rng.below(1500); + n += 1; + let (h, m, s, ms) = ((t / 3_600_000) % 24, (t / 60_000) % 60, (t / 1000) % 60, t % 1000); + let level = LEVELS[rng.below(5) as usize]; + let thread = THREADS[rng.below(4) as usize]; + let words = match kind { + "short" => 2, + "long" => 40 + rng.below(80), + _ => 4 + rng.below(12), + }; + let mut line = format!("2026-10-21 {h:02}:{m:02}:{s:02},{ms:03} {level:<5} [{thread}] entry {n}:"); + for _ in 0..words { + line.push(' '); + line.push_str(WORDS[rng.below(16) as usize]); + } + line.push('\n'); + if kind != "short" && level == "ERROR" && rng.below(3) == 0 { + line.push_str("java.lang.IllegalStateException: something went wrong\n"); + for d in 0..(3 + rng.below(25)) { + line.push_str(&format!("\tat com.example.service.Handler{d}.handle(Handler{d}.java:{})\n", 10 + d * 7)); + } + if rng.below(2) == 0 { + line.push_str("Caused by: java.io.IOException: connection reset\n\tat java.base/sun.nio.ch.Net.read(Net.java:1)\n\t... 12 more\n"); + } + } + written += line.len() as u64; + w.write_all(line.as_bytes())?; + } + w.flush() +} + +fn main() -> std::io::Result<()> { + let args: Vec = std::env::args().skip(1).collect(); + if args.first().map(String::as_str) == Some("--folder") { + let dir = Path::new(&args[1]); + let files: u64 = args[2].parse().expect("file count"); + let mb: u64 = args[3].parse().expect("size in MB"); + std::fs::create_dir_all(dir)?; + for i in 0..files { + let sub = dir.join(format!("svc{}", i % 10)); + std::fs::create_dir_all(&sub)?; + write_log(&sub.join(format!("app-{i}.log")), mb << 20, "traces", i + 1)?; + } + return Ok(()); + } + let out = args.first().expect("usage: gen_fixture [short|long|traces]"); + let mb: u64 = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(100); + let kind = args.get(2).map(String::as_str).unwrap_or("traces"); + write_log(Path::new(out), mb << 20, kind, 42) +} diff --git a/log-reader-implementation-plan.md b/log-reader-implementation-plan.md new file mode 100644 index 0000000..66f7f42 --- /dev/null +++ b/log-reader-implementation-plan.md @@ -0,0 +1,249 @@ +# Log reader implementation plan + +Oct 21, 2026 · Torbjörn + +The app is a single native Rust binary built on egui/eframe for Windows, macOS and Linux. It opens a log file of hundreds of MB in under a second, then indexes it in the background so the UI never blocks. Everything below is a plan, not code. + +## Goals and scope + +- **Large files:** open 100 MB to 2 GB files without loading them into memory; first screen visible in under 1 s, full index in seconds. +- **Entries, not lines:** group multi-line records (stack traces, JSON dumps) into one entry, split on a detected line-start pattern. +- **Editable pattern:** auto-detect the start-of-entry pattern, show it, and let the user edit it with a live preview. +- **Collapsed by default:** a multi-line entry shows its first line plus a "+N lines" badge and expands in place. +- **Line wrap:** a toggle between one row per line with horizontal scrolling and wrapped lines. +- **Filter:** hide (or show only) entries matching keywords. +- **Highlight:** color whole entries, or the matched words, by keyword rules. +- **Rule files:** import and export filter and highlight rules as files. +- **Search:** regex search with next/previous and a match count. +- **Folder grep:** search every file in a folder for matching lines, then open any hit in the viewer at that line. + +Out of scope for v1: live tailing of a growing file, UTF-16 and other non-UTF-8 encodings, remote sources, compressed files (.gz), and multi-file merge. Each open file is its own tab, with its own index and workers. + +## Architecture + +``` + +------------------------------+ + | Background workers (rayon) | ++--------------------+ | +------------------------+ | +-----------------------------+ +| Log file (mmap) | | | Indexer | | results | Shared results | +| memmap2, read-only |-->| | entry starts, lines | |---------->| entry index (offset, lines) | +| never copied | | +------------------------+ | | visible-entry bitset | ++--------------------+ | | Filter pass | | | search match offsets | + bytes | | aho-corasick, RegexSet | | +-----------------------------+ + | +------------------------+ | | read each frame + | | Search pass | | v + | | regex over raw bytes | | +-----------------------------+ + | +------------------------+ | | UI thread (egui) | + +------------------------------+ | view model, expand state | + ^ | decodes visible rows only | + | | highlights, LayoutJob cache | + | +-----------------------------+ + | | + +------------------------------------------+ + pattern, filter, query + generation (cancels stale work) +``` + +The UI thread never touches more of the file than the rows on screen. Indexing, filtering and searching run as parallel passes over the mapped bytes, publish results as they go, and are cancelled by a generation number whenever the user changes the pattern, filter or query. + +## File access and background indexing + +The file is memory-mapped read-only and never copied; the only thing held in RAM is a compact index of where each entry starts. Every pass over the bytes (index, filter, search) runs on worker threads and publishes partial results, so the UI is usable while they run. + +**Byte source.** A `ByteSource` trait with one method, `bytes() -> &[u8]`, implemented with `memmap2`. Keeping it behind a trait leaves room for a chunked `pread` fallback (see Risks: Windows file locking) and for tailing later. + +**Entry index.** One `Vec` where `EntryRec { offset: u64, lines: u32 }`, 12 bytes per entry. A 500 MB file with 100-byte lines and mostly single-line entries is about 5M entries, or 60 MB. The line count is free during the scan and makes expand-all and the "+N lines" badge cheap. + +**How the scan works.** + +1. Split the file into N chunks (N = CPU cores), each boundary moved forward to the next `\n`. +2. In each chunk, find line starts with `memchr`. For each line, test the entry-start regex against only the first ~128 bytes of that line. +3. A line that matches starts a new entry; a line that does not is a continuation and bumps the current entry's line count. +4. Because the start/continuation decision is local to each line, chunks are independent. Run them with `rayon`, then concatenate in order and fix up the one entry that straddles each chunk boundary. +5. Publish progress (bytes scanned) and the first chunk's entries as soon as they exist, so the first screen renders before the scan finishes. + +**Cancellation.** Every background job carries a generation number. Changing the pattern, filter or search bumps the generation; workers check it between blocks of ~1 MB and drop stale work. + +**Text decoding.** Files are treated as UTF-8, which also covers plain ASCII. Rows are decoded lossily when drawn (`String::from_utf8_lossy`), so a bad byte shows as a replacement character instead of failing. + +## Detecting and editing the entry-start pattern + +The pattern is a regex anchored at line start. Detection picks the best of a fixed set of known formats by scoring them on a sample, falls back to inferring a pattern from line shapes, and always shows the result so the user can correct it. + +**Sample.** The first 2,000 lines plus 500 lines from the middle and 500 from the end of the file, so a header block or a single huge stack trace does not skew the result. + +**Built-in candidates** (tried in this order; more can be added as data in a TOML file): + +| Name | Pattern (anchored with `^`) | Example | +| --- | --- | --- | +| ISO 8601 timestamp | `\[?\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}` | `2026-10-21 05:06:48,123 INFO ...` | +| Syslog | `[A-Z][a-z]{2} [ \d]\d \d{2}:\d{2}:\d{2}` | `Oct 21 05:06:48 host sshd[42]: ...` | +| Apache / nginx access | `\S+ \S+ \S+ \[\d{2}/\w{3}/\d{4}:` | `10.0.0.1 - - [21/Oct/2026:05:06:48 ...` | +| Slash date | `\d{1,2}/\d{1,2}/\d{2,4}[ T]\d{1,2}:\d{2}` | `10/21/2026 5:06:48 AM ...` | +| Time only | `\[?\d{2}:\d{2}:\d{2}` | `05:06:48.123 [main] ...` | +| Level first | `\[?(TRACE\|DEBUG\|INFO\|WARN\|WARNING\|ERROR\|FATAL)\b` | `ERROR [db] connection lost` | +| Epoch seconds | `\d{10}(\.\d+)?\b` | `1792472808.123 ...` | +| JSON lines | `\{` | `{"ts":"...","msg":"..."}` | + +(In the Level-first row, `\|` is only Markdown table escaping; the regex uses plain `|`.) + +**Scoring.** For each candidate, over the sample lines: + +- `coverage` = share of lines that match. +- `false_starts` = matching lines that look like continuations (start with whitespace, `at `, `Caused by`, `}` or `]`). +- `score` = coverage of non-indented lines minus a penalty for false starts. A candidate needs a score above 0.6 to win; ties go to the more specific (earlier) pattern. + +**Fallback inference.** If no candidate wins, map the first 24 bytes of each line to a shape (digit to `d`, letter to `a`, punctuation kept), take the most common shape prefix that covers at least 30% of lines, and turn it into a regex. If that also fails, use "every line not starting with whitespace" (`^\S`), which handles most stack traces. + +**Editing UI.** A bar above the log shows the active pattern by name, for example "Entry start: ISO 8601 timestamp", with an edit button that opens a side panel: + +- A dropdown of the built-in candidates, each with its sample score, plus a free-text regex field. +- A live preview of the first ~40 sample lines with entry boundaries drawn as rules and continuation lines indented, plus "N entries in sample". +- Invalid regex shows the parser's error inline and disables Apply. +- Apply re-runs the indexer (cancelling the old run). The choice is saved per file path, and optionally per file-name glob such as `*.app.log`, so the next open skips detection. + +## Virtualized view and expandable entries + +Only the rows on screen are ever decoded or laid out. Every display row is one physical line of fixed height, which lets egui's `ScrollArea::show_rows` do the virtualization; expansion just changes how many display rows an entry occupies. Line wrap breaks the fixed-height assumption, so it gets its own scrolling mode (below). + +**View model.** + +- `visible: Vec` holds the entry indices that pass the current filter (all entries when no filter is set). +- `expanded: BTreeSet` holds expanded entries, plus an `expand_all` flag. +- A collapsed entry is 1 display row; an expanded one is `lines` rows. +- A prefix-sum array over `visible` maps display row to (entry, line within entry) with a binary search. It is rebuilt only when the filter or the expanded set changes; with few expansions an incremental Fenwick tree avoids a full rebuild on each click. + +**Row rendering.** + +- Each row is a `LayoutJob` with highlight colors applied (next section), cached in an LRU keyed by (entry, line, wrap width, rules generation). +- The first line of a multi-line entry gets a disclosure triangle and a muted "+N lines" badge; continuation lines are indented and drawn in a slightly dimmer color when expanded. +- An optional left gutter shows the entry number or line number. +- Lines longer than 64 KB are cut at that length with a "show full line" action that opens a detail pane, since egui slows down on very long galleys. + +**Line wrap toggle.** A toolbar toggle (Alt+Z) switches wrapping per tab, and the choice is remembered per file. + +- **Wrap off** (default): one fixed-height row per line, horizontal scrolling, `show_rows` virtualization as above. +- **Wrap on:** rows have different heights, and measuring every line in the file to get exact heights would mean a full pass. Instead the scroll position is an anchor, (entry, line, wrapped sub-row), and each frame lays out rows downward from the anchor until the screen is full. Wrapped row counts are only computed for lines that are drawn. +- The scrollbar in wrap mode is a custom widget mapped to byte offset in the file. Dragging it binary-searches the entry index for the new anchor; wheel and keys move the anchor by sub-rows. +- Width changes (window resize) invalidate the layout cache and are debounced by ~100 ms. The anchor entry stays at the top so the view does not jump. + +**Interaction.** Click the triangle or press Space/Right to expand, Left to collapse; a toolbar has Expand all and Collapse all. Ctrl/Cmd+C copies the selected entry (all lines), and a context menu offers "copy line" and "filter out entries like this". Go-to-line maps a line number to its entry with a binary search on byte offsets. + +**Scrollbar during indexing.** Until the index is complete, the total row count is estimated from bytes scanned so far, so the scrollbar is roughly right and settles when the scan finishes. + +## Filter, highlight and search + +All three match against the whole entry (every line), not just its first line. Filter and search run as cancellable background passes over the full file; highlighting runs only on the rows being drawn. + +### Keyword filter + +- A filter bar holds chips, each a rule: **Exclude** (hide entries containing it) or **Only** (show only entries containing it). Each chip has case-sensitive and regex toggles. +- Semantics: an entry is shown if it matches at least one Only rule (or there are none) and no Exclude rule. +- Plain keywords are compiled together into one `aho-corasick` automaton per rule kind, which scans at memory speed regardless of keyword count; regex chips use a `RegexSet`. +- The pass runs with `rayon` over entry ranges and writes a bitset; `visible` is rebuilt from it. Partial results stream in, and the status bar shows "12,408 of 1,203,551 entries (filtering 63%)". +- Typing is debounced by 150 ms; each change bumps the generation and cancels the previous pass. +- The scroll position is kept anchored to the entry at the top of the screen (or the nearest visible one) when the filter changes. + +### Keyword highlighting + +- An ordered list of rules: pattern (keyword or regex), color, and scope, which is either **row** (tint the whole entry's background) or **match** (color only the matched text). +- For a row tint the first matching rule wins; match colors from all rules are applied, later rules drawn under earlier ones. +- Defaults: `ERROR`/`FATAL` red row tint, `WARN` amber row tint. Colors come from a palette that has light and dark variants. +- Rules are evaluated only for visible rows while building the `LayoutJob`, so changing them is instant and needs no full-file pass. +- Rule sets are saved globally and can be overridden per file glob. + +### Regex search + +- A search box (Ctrl/Cmd+F) with toggles for regex, case sensitivity and whole word. Plain-text mode escapes the input. +- Uses `regex::bytes::Regex` over the mapped bytes in parallel chunks, collecting match byte offsets (capped at 1M with a "too many matches" note). Each offset maps to its entry with a binary search on the entry index. +- The status bar shows "match 37 of 1,204" and updates as the scan progresses; Enter / Shift+Enter (and F3) go to the next and previous match. +- Jumping to a match scrolls to its entry, auto-expands it if the match is on a continuation line, and draws the current match in a distinct color; other matches on screen are outlined. +- A match inside an entry hidden by the filter is skipped by default, with a toggle to "search hidden entries too" that temporarily reveals it. +- The `regex` crate has no look-around or backreferences. That is the right trade for guaranteed linear-time scans of large files; `fancy-regex` can be an opt-in later. + +### Importing and exporting rules + +- Filters and highlight rules export to a `.logrules.toml` file, which can also carry an entry-start pattern. TOML keeps it readable and easy to review when a team shares it in a repo. +- The file has a `version` field. Each rule keeps its kind (exclude, only, highlight), pattern, regex and case flags, color and scope. +- Export offers everything, filters only, highlights only, or the selected rules. +- Import comes from a menu item or by dropping the file on the window. It asks whether to **merge** (skip exact duplicates) or **replace**, and whether to apply to this tab or save as the global default. +- Every pattern is compiled on import. Invalid ones are listed with the regex error and skipped, so the rest still load. +- Named rule sets in settings (for example "Java service" or "nginx") are just saved rule files and can be switched from a dropdown. + +## Folder grep + +A separate "Find in files" tab searches every file under a folder and lists matching lines grouped by file. Double-clicking a hit opens that file in a viewer tab, scrolled to the entry that holds the line. + +**Inputs.** Folder picker (or drag a folder in), pattern with regex, case and whole-word toggles, include and exclude globs (default `*.log;*.txt;*.out`), recursive toggle, "respect .gitignore" toggle, skip binary files, and a max file size. + +**Engine.** Built on ripgrep's own libraries rather than a hand-rolled loop: + +- `ignore` walks the folder in parallel and applies globs and ignore files. +- `grep-searcher` and `grep-regex` search each file, using mmap for large files, detecting binary files, and reporting line numbers and byte offsets. + +**Results.** Results stream into a virtualized tree as they arrive: file (with path, match count and size), then its matching lines with the line number and the match highlighted. The header shows "1,284 matches in 37 of 2,910 files" and a cancel button. Matches are capped at 10,000 per file and 1M overall, with a note when a cap is hit. Results can be copied or exported as plain text in `path:line:text` form. + +**Opening a hit.** Opening a result (double-click, or Enter) opens the file in a viewer tab, or reuses the tab if the file is already open. The viewer turns the byte offset into an entry with a binary search on the index, expands the entry if the match is on a continuation line, and fills its search box with the grep pattern, so next and previous keep working inside the file. If indexing has not reached that offset yet, the viewer waits for that chunk and then jumps. + +## Crate choices + +All of these are mature, pure-Rust (or with well-supported native bits) and build on all three platforms. Pin current versions when the project starts. + +| Need | Crate | Why this one | +| --- | --- | --- | +| App shell and UI | `eframe` + `egui` | The requested stack; one binary, native windows on Win/macOS/Linux | +| Tabs, tables, extra widgets | `egui_extras` (+ `egui_dock` if tabs need docking) | Settings and rules panels, file and grep tabs | +| Memory-mapped file | `memmap2` | Maintained successor of `memmap`, cross-platform | +| Newline scanning | `memchr` | SIMD byte search, the fastest way to find line starts | +| Regex | `regex` (bytes API) | Linear-time guarantee, works on `&[u8]` without UTF-8 validation | +| Multi-keyword match | `aho-corasick` | One pass for any number of filter keywords | +| Parallel passes | `rayon` | Chunked parallel index, filter and search | +| Worker messages | `crossbeam-channel` | Progress and partial results from workers to the UI | +| Folder walk | `ignore` | ripgrep's parallel walker with globs and .gitignore | +| Folder grep | `grep-searcher` + `grep-regex` | ripgrep's search core: mmap, binary detection, line numbers | +| File dialogs | `rfd` | Native open dialogs on all three platforms | +| Settings and rule files | `serde` + `toml` + `directories` | Human-editable config and `.logrules.toml` files in OS-standard folders | +| Row layout cache | `lru` | Bounded cache of `LayoutJob`s | +| Errors and logging | `anyhow`, `thiserror`, `tracing` | Standard choices | +| Later: tailing | `notify` | File-change events for live tail | +| Later: encodings | `encoding_rs` | UTF-16 and legacy code pages | +| Packaging | `cargo-dist` or `cargo-bundle` | Installers, .app bundle, and a GitHub Actions release matrix | + +Benchmarks use `criterion` with generated fixture files (100 MB, 1 GB; short lines, long lines, heavy stack traces) and a generated folder of 1,000 files for grep. + +## Phased milestones + +Nine phases, each ending in something usable. Phases 1 to 3 come first in order; phases 4 to 8 depend only on them and can be reordered, except that folder grep (8) reuses search (5). + +1. **Skeleton and big-file viewing.** eframe app with a tab per open file; open via dialog, drag-and-drop and command-line argument; `memmap2` source; a plain line view (each line is an entry) using `show_rows`; recent files. + - Exit: a 1 GB file opens in under 1 s and scrolls at 60 fps on a mid-range laptop. +2. **Entry index and expandable entries.** Parallel background indexer with a hard-coded ISO-timestamp pattern, progress bar, cancellation; view model with expand/collapse, expand all, "+N lines" badges, copy entry. + - Exit: 1 GB indexed in under 5 s; UI stays responsive during the scan. +3. **Auto-detection and pattern editor.** Sampling, candidate scoring, shape-based fallback, side panel with live preview, per-path persistence. + - Exit: correct detection on a fixture set of at least 10 real log formats (app, syslog, nginx, Java with stack traces, .NET, JSON lines). +4. **Line wrap.** Wrap toggle with anchor-based scrolling, the byte-offset scrollbar, and debounced relayout on resize. + - Exit: wrapped scrolling through a 1 GB file stays at 60 fps. +5. **Regex search.** Search box, parallel scan, match list, next/previous with auto-expand, match coloring. +6. **Keyword filter.** Filter chips, aho-corasick and `RegexSet` pass, bitset, streaming results, scroll anchoring. +7. **Highlight rules, settings and rule files.** Rules panel, row and match scopes, light and dark palettes, settings file, `.logrules.toml` import and export with merge or replace, named rule sets. +8. **Folder grep.** Find-in-files tab on `ignore` + `grep-searcher`, streaming result tree, caps and cancel, open a hit in a viewer tab at the right entry. + - Exit: greps a 2 GB folder of 1,000 logs in under 5 s on SSD with a warm cache. +9. **Polish and release.** Keyboard map, go-to-line, error states (file deleted, permission denied), signed and notarized macOS build, Windows installer, Linux AppImage or tarball via a CI release matrix. + +After v1, the likely next items are live tailing, UTF-16 and other encodings, opening .gz files, merging several files into one timeline, remote sources (SSH, cloud logs), and a minimap of highlight and match positions beside the scrollbar. + +## Risks and open questions + +| Risk | Impact | Mitigation | +| --- | --- | --- | +| Windows: a mapped file cannot be truncated by its writer | An app that rotates its log by truncation gets an error while the viewer has that file open | Acceptable for a viewer of finished logs; the `pread` source behind `ByteSource` stays available if it ever bites | +| Unix: file truncated while mapped | Reading past the new end raises SIGBUS and crashes the app | Check file size on focus and before each pass; on shrink, remap and reindex | +| Wrap mode on huge entries | Laying out a multi-MB entry stalls a frame | 64 KB line cap plus the detail pane; lay out only the rows on screen | +| Files with tiny lines (e.g. 20 bytes) | 1 GB becomes ~50M entries, 600 MB of index | Store offsets as u32 deltas per 4 GB block (8 bytes per entry), or page the index | +| Folder grep on huge trees | Long runs, too many results to hold | Streaming results, caps, cancel, and default include globs | +| Pattern detection picks wrong format | Entries merged or split | Always show the active pattern and make it one click to change | +| macOS distribution | Unsigned apps are blocked by Gatekeeper | Budget an Apple developer account and notarization in phase 9 | + +Open questions: + +- [x] Should grep results show only the matching line, or also the first line of the entry it belongs to? Answer: Matching line only. +- [x] Should rule files also be loadable from a fixed team folder or URL, not just by import? Answer: File import/export only. diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..c775577 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,2 @@ +max_width = 120 +use_small_heuristics = "Max" diff --git a/src/grep.rs b/src/grep.rs new file mode 100644 index 0000000..c67f5b1 --- /dev/null +++ b/src/grep.rs @@ -0,0 +1,282 @@ +//! Find in files: ripgrep's walker and searcher over a folder. + +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex}; + +use anyhow::{Context, Result}; +use grep_regex::RegexMatcherBuilder; +use grep_searcher::{BinaryDetection, MmapChoice, Searcher, SearcherBuilder, Sink, SinkMatch}; +use ignore::overrides::OverrideBuilder; +use ignore::{WalkBuilder, WalkState}; + +use crate::job::{Notify, Token}; +use crate::passes::SearchQuery; + +pub const MAX_PER_FILE: usize = 10_000; +pub const MAX_TOTAL: usize = 1_000_000; +const MAX_LINE_SHOWN: usize = 1000; + +#[derive(Clone, Debug)] +pub struct GrepOptions { + pub folder: PathBuf, + pub query: SearchQuery, + /// `;`-separated globs, e.g. `*.log;*.txt;*.out`. Empty = every file. + pub include: String, + pub exclude: String, + pub recursive: bool, + pub respect_gitignore: bool, + pub skip_binary: bool, + /// In MB; 0 = no limit. + pub max_file_mb: u64, +} + +impl Default for GrepOptions { + fn default() -> Self { + Self { + folder: PathBuf::new(), + query: SearchQuery::default(), + include: "*.log;*.txt;*.out".into(), + exclude: String::new(), + recursive: true, + respect_gitignore: true, + skip_binary: true, + max_file_mb: 0, + } + } +} + +#[derive(Clone, Debug)] +pub struct Hit { + pub line_number: u64, + pub offset: u64, + pub text: String, + /// Byte ranges of matches within `text`. + pub ranges: Vec>, +} + +#[derive(Clone, Debug)] +pub struct FileResult { + pub path: PathBuf, + pub size: u64, + pub hits: Vec, + pub truncated: bool, +} + +#[derive(Default)] +pub struct GrepShared { + pub results: Mutex>, + pub files_searched: AtomicUsize, + pub total_matches: AtomicUsize, + pub capped: AtomicBool, + pub done: AtomicBool, + pub errors: Mutex>, +} + +impl GrepShared { + pub fn is_done(&self) -> bool { + self.done.load(Ordering::Acquire) + } +} + +fn globs(spec: &str) -> impl Iterator { + spec.split([';', ',']).map(str::trim).filter(|g| !g.is_empty()) +} + +pub fn spawn(opts: GrepOptions, token: Token, notify: Notify) -> Result> { + let source = opts.query.regex_source(); + let matcher = RegexMatcherBuilder::new() + .case_insensitive(!opts.query.case_sensitive) + .line_terminator(Some(b'\n')) + .build(&source) + .context("invalid pattern")?; + let display_re = regex::RegexBuilder::new(&source).case_insensitive(!opts.query.case_sensitive).build()?; + + let mut ob = OverrideBuilder::new(&opts.folder); + for g in globs(&opts.include) { + ob.add(g).with_context(|| format!("bad include glob {g}"))?; + } + for g in globs(&opts.exclude) { + ob.add(&format!("!{g}")).with_context(|| format!("bad exclude glob {g}"))?; + } + let overrides = ob.build()?; + + let mut wb = WalkBuilder::new(&opts.folder); + wb.overrides(overrides) + .max_depth(if opts.recursive { None } else { Some(1) }) + .git_ignore(opts.respect_gitignore) + .git_exclude(opts.respect_gitignore) + .git_global(opts.respect_gitignore) + .ignore(opts.respect_gitignore) + .parents(opts.respect_gitignore) + .require_git(false) + .max_filesize((opts.max_file_mb > 0).then_some(opts.max_file_mb * 1024 * 1024)); + let walker = wb.build_parallel(); + + let shared = Arc::new(GrepShared::default()); + let out = shared.clone(); + let skip_binary = opts.skip_binary; + std::thread::Builder::new().name("grep".into()).spawn(move || { + walker.run(|| { + let matcher = matcher.clone(); + let display_re = display_re.clone(); + let out = out.clone(); + let token = token.clone(); + let notify = notify.clone(); + let mut searcher = SearcherBuilder::new() + .line_number(true) + .binary_detection(if skip_binary { BinaryDetection::quit(0) } else { BinaryDetection::none() }) + // SAFETY: files are only read; a file truncated mid-search can fault, + // which ripgrep accepts for the same reason. + .memory_map(unsafe { MmapChoice::auto() }) + .build(); + Box::new(move |entry| { + if token.cancelled() || out.capped.load(Ordering::Relaxed) { + return WalkState::Quit; + } + let entry = match entry { + Ok(e) => e, + Err(e) => { + out.errors.lock().unwrap().push(e.to_string()); + return WalkState::Continue; + } + }; + if !entry.file_type().is_some_and(|t| t.is_file()) { + return WalkState::Continue; + } + let path = entry.path(); + let mut sink = HitSink { re: &display_re, hits: Vec::new(), truncated: false, out: &out }; + if let Err(e) = searcher.search_path(&matcher, path, &mut sink) { + out.errors.lock().unwrap().push(format!("{}: {e}", path.display())); + } + out.files_searched.fetch_add(1, Ordering::Relaxed); + if !sink.hits.is_empty() { + let size = entry.metadata().map(|m| m.len()).unwrap_or(0); + let res = FileResult { path: path.to_path_buf(), size, truncated: sink.truncated, hits: sink.hits }; + out.results.lock().unwrap().push(res); + notify(); + } + WalkState::Continue + }) + }); + out.done.store(true, Ordering::Release); + notify(); + })?; + Ok(shared) +} + +struct HitSink<'a> { + re: &'a regex::Regex, + hits: Vec, + truncated: bool, + out: &'a GrepShared, +} + +impl Sink for HitSink<'_> { + type Error = std::io::Error; + + fn matched(&mut self, _s: &Searcher, m: &SinkMatch<'_>) -> Result { + if self.hits.len() >= MAX_PER_FILE { + self.truncated = true; + return Ok(false); + } + if self.out.total_matches.fetch_add(1, Ordering::Relaxed) >= MAX_TOTAL { + self.out.capped.store(true, Ordering::Relaxed); + return Ok(false); + } + let mut line = m.bytes(); + while let Some((b'\n' | b'\r', rest)) = line.split_last() { + line = rest; + } + let shown = &line[..line.len().min(MAX_LINE_SHOWN)]; + let text = String::from_utf8_lossy(shown).into_owned(); + let ranges = self.re.find_iter(&text).filter(|x| !x.is_empty()).map(|x| x.range()).collect(); + self.hits.push(Hit { + line_number: m.line_number().unwrap_or(0), + offset: m.absolute_byte_offset(), + text, + ranges, + }); + Ok(true) + } +} + +/// Plain text export in `path:line:text` form. +pub fn export_text(results: &[FileResult]) -> String { + let mut s = String::new(); + for f in results { + for h in &f.hits { + s.push_str(&format!("{}:{}:{}\n", f.path.display(), h.line_number, h.text)); + } + } + s +} + +pub fn display_path<'a>(root: &Path, path: &'a Path) -> std::borrow::Cow<'a, str> { + path.strip_prefix(root).unwrap_or(path).to_string_lossy() +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::job::{Generation, no_notify}; + + #[test] + fn greps_a_folder() { + let dir = tempfile::tempdir().unwrap(); + std::fs::write(dir.path().join("a.log"), "one\nneedle here\nthree\n").unwrap(); + std::fs::write(dir.path().join("b.txt"), "Needle\n").unwrap(); + std::fs::write(dir.path().join("c.bin"), "needle\n").unwrap(); + std::fs::create_dir(dir.path().join("sub")).unwrap(); + std::fs::write(dir.path().join("sub/d.log"), "x\ny\nneedle needle\n").unwrap(); + + let opts = GrepOptions { + folder: dir.path().into(), + query: SearchQuery { text: "needle".into(), ..Default::default() }, + ..Default::default() + }; + let shared = spawn(opts, Generation::new().bump(), no_notify()).unwrap(); + while !shared.is_done() { + std::thread::sleep(std::time::Duration::from_millis(5)); + } + let mut res = shared.results.lock().unwrap().clone(); + res.sort_by(|a, b| a.path.cmp(&b.path)); + assert_eq!(res.len(), 3); + assert_eq!(res[0].hits[0].line_number, 2); + assert_eq!(res[0].hits[0].offset, 4); + assert_eq!(res[2].hits[0].ranges.len(), 2); + assert_eq!(shared.files_searched.load(Ordering::Relaxed), 3); + } +} + +#[cfg(test)] +mod timing { + use super::*; + use crate::job::{Generation, no_notify}; + + /// `LOGREADLITE_GREP_DIR= cargo test --release grep_timing -- --ignored --nocapture` + #[test] + #[ignore] + fn grep_timing() { + let dir = std::env::var("LOGREADLITE_GREP_DIR").expect("set LOGREADLITE_GREP_DIR"); + let opts = GrepOptions { + folder: dir.into(), + query: SearchQuery { text: r"Handler2\d\.handle".into(), regex: true, ..Default::default() }, + ..Default::default() + }; + let t = std::time::Instant::now(); + let shared = spawn(opts, Generation::new().bump(), no_notify()).unwrap(); + while !shared.is_done() { + std::thread::sleep(std::time::Duration::from_millis(2)); + } + let files = shared.results.lock().unwrap(); + let hits: usize = files.iter().map(|f| f.hits.len()).sum(); + println!( + "{} hits in {} of {} files in {:.2?}", + hits, + files.len(), + shared.files_searched.load(Ordering::Relaxed), + t.elapsed() + ); + } +} diff --git a/src/index.rs b/src/index.rs new file mode 100644 index 0000000..22b7401 --- /dev/null +++ b/src/index.rs @@ -0,0 +1,246 @@ +//! The entry index: where each entry starts and how many lines it has. +//! +//! The scan splits the file into chunks at line boundaries and runs them on the +//! rayon pool. Whether a line starts an entry depends only on that line, so the +//! chunks are independent; the only fix-up is that continuation lines at the +//! start of a chunk belong to the last entry of the previous chunk. Chunks are +//! handed out in file order and published as an in-order prefix, so the first +//! screen can render long before the scan finishes. + +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::{Arc, RwLock}; + +use regex::bytes::Regex; + +use crate::job::{CHECK_EVERY, Notify, Token, ordered_parallel}; +use crate::pattern::MATCH_PREFIX; +use crate::source::ByteSource; + +const CHUNK_SIZE: usize = 8 << 20; + +/// Entry starts and line counts, stored as two parallel arrays (12 bytes per entry). +#[derive(Default, Clone)] +pub struct EntryIndex { + pub offsets: Vec, + pub lines: Vec, +} + +impl EntryIndex { + pub fn len(&self) -> usize { + self.offsets.len() + } + + pub fn is_empty(&self) -> bool { + self.offsets.is_empty() + } + + /// Byte range of entry `i`; `file_len` closes the last entry. + pub fn range(&self, i: usize, file_len: u64) -> std::ops::Range { + let start = self.offsets[i] as usize; + let end = self.offsets.get(i + 1).copied().unwrap_or(file_len) as usize; + start..end + } + + /// The entry containing byte `offset`. + pub fn entry_at(&self, offset: u64) -> Option { + let p = self.offsets.partition_point(|&o| o <= offset); + p.checked_sub(1) + } + + fn push_chunk(&mut self, chunk: ChunkResult) { + if chunk.lead_lines > 0 { + match self.lines.last_mut() { + Some(last) => *last = last.saturating_add(chunk.lead_lines), + None => { + // The file starts with lines that match nothing; they form the first entry. + self.offsets.push(chunk.start); + self.lines.push(chunk.lead_lines); + } + } + } + self.offsets.extend_from_slice(&chunk.offsets); + self.lines.extend_from_slice(&chunk.lines); + } +} + +/// The index as seen by the UI while a scan is running. +pub struct SharedIndex { + pub index: RwLock, + /// Bytes covered by the published prefix of the index. + pub bytes_done: AtomicU64, + pub total_bytes: u64, + pub done: AtomicBool, + /// Wall time of the scan in microseconds, set when it completes. + pub elapsed_us: AtomicU64, +} + +impl SharedIndex { + pub fn new(total_bytes: u64) -> Self { + Self { + index: RwLock::new(EntryIndex::default()), + bytes_done: AtomicU64::new(0), + total_bytes, + done: AtomicBool::new(total_bytes == 0), + elapsed_us: AtomicU64::new(0), + } + } + + pub fn is_done(&self) -> bool { + self.done.load(Ordering::Acquire) + } + + pub fn progress(&self) -> f32 { + if self.total_bytes == 0 { + 1.0 + } else { + self.bytes_done.load(Ordering::Relaxed) as f32 / self.total_bytes as f32 + } + } +} + +struct ChunkResult { + start: u64, + lead_lines: u32, + offsets: Vec, + lines: Vec, +} + +/// Chunk boundaries, each moved forward to the next line start. +pub fn chunk_bounds(bytes: &[u8], chunk_size: usize) -> Vec { + let mut bounds = vec![0]; + let mut pos = chunk_size; + while pos < bytes.len() { + match memchr::memchr(b'\n', &bytes[pos..]) { + Some(p) if pos + p + 1 < bytes.len() => { + bounds.push(pos + p + 1); + pos = pos + p + 1 + chunk_size; + } + _ => break, + } + } + bounds.push(bytes.len()); + bounds +} + +/// Scans one chunk. Returns `None` if the job was cancelled. +fn scan_chunk(bytes: &[u8], start: usize, end: usize, re: &Regex, token: &Token) -> Option { + let mut res = ChunkResult { start: start as u64, lead_lines: 0, offsets: Vec::new(), lines: Vec::new() }; + let mut line_start = start; + let mut next_check = start + CHECK_EVERY; + while line_start < end { + let line_end = memchr::memchr(b'\n', &bytes[line_start..end]).map(|p| line_start + p).unwrap_or(end); + let prefix = &bytes[line_start..line_end.min(line_start + MATCH_PREFIX)]; + if re.is_match(prefix) { + res.offsets.push(line_start as u64); + res.lines.push(1); + } else if let Some(last) = res.lines.last_mut() { + *last = last.saturating_add(1); + } else { + res.lead_lines += 1; + } + line_start = line_end + 1; + if line_start >= next_check { + if token.cancelled() { + return None; + } + next_check = line_start + CHECK_EVERY; + } + } + Some(res) +} + +/// Builds the index on the rayon pool, publishing into `shared` as it goes. +/// Blocks until done or cancelled; call it from a worker thread. +pub fn build(src: &dyn ByteSource, re: &Regex, shared: &SharedIndex, token: &Token, notify: &Notify) { + build_with_chunk(src, re, shared, token, notify, CHUNK_SIZE) +} + +pub fn build_with_chunk( + src: &dyn ByteSource, + re: &Regex, + shared: &SharedIndex, + token: &Token, + notify: &Notify, + chunk_size: usize, +) { + let started = std::time::Instant::now(); + let bytes = src.bytes(); + let bounds = chunk_bounds(bytes, chunk_size); + ordered_parallel( + bounds.len() - 1, + token, + |i| scan_chunk(bytes, bounds[i], bounds[i + 1], re, token), + |i, chunk| { + shared.index.write().unwrap().push_chunk(chunk); + shared.bytes_done.store(bounds[i + 1] as u64, Ordering::Relaxed); + notify(); + }, + ); + + if !token.cancelled() { + shared.elapsed_us.store(started.elapsed().as_micros() as u64, Ordering::Relaxed); + shared.done.store(true, Ordering::Release); + notify(); + } +} + +/// Spawns `build` on a dedicated thread and returns the shared index right away. +pub fn spawn(src: Arc, re: Regex, token: Token, notify: Notify) -> Arc { + let shared = Arc::new(SharedIndex::new(src.len())); + let out = shared.clone(); + std::thread::Builder::new() + .name("indexer".into()) + .spawn(move || build(&*src, &re, &out, &token, ¬ify)) + .expect("spawn indexer thread"); + shared +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::job::no_notify; + use crate::pattern::compile_anchored; + use crate::source::VecSource; + + fn index(text: &str, pat: &str, chunk: usize) -> EntryIndex { + let src = VecSource(text.as_bytes().to_vec()); + let shared = SharedIndex::new(src.len()); + let re = compile_anchored(pat).unwrap(); + build_with_chunk(&src, &re, &shared, &Token::detached(), &no_notify(), chunk); + assert!(shared.is_done()); + shared.index.into_inner().unwrap() + } + + #[test] + fn groups_continuations() { + let text = "A one\n two\n three\nA four\nA five\n six"; + for chunk in [1, 3, 7, 1000] { + let idx = index(text, "A", chunk); + assert_eq!(idx.offsets, vec![0, 20, 27], "chunk {chunk}"); + assert_eq!(idx.lines, vec![3, 1, 2], "chunk {chunk}"); + } + } + + #[test] + fn leading_continuations_form_first_entry() { + let text = "header\nmore\nA one\n"; + let idx = index(text, "A", 4); + assert_eq!(idx.offsets, vec![0, 12]); + assert_eq!(idx.lines, vec![2, 1]); + } + + #[test] + fn every_line_pattern() { + let idx = index("a\nb\n\nc\n", "", 2); + assert_eq!(idx.offsets, vec![0, 2, 4, 5]); + assert_eq!(idx.lines, vec![1, 1, 1, 1]); + assert_eq!(idx.entry_at(3), Some(1)); + assert_eq!(idx.entry_at(100), Some(3)); + } + + #[test] + fn empty_file() { + let idx = index("", "A", 4); + assert!(idx.is_empty()); + } +} diff --git a/src/job.rs b/src/job.rs new file mode 100644 index 0000000..025556e --- /dev/null +++ b/src/job.rs @@ -0,0 +1,93 @@ +//! Cancellation and progress plumbing shared by every background pass. + +use std::sync::Arc; +use std::sync::atomic::{AtomicU64, Ordering}; + +/// Wakes the UI when a worker has published something new. +pub type Notify = Arc; + +pub fn no_notify() -> Notify { + Arc::new(|| {}) +} + +/// A generation counter. Bumping it cancels every job started with an older value. +#[derive(Clone, Default)] +pub struct Generation(Arc); + +impl Generation { + pub fn new() -> Self { + Self::default() + } + + /// Cancels running jobs and returns a token for a new one. + pub fn bump(&self) -> Token { + let generation = self.0.fetch_add(1, Ordering::SeqCst) + 1; + Token { generation, current: self.0.clone() } + } + + pub fn cancel(&self) { + self.0.fetch_add(1, Ordering::SeqCst); + } +} + +#[derive(Clone)] +pub struct Token { + generation: u64, + current: Arc, +} + +impl Token { + pub fn cancelled(&self) -> bool { + self.current.load(Ordering::Relaxed) != self.generation + } + + /// A token that is never cancelled, for tests and synchronous calls. + pub fn detached() -> Self { + Self { generation: 0, current: Arc::new(AtomicU64::new(0)) } + } +} + +/// Workers check for cancellation after roughly this many bytes. +pub const CHECK_EVERY: usize = 1 << 20; + +/// Runs `work(i)` for chunks `0..n` on the rayon pool, handing chunks out in +/// order, and calls `publish(i, result)` strictly in order as soon as each +/// in-order prefix is complete. `work` returns `None` when cancelled. +pub fn ordered_parallel( + n: usize, + token: &Token, + work: impl Fn(usize) -> Option + Sync, + publish: impl FnMut(usize, T) + Send, +) { + use std::sync::Mutex; + use std::sync::atomic::AtomicUsize; + + let slots: Vec>> = (0..n).map(|_| Mutex::new(None)).collect(); + let next_chunk = AtomicUsize::new(0); + let publisher = Mutex::new((0usize, publish)); + let workers = rayon::current_num_threads().min(n).max(1); + rayon::scope(|s| { + for _ in 0..workers { + s.spawn(|_| { + loop { + let i = next_chunk.fetch_add(1, Ordering::Relaxed); + if i >= n || token.cancelled() { + return; + } + let Some(res) = work(i) else { return }; + *slots[i].lock().unwrap() = Some(res); + let mut guard = publisher.lock().unwrap(); + let (next, publish) = &mut *guard; + while *next < n { + let Some(r) = slots[*next].lock().unwrap().take() else { break }; + if token.cancelled() { + return; + } + publish(*next, r); + *next += 1; + } + } + }); + } + }); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..ccee1b5 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,16 @@ +//! logreadlite: a fast viewer for large log files. +//! +//! The modules here hold everything that does not draw: file access, the entry +//! index, pattern detection, filter/search passes, rules and folder grep. The +//! `ui` module holds the egui front end. + +pub mod grep; +pub mod index; +pub mod job; +pub mod passes; +pub mod pattern; +pub mod rowmap; +pub mod rules; +pub mod settings; +pub mod source; +pub mod ui; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..28aa285 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,16 @@ +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +use std::path::PathBuf; + +fn main() -> eframe::Result { + let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); + let options = eframe::NativeOptions { + viewport: egui::ViewportBuilder::default() + .with_title("logreadlite") + .with_inner_size([1200.0, 800.0]) + .with_min_inner_size([480.0, 320.0]) + .with_drag_and_drop(true), + ..Default::default() + }; + eframe::run_native("logreadlite", options, Box::new(move |cc| Ok(Box::new(logreadlite::ui::App::new(cc, args))))) +} diff --git a/src/passes.rs b/src/passes.rs new file mode 100644 index 0000000..18f13ee --- /dev/null +++ b/src/passes.rs @@ -0,0 +1,268 @@ +//! Background filter and search passes over the whole file. + +use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; +use std::sync::{Arc, RwLock}; + +use regex::bytes::{Regex, RegexBuilder}; + +use crate::index::{SharedIndex, chunk_bounds}; +use crate::job::{Notify, Token, ordered_parallel}; +use crate::rules::CompiledFilter; +use crate::source::ByteSource; + +// ----- filter ----- + +const FILTER_BLOCK: usize = 32 * 1024; + +pub struct SharedFilter { + /// Sorted indices of the entries that pass, for the processed prefix. + pub visible: RwLock>, + pub entries_done: AtomicUsize, + pub total_entries: usize, + pub done: AtomicBool, +} + +impl SharedFilter { + pub fn progress(&self) -> f32 { + if self.total_entries == 0 { + 1.0 + } else { + self.entries_done.load(Ordering::Relaxed) as f32 / self.total_entries as f32 + } + } + + pub fn is_done(&self) -> bool { + self.done.load(Ordering::Acquire) + } +} + +/// Runs the filter over a finished index on a worker thread. +pub fn spawn_filter( + src: Arc, + index: Arc, + filter: CompiledFilter, + token: Token, + notify: Notify, +) -> Arc { + let total_entries = index.index.read().unwrap().len(); + let shared = Arc::new(SharedFilter { + visible: RwLock::new(Vec::new()), + entries_done: AtomicUsize::new(0), + total_entries, + done: AtomicBool::new(false), + }); + let out = shared.clone(); + std::thread::Builder::new() + .name("filter".into()) + .spawn(move || run_filter(&*src, &index, &filter, &out, &token, ¬ify)) + .expect("spawn filter thread"); + shared +} + +pub fn run_filter( + src: &dyn ByteSource, + index: &SharedIndex, + filter: &CompiledFilter, + out: &SharedFilter, + token: &Token, + notify: &Notify, +) { + let idx = index.index.read().unwrap(); + let bytes = src.bytes(); + let n = idx.len(); + let blocks = n.div_ceil(FILTER_BLOCK); + ordered_parallel( + blocks, + token, + |b| { + let start = b * FILTER_BLOCK; + let end = (start + FILTER_BLOCK).min(n); + let mut keep = Vec::new(); + for i in start..end { + if filter.shows(&bytes[idx.range(i, bytes.len() as u64)]) { + keep.push(i as u32); + } + if i % 4096 == 0 && token.cancelled() { + return None; + } + } + Some((end, keep)) + }, + |_, (end, keep)| { + out.visible.write().unwrap().extend_from_slice(&keep); + out.entries_done.store(end, Ordering::Relaxed); + notify(); + }, + ); + if !token.cancelled() { + out.done.store(true, Ordering::Release); + notify(); + } +} + +// ----- search ----- + +pub const MAX_MATCHES: usize = 1_000_000; +const SEARCH_CHUNK: usize = 4 << 20; + +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct SearchQuery { + pub text: String, + pub regex: bool, + pub case_sensitive: bool, + pub whole_word: bool, +} + +impl SearchQuery { + pub fn regex_source(&self) -> String { + let body = if self.regex { self.text.clone() } else { regex::escape(&self.text) }; + if self.whole_word { format!(r"\b(?:{body})\b") } else { body } + } + + pub fn compile(&self) -> Result { + RegexBuilder::new(&self.regex_source()).case_insensitive(!self.case_sensitive).build() + } +} + +/// A match: byte offset and length. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub struct Match { + pub offset: u64, + pub len: u32, +} + +impl Match { + pub fn end(&self) -> u64 { + self.offset + self.len as u64 + } +} + +pub struct SharedSearch { + /// Sorted by offset. + pub matches: RwLock>, + pub bytes_done: AtomicU64, + pub total_bytes: u64, + pub done: AtomicBool, + pub capped: AtomicBool, +} + +impl SharedSearch { + pub fn progress(&self) -> f32 { + if self.total_bytes == 0 { + 1.0 + } else { + self.bytes_done.load(Ordering::Relaxed) as f32 / self.total_bytes as f32 + } + } + + pub fn is_done(&self) -> bool { + self.done.load(Ordering::Acquire) + } + + /// Matches overlapping the byte range `start..end`. + pub fn in_range(&self, start: u64, end: u64) -> Vec { + let m = self.matches.read().unwrap(); + let first = m.partition_point(|x| x.end() <= start); + m[first..].iter().take_while(|x| x.offset < end).copied().collect() + } +} + +pub fn spawn_search(src: Arc, re: Regex, token: Token, notify: Notify) -> Arc { + let shared = Arc::new(SharedSearch { + matches: RwLock::new(Vec::new()), + bytes_done: AtomicU64::new(0), + total_bytes: src.len(), + done: AtomicBool::new(false), + capped: AtomicBool::new(false), + }); + let out = shared.clone(); + std::thread::Builder::new() + .name("search".into()) + .spawn(move || run_search(&*src, &re, &out, &token, ¬ify)) + .expect("spawn search thread"); + shared +} + +pub fn run_search(src: &dyn ByteSource, re: &Regex, out: &SharedSearch, token: &Token, notify: &Notify) { + let bytes = src.bytes(); + let bounds = chunk_bounds(bytes, SEARCH_CHUNK); + let found = AtomicUsize::new(0); + ordered_parallel( + bounds.len() - 1, + token, + |i| { + if found.load(Ordering::Relaxed) >= MAX_MATCHES { + return Some(Vec::new()); + } + let (start, end) = (bounds[i], bounds[i + 1]); + let mut v = Vec::new(); + for m in re.find_iter(&bytes[start..end]) { + if m.is_empty() { + continue; + } + v.push(Match { offset: (start + m.start()) as u64, len: m.len() as u32 }); + } + found.fetch_add(v.len(), Ordering::Relaxed); + Some(v) + }, + |i, v| { + let mut all = out.matches.write().unwrap(); + let room = MAX_MATCHES.saturating_sub(all.len()); + if v.len() > room { + out.capped.store(true, Ordering::Relaxed); + } + all.extend(v.into_iter().take(room)); + drop(all); + out.bytes_done.store(bounds[i + 1] as u64, Ordering::Relaxed); + notify(); + }, + ); + if !token.cancelled() { + out.done.store(true, Ordering::Release); + notify(); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::job::no_notify; + use crate::pattern::compile_anchored; + use crate::rules::{Rule, RuleKind}; + use crate::source::VecSource; + + #[test] + fn filter_whole_entries() { + let src: Arc = Arc::new(VecSource(b"A ok\n detail error\nA fine\nA error\n".to_vec())); + let index = Arc::new(SharedIndex::new(src.len())); + crate::index::build(&*src, &compile_anchored("A").unwrap(), &index, &Token::detached(), &no_notify()); + let f = CompiledFilter::new(&[Rule::filter(RuleKind::Exclude, "error")]); + let out = SharedFilter { + visible: RwLock::new(Vec::new()), + entries_done: AtomicUsize::new(0), + total_entries: 3, + done: AtomicBool::new(false), + }; + run_filter(&*src, &index, &f, &out, &Token::detached(), &no_notify()); + assert_eq!(*out.visible.read().unwrap(), vec![1]); + assert!(out.is_done()); + } + + #[test] + fn search_finds_offsets() { + let src = VecSource(b"foo bar\nbaz FOO\nfoofoo\n".to_vec()); + let q = SearchQuery { text: "foo".into(), whole_word: true, ..Default::default() }; + let out = SharedSearch { + matches: RwLock::new(Vec::new()), + bytes_done: AtomicU64::new(0), + total_bytes: src.len(), + done: AtomicBool::new(false), + capped: AtomicBool::new(false), + }; + run_search(&src, &q.compile().unwrap(), &out, &Token::detached(), &no_notify()); + let offs: Vec = out.matches.read().unwrap().iter().map(|m| m.offset).collect(); + assert_eq!(offs, vec![0, 12]); + assert_eq!(out.in_range(1, 13).len(), 2); + assert_eq!(out.in_range(3, 12).len(), 0); + } +} diff --git a/src/pattern.rs b/src/pattern.rs new file mode 100644 index 0000000..dee6d83 --- /dev/null +++ b/src/pattern.rs @@ -0,0 +1,362 @@ +//! Entry-start patterns: built-in candidates, auto-detection and compilation. +//! +//! A pattern is a regex anchored at line start. A line that matches starts a +//! new entry; a line that does not is a continuation of the current entry. + +use std::collections::HashMap; + +use regex::bytes::Regex; +use serde::{Deserialize, Serialize}; + +/// Only this many bytes of each line are tested against the entry-start regex. +pub const MATCH_PREFIX: usize = 128; + +/// Minimum score a built-in candidate needs to win detection. +pub const MIN_SCORE: f32 = 0.6; + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct PatternDef { + pub name: String, + /// Regex source without the leading `^`; the anchor is added on compile. + pub regex: String, +} + +impl PatternDef { + pub fn new(name: &str, regex: &str) -> Self { + Self { name: name.to_string(), regex: regex.to_string() } + } + + pub fn compile(&self) -> Result { + compile_anchored(&self.regex) + } +} + +pub fn compile_anchored(src: &str) -> Result { + Regex::new(&format!("^(?:{src})")) +} + +/// The built-in candidates, in priority order (earlier = more specific). +pub fn builtin_candidates() -> Vec { + vec![ + PatternDef::new("ISO 8601 timestamp", r"\[?\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}"), + PatternDef::new("Syslog", r"[A-Z][a-z]{2} [ \d]\d \d{2}:\d{2}:\d{2}"), + PatternDef::new("Apache / nginx access", r"\S+ \S+ \S+ \[\d{2}/\w{3}/\d{4}:"), + PatternDef::new("Slash date", r"\d{1,2}/\d{1,2}/\d{2,4}[ T]\d{1,2}:\d{2}"), + PatternDef::new("Time only", r"\[?\d{2}:\d{2}:\d{2}"), + PatternDef::new("Level first", r"\[?(TRACE|DEBUG|INFO|WARN|WARNING|ERROR|FATAL)\b"), + PatternDef::new("Epoch seconds", r"\d{10}(\.\d+)?\b"), + PatternDef::new("JSON lines", r"\{"), + ] +} + +pub fn every_non_indented_line() -> PatternDef { + PatternDef::new("Every line not starting with whitespace", r"\S") +} + +/// One line per entry; used for the plain line view and as a last resort. +pub fn every_line() -> PatternDef { + PatternDef::new("Every line", "") +} + +/// Lines that look like the continuation of a previous entry. +pub fn looks_like_continuation(line: &[u8]) -> bool { + match line.first() { + None => true, + Some(b' ' | b'\t' | b'}' | b']') => true, + _ => { + line.starts_with(b"at ") + || line.starts_with(b"Caused by") + || line.starts_with(b"Traceback ") + || is_exception_line(line) + } + } +} + +/// `java.lang.IllegalStateException: ...`, `ValueError: bad` and the like: +/// the unindented header of a stack trace. +fn is_exception_line(line: &[u8]) -> bool { + let head = line.split(|&b| b == b':' || b == b' ').next().unwrap_or(b""); + head.len() > 5 && [&b"Exception"[..], b"Error", b"Throwable"].iter().any(|s| head.ends_with(s)) +} + +/// A sample of lines from the start, middle and end of the file. +pub struct Sample<'a> { + pub lines: Vec<&'a [u8]>, +} + +impl<'a> Sample<'a> { + pub fn take(bytes: &'a [u8]) -> Self { + let mut lines = Vec::new(); + take_lines(bytes, 0, 2000, &mut lines); + let head_end = lines.last().map(|l| l.as_ptr() as usize - bytes.as_ptr() as usize + l.len()).unwrap_or(0); + let mid = bytes.len() / 2; + if mid > head_end { + let start = next_line_start(bytes, mid); + take_lines(bytes, start, 500, &mut lines); + } + // Take the last ~500 lines by walking back from the end. + let mut start = bytes.len(); + let mut count = 0; + while start > 0 && count < 500 { + match memchr::memrchr(b'\n', &bytes[..start.saturating_sub(1)]) { + Some(p) => start = p + 1, + None => start = 0, + } + count += 1; + if start == 0 { + break; + } + } + let tail_floor = (bytes.len() / 2).max(head_end); + if start > tail_floor { + take_lines(bytes, start, 500, &mut lines); + } + Self { lines } + } +} + +fn next_line_start(bytes: &[u8], from: usize) -> usize { + match memchr::memchr(b'\n', &bytes[from..]) { + Some(p) => from + p + 1, + None => bytes.len(), + } +} + +fn take_lines<'a>(bytes: &'a [u8], mut pos: usize, max: usize, out: &mut Vec<&'a [u8]>) { + for _ in 0..max { + if pos >= bytes.len() { + break; + } + let end = memchr::memchr(b'\n', &bytes[pos..]).map(|p| pos + p).unwrap_or(bytes.len()); + let mut line = &bytes[pos..end]; + if line.last() == Some(&b'\r') { + line = &line[..line.len() - 1]; + } + out.push(line); + pos = end + 1; + } +} + +#[derive(Clone, Debug)] +pub struct Scored { + pub def: PatternDef, + pub score: f32, +} + +#[derive(Clone, Debug)] +pub struct Detection { + pub chosen: PatternDef, + /// Every candidate with its score on the sample, in candidate order. + pub scores: Vec, +} + +pub fn score(re: &Regex, lines: &[&[u8]]) -> f32 { + let mut heads = 0usize; + let mut head_hits = 0usize; + let mut false_starts = 0usize; + let mut nonempty = 0usize; + for line in lines { + if line.is_empty() { + continue; + } + nonempty += 1; + let hit = re.is_match(&line[..line.len().min(MATCH_PREFIX)]); + if looks_like_continuation(line) { + if hit { + false_starts += 1; + } + } else { + heads += 1; + if hit { + head_hits += 1; + } + } + } + if heads == 0 { + return 0.0; + } + let coverage = head_hits as f32 / heads as f32; + let penalty = 2.0 * false_starts as f32 / nonempty as f32; + coverage - penalty +} + +/// Picks the best entry-start pattern for a file. +pub fn detect(bytes: &[u8], extra: &[PatternDef]) -> Detection { + let sample = Sample::take(bytes); + detect_lines(&sample.lines, extra) +} + +pub fn detect_lines(lines: &[&[u8]], extra: &[PatternDef]) -> Detection { + let mut scores = Vec::new(); + let mut best: Option<(f32, PatternDef)> = None; + for def in builtin_candidates().into_iter().chain(extra.iter().cloned()) { + let Ok(re) = def.compile() else { continue }; + let s = score(&re, lines); + // Strictly greater: ties go to the earlier, more specific pattern. + if s > MIN_SCORE && best.as_ref().is_none_or(|(b, _)| s > *b) { + best = Some((s, def.clone())); + } + scores.push(Scored { def, score: s }); + } + let chosen = match best { + Some((_, def)) => def, + None => infer_from_shapes(lines).unwrap_or_else(every_non_indented_line), + }; + if !scores.iter().any(|s| s.def == chosen) { + let s = chosen.compile().map(|re| score(&re, lines)).unwrap_or(0.0); + scores.push(Scored { def: chosen.clone(), score: s }); + } + Detection { chosen, scores } +} + +const SHAPE_LEN: usize = 24; + +fn shape(line: &[u8]) -> Vec { + line.iter() + .take(SHAPE_LEN) + .map(|&b| match b { + b'0'..=b'9' => b'd', + b'a'..=b'z' | b'A'..=b'Z' => b'a', + b'\t' => b' ', + b if b >= 0x80 => b'?', + b => b, + }) + .collect() +} + +/// Maps line prefixes to shapes and turns the most common one into a regex. +pub fn infer_from_shapes(lines: &[&[u8]]) -> Option { + let shapes: Vec> = lines.iter().filter(|l| !l.is_empty()).map(|l| shape(l)).collect(); + if shapes.len() < 3 { + return None; + } + let need = (shapes.len() as f32 * 0.3).ceil() as usize; + for len in (4..=SHAPE_LEN).rev() { + let mut counts: HashMap<&[u8], usize> = HashMap::new(); + for s in &shapes { + if s.len() >= len { + *counts.entry(&s[..len]).or_default() += 1; + } + } + let Some((prefix, count)) = counts.into_iter().max_by_key(|(p, c)| (*c, std::cmp::Reverse(*p))) else { + continue; + }; + // A shape needs some structure (digits or punctuation) to be a useful + // marker; a run of letters would match ordinary prose. + let structured = prefix.iter().filter(|&&b| b != b'a' && b != b' ').count() >= 3; + if count >= need && structured && prefix[0] != b' ' { + // Words after the marker vary in length, so drop a trailing letter run. + let mut end = prefix.len(); + while end > 1 && matches!(prefix[end - 1], b'a' | b' ') { + end -= 1; + } + return Some(PatternDef { + name: "Inferred from line shapes".into(), + regex: shape_to_regex(&prefix[..end]), + }); + } + } + None +} + +fn shape_to_regex(shape: &[u8]) -> String { + let mut out = String::new(); + let mut i = 0; + while i < shape.len() { + let c = shape[i]; + let mut j = i; + while j < shape.len() && shape[j] == c { + j += 1; + } + let n = j - i; + let atom = match c { + b'd' => r"\d".to_string(), + b'a' => "[A-Za-z]".to_string(), + b'?' => "[^\\x00-\\x7F]".to_string(), + b' ' => r"\s".to_string(), + other => regex::escape(&(other as char).to_string()), + }; + out.push_str(&atom); + if n > 1 { + // Digit and letter runs vary in width (`9` vs `12`); punctuation does not. + if c == b'd' || c == b'a' { + out.push('+'); + } else { + out.push_str(&format!("{{{n}}}")); + } + } + i = j; + } + out +} + +#[cfg(test)] +mod tests { + use super::*; + + fn lines(s: &str) -> Vec<&[u8]> { + s.lines().map(|l| l.as_bytes()).collect() + } + + #[test] + fn detects_iso_with_stack_traces() { + let text = "2026-10-21 05:06:48,123 INFO start\n\ + 2026-10-21 05:06:49,000 ERROR boom\n\ + java.lang.RuntimeException: x\n\ + \tat a.b.C.d(C.java:1)\n\ + \tat a.b.C.e(C.java:2)\n\ + Caused by: y\n\ + 2026-10-21 05:06:50,000 INFO ok\n"; + let d = detect_lines(&lines(text), &[]); + assert_eq!(d.chosen.name, "ISO 8601 timestamp"); + } + + #[test] + fn detects_syslog() { + let text = + "Oct 21 05:06:48 host sshd[42]: a\nOct 21 05:06:49 host sshd[42]: b\nOct 1 05:06:49 host cron[1]: c\n"; + assert_eq!(detect_lines(&lines(text), &[]).chosen.name, "Syslog"); + } + + #[test] + fn detects_nginx() { + let text = "10.0.0.1 - - [21/Oct/2026:05:06:48 +0000] \"GET / HTTP/1.1\" 200 1\n\ + 10.0.0.2 - bob [21/Oct/2026:05:06:49 +0000] \"GET /x HTTP/1.1\" 404 2\n"; + assert_eq!(detect_lines(&lines(text), &[]).chosen.name, "Apache / nginx access"); + } + + #[test] + fn detects_json_lines() { + let text = "{\"ts\":1,\"msg\":\"a\"}\n{\"ts\":2,\"msg\":\"b\"}\n{\"ts\":3}\n"; + assert_eq!(detect_lines(&lines(text), &[]).chosen.name, "JSON lines"); + } + + #[test] + fn falls_back_to_shapes() { + let text = "#12|a| started\n#13|b| more\n detail\n#14|c| done\n#15|d| x\n"; + let d = detect_lines(&lines(text), &[]); + assert_eq!(d.chosen.name, "Inferred from line shapes"); + let re = d.chosen.compile().unwrap(); + assert!(re.is_match(b"#99|z| y")); + assert!(!re.is_match(b" detail")); + } + + #[test] + fn last_resort_is_non_indented() { + let text = "hello\n world\nfoo\n"; + assert_eq!(detect_lines(&lines(text), &[]).chosen, every_non_indented_line()); + } + + #[test] + fn sample_covers_start_middle_end() { + let mut s = String::new(); + for i in 0..10_000 { + s.push_str(&format!("line {i}\n")); + } + let sample = Sample::take(s.as_bytes()); + assert_eq!(sample.lines[0], b"line 0"); + assert_eq!(*sample.lines.last().unwrap(), b"line 9999"); + assert!(sample.lines.iter().any(|l| l.starts_with(b"line 5"))); + assert!(sample.lines.len() <= 3001); + } +} diff --git a/src/rowmap.rs b/src/rowmap.rs new file mode 100644 index 0000000..a07b562 --- /dev/null +++ b/src/rowmap.rs @@ -0,0 +1,217 @@ +//! Maps display rows to (visible entry, line within entry). +//! +//! A collapsed entry is one display row and an expanded entry is `lines` rows. +//! With a few expanded entries the map is a sorted list of the expanded ones +//! with running sums of their extra rows (rebuilt in O(k log n) per click). +//! With "expand all" it is a dense prefix sum over every visible entry. + +/// Which entries pass the filter: all of them, or a sorted subset. +#[derive(Clone, Debug)] +pub enum Visible { + All(usize), + Some(Vec), +} + +impl Visible { + pub fn len(&self) -> usize { + match self { + Visible::All(n) => *n, + Visible::Some(v) => v.len(), + } + } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Entry index at visible position `pos`. + pub fn entry(&self, pos: usize) -> u32 { + match self { + Visible::All(_) => pos as u32, + Visible::Some(v) => v[pos], + } + } + + /// Visible position of `entry`, if it is visible. + pub fn position(&self, entry: u32) -> Option { + match self { + Visible::All(n) => ((entry as usize) < *n).then_some(entry as usize), + Visible::Some(v) => v.binary_search(&entry).ok(), + } + } + + /// Position of the first visible entry at or after `entry` (or the last one). + pub fn nearest_position(&self, entry: u32) -> usize { + match self { + Visible::All(n) => (entry as usize).min(n.saturating_sub(1)), + Visible::Some(v) => v.partition_point(|&e| e < entry).min(v.len().saturating_sub(1)), + } + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct RowPos { + /// Position in the visible list. + pub vpos: usize, + /// Line within the entry (0 = first line). + pub line: u32, +} + +#[derive(Clone, Debug)] +enum Map { + /// Sorted (vpos, extra rows) of expanded entries, and the extra rows before each. + Sparse { expanded: Vec<(usize, u64)>, before: Vec }, + /// `starts[v]` is the first display row of visible entry `v`; one extra element at the end. + Dense { starts: Vec }, +} + +#[derive(Clone, Debug)] +pub struct RowMap { + map: Map, + visible_len: usize, + total: u64, +} + +impl Default for RowMap { + fn default() -> Self { + Self::sparse(0, Vec::new()) + } +} + +impl RowMap { + /// `expanded` holds (vpos, line count) of expanded entries in any order. + pub fn sparse(visible_len: usize, mut expanded: Vec<(usize, u32)>) -> Self { + expanded.sort_unstable(); + expanded.dedup_by_key(|e| e.0); + let mut list = Vec::with_capacity(expanded.len()); + let mut before = Vec::with_capacity(expanded.len() + 1); + let mut sum = 0u64; + for (vpos, lines) in expanded { + if lines > 1 && vpos < visible_len { + before.push(sum); + let extra = (lines - 1) as u64; + list.push((vpos, extra)); + sum += extra; + } + } + before.push(sum); + Self { map: Map::Sparse { expanded: list, before }, visible_len, total: visible_len as u64 + sum } + } + + /// `rows_of(vpos)` gives the display rows of each visible entry. + pub fn dense(visible_len: usize, rows_of: impl Fn(usize) -> u32) -> Self { + let mut starts = Vec::with_capacity(visible_len + 1); + let mut sum = 0u64; + for v in 0..visible_len { + starts.push(sum); + sum += rows_of(v).max(1) as u64; + } + starts.push(sum); + Self { map: Map::Dense { starts }, visible_len, total: sum } + } + + pub fn total_rows(&self) -> u64 { + self.total + } + + pub fn visible_len(&self) -> usize { + self.visible_len + } + + pub fn locate(&self, row: u64) -> Option { + if row >= self.total { + return None; + } + match &self.map { + Map::Sparse { expanded, before } => { + // Number of expanded entries whose first row is <= row. + let k = expanded.partition_point(|&(vpos, _)| vpos as u64 + before_of(before, expanded, vpos) <= row); + if k == 0 { + return Some(RowPos { vpos: row as usize, line: 0 }); + } + let (vpos, extra) = expanded[k - 1]; + let start = vpos as u64 + before[k - 1]; + if row <= start + extra { + Some(RowPos { vpos, line: (row - start) as u32 }) + } else { + Some(RowPos { vpos: (row - before[k]) as usize, line: 0 }) + } + } + Map::Dense { starts } => { + let v = starts.partition_point(|&s| s <= row) - 1; + Some(RowPos { vpos: v, line: (row - starts[v]) as u32 }) + } + } + } + + /// First display row of visible entry `vpos`. + pub fn row_of(&self, vpos: usize) -> u64 { + match &self.map { + Map::Sparse { expanded, before } => { + let k = expanded.partition_point(|&(v, _)| v < vpos); + vpos as u64 + before[k] + } + Map::Dense { starts } => starts[vpos.min(starts.len() - 1)], + } + } + + /// Display rows occupied by visible entry `vpos`. + pub fn rows_in(&self, vpos: usize) -> u64 { + match &self.map { + Map::Sparse { expanded, .. } => match expanded.binary_search_by_key(&vpos, |e| e.0) { + Ok(i) => expanded[i].1 + 1, + Err(_) => 1, + }, + Map::Dense { starts } => starts[vpos + 1] - starts[vpos], + } + } +} + +// The partition_point closure only sees the element, so look its running sum up. +fn before_of(before: &[u64], expanded: &[(usize, u64)], vpos: usize) -> u64 { + let i = expanded.partition_point(|&(v, _)| v < vpos); + before[i] +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn sparse_maps_rows() { + // Entries 0..5; entry 1 has 3 lines and entry 3 has 2, both expanded. + let m = RowMap::sparse(5, vec![(3, 2), (1, 3)]); + assert_eq!(m.total_rows(), 8); + let got: Vec<(usize, u32)> = (0..8).map(|r| m.locate(r).map(|p| (p.vpos, p.line)).unwrap()).collect(); + assert_eq!(got, vec![(0, 0), (1, 0), (1, 1), (1, 2), (2, 0), (3, 0), (3, 1), (4, 0)]); + assert_eq!(m.locate(8), None); + assert_eq!(m.row_of(2), 4); + assert_eq!(m.row_of(4), 7); + assert_eq!(m.rows_in(1), 3); + assert_eq!(m.rows_in(2), 1); + } + + #[test] + fn dense_matches_sparse() { + let lines = [1u32, 3, 1, 2, 1]; + let d = RowMap::dense(5, |v| lines[v]); + let s = RowMap::sparse(5, lines.iter().enumerate().map(|(v, &l)| (v, l)).collect()); + assert_eq!(d.total_rows(), s.total_rows()); + for r in 0..d.total_rows() { + assert_eq!(d.locate(r), s.locate(r)); + } + for v in 0..5 { + assert_eq!(d.row_of(v), s.row_of(v)); + assert_eq!(d.rows_in(v), s.rows_in(v)); + } + } + + #[test] + fn visible_positions() { + let v = Visible::Some(vec![2, 5, 9]); + assert_eq!(v.position(5), Some(1)); + assert_eq!(v.position(6), None); + assert_eq!(v.nearest_position(6), 2); + assert_eq!(v.nearest_position(100), 2); + } +} diff --git a/src/rules.rs b/src/rules.rs new file mode 100644 index 0000000..88834a8 --- /dev/null +++ b/src/rules.rs @@ -0,0 +1,324 @@ +//! Filter and highlight rules, their compiled forms, and `.logrules.toml` files. + +use aho_corasick::{AhoCorasick, AhoCorasickBuilder}; +use regex::bytes::{Regex, RegexBuilder, RegexSet, RegexSetBuilder}; +use serde::{Deserialize, Serialize}; + +use crate::pattern::PatternDef; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum RuleKind { + Exclude, + Only, + Highlight, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum Scope { + /// Tint the whole entry's background. + #[default] + Row, + /// Color only the matched text. + Match, +} + +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct Rule { + pub kind: RuleKind, + pub pattern: String, + #[serde(default)] + pub regex: bool, + #[serde(default)] + pub case_sensitive: bool, + /// Highlight rules only: a palette name (`red`, `amber`, ...) or `#rrggbb`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub color: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub scope: Option, + #[serde(default = "yes", skip_serializing_if = "is_true")] + pub enabled: bool, +} + +fn yes() -> bool { + true +} + +fn is_true(b: &bool) -> bool { + *b +} + +impl Rule { + pub fn filter(kind: RuleKind, pattern: &str) -> Self { + Self { + kind, + pattern: pattern.into(), + regex: false, + case_sensitive: false, + color: None, + scope: None, + enabled: true, + } + } + + pub fn highlight(pattern: &str, color: &str, scope: Scope) -> Self { + Self { + kind: RuleKind::Highlight, + pattern: pattern.into(), + regex: false, + case_sensitive: false, + color: Some(color.into()), + scope: Some(scope), + enabled: true, + } + } + + pub fn is_filter(&self) -> bool { + matches!(self.kind, RuleKind::Exclude | RuleKind::Only) + } + + /// The regex source this rule matches, with flags applied. + pub fn regex_source(&self) -> String { + let body = if self.regex { self.pattern.clone() } else { regex::escape(&self.pattern) }; + if self.case_sensitive { body } else { format!("(?i:{body})") } + } + + pub fn validate(&self) -> Result<(), String> { + if self.pattern.is_empty() { + return Err("empty pattern".into()); + } + if self.regex { + RegexBuilder::new(&self.regex_source()).build().map(|_| ()).map_err(|e| e.to_string()) + } else { + Ok(()) + } + } +} + +pub fn default_highlights() -> Vec { + vec![ + Rule::highlight("ERROR", "red", Scope::Row), + Rule::highlight("FATAL", "red", Scope::Row), + Rule::highlight("WARN", "amber", Scope::Row), + ] +} + +/// One kind's keywords, compiled for a single pass. +#[derive(Default)] +struct Matcher { + sensitive: Option, + insensitive: Option, + regexes: Option, +} + +impl Matcher { + fn build(rules: &[&Rule]) -> Self { + let words = |cs: bool| -> Option { + let pats: Vec<&str> = + rules.iter().filter(|r| !r.regex && r.case_sensitive == cs).map(|r| r.pattern.as_str()).collect(); + if pats.is_empty() { + return None; + } + AhoCorasickBuilder::new().ascii_case_insensitive(!cs).build(pats).ok() + }; + let regexes: Vec = rules.iter().filter(|r| r.regex).map(|r| r.regex_source()).collect(); + Self { + sensitive: words(true), + insensitive: words(false), + regexes: if regexes.is_empty() { None } else { RegexSetBuilder::new(regexes).build().ok() }, + } + } + + fn is_empty(&self) -> bool { + self.sensitive.is_none() && self.insensitive.is_none() && self.regexes.is_none() + } + + fn is_match(&self, hay: &[u8]) -> bool { + self.sensitive.as_ref().is_some_and(|a| a.is_match(hay)) + || self.insensitive.as_ref().is_some_and(|a| a.is_match(hay)) + || self.regexes.as_ref().is_some_and(|s| s.is_match(hay)) + } +} + +/// The filter rules compiled into one automaton per kind. +pub struct CompiledFilter { + exclude: Matcher, + only: Matcher, +} + +impl CompiledFilter { + /// Compiles the enabled, valid filter rules; invalid ones are skipped. + pub fn new(rules: &[Rule]) -> Self { + let pick = |k: RuleKind| -> Vec<&Rule> { + rules.iter().filter(|r| r.enabled && r.kind == k && r.validate().is_ok()).collect() + }; + Self { exclude: Matcher::build(&pick(RuleKind::Exclude)), only: Matcher::build(&pick(RuleKind::Only)) } + } + + pub fn is_empty(&self) -> bool { + self.exclude.is_empty() && self.only.is_empty() + } + + /// An entry is shown if it matches some Only rule (or there are none) and no Exclude rule. + pub fn shows(&self, entry: &[u8]) -> bool { + (self.only.is_empty() || self.only.is_match(entry)) && !self.exclude.is_match(entry) + } +} + +/// A highlight rule ready for matching. +pub struct CompiledHighlight { + pub color: String, + pub scope: Scope, + pub re: Regex, +} + +pub fn compile_highlights(rules: &[Rule]) -> Vec { + rules + .iter() + .filter(|r| r.enabled && r.kind == RuleKind::Highlight) + .filter_map(|r| { + let re = RegexBuilder::new(&r.regex_source()).build().ok()?; + Some(CompiledHighlight { + color: r.color.clone().unwrap_or_else(|| "amber".into()), + scope: r.scope.unwrap_or_default(), + re, + }) + }) + .collect() +} + +// ----- rule files ----- + +pub const RULES_FILE_VERSION: u32 = 1; +pub const RULES_FILE_EXT: &str = "logrules.toml"; + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct RulesFile { + pub version: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pattern: Option, + #[serde(default)] + pub rules: Vec, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ExportWhat { + All, + FiltersOnly, + HighlightsOnly, +} + +impl RulesFile { + pub fn new(rules: impl IntoIterator, pattern: Option) -> Self { + Self { version: RULES_FILE_VERSION, pattern, rules: rules.into_iter().collect() } + } + + pub fn select(rules: &[Rule], what: ExportWhat, pattern: Option) -> Self { + let keep = |r: &&Rule| match what { + ExportWhat::All => true, + ExportWhat::FiltersOnly => r.is_filter(), + ExportWhat::HighlightsOnly => !r.is_filter(), + }; + Self::new(rules.iter().filter(keep).cloned(), pattern) + } + + pub fn to_toml(&self) -> String { + toml::to_string_pretty(self).expect("rules serialize") + } + + /// Parses a rule file. Rules whose pattern does not compile are dropped and + /// reported, so the rest still load. + pub fn parse(text: &str) -> anyhow::Result<(Self, Vec)> { + let mut file: RulesFile = toml::from_str(text)?; + if file.version > RULES_FILE_VERSION { + anyhow::bail!("rule file version {} is newer than this app supports ({RULES_FILE_VERSION})", file.version); + } + let mut errors = Vec::new(); + file.rules.retain(|r| match r.validate() { + Ok(()) => true, + Err(e) => { + errors.push(format!("{:?} rule `{}`: {e}", r.kind, r.pattern)); + false + } + }); + if let Some(p) = &file.pattern + && let Err(e) = p.compile() + { + errors.push(format!("entry-start pattern `{}`: {e}", p.regex)); + file.pattern = None; + } + Ok((file, errors)) + } +} + +/// Merges `incoming` into `rules`, skipping exact duplicates. +pub fn merge(rules: &mut Vec, incoming: Vec) -> usize { + let mut added = 0; + for r in incoming { + if !rules.contains(&r) { + rules.push(r); + added += 1; + } + } + added +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn filter_semantics() { + let mut rules = vec![Rule::filter(RuleKind::Exclude, "debug")]; + let f = CompiledFilter::new(&rules); + assert!(!f.shows(b"a DEBUG line")); + assert!(f.shows(b"an info line")); + + rules.push(Rule::filter(RuleKind::Only, "db")); + let mut re = Rule::filter(RuleKind::Only, r"user=\d+"); + re.regex = true; + rules.push(re); + let f = CompiledFilter::new(&rules); + assert!(f.shows(b"db connected")); + assert!(f.shows(b"login user=42")); + assert!(!f.shows(b"login user=bob")); + assert!(!f.shows(b"db debug")); + } + + #[test] + fn case_sensitive_keyword() { + let mut r = Rule::filter(RuleKind::Only, "Error"); + r.case_sensitive = true; + let f = CompiledFilter::new(&[r]); + assert!(f.shows(b"Error x")); + assert!(!f.shows(b"ERROR x")); + } + + #[test] + fn rules_file_roundtrip_and_validation() { + let mut rules = default_highlights(); + rules.push(Rule::filter(RuleKind::Exclude, "health")); + let file = RulesFile::new(rules.clone(), Some(PatternDef::new("x", r"\d+"))); + let text = file.to_toml(); + let (back, errors) = RulesFile::parse(&text).unwrap(); + assert!(errors.is_empty()); + assert_eq!(back.rules, rules); + assert_eq!(back.pattern.unwrap().regex, r"\d+"); + + let bad = "version = 1\n[[rules]]\nkind = \"only\"\npattern = \"(\"\nregex = true\n\ + [[rules]]\nkind = \"exclude\"\npattern = \"ok\"\n"; + let (f, errors) = RulesFile::parse(bad).unwrap(); + assert_eq!(f.rules.len(), 1); + assert_eq!(errors.len(), 1); + } + + #[test] + fn merge_skips_duplicates() { + let mut rules = default_highlights(); + let added = + merge(&mut rules, default_highlights().into_iter().chain([Rule::filter(RuleKind::Only, "x")]).collect()); + assert_eq!(added, 1); + assert_eq!(rules.len(), 4); + } +} diff --git a/src/settings.rs b/src/settings.rs new file mode 100644 index 0000000..38c64db --- /dev/null +++ b/src/settings.rs @@ -0,0 +1,196 @@ +//! Persistent settings in the OS config folder (`settings.toml` and `rulesets/`). + +use std::collections::BTreeMap; +use std::path::{Path, PathBuf}; + +use serde::{Deserialize, Serialize}; + +use crate::pattern::PatternDef; +use crate::rules::{RULES_FILE_EXT, Rule, RulesFile, default_highlights}; + +const MAX_RECENT: usize = 15; + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct FileSettings { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pattern: Option, + #[serde(default)] + pub wrap: bool, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct GlobPattern { + /// Matched against the file name, e.g. `*.app.log`. + pub glob: String, + pub pattern: PatternDef, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct GlobRules { + pub glob: String, + pub rules: Vec, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(default)] +pub struct Settings { + pub recent_files: Vec, + pub files: BTreeMap, + pub glob_patterns: Vec, + /// Extra entry-start candidates tried after the built-in ones. + pub extra_patterns: Vec, + /// Global default filter and highlight rules for new tabs. + pub rules: Vec, + /// Per-file-name-glob overrides of the global rules. + pub glob_rules: Vec, + pub show_gutter: bool, + pub gutter_line_numbers: bool, + pub font_size: f32, +} + +impl Default for Settings { + fn default() -> Self { + Self { + recent_files: Vec::new(), + files: BTreeMap::new(), + glob_patterns: Vec::new(), + extra_patterns: Vec::new(), + rules: default_highlights(), + glob_rules: Vec::new(), + show_gutter: true, + gutter_line_numbers: false, + font_size: 13.0, + } + } +} + +pub fn config_dir() -> Option { + directories::ProjectDirs::from("se", "logreadlite", "logreadlite").map(|d| d.config_dir().to_path_buf()) +} + +fn glob_matches(glob: &str, path: &Path) -> bool { + let Ok(g) = globset::Glob::new(glob) else { return false }; + let m = g.compile_matcher(); + path.file_name().is_some_and(|n| m.is_match(n)) || m.is_match(path) +} + +fn key(path: &Path) -> String { + std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf()).to_string_lossy().into_owned() +} + +impl Settings { + pub fn path() -> Option { + config_dir().map(|d| d.join("settings.toml")) + } + + pub fn load() -> Self { + Self::path() + .and_then(|p| std::fs::read_to_string(p).ok()) + .and_then(|s| toml::from_str(&s).ok()) + .unwrap_or_default() + } + + pub fn save(&self) -> anyhow::Result<()> { + let Some(path) = Self::path() else { return Ok(()) }; + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir)?; + } + std::fs::write(path, toml::to_string_pretty(self)?)?; + Ok(()) + } + + pub fn add_recent(&mut self, path: &Path) { + let path = std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf()); + self.recent_files.retain(|p| p != &path); + self.recent_files.insert(0, path); + self.recent_files.truncate(MAX_RECENT); + } + + pub fn file(&self, path: &Path) -> FileSettings { + self.files.get(&key(path)).cloned().unwrap_or_default() + } + + pub fn file_mut(&mut self, path: &Path) -> &mut FileSettings { + self.files.entry(key(path)).or_default() + } + + /// A saved pattern for this path, or for a glob matching its file name. + pub fn saved_pattern(&self, path: &Path) -> Option { + self.file(path) + .pattern + .or_else(|| self.glob_patterns.iter().find(|g| glob_matches(&g.glob, path)).map(|g| g.pattern.clone())) + } + + pub fn save_glob_pattern(&mut self, glob: &str, pattern: PatternDef) { + self.glob_patterns.retain(|g| g.glob != glob); + self.glob_patterns.push(GlobPattern { glob: glob.into(), pattern }); + } + + /// Rules for a newly opened file: a glob override, else the global defaults. + pub fn rules_for(&self, path: &Path) -> Vec { + self.glob_rules + .iter() + .find(|g| glob_matches(&g.glob, path)) + .map(|g| g.rules.clone()) + .unwrap_or_else(|| self.rules.clone()) + } +} + +// ----- named rule sets: saved rule files in the config folder ----- + +pub fn rulesets_dir() -> Option { + config_dir().map(|d| d.join("rulesets")) +} + +pub fn list_rulesets() -> Vec { + let Some(dir) = rulesets_dir() else { return Vec::new() }; + let Ok(rd) = std::fs::read_dir(dir) else { return Vec::new() }; + let suffix = format!(".{RULES_FILE_EXT}"); + let mut names: Vec = rd + .filter_map(|e| e.ok()?.file_name().into_string().ok()) + .filter_map(|n| n.strip_suffix(&suffix).map(str::to_string)) + .collect(); + names.sort(); + names +} + +pub fn ruleset_path(name: &str) -> Option { + let safe: String = name.chars().map(|c| if c.is_alphanumeric() || " -_.".contains(c) { c } else { '_' }).collect(); + rulesets_dir().map(|d| d.join(format!("{safe}.{RULES_FILE_EXT}"))) +} + +pub fn save_ruleset(name: &str, file: &RulesFile) -> anyhow::Result<()> { + let path = ruleset_path(name).ok_or_else(|| anyhow::anyhow!("no config folder"))?; + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir)?; + } + std::fs::write(path, file.to_toml())?; + Ok(()) +} + +pub fn load_ruleset(name: &str) -> anyhow::Result<(RulesFile, Vec)> { + let path = ruleset_path(name).ok_or_else(|| anyhow::anyhow!("no config folder"))?; + RulesFile::parse(&std::fs::read_to_string(path)?) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn glob_pattern_lookup() { + let mut s = Settings::default(); + s.save_glob_pattern("*.app.log", PatternDef::new("x", "X")); + assert_eq!(s.saved_pattern(Path::new("/tmp/foo.app.log")).unwrap().regex, "X"); + assert!(s.saved_pattern(Path::new("/tmp/foo.log")).is_none()); + } + + #[test] + fn settings_roundtrip() { + let mut s = Settings::default(); + s.file_mut(Path::new("/nonexistent/a.log")).wrap = true; + let back: Settings = toml::from_str(&toml::to_string_pretty(&s).unwrap()).unwrap(); + assert!(back.file(Path::new("/nonexistent/a.log")).wrap); + assert_eq!(back.rules, s.rules); + } +} diff --git a/src/source.rs b/src/source.rs new file mode 100644 index 0000000..0ae136e --- /dev/null +++ b/src/source.rs @@ -0,0 +1,67 @@ +//! Read-only access to the bytes of a log file. +//! +//! The file is memory-mapped and never copied. The `ByteSource` trait keeps the +//! rest of the app independent of mmap so a chunked `pread` fallback can be +//! added later (Windows file locking) without touching the indexer or the view. + +use std::fs::File; +use std::path::{Path, PathBuf}; + +use anyhow::{Context, Result}; +use memmap2::Mmap; + +pub trait ByteSource: Send + Sync { + fn bytes(&self) -> &[u8]; + + fn len(&self) -> u64 { + self.bytes().len() as u64 + } + + fn is_empty(&self) -> bool { + self.bytes().is_empty() + } +} + +pub struct MmapSource { + path: PathBuf, + // `None` for empty files, which cannot be mapped on every platform. + map: Option, +} + +impl MmapSource { + pub fn open(path: &Path) -> Result { + let file = File::open(path).with_context(|| format!("cannot open {}", path.display()))?; + let meta = file.metadata().with_context(|| format!("cannot read metadata of {}", path.display()))?; + if meta.is_dir() { + anyhow::bail!("{} is a folder, not a file", path.display()); + } + let map = if meta.len() == 0 { + None + } else { + // SAFETY: the map is read-only. If another process truncates the file + // while it is mapped, reads past the new end fault; the viewer checks + // the file size before each pass and on focus, and remaps on shrink. + Some(unsafe { Mmap::map(&file) }.with_context(|| format!("cannot map {}", path.display()))?) + }; + Ok(Self { path: path.to_path_buf(), map }) + } + + pub fn path(&self) -> &Path { + &self.path + } +} + +impl ByteSource for MmapSource { + fn bytes(&self) -> &[u8] { + self.map.as_deref().unwrap_or(&[]) + } +} + +/// An in-memory source, used by tests, benchmarks and the pattern preview. +pub struct VecSource(pub Vec); + +impl ByteSource for VecSource { + fn bytes(&self) -> &[u8] { + &self.0 + } +} diff --git a/src/ui/debug.rs b/src/ui/debug.rs new file mode 100644 index 0000000..402ee58 --- /dev/null +++ b/src/ui/debug.rs @@ -0,0 +1,71 @@ +//! Development aid: `LOGREADLITE_DEBUG_SCRIPT="search:foo;next;exclude:DEBUG;wrap"` +//! replays actions on the active tab, one every 300 ms, so screenshots can +//! cover interactive states without an input-injection tool. + +use std::time::Duration; + +use crate::passes::SearchQuery; +use crate::rules::{Rule, RuleKind, Scope}; +use crate::ui::{App, Tab}; + +pub fn step(app: &mut App, ctx: &egui::Context) { + let Ok(script) = std::env::var("LOGREADLITE_DEBUG_SCRIPT") else { return }; + let id = egui::Id::unique("debug_script_step"); + let (step, last): (usize, f64) = ctx.data(|d| d.get_temp(id)).unwrap_or((0, 0.0)); + let now = ctx.input(|i| i.time); + ctx.request_repaint_after(Duration::from_millis(100)); + if now - last < 0.3 { + return; + } + let Some(cmd) = script.split(';').nth(step) else { return }; + ctx.data_mut(|d| d.insert_temp(id, (step + 1, now))); + let (name, arg) = cmd.split_once(':').unwrap_or((cmd, "")); + if name == "grep" { + let (folder, pat) = arg.split_once('|').unwrap_or((arg, "")); + let mut g = crate::ui::grep_tab::GrepTab::new(Some(folder.into()), app.notify.clone()); + g.opts.query = SearchQuery { text: pat.into(), ..Default::default() }; + g.start(); + app.tabs.push(Tab::Grep(Box::new(g))); + app.active = app.tabs.len() - 1; + return; + } + if name == "light" { + ctx.set_theme(egui::Theme::Light); + return; + } + if name == "tab" { + app.active = arg.parse().unwrap_or(0); + return; + } + let Some(Tab::Log(t)) = app.tabs.get_mut(app.active) else { return }; + match name { + "search" => t.set_search(&SearchQuery { text: arg.into(), ..Default::default() }), + "next" => t.step_match(true), + "prev" => t.step_match(false), + "exclude" => { + t.rules.push(Rule::filter(RuleKind::Exclude, arg)); + t.filters_changed(); + } + "only" => { + t.rules.push(Rule::filter(RuleKind::Only, arg)); + t.filters_changed(); + } + "highlight" => { + t.rules.push(Rule::highlight(arg, "blue", Scope::Match)); + t.rules_changed(); + } + "expandall" => t.set_expand_all(true), + "wrap" => t.wrap = !t.wrap, + "rules" => t.show_rules = !t.show_rules, + "pattern" => { + let ed = crate::ui::panels::PatternEditor::new(t, &app.settings); + t.pattern_editor = Some(ed); + } + "goto" => { + let _ = t.goto_line(arg.parse().unwrap_or(1)); + } + "jump" => t.jump_to_offset(arg.parse().unwrap_or(0), true), + "detail" => t.detail = Some(arg.parse().unwrap_or(0)), + _ => {} + } +} diff --git a/src/ui/grep_tab.rs b/src/ui/grep_tab.rs new file mode 100644 index 0000000..dfdd944 --- /dev/null +++ b/src/ui/grep_tab.rs @@ -0,0 +1,327 @@ +//! The "Find in files" tab. + +use std::collections::HashSet; +use std::path::PathBuf; +use std::sync::Arc; +use std::sync::atomic::Ordering; + +use egui::text::LayoutJob; +use egui::{Key, RichText, TextFormat, Ui}; + +use crate::grep::{self, GrepOptions, GrepShared}; +use crate::job::{Generation, Notify}; +use crate::passes::SearchQuery; +use crate::ui::log_tab::{fmt_num, fmt_size}; +use crate::ui::palette; + +pub enum GrepAction { + Open { path: PathBuf, offset: u64, query: SearchQuery }, + Status(String), +} + +#[derive(Clone, Copy)] +enum Row { + File(usize), + Hit(usize, usize), +} + +pub struct GrepTab { + pub opts: GrepOptions, + folder_text: String, + max_mb_text: String, + generation: Generation, + shared: Option>, + /// The query the current results were produced with. + ran: Option, + error: Option, + collapsed: HashSet, + rows: Vec, + rows_key: (usize, usize), + selected: Option, + notify: Notify, +} + +impl GrepTab { + pub fn new(folder: Option, notify: Notify) -> Self { + let opts = GrepOptions { folder: folder.unwrap_or_default(), ..Default::default() }; + Self { + folder_text: opts.folder.display().to_string(), + max_mb_text: String::new(), + opts, + generation: Generation::new(), + shared: None, + ran: None, + error: None, + collapsed: HashSet::new(), + rows: Vec::new(), + rows_key: (usize::MAX, 0), + selected: None, + notify, + } + } + + pub fn title(&self) -> String { + match self.opts.folder.file_name() { + Some(n) => format!("Find in {}", n.to_string_lossy()), + None => "Find in files".into(), + } + } + + pub fn set_folder(&mut self, folder: PathBuf) { + self.folder_text = folder.display().to_string(); + self.opts.folder = folder; + } + + pub fn start(&mut self) { + self.opts.folder = PathBuf::from(self.folder_text.trim()); + self.opts.max_file_mb = self.max_mb_text.trim().parse().unwrap_or(0); + self.error = None; + self.collapsed.clear(); + self.selected = None; + self.rows_key = (usize::MAX, 0); + if self.opts.query.text.is_empty() { + self.error = Some("Enter a pattern".into()); + return; + } + if !self.opts.folder.is_dir() { + self.error = Some(format!("{} is not a folder", self.opts.folder.display())); + return; + } + match grep::spawn(self.opts.clone(), self.generation.bump(), self.notify.clone()) { + Ok(s) => { + self.shared = Some(s); + self.ran = Some(self.opts.clone()); + } + Err(e) => self.error = Some(format!("{e:#}")), + } + } + + pub fn cancel(&mut self) { + self.generation.cancel(); + } + + fn rebuild_rows(&mut self, files: &[grep::FileResult]) { + let key = (files.len(), self.collapsed.len()); + if key == self.rows_key { + return; + } + self.rows_key = key; + self.rows.clear(); + for (fi, f) in files.iter().enumerate() { + self.rows.push(Row::File(fi)); + if !self.collapsed.contains(&fi) { + self.rows.extend((0..f.hits.len()).map(|hi| Row::Hit(fi, hi))); + } + } + } + + pub fn show(&mut self, ui: &mut Ui) -> Vec { + let mut actions = Vec::new(); + egui::Panel::top("grep_inputs").show(ui, |ui| self.inputs(ui, &mut actions)); + egui::CentralPanel::default().show(ui, |ui| self.results(ui, &mut actions)); + actions + } + + fn inputs(&mut self, ui: &mut Ui, _actions: &mut [GrepAction]) { + let mut go = false; + egui::Grid::new("grep_grid").num_columns(2).spacing([8.0, 4.0]).show(ui, |ui| { + ui.label("Folder"); + ui.horizontal(|ui| { + ui.add(egui::TextEdit::singleline(&mut self.folder_text).desired_width(420.0)); + if ui.button("Browse…").clicked() + && let Some(d) = rfd::FileDialog::new().pick_folder() + { + self.folder_text = d.display().to_string(); + } + }); + ui.end_row(); + + ui.label("Pattern"); + ui.horizontal(|ui| { + let r = ui.add( + egui::TextEdit::singleline(&mut self.opts.query.text) + .desired_width(320.0) + .hint_text("text or regex"), + ); + go |= r.lost_focus() && ui.input(|i| i.key_pressed(Key::Enter)); + ui.toggle_value(&mut self.opts.query.regex, ".*").on_hover_text("Regex"); + ui.toggle_value(&mut self.opts.query.case_sensitive, "Aa").on_hover_text("Case sensitive"); + ui.toggle_value(&mut self.opts.query.whole_word, "\\b").on_hover_text("Whole word"); + }); + ui.end_row(); + + ui.label("Include"); + ui.horizontal(|ui| { + ui.add(egui::TextEdit::singleline(&mut self.opts.include).desired_width(180.0)); + ui.label("Exclude"); + ui.add( + egui::TextEdit::singleline(&mut self.opts.exclude).desired_width(140.0).hint_text("*.gz;old/**"), + ); + }); + ui.end_row(); + + ui.label(""); + ui.horizontal(|ui| { + ui.checkbox(&mut self.opts.recursive, "Recursive"); + ui.checkbox(&mut self.opts.respect_gitignore, "Respect .gitignore"); + ui.checkbox(&mut self.opts.skip_binary, "Skip binary files"); + ui.label("Max size (MB)"); + ui.add(egui::TextEdit::singleline(&mut self.max_mb_text).desired_width(50.0).hint_text("any")); + }); + ui.end_row(); + }); + ui.horizontal(|ui| { + let running = self.shared.as_ref().is_some_and(|s| !s.is_done()); + if ui.button("🔍 Search").clicked() || go { + self.start(); + } + if running && ui.button("Cancel").clicked() { + self.cancel(); + if let Some(s) = &self.shared { + s.done.store(true, Ordering::Release); + } + } + if let Some(s) = self.shared.clone() { + let files = s.results.lock().unwrap(); + let matches: usize = files.iter().map(|f| f.hits.len()).sum(); + let searched = s.files_searched.load(Ordering::Relaxed); + ui.label(format!( + "{} matches in {} of {} files{}", + fmt_num(matches as u64), + fmt_num(files.len() as u64), + fmt_num(searched as u64), + if running { " (searching…)" } else { "" } + )); + if s.capped.load(Ordering::Relaxed) || files.iter().any(|f| f.truncated) { + ui.colored_label(ui.visuals().warn_fg_color, "results capped (10,000 per file, 1M total)"); + } + let errs = s.errors.lock().unwrap(); + if !errs.is_empty() { + ui.colored_label(ui.visuals().warn_fg_color, format!("{} errors", errs.len())) + .on_hover_text(errs.iter().take(20).cloned().collect::>().join("\n")); + } + drop(errs); + if !files.is_empty() { + if ui.button("📋 Copy").on_hover_text("Copy as path:line:text").clicked() { + ui.ctx().copy_text(grep::export_text(&files)); + } + if ui.button("Export…").clicked() + && let Some(p) = rfd::FileDialog::new().set_file_name("grep-results.txt").save_file() + { + let _ = std::fs::write(p, grep::export_text(&files)); + } + } + } + if let Some(e) = &self.error { + ui.colored_label(ui.visuals().error_fg_color, e); + } + }); + } + + fn results(&mut self, ui: &mut Ui, actions: &mut Vec) { + let Some(shared) = self.shared.clone() else { + ui.weak("Pick a folder and a pattern, then press Search. Double-click a hit to open it."); + return; + }; + let files = shared.results.lock().unwrap(); + self.rebuild_rows(&files); + let root = self.ran.as_ref().map(|o| o.folder.clone()).unwrap_or_default(); + let query = self.ran.as_ref().map(|o| o.query.clone()).unwrap_or_default(); + // Selectable labels are padded; the virtualized rows must use the same height. + let pad = ui.spacing().button_padding.y * 2.0; + let row_h = ui.spacing().interact_size.y.max(ui.text_style_height(&egui::TextStyle::Monospace) + pad); + let dark = ui.visuals().dark_mode; + let font = egui::FontId::monospace(ui.text_style_height(&egui::TextStyle::Monospace) - 1.0); + let text_color = ui.visuals().text_color(); + let weak = ui.visuals().weak_text_color(); + let mut open: Option<(usize, usize)> = None; + let mut toggle: Option = None; + + // Keyboard: Up/Down to move, Enter to open. + if !ui.ctx().egui_wants_keyboard_input() && !self.rows.is_empty() { + let (up, down, enter) = + ui.input(|i| (i.key_pressed(Key::ArrowUp), i.key_pressed(Key::ArrowDown), i.key_pressed(Key::Enter))); + let cur = self.selected.unwrap_or(0); + if down { + self.selected = Some((cur + 1).min(self.rows.len() - 1)); + } + if up { + self.selected = Some(cur.saturating_sub(1)); + } + if enter && let Some(Row::Hit(f, h)) = self.selected.and_then(|s| self.rows.get(s).copied()) { + open = Some((f, h)); + } + } + + egui::ScrollArea::both().auto_shrink(false).show_rows(ui, row_h, self.rows.len(), |ui, range| { + for i in range { + let selected = self.selected == Some(i); + match self.rows[i] { + Row::File(fi) => { + let f = &files[fi]; + let arrow = if self.collapsed.contains(&fi) { "▶" } else { "▼" }; + let text = format!( + "{arrow} {} ({} matches{}, {})", + grep::display_path(&root, &f.path), + fmt_num(f.hits.len() as u64), + if f.truncated { "+" } else { "" }, + fmt_size(f.size) + ); + let r = ui.selectable_label(selected, RichText::new(text).strong()); + if r.clicked() { + self.selected = Some(i); + toggle = Some(fi); + } + } + Row::Hit(fi, hi) => { + let h = &files[fi].hits[hi]; + let mut job = LayoutJob::default(); + job.append(&format!("{:>8}: ", h.line_number), 16.0, TextFormat::simple(font.clone(), weak)); + let mut pos = 0; + let (bg, fg) = palette::match_colors("amber", dark); + for r in &h.ranges { + if r.start < pos || r.end > h.text.len() { + continue; + } + job.append(&h.text[pos..r.start], 0.0, TextFormat::simple(font.clone(), text_color)); + job.append( + &h.text[r.clone()], + 0.0, + TextFormat { background: bg, ..TextFormat::simple(font.clone(), fg) }, + ); + pos = r.end; + } + job.append(&h.text[pos..], 0.0, TextFormat::simple(font.clone(), text_color)); + job.wrap.max_width = f32::INFINITY; + let r = ui.selectable_label(selected, job); + if r.clicked() { + self.selected = Some(i); + } + if r.double_clicked() { + open = Some((fi, hi)); + } + r.context_menu(|ui| { + if ui.button("Open in viewer").clicked() { + open = Some((fi, hi)); + ui.close(); + } + if ui.button("Copy line").clicked() { + ui.ctx().copy_text(h.text.clone()); + ui.close(); + } + }); + } + } + } + }); + if let Some(fi) = toggle + && !self.collapsed.remove(&fi) + { + self.collapsed.insert(fi); + } + if let Some((fi, hi)) = open { + let f = &files[fi]; + actions.push(GrepAction::Open { path: f.path.clone(), offset: f.hits[hi].offset, query: query.clone() }); + } + } +} diff --git a/src/ui/log_tab.rs b/src/ui/log_tab.rs new file mode 100644 index 0000000..687b4fe --- /dev/null +++ b/src/ui/log_tab.rs @@ -0,0 +1,1654 @@ +//! One open log file: its index, view model, filter, search and highlights. + +use std::collections::{BTreeSet, HashMap}; +use std::num::NonZeroUsize; +use std::path::{Path, PathBuf}; +use std::sync::Arc; +use std::time::{Duration, Instant}; + +use egui::{Color32, FontId, Galley, Key, Modifiers, Rect, Sense, Ui, pos2, vec2}; +use lru::LruCache; + +use crate::index::{EntryIndex, SharedIndex}; +use crate::job::{Generation, Notify}; +use crate::passes::{self, Match, SearchQuery, SharedFilter, SharedSearch}; +use crate::pattern::{self, Detection, PatternDef}; +use crate::rowmap::{RowMap, Visible}; +use crate::rules::{self, CompiledFilter, CompiledHighlight, Rule, RuleKind, Scope}; +use crate::settings::Settings; +use crate::source::{ByteSource, MmapSource}; +use crate::ui::palette; +use crate::ui::panels::{PatternEditor, RulesDialog}; +use crate::ui::text::{self, LineSpec, MAX_LINE_SHOWN, Style}; + +const FILTER_DEBOUNCE: Duration = Duration::from_millis(150); +const SEARCH_DEBOUNCE: Duration = Duration::from_millis(200); +const RESIZE_DEBOUNCE: Duration = Duration::from_millis(100); +const SIZE_CHECK_EVERY: Duration = Duration::from_secs(1); +const SCROLLBAR_W: f32 = 12.0; +const MIN_THUMB: f32 = 24.0; +/// Entries with more lines than this get their line starts cached. +const LINE_CACHE_MIN_LINES: u32 = 64; +/// Row-tint rules look at no more than this much of an entry. +const TINT_SCAN_LIMIT: usize = 1 << 20; + +/// The scroll position: an entry, a line within it, and a pixel offset into that row. +#[derive(Clone, Copy, Debug, Default)] +struct Anchor { + entry: u32, + line: u32, + px: f32, +} + +#[derive(Hash, PartialEq, Eq, Clone, Copy)] +struct RowKey { + entry: u32, + line: u32, + width: u32, + collapsed_badge: bool, + decor: u64, +} + +/// Something the tab asks the app to do. +pub enum TabAction { + SaveSettings, + Status(String), +} + +pub struct SearchState { + pub text: String, + pub regex: bool, + pub case_sensitive: bool, + pub whole_word: bool, + pub hidden_too: bool, + active: Option, + shared: Option>, + generation: Generation, + pub error: Option, + current: Option, + dirty_at: Option, + pending_step: Option, + seen: usize, + pub focus: bool, +} + +impl Default for SearchState { + fn default() -> Self { + Self { + text: String::new(), + regex: false, + case_sensitive: false, + whole_word: false, + hidden_too: false, + active: None, + shared: None, + generation: Generation::new(), + error: None, + current: None, + dirty_at: None, + pending_step: None, + seen: 0, + focus: false, + } + } +} + +struct FilterState { + generation: Generation, + shared: Option>, + synced: usize, + dirty_at: Option, + new_text: String, +} + +struct PendingJump { + offset: u64, + expand: bool, + reveal: bool, +} + +pub struct LogTab { + pub path: PathBuf, + pub title: String, + src: Arc, + file_len: u64, + last_size_check: Instant, + pub file_grew: bool, + pub file_missing: bool, + pub error: Option, + notify: Notify, + + pub pattern: PatternDef, + pub detection: Option, + index_gen: Generation, + pub index: Arc, + index_elapsed: Option, + line_prefix: Option>, + + // View model. + visible: Visible, + expanded: BTreeSet, + collapsed: BTreeSet, + pub expand_all: bool, + revealed: BTreeSet, + expand_version: u64, + /// Bumped whenever `visible` is replaced rather than extended. + visible_version: u64, + rowmap: RowMap, + rowmap_key: (usize, usize, u64, u64, bool), + rowmap_built: Instant, + anchor: Anchor, + h_offset: f32, + content_w: f32, + pub wrap: bool, + wrap_width: f32, + width_changed_at: Option, + pending_width: f32, + selected: Option, + pending_jump: Option, + center_on_anchor: bool, + ensure_visible: Option, + /// Pixels to scroll on the next frame (positive = down). + scroll_px: f32, + page_h: f32, + row_h: f32, + + // Rules. + pub rules: Vec, + highlights: Vec, + filter: FilterState, + decor_gen: u64, + pub search: SearchState, + + // Caches. + galleys: LruCache>, + tints: HashMap>, + line_starts: LruCache>>, + dark: bool, + + // Panels and dialogs. + pub pattern_editor: Option, + pub show_rules: bool, + pub rules_dialog: Option, + pub detail: Option, + goto: Option, +} + +impl LogTab { + pub fn open(path: &Path, settings: &Settings, notify: Notify) -> anyhow::Result { + let src = MmapSource::open(path)?; + let file_len = src.len(); + let src: Arc = Arc::new(src); + let (pattern, detection) = match settings.saved_pattern(path) { + Some(p) if p.compile().is_ok() => (p, None), + _ => { + let d = pattern::detect(src.bytes(), &settings.extra_patterns); + (d.chosen.clone(), Some(d)) + } + }; + let file_settings = settings.file(path); + let rules = settings.rules_for(path); + let title = + path.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_else(|| path.display().to_string()); + let index_gen = Generation::new(); + let index = crate::index::spawn( + src.clone(), + pattern.compile().unwrap_or_else(|_| pattern::every_line().compile().unwrap()), + index_gen.bump(), + notify.clone(), + ); + let mut tab = Self { + path: path.to_path_buf(), + title, + src, + file_len, + last_size_check: Instant::now(), + file_grew: false, + file_missing: false, + error: None, + notify, + pattern, + detection, + index_gen, + index, + index_elapsed: None, + line_prefix: None, + visible: Visible::All(0), + expanded: BTreeSet::new(), + collapsed: BTreeSet::new(), + expand_all: false, + revealed: BTreeSet::new(), + expand_version: 0, + visible_version: 0, + rowmap: RowMap::default(), + rowmap_key: (usize::MAX, 0, 0, 0, false), + rowmap_built: Instant::now(), + anchor: Anchor::default(), + h_offset: 0.0, + content_w: 0.0, + wrap: file_settings.wrap, + wrap_width: 0.0, + width_changed_at: None, + pending_width: 0.0, + selected: None, + pending_jump: None, + center_on_anchor: false, + ensure_visible: None, + scroll_px: 0.0, + page_h: 400.0, + row_h: 16.0, + rules: Vec::new(), + highlights: Vec::new(), + filter: FilterState { + generation: Generation::new(), + shared: None, + synced: 0, + dirty_at: None, + new_text: String::new(), + }, + decor_gen: 0, + search: SearchState::default(), + galleys: LruCache::new(NonZeroUsize::new(4000).unwrap()), + tints: HashMap::new(), + line_starts: LruCache::new(NonZeroUsize::new(16).unwrap()), + dark: false, + pattern_editor: None, + show_rules: false, + rules_dialog: None, + detail: None, + goto: None, + }; + tab.set_rules(rules); + Ok(tab) + } + + pub fn bytes(&self) -> &[u8] { + self.src.bytes() + } + + // ----- index ----- + + /// Re-runs the indexer with `pattern`, keeping the view on the same bytes. + pub fn reindex(&mut self, pattern: PatternDef) { + let Ok(re) = pattern.compile() else { return }; + let keep = self.anchor_offset(); + self.pattern = pattern; + self.restart_index(re); + if let Some(off) = keep { + self.pending_jump = Some(PendingJump { offset: off, expand: false, reveal: false }); + } + } + + fn restart_index(&mut self, re: regex::bytes::Regex) { + self.filter.generation.cancel(); + self.index = crate::index::spawn(self.src.clone(), re, self.index_gen.bump(), self.notify.clone()); + self.index_elapsed = None; + self.line_prefix = None; + self.expanded.clear(); + self.collapsed.clear(); + self.revealed.clear(); + self.selected = None; + self.anchor = Anchor::default(); + self.expand_version += 1; + self.rowmap_key.0 = usize::MAX; + self.filter.shared = None; + self.visible = Visible::All(0); + self.visible_version += 1; + self.invalidate_decor(); + if self.has_filter() { + self.filter.dirty_at = Some(Instant::now() - FILTER_DEBOUNCE); + } + } + + fn anchor_offset(&self) -> Option { + self.index.index.read().unwrap().offsets.get(self.anchor.entry as usize).copied() + } + + /// Reopens the file after it changed on disk. + pub fn reload(&mut self) { + match MmapSource::open(&self.path) { + Ok(src) => { + self.file_len = src.len(); + self.src = Arc::new(src); + self.file_grew = false; + self.file_missing = false; + self.error = None; + self.line_starts.clear(); + let re = self.pattern.compile().unwrap_or_else(|_| pattern::every_line().compile().unwrap()); + let keep = self.anchor_offset(); + self.restart_index(re); + if let Some(off) = keep.filter(|&o| o < self.file_len) { + self.pending_jump = Some(PendingJump { offset: off, expand: false, reveal: false }); + } + if self.search.active.is_some() { + self.search.dirty_at = Some(Instant::now() - SEARCH_DEBOUNCE); + self.search.active = None; + } + } + Err(e) => self.error = Some(format!("{e:#}")), + } + } + + /// Guards against SIGBUS: a mapped file that shrank must be remapped. + pub fn check_file(&mut self, force: bool) { + if !force && self.last_size_check.elapsed() < SIZE_CHECK_EVERY { + return; + } + self.last_size_check = Instant::now(); + match std::fs::metadata(&self.path) { + Ok(m) if m.len() < self.file_len => { + self.cancel_all(); + self.reload(); + } + Ok(m) => { + self.file_missing = false; + self.file_grew = m.len() > self.file_len; + } + Err(_) => self.file_missing = true, + } + } + + pub fn cancel_all(&mut self) { + self.index_gen.cancel(); + self.filter.generation.cancel(); + self.search.generation.cancel(); + } + + // ----- rules ----- + + pub fn set_rules(&mut self, rules: Vec) { + self.rules = rules; + self.rules_changed(); + self.filter.dirty_at = Some(Instant::now() - FILTER_DEBOUNCE); + } + + pub fn rules_changed(&mut self) { + self.highlights = rules::compile_highlights(&self.rules); + self.invalidate_decor(); + } + + pub fn filters_changed(&mut self) { + self.filter.dirty_at = Some(Instant::now()); + } + + fn has_filter(&self) -> bool { + self.rules.iter().any(|r| r.enabled && r.is_filter() && r.validate().is_ok()) + } + + fn invalidate_decor(&mut self) { + self.decor_gen += 1; + self.tints.clear(); + } + + // ----- per-frame sync ----- + + /// Pulls fresh results from the workers. Called once per frame. + pub fn poll(&mut self, settings: &Settings) { + let index = self.index.clone(); + if index.is_done() && self.index_elapsed.is_none() { + self.index_elapsed = + Some(Duration::from_micros(index.elapsed_us.load(std::sync::atomic::Ordering::Relaxed))); + let idx = index.index.read().unwrap(); + let mut prefix = Vec::with_capacity(idx.len() + 1); + let mut sum = 0u64; + for &l in &idx.lines { + prefix.push(sum); + sum += l as u64; + } + prefix.push(sum); + self.line_prefix = Some(prefix); + } + let _ = settings; + + // Filter: start a pass once debounced and the index is complete. + if let Some(at) = self.filter.dirty_at + && at.elapsed() >= FILTER_DEBOUNCE + && index.is_done() + { + self.filter.dirty_at = None; + self.start_filter(); + } + let n = index.index.read().unwrap().len(); + match &self.filter.shared { + None => self.visible = Visible::All(n), + Some(shared) => { + let shared = shared.clone(); + let got = shared.visible.read().unwrap(); + let Visible::Some(v) = &mut self.visible else { unreachable!("filter view is a subset") }; + if got.len() > self.filter.synced { + v.extend_from_slice(&got[self.filter.synced..]); + self.filter.synced = got.len(); + for &r in &self.revealed { + if let Err(p) = v.binary_search(&r) { + v.insert(p, r); + self.visible_version += 1; + } + } + } + } + } + + // Search: start once debounced. + if let Some(at) = self.search.dirty_at + && at.elapsed() >= SEARCH_DEBOUNCE + { + self.search.dirty_at = None; + self.start_search(); + } + if let Some(s) = self.search.shared.clone() { + let count = s.matches.read().unwrap().len(); + if count != self.search.seen { + self.search.seen = count; + self.invalidate_decor(); + } + if let Some(forward) = self.search.pending_step + && (count > 0 || s.is_done()) + { + self.search.pending_step = None; + self.step_match(forward); + } + } + + // Debounced relayout after a width change in wrap mode. + if let Some(at) = self.width_changed_at + && at.elapsed() >= RESIZE_DEBOUNCE + { + self.width_changed_at = None; + self.wrap_width = self.pending_width; + self.galleys.clear(); + } + + self.check_file(false); + } + + fn start_filter(&mut self) { + let token = self.filter.generation.bump(); + self.filter.synced = 0; + self.visible_version += 1; + self.revealed.clear(); + if !self.has_filter() { + self.filter.shared = None; + return; + } + let compiled = CompiledFilter::new(&self.rules); + self.visible = Visible::Some(Vec::new()); + self.filter.shared = + Some(passes::spawn_filter(self.src.clone(), self.index.clone(), compiled, token, self.notify.clone())); + } + + pub fn start_search(&mut self) { + let token = self.search.generation.bump(); + self.search.current = None; + self.search.seen = 0; + self.search.error = None; + if self.search.text.is_empty() { + self.search.active = None; + self.search.shared = None; + self.invalidate_decor(); + return; + } + let q = SearchQuery { + text: self.search.text.clone(), + regex: self.search.regex, + case_sensitive: self.search.case_sensitive, + whole_word: self.search.whole_word, + }; + match q.compile() { + Ok(re) => { + self.search.shared = Some(passes::spawn_search(self.src.clone(), re, token, self.notify.clone())); + self.search.active = Some(q); + } + Err(e) => { + self.search.error = Some(e.to_string()); + self.search.shared = None; + self.search.active = None; + } + } + self.invalidate_decor(); + } + + pub fn search_changed(&mut self) { + self.search.dirty_at = Some(Instant::now()); + } + + /// Sets the search box (used by folder grep) and runs it right away. + pub fn set_search(&mut self, q: &SearchQuery) { + self.search.text = q.text.clone(); + self.search.regex = q.regex; + self.search.case_sensitive = q.case_sensitive; + self.search.whole_word = q.whole_word; + self.start_search(); + } + + fn sync_rowmap(&mut self, idx: &EntryIndex) { + let key = (self.visible.len(), idx.len(), self.expand_version, self.visible_version, self.expand_all); + let old = self.rowmap_key; + let growing = !self.index.is_done(); + if self.expand_all { + if key == old { + return; + } + // A dense rebuild is O(n): throttle it while the index or filter is still growing. + let only_grew = key.0 >= old.0 && old.0 != usize::MAX && (key.2, key.3, key.4) == (old.2, old.3, old.4); + let filtering = self.filter.shared.as_ref().is_some_and(|f| !f.is_done()); + if only_grew && (growing || filtering) && self.rowmap_built.elapsed() < Duration::from_millis(500) { + return; + } + let vis = &self.visible; + let collapsed = &self.collapsed; + self.rowmap = RowMap::dense(vis.len(), |v| { + let e = vis.entry(v); + if collapsed.contains(&e) { 1 } else { idx.lines[e as usize] } + }); + } else { + // Cheap (k log n); while indexing, the last entry can still grow. + if key == old && !growing { + return; + } + let list = self + .expanded + .iter() + .filter_map(|&e| Some((self.visible.position(e)?, *idx.lines.get(e as usize)?))) + .collect(); + self.rowmap = RowMap::sparse(self.visible.len(), list); + } + self.rowmap_key = key; + self.rowmap_built = Instant::now(); + } + + // ----- expansion ----- + + pub fn is_expanded(&self, entry: u32) -> bool { + if self.expand_all { !self.collapsed.contains(&entry) } else { self.expanded.contains(&entry) } + } + + pub fn set_expanded(&mut self, entry: u32, yes: bool) { + if self.is_expanded(entry) == yes { + return; + } + if self.expand_all { + if yes { + self.collapsed.remove(&entry) + } else { + self.collapsed.insert(entry) + }; + } else if yes { + self.expanded.insert(entry); + } else { + self.expanded.remove(&entry); + } + if !yes && self.anchor.entry == entry { + self.anchor.line = 0; + self.anchor.px = 0.0; + } + self.expand_version += 1; + } + + pub fn set_expand_all(&mut self, yes: bool) { + self.expand_all = yes; + self.expanded.clear(); + self.collapsed.clear(); + self.expand_version += 1; + if !yes { + self.anchor.line = 0; + self.anchor.px = 0.0; + } + } + + // ----- navigation ----- + + pub fn jump_to_offset(&mut self, offset: u64, reveal: bool) { + self.pending_jump = Some(PendingJump { offset, expand: true, reveal }); + } + + fn process_pending_jump(&mut self, idx: &EntryIndex) { + let Some(j) = &self.pending_jump else { return }; + let covered = + self.index.is_done() || self.index.bytes_done.load(std::sync::atomic::Ordering::Relaxed) > j.offset; + if !covered { + return; + } + let (offset, expand, reveal) = (j.offset, j.expand, j.reveal); + // Wait for the filter to reach the entry before deciding visibility. + let Some(entry) = idx.entry_at(offset) else { + self.pending_jump = None; + return; + }; + if let Some(f) = &self.filter.shared + && !f.is_done() + && f.entries_done.load(std::sync::atomic::Ordering::Relaxed) <= entry + { + return; + } + if self.filter.dirty_at.is_some() { + return; + } + self.pending_jump = None; + let entry = entry as u32; + let start = idx.offsets[entry as usize] as usize; + let line = memchr::memchr_iter(b'\n', &self.bytes()[start..offset as usize]).count() as u32; + if reveal && self.visible.position(entry).is_none() { + self.revealed.insert(entry); + if let Visible::Some(v) = &mut self.visible + && let Err(p) = v.binary_search(&entry) + { + v.insert(p, entry); + self.visible_version += 1; + } + } + if line > 0 && expand { + self.set_expanded(entry, true); + } + let line = if self.is_expanded(entry) { line } else { 0 }; + self.anchor = Anchor { entry, line, px: 0.0 }; + self.selected = Some(entry); + self.center_on_anchor = expand; + self.rowmap_key.0 = usize::MAX; + } + + pub fn goto_line(&mut self, line_1: u64) -> Result<(), String> { + let Some(prefix) = &self.line_prefix else { return Err("indexing not finished yet".into()) }; + let total = *prefix.last().unwrap_or(&0); + if line_1 == 0 || line_1 > total { + return Err(format!("line must be 1–{total}")); + } + let line0 = line_1 - 1; + let entry = prefix.partition_point(|&p| p <= line0) - 1; + let within = line0 - prefix[entry]; + let idx = self.index.index.read().unwrap(); + let start = idx.offsets[entry] as usize; + let bytes = self.src.bytes(); + let mut off = start; + for _ in 0..within { + off += memchr::memchr(b'\n', &bytes[off..]).map(|p| p + 1).unwrap_or(0); + } + drop(idx); + self.jump_to_offset(off as u64, true); + Ok(()) + } + + /// Moves to the next or previous search match. + pub fn step_match(&mut self, forward: bool) { + if self.search.dirty_at.is_some() { + self.search.dirty_at = None; + self.start_search(); + } + let Some(shared) = self.search.shared.clone() else { return }; + let matches = shared.matches.read().unwrap(); + if matches.is_empty() { + if !shared.is_done() { + self.search.pending_step = Some(forward); + } + return; + } + let idx = self.index.index.read().unwrap(); + let n = matches.len(); + let start = match self.search.current { + Some(cur) => { + let p = matches.partition_point(|m| *m < cur); + if forward { p + 1 } else { p + n - 1 } + } + None => { + let top = idx.offsets.get(self.anchor.entry as usize).copied().unwrap_or(0); + let p = matches.partition_point(|m| m.offset < top); + if forward { p } else { p + n - 1 } + } + }; + let filtered = self.filter.shared.is_some(); + let mut found = None; + for k in 0..n { + let i = if forward { (start + k) % n } else { (start + n - k % n) % n }; + let m = matches[i]; + if filtered && !self.search.hidden_too { + match idx.entry_at(m.offset) { + Some(e) if self.visible.position(e as u32).is_some() => {} + _ => continue, + } + } + found = Some(m); + break; + } + drop(idx); + drop(matches); + if let Some(m) = found { + self.search.current = Some(m); + self.invalidate_decor(); + self.jump_to_offset(m.offset, self.search.hidden_too); + } + } + + pub fn search_status(&self) -> Option { + let s = self.search.shared.as_ref()?; + let matches = s.matches.read().unwrap(); + let total = matches.len(); + let pos = self.search.current.map(|c| matches.partition_point(|m| *m < c) + 1); + let mut out = match pos { + Some(p) => format!("match {} of {}", fmt_num(p as u64), fmt_num(total as u64)), + None => format!("{} matches", fmt_num(total as u64)), + }; + if s.capped.load(std::sync::atomic::Ordering::Relaxed) { + out.push_str(" (too many matches, capped at 1M)"); + } + if !s.is_done() { + out.push_str(&format!(" (searching {:.0}%)", s.progress() * 100.0)); + } + Some(out) + } + + pub fn status_text(&self) -> String { + let idx_len = self.index.index.read().unwrap().len() as u64; + let mut s = String::new(); + match &self.filter.shared { + Some(f) => { + s.push_str(&format!("{} of {} entries", fmt_num(self.visible.len() as u64), fmt_num(idx_len))); + if !f.is_done() { + s.push_str(&format!(" (filtering {:.0}%)", f.progress() * 100.0)); + } + } + None => s.push_str(&format!("{} entries", fmt_num(idx_len))), + } + if let Some(p) = &self.line_prefix { + s.push_str(&format!(" · {} lines", fmt_num(*p.last().unwrap_or(&0)))); + } + s.push_str(&format!(" · {}", fmt_size(self.file_len))); + if let Some(t) = self.index_elapsed { + s.push_str(&format!(" · indexed in {:.2} s", t.as_secs_f32())); + } + s + } + + // ----- text access ----- + + fn entry_text(&self, idx: &EntryIndex, entry: u32, limit: usize) -> String { + let r = idx.range(entry as usize, self.file_len); + let end = r.end.min(r.start + limit); + let mut s = String::from_utf8_lossy(&self.bytes()[r.start..end]).into_owned(); + while s.ends_with('\n') || s.ends_with('\r') { + s.pop(); + } + if end < r.end { + s.push_str("\n… (cut)"); + } + s + } + + pub fn detail_text(&self, entry: u32) -> String { + let idx = self.index.index.read().unwrap(); + if entry as usize >= idx.len() { + return String::new(); + } + self.entry_text(&idx, entry, 16 << 20) + } + + /// Byte range of line `line` of `entry`, without its terminator. + fn line_range(&mut self, idx: &EntryIndex, entry: u32, line: u32) -> (usize, usize) { + let r = idx.range(entry as usize, self.file_len); + let src = self.src.clone(); + let bytes = src.bytes(); + let lines = idx.lines[entry as usize]; + let start = if line == 0 { + r.start + } else if lines > LINE_CACHE_MIN_LINES { + let starts = match self.line_starts.get(&entry) { + Some(s) => s.clone(), + None => { + let mut v = vec![r.start]; + v.extend(memchr::memchr_iter(b'\n', &bytes[r.clone()]).map(|p| r.start + p + 1)); + let v = Arc::new(v); + self.line_starts.put(entry, v.clone()); + v + } + }; + starts.get(line as usize).copied().unwrap_or(r.end) + } else { + let mut pos = r.start; + for _ in 0..line { + pos = memchr::memchr(b'\n', &bytes[pos..r.end]).map(|p| pos + p + 1).unwrap_or(r.end); + } + pos + }; + let mut end = memchr::memchr(b'\n', &bytes[start.min(r.end)..r.end]).map(|p| start + p).unwrap_or(r.end); + if end > start && bytes[end - 1] == b'\r' { + end -= 1; + } + (start, end.max(start)) + } + + fn entry_tint(&mut self, idx: &EntryIndex, entry: u32) -> Option { + let hit = match self.tints.get(&entry) { + Some(h) => *h, + None => { + let r = idx.range(entry as usize, self.file_len); + let hay = &self.src.bytes()[r.start..r.end.min(r.start + TINT_SCAN_LIMIT)]; + let h = self.highlights.iter().position(|h| h.scope == Scope::Row && h.re.is_match(hay)); + self.tints.insert(entry, h); + h + } + }; + hit.map(|i| palette::row_tint(&self.highlights[i].color, self.dark)) + } + + fn galley(&mut self, ui: &Ui, idx: &EntryIndex, entry: u32, line: u32, text_w: f32) -> Arc { + let lines = idx.lines[entry as usize]; + let badge = (line == 0 && lines > 1 && !self.is_expanded(entry)).then_some(lines - 1); + let width = if self.wrap { text_w.max(50.0) } else { 0.0 }; + let key = RowKey { entry, line, width: width as u32, collapsed_badge: badge.is_some(), decor: self.decor_gen }; + if let Some(g) = self.galleys.get(&key) { + return g.clone(); + } + let (start, end) = self.line_range(idx, entry, line); + let truncated = end - start > MAX_LINE_SHOWN; + let end_shown = if truncated { start + MAX_LINE_SHOWN } else { end }; + let matches = match &self.search.shared { + Some(s) => s.in_range(start as u64, end_shown as u64), + None => Vec::new(), + }; + let src = self.src.clone(); + let spec = LineSpec { + bytes: &src.bytes()[start..end_shown], + file_offset: start as u64, + truncated, + matches: &matches, + current: self.search.current, + badge, + continuation: line > 0, + }; + let style = Style { + font: FontId::monospace(ui.style().text_styles[&egui::TextStyle::Monospace].size), + dark: self.dark, + text: ui.visuals().text_color(), + dim: ui.visuals().weak_text_color(), + wrap_width: self.wrap.then_some(width), + }; + let job = text::build_job(&spec, &self.highlights, &style); + let g = ui.painter().layout_job(job); + self.galleys.put(key, g.clone()); + g + } + + // ----- drawing ----- + + pub fn show(&mut self, ui: &mut Ui, settings: &mut Settings) -> Vec { + let mut actions = Vec::new(); + if self.dark != ui.visuals().dark_mode { + self.dark = ui.visuals().dark_mode; + self.invalidate_decor(); + } + self.poll(settings); + + egui::Panel::top("toolbar").show(ui, |ui| { + self.toolbar(ui, settings, &mut actions); + }); + egui::Panel::top("filterbar").show(ui, |ui| { + self.filter_bar(ui); + }); + egui::Panel::bottom("status").show(ui, |ui| { + self.status_bar(ui); + }); + if self.pattern_editor.is_some() { + egui::Panel::left("pattern").resizable(true).default_size(480.0).show(ui, |ui| { + if let Some(a) = crate::ui::panels::pattern_panel(self, ui, settings) { + actions.push(a); + } + }); + } + if self.show_rules { + egui::Panel::right("rules").resizable(true).default_size(360.0).show(ui, |ui| { + actions.extend(crate::ui::panels::rules_panel(self, ui, settings)); + }); + } + egui::CentralPanel::default().show(ui, |ui| { + if let Some(e) = &self.error { + ui.colored_label(ui.visuals().error_fg_color, e); + } + if self.file_missing { + ui.colored_label( + ui.visuals().warn_fg_color, + "The file was deleted or moved. Showing the last version.", + ); + } + self.log_view(ui, settings); + }); + self.dialogs(ui, settings, &mut actions); + actions + } + + fn toolbar(&mut self, ui: &mut Ui, settings: &mut Settings, actions: &mut Vec) { + ui.horizontal(|ui| { + if ui.button("✏ Entry start").on_hover_text("Edit the entry-start pattern").clicked() { + self.pattern_editor = match self.pattern_editor { + Some(_) => None, + None => Some(PatternEditor::new(self, settings)), + }; + } + ui.label(egui::RichText::new(&self.pattern.name).strong()) + .on_hover_text(format!("^{}", self.pattern.regex)); + ui.separator(); + if ui.button("⊞ Expand all").clicked() { + self.set_expand_all(true); + } + if ui.button("⊟ Collapse all").clicked() { + self.set_expand_all(false); + } + let wrap = ui.toggle_value(&mut self.wrap, "↩ Wrap").on_hover_text("Line wrap (Alt+Z)"); + if wrap.changed() { + self.wrap_changed(settings, actions); + } + ui.toggle_value(&mut self.show_rules, "🎨 Highlights"); + ui.separator(); + self.search_box(ui); + }); + } + + pub fn wrap_changed(&mut self, settings: &mut Settings, actions: &mut Vec) { + settings.file_mut(&self.path).wrap = self.wrap; + self.galleys.clear(); + self.anchor.px = 0.0; + self.h_offset = 0.0; + actions.push(TabAction::SaveSettings); + } + + fn search_box(&mut self, ui: &mut Ui) { + ui.label("🔍"); + let edit = egui::TextEdit::singleline(&mut self.search.text).hint_text("Search (Ctrl+F)").desired_width(220.0); + let resp = ui.add(edit); + if self.search.focus { + resp.request_focus(); + self.search.focus = false; + } + if resp.changed() { + self.search_changed(); + } + if resp.lost_focus() && ui.input(|i| i.key_pressed(Key::Enter)) { + let back = ui.input(|i| i.modifiers.shift); + self.step_match(!back); + resp.request_focus(); + } + let mut changed = false; + changed |= ui.toggle_value(&mut self.search.regex, ".*").on_hover_text("Regex").changed(); + changed |= ui.toggle_value(&mut self.search.case_sensitive, "Aa").on_hover_text("Case sensitive").changed(); + changed |= ui.toggle_value(&mut self.search.whole_word, "\\b").on_hover_text("Whole word").changed(); + if changed { + self.search_changed(); + } + if ui.button("⏶").on_hover_text("Previous match (Shift+Enter, Shift+F3)").clicked() { + self.step_match(false); + } + if ui.button("⏷").on_hover_text("Next match (Enter, F3)").clicked() { + self.step_match(true); + } + if self.filter.shared.is_some() { + ui.checkbox(&mut self.search.hidden_too, "hidden too") + .on_hover_text("Also stop at matches in entries hidden by the filter"); + } + if let Some(e) = &self.search.error { + ui.colored_label(ui.visuals().error_fg_color, "invalid regex").on_hover_text(e); + } + } + + fn filter_bar(&mut self, ui: &mut Ui) { + ui.horizontal_wrapped(|ui| { + ui.label("Filter:"); + let mut remove = None; + let mut changed = false; + for (i, r) in self.rules.iter_mut().enumerate().filter(|(_, r)| r.is_filter()) { + let fill = match r.kind { + RuleKind::Exclude => Color32::from_rgba_unmultiplied(0xe5, 0x48, 0x4d, 40), + _ => Color32::from_rgba_unmultiplied(0x30, 0xa4, 0x6c, 40), + }; + egui::Frame::new().fill(fill).corner_radius(4.0).inner_margin(vec2(4.0, 1.0)).show(ui, |ui| { + ui.horizontal(|ui| { + changed |= ui.checkbox(&mut r.enabled, "").changed(); + let label = if r.kind == RuleKind::Exclude { "not" } else { "only" }; + if ui.small_button(label).on_hover_text("Switch between Exclude and Only").clicked() { + r.kind = if r.kind == RuleKind::Exclude { RuleKind::Only } else { RuleKind::Exclude }; + changed = true; + } + let font = egui::TextStyle::Body.resolve(ui.style()); + let w = ui.fonts_mut(|f| f.layout_no_wrap(r.pattern.clone(), font, Color32::WHITE).size().x); + let w = (w + 24.0).clamp(40.0, 300.0); + changed |= ui.add(egui::TextEdit::singleline(&mut r.pattern).desired_width(w)).changed(); + changed |= ui.toggle_value(&mut r.regex, ".*").on_hover_text("Regex").changed(); + changed |= + ui.toggle_value(&mut r.case_sensitive, "Aa").on_hover_text("Case sensitive").changed(); + if let Err(e) = r.validate() { + ui.colored_label(ui.visuals().error_fg_color, "⚠").on_hover_text(e); + } + if ui.small_button("✖").clicked() { + remove = Some(i); + } + }); + }); + } + if let Some(i) = remove { + self.rules.remove(i); + changed = true; + } + let resp = + ui.add(egui::TextEdit::singleline(&mut self.filter.new_text).hint_text("keyword").desired_width(140.0)); + let enter = resp.lost_focus() && ui.input(|i| i.key_pressed(Key::Enter)); + let add_ex = ui.button("− Exclude").on_hover_text("Hide entries containing this").clicked() || enter; + let add_only = ui.button("+ Only").on_hover_text("Show only entries containing this").clicked(); + if (add_ex || add_only) && !self.filter.new_text.is_empty() { + let kind = if add_only { RuleKind::Only } else { RuleKind::Exclude }; + self.rules.push(Rule::filter(kind, &std::mem::take(&mut self.filter.new_text))); + changed = true; + } + if changed { + self.filters_changed(); + } + }); + } + + fn status_bar(&mut self, ui: &mut Ui) { + ui.horizontal(|ui| { + if !self.index.is_done() { + let p = self.index.progress(); + ui.add(egui::ProgressBar::new(p).desired_width(160.0).text(format!("indexing {:.0}%", p * 100.0))); + } + ui.label(self.status_text()); + if let Some(s) = self.search_status() { + ui.separator(); + ui.label(s); + } + ui.separator(); + ui.label("UTF-8"); + if self.file_grew { + ui.separator(); + ui.colored_label(ui.visuals().warn_fg_color, "file grew on disk"); + if ui.small_button("Reload").clicked() { + self.reload(); + } + } + }); + } + + fn dialogs(&mut self, ui: &mut Ui, settings: &mut Settings, actions: &mut Vec) { + let ctx = ui.ctx().clone(); + if let Some(entry) = self.detail { + let mut open = true; + let text = self.detail_text(entry); + egui::Window::new(format!("Entry {}", entry + 1)) + .open(&mut open) + .default_size([720.0, 420.0]) + .resizable(true) + .show(&ctx, |ui| { + ui.horizontal(|ui| { + if ui.button("📋 Copy").clicked() { + ui.ctx().copy_text(text.clone()); + } + ui.label(format!("{} bytes", fmt_num(text.len() as u64))); + }); + egui::ScrollArea::both().auto_shrink(false).show(ui, |ui| { + let mut t = text.as_str(); + ui.add( + egui::TextEdit::multiline(&mut t) + .font(egui::TextStyle::Monospace) + .desired_width(f32::INFINITY), + ); + }); + }); + if !open { + self.detail = None; + } + } + if let Some(text) = &mut self.goto { + let mut close = false; + let mut go = None; + egui::Modal::new(egui::Id::unique("goto")).show(&ctx, |ui| { + ui.heading("Go to line"); + let r = ui.add(egui::TextEdit::singleline(text).hint_text("line number")); + r.request_focus(); + ui.horizontal(|ui| { + if ui.button("Go").clicked() || (r.lost_focus() && ui.input(|i| i.key_pressed(Key::Enter))) { + go = text.trim().replace([',', '_', ' '], "").parse::().ok(); + close = true; + } + if ui.button("Cancel").clicked() || ui.input(|i| i.key_pressed(Key::Escape)) { + close = true; + } + }); + }); + if close { + self.goto = None; + } + if let Some(n) = go + && let Err(e) = self.goto_line(n) + { + actions.push(TabAction::Status(e)); + } + } + if self.rules_dialog.is_some() { + actions.extend(crate::ui::panels::rules_dialog(self, &ctx, settings)); + } + } + + /// Keyboard shortcuts for the log view. Text fields keep their own keys. + pub fn handle_keys(&mut self, ctx: &egui::Context, settings: &mut Settings, actions: &mut Vec) { + let cmd = Modifiers::COMMAND; + let f = ctx.input_mut(|i| i.consume_key(cmd, Key::F)); + if f { + self.search.focus = true; + } + if ctx.input_mut(|i| i.consume_key(cmd, Key::G)) { + self.goto = Some(String::new()); + } + if ctx.input_mut(|i| i.consume_key(Modifiers::ALT, Key::Z)) { + self.wrap = !self.wrap; + self.wrap_changed(settings, actions); + } + if ctx.input_mut(|i| i.consume_key(Modifiers::SHIFT, Key::F3)) { + self.step_match(false); + } + if ctx.input_mut(|i| i.consume_key(Modifiers::NONE, Key::F3)) { + self.step_match(true); + } + if ctx.egui_wants_keyboard_input() { + return; + } + let page = (self.page_h - self.row_h).max(self.row_h); + let (up, down, pgup, pgdn, home, end, left, right, space, copy) = ctx.input_mut(|i| { + ( + i.consume_key(Modifiers::NONE, Key::ArrowUp), + i.consume_key(Modifiers::NONE, Key::ArrowDown), + i.consume_key(Modifiers::NONE, Key::PageUp), + i.consume_key(Modifiers::NONE, Key::PageDown), + i.consume_key(cmd, Key::Home) || i.consume_key(Modifiers::NONE, Key::Home), + i.consume_key(cmd, Key::End) || i.consume_key(Modifiers::NONE, Key::End), + i.consume_key(Modifiers::NONE, Key::ArrowLeft), + i.consume_key(Modifiers::NONE, Key::ArrowRight), + i.consume_key(Modifiers::NONE, Key::Space), + // Ctrl/Cmd+C arrives as a Copy event, not as a key press. + i.events.iter().any(|e| matches!(e, egui::Event::Copy)), + ) + }); + if up || down { + self.move_selection(if down { 1 } else { -1 }); + } + if pgup { + self.scroll_px = -page; + } + if pgdn { + self.scroll_px = page; + } + if home { + self.anchor = Anchor::default(); + } + if end { + // Anchor on the last row; the view's end clamp then fills the screen upwards. + self.anchor = Anchor { entry: u32::MAX, line: u32::MAX, px: 0.0 }; + } + if let Some(sel) = self.selected { + if right || space { + let yes = if space { !self.is_expanded(sel) } else { true }; + self.set_expanded(sel, yes); + } + if left { + self.set_expanded(sel, false); + } + if copy { + let idx = self.index.index.read().unwrap(); + if (sel as usize) < idx.len() { + ctx.copy_text(self.entry_text(&idx, sel, 64 << 20)); + } + } + } + } + + fn move_selection(&mut self, delta: i64) { + if self.visible.is_empty() { + return; + } + let cur = match self.selected.and_then(|s| self.visible.position(s)) { + Some(p) => p as i64 + delta, + None => self.visible.nearest_position(self.anchor.entry) as i64, + }; + let p = cur.clamp(0, self.visible.len() as i64 - 1) as usize; + let e = self.visible.entry(p); + self.selected = Some(e); + self.ensure_visible = Some(e); + } +} + +pub fn fmt_num(n: u64) -> String { + let s = n.to_string(); + let mut out = String::new(); + for (i, c) in s.chars().enumerate() { + if i > 0 && (s.len() - i).is_multiple_of(3) { + out.push(','); + } + out.push(c); + } + out +} + +pub fn fmt_size(n: u64) -> String { + const U: [&str; 5] = ["B", "KB", "MB", "GB", "TB"]; + let mut v = n as f64; + let mut u = 0; + while v >= 1024.0 && u < U.len() - 1 { + v /= 1024.0; + u += 1; + } + if u == 0 { format!("{n} B") } else { format!("{v:.1} {}", U[u]) } +} + +// ----- the virtualized log view ----- + +impl LogTab { + fn log_view(&mut self, ui: &mut Ui, settings: &Settings) { + let index = self.index.clone(); + let idx = index.index.read().unwrap(); + self.process_pending_jump(&idx); + self.sync_rowmap(&idx); + + let font = FontId::monospace(ui.style().text_styles[&egui::TextStyle::Monospace].size); + self.row_h = ui.fonts_mut(|f| f.row_height(&font)).ceil() + 2.0; + let char_w = ui.fonts_mut(|f| f.glyph_width(&font, '0')); + + let full = ui.available_rect_before_wrap(); + let hbar_h = if self.wrap { 0.0 } else { SCROLLBAR_W }; + let view = Rect::from_min_max(full.min, pos2(full.max.x - SCROLLBAR_W, full.max.y - hbar_h)); + self.page_h = view.height(); + let id = ui.scope_id().with(("logview", &self.path)); + let bg = ui.interact(view, id, Sense::click()); + + // Gutter. + let total_entries = idx.len() as u64; + let gutter_numbers = settings.show_gutter; + let max_num = if settings.gutter_line_numbers { + self.line_prefix.as_ref().and_then(|p| p.last().copied()).unwrap_or(total_entries) + } else { + total_entries + }; + let gutter_w = if gutter_numbers { (max_num.max(1).ilog10() + 1) as f32 * char_w + 12.0 } else { 0.0 }; + let tri_w = char_w * 2.0; + let text_x = view.left() + gutter_w + tri_w; + let text_w = view.right() - text_x - 4.0; + + // Debounced width tracking for wrap mode. + if self.wrap { + if self.wrap_width == 0.0 { + self.wrap_width = text_w; + } else if (text_w - self.wrap_width).abs() > 0.5 && (text_w - self.pending_width).abs() > 0.5 { + self.pending_width = text_w; + self.width_changed_at = Some(Instant::now()); + ui.ctx().request_repaint_after(RESIZE_DEBOUNCE); + } + } + let wrap_w = self.wrap_width; + + // Scroll input. + if ui.rect_contains_pointer(full) { + let d = ui.input(|i| i.smooth_scroll_delta); + if d.y != 0.0 { + self.scroll_px -= d.y; + } + if !self.wrap && d.x != 0.0 { + self.h_offset -= d.x; + } + } + + let total = self.rowmap.total_rows(); + if total == 0 { + let msg = if !index.is_done() { + "Indexing…" + } else if self.filter.shared.as_ref().is_some_and(|f| !f.is_done()) { + "Filtering…" + } else if idx.is_empty() { + "The file is empty." + } else { + "No entries match the filter." + }; + ui.painter().text( + view.center(), + egui::Align2::CENTER_CENTER, + msg, + FontId::proportional(16.0), + ui.visuals().weak_text_color(), + ); + self.scroll_px = 0.0; + return; + } + + let height_of = |tab: &mut Self, row: u64| -> f32 { + if !tab.wrap { + return tab.row_h; + } + let Some(p) = tab.rowmap.locate(row) else { return tab.row_h }; + let e = tab.visible.entry(p.vpos); + let g = tab.galley(ui, &idx, e, p.line, wrap_w); + g.size().y.max(tab.row_h) + }; + + // Resolve the anchor to a row and apply pending scrolling. + let mut row = self.anchor_row(); + let mut px = self.anchor.px.max(0.0); + let (row0, px0) = (row, px); + if let Some(e) = self.ensure_visible.take() + && let Some(vpos) = self.visible.position(e) + { + let target = self.rowmap.row_of(vpos); + let rows_on_screen = (view.height() / self.row_h).floor().max(1.0) as u64; + if target < row || (target == row && px > 0.0) { + row = target; + px = 0.0; + } else if !self.wrap && target >= row + rows_on_screen { + row = target + 1 - rows_on_screen; + px = 0.0; + } else if self.wrap && target > row + rows_on_screen / 2 { + row = target; + px = 0.0; + self.scroll_px -= view.height() / 2.0; + } + } + if self.center_on_anchor { + self.center_on_anchor = false; + self.scroll_px -= view.height() / 3.0; + } + px += self.scroll_px; + self.scroll_px = 0.0; + while px < 0.0 && row > 0 { + row -= 1; + px += height_of(self, row); + } + px = px.max(0.0); + if row >= total { + row = total - 1; + px = 0.0; + } + while row + 1 < total { + let h = height_of(self, row); + if px < h { + break; + } + px -= h; + row += 1; + } + // Do not scroll past the end: the last row sits at the bottom. + { + let mut fill = -px; + let mut r = row; + while r < total && fill < view.height() { + fill += height_of(self, r); + r += 1; + } + let filtering = self.filter.shared.as_ref().is_some_and(|f| !f.is_done()); + if r >= total && fill < view.height() && index.is_done() && !filtering { + let mut gap = view.height() - fill; + while gap > 0.0 { + if px >= gap { + px -= gap; + gap = 0.0; + } else if row > 0 { + gap -= px; + row -= 1; + px = height_of(self, row); + } else { + px = 0.0; + break; + } + } + } + } + // Keep the anchor entry itself unless the view really moved: while a filter + // is still streaming, the anchor may lie beyond the visible prefix so far. + if (row, px) != (row0, px0) { + self.set_anchor_row(row, px); + } + + // Paint rows. + let painter = ui.painter_at(view); + painter.rect_filled(view, 0.0, ui.visuals().extreme_bg_color); + let sel_fill = ui.visuals().selection.bg_fill.gamma_multiply(0.35); + let gutter_color = ui.visuals().weak_text_color(); + let mut y = view.top() - px; + let mut r = row; + let mut max_w = 0.0f32; + let mut clicked_row: Option<(u32, bool)> = None; + let mut toggle: Option = None; + while y < view.bottom() && r < total { + let Some(p) = self.rowmap.locate(r) else { break }; + let entry = self.visible.entry(p.vpos); + let lines = idx.lines[entry as usize]; + let g = self.galley(ui, &idx, entry, p.line, wrap_w); + let h = g.size().y.max(self.row_h); + let row_rect = Rect::from_min_max(pos2(view.left(), y), pos2(view.right(), y + h)); + + if let Some(tint) = self.entry_tint(&idx, entry) { + painter.rect_filled(row_rect, 0.0, tint); + } + if self.selected == Some(entry) { + painter.rect_filled(row_rect, 0.0, sel_fill); + } + if gutter_numbers { + let n = if settings.gutter_line_numbers { + self.line_prefix.as_ref().map(|lp| lp[entry as usize] + p.line as u64 + 1) + } else { + (p.line == 0).then_some(entry as u64 + 1) + }; + if let Some(n) = n { + painter.text( + pos2(view.left() + gutter_w - 8.0, y + 1.0), + egui::Align2::RIGHT_TOP, + n.to_string(), + font.clone(), + gutter_color, + ); + } + } + let tri_rect = Rect::from_min_size(pos2(view.left() + gutter_w, y), vec2(tri_w, self.row_h)); + if p.line == 0 && lines > 1 { + let open = self.is_expanded(entry); + let tri = ui.interact(tri_rect, id.with(("tri", r)), Sense::click()); + let color = if tri.hovered() { ui.visuals().strong_text_color() } else { gutter_color }; + painter.text( + tri_rect.center(), + egui::Align2::CENTER_CENTER, + if open { "▼" } else { "▶" }, + FontId::proportional(10.0), + color, + ); + if tri.clicked() { + toggle = Some(entry); + } + } + let indent = if p.line > 0 { char_w * 2.0 } else { 0.0 }; + let x = if self.wrap { text_x + indent } else { text_x + indent - self.h_offset }; + let text_clip = Rect::from_min_max(pos2(text_x, view.top()), view.max); + ui.painter_at(text_clip).galley(pos2(x, y + 1.0), g.clone(), ui.visuals().text_color()); + max_w = max_w.max(g.size().x + indent); + + let resp = ui.interact( + Rect::from_min_max(pos2(tri_rect.right(), row_rect.top()), row_rect.max), + id.with(("row", r)), + Sense::click(), + ); + if resp.clicked() { + clicked_row = Some((entry, false)); + } + if resp.double_clicked() && lines > 1 { + clicked_row = Some((entry, true)); + } + let (ls, le) = self.line_range(&idx, entry, p.line); + resp.context_menu(|ui| { + self.selected = Some(entry); + if ui.button("Copy line").clicked() { + ui.ctx().copy_text(String::from_utf8_lossy(&self.bytes()[ls..le]).into_owned()); + ui.close(); + } + if ui.button("Copy entry").clicked() { + ui.ctx().copy_text(self.entry_text(&idx, entry, 64 << 20)); + ui.close(); + } + if ui.button("Show full entry").clicked() { + self.detail = Some(entry); + ui.close(); + } + if lines > 1 { + let label = if self.is_expanded(entry) { "Collapse" } else { "Expand" }; + if ui.button(label).clicked() { + toggle = Some(entry); + ui.close(); + } + } + ui.separator(); + if ui.button("Filter out entries like this").clicked() { + let r = idx.range(entry as usize, self.file_len); + let kw = like_this_keyword(&self.bytes()[r.start..r.end.min(r.start + 4096)], &self.pattern); + if !kw.is_empty() { + self.rules.push(Rule::filter(RuleKind::Exclude, &kw)); + self.filters_changed(); + } + ui.close(); + } + if ui.button("Highlight entries like this").clicked() { + let r = idx.range(entry as usize, self.file_len); + let kw = like_this_keyword(&self.bytes()[r.start..r.end.min(r.start + 4096)], &self.pattern); + if !kw.is_empty() { + self.rules.push(Rule::highlight(&kw, "blue", Scope::Row)); + self.rules_changed(); + self.show_rules = true; + } + ui.close(); + } + }); + y += h; + r += 1; + } + drop(painter); + if bg.clicked() { + ui.memory_mut(|m| m.surrender_focus(id)); + } + if let Some((e, dbl)) = clicked_row { + self.selected = Some(e); + if dbl { + toggle = Some(e); + } + // Give the keyboard back to the view from any text field. + ui.memory_mut(|m| { + if let Some(f) = m.focused() { + m.surrender_focus(f); + } + }); + } + if let Some(e) = toggle { + let open = self.is_expanded(e); + self.set_expanded(e, !open); + self.selected = Some(e); + } + + // Horizontal extent and scrollbar (wrap off). + if !self.wrap { + self.content_w = self.content_w.max(max_w + 16.0); + let max_h = (self.content_w - text_w).max(0.0); + self.h_offset = self.h_offset.clamp(0.0, max_h); + let track = Rect::from_min_max(pos2(text_x, view.bottom()), pos2(view.right(), full.bottom())); + if max_h > 0.0 { + let frac = self.h_offset / max_h; + if let Some(f) = scrollbar(ui, track, id.with("h"), frac, text_w / self.content_w, false) { + self.h_offset = f * max_h; + } + } + } + + // Vertical scrollbar. + let vtrack = Rect::from_min_max(pos2(view.right(), full.top()), pos2(full.right(), view.bottom())); + let rows_on_screen = (view.height() / self.row_h).max(1.0); + let est_total = self.estimated_total_rows(); + let thumb = (rows_on_screen / est_total.max(1) as f32).min(1.0); + let frac = if self.wrap { + let off = idx.offsets.get(self.anchor.entry as usize).copied().unwrap_or(0); + off as f32 / self.file_len.max(1) as f32 + } else { + let span = (est_total as f32 - rows_on_screen).max(1.0); + (row as f32 + px / self.row_h) / span + }; + if let Some(f) = scrollbar(ui, vtrack, id.with("v"), frac.clamp(0.0, 1.0), thumb, true) { + if self.wrap { + let off = (f as f64 * self.file_len as f64) as u64; + if let Some(e) = idx.entry_at(off) { + let vpos = self.visible.nearest_position(e as u32); + self.anchor = Anchor { entry: self.visible.entry(vpos), line: 0, px: 0.0 }; + } + } else { + let span = (est_total as f32 - rows_on_screen).max(0.0); + let target = ((f * span) as u64).min(total - 1); + self.set_anchor_row(target, 0.0); + } + } + } + + fn estimated_total_rows(&self) -> u64 { + let total = self.rowmap.total_rows(); + let mut p = self.index.progress(); + if let Some(f) = &self.filter.shared { + p *= f.progress(); + } + if self.index.is_done() && self.filter.shared.as_ref().is_none_or(|f| f.is_done()) { + total + } else { + (total as f64 / p.max(0.001) as f64) as u64 + } + } + + fn anchor_row(&self) -> u64 { + if self.visible.is_empty() { + return 0; + } + let vpos = self.visible.nearest_position(self.anchor.entry); + let exact = self.visible.entry(vpos) == self.anchor.entry; + let line = if exact { (self.anchor.line as u64).min(self.rowmap.rows_in(vpos) - 1) } else { 0 }; + self.rowmap.row_of(vpos) + line + } + + fn set_anchor_row(&mut self, row: u64, px: f32) { + if let Some(p) = self.rowmap.locate(row) { + self.anchor = Anchor { entry: self.visible.entry(p.vpos), line: p.line, px }; + } + } +} + +/// A plain scrollbar. Returns a new position fraction when dragged or clicked. +fn scrollbar(ui: &mut Ui, track: Rect, id: egui::Id, frac: f32, thumb_frac: f32, vertical: bool) -> Option { + let resp = ui.interact(track, id, Sense::click_and_drag()); + let len = if vertical { track.height() } else { track.width() }; + let thumb_len = (thumb_frac * len).clamp(MIN_THUMB.min(len), len); + let travel = (len - thumb_len).max(1.0); + let start = frac * travel; + let thumb = if vertical { + Rect::from_min_size(pos2(track.left() + 2.0, track.top() + start), vec2(track.width() - 4.0, thumb_len)) + } else { + Rect::from_min_size(pos2(track.left() + start, track.top() + 2.0), vec2(thumb_len, track.height() - 4.0)) + }; + let v = ui.visuals(); + let color = if resp.dragged() || resp.hovered() { v.widgets.hovered.bg_fill } else { v.widgets.inactive.bg_fill }; + ui.painter().rect_filled(track, 0.0, v.faint_bg_color); + ui.painter().rect_filled(thumb, 4.0, color); + let grab = ui.scope_id().with(id).with("grab"); + if resp.drag_started() + && let Some(p) = resp.interact_pointer_pos() + { + let along = if vertical { p.y - thumb.top() } else { p.x - thumb.left() }; + let offset = if (0.0..=thumb_len).contains(&along) { along } else { thumb_len / 2.0 }; + ui.data_mut(|d| d.insert_temp(grab, offset)); + } + if (resp.dragged() || resp.clicked()) + && let Some(p) = resp.interact_pointer_pos() + { + let offset = ui.data(|d| d.get_temp::(grab)).filter(|_| resp.dragged()).unwrap_or(thumb_len / 2.0); + let along = if vertical { p.y - track.top() } else { p.x - track.left() }; + return Some(((along - offset) / travel).clamp(0.0, 1.0)); + } + None +} + +/// A keyword for "filter out entries like this": the first line after the +/// entry-start match (timestamp etc.), trimmed. +fn like_this_keyword(entry: &[u8], pattern: &PatternDef) -> String { + let first = &entry[..memchr::memchr(b'\n', entry).unwrap_or(entry.len())]; + let skip = pattern.compile().ok().and_then(|re| re.find(first)).map(|m| m.end()).unwrap_or(0); + let rest = String::from_utf8_lossy(&first[skip..]); + let rest = rest.trim().trim_start_matches([']', ',', '.', ':']).trim(); + rest.chars().take(80).collect() +} diff --git a/src/ui/mod.rs b/src/ui/mod.rs new file mode 100644 index 0000000..a2ea86b --- /dev/null +++ b/src/ui/mod.rs @@ -0,0 +1,455 @@ +//! The egui front end: the app shell with its tabs, menus and drag-and-drop. + +pub mod debug; +pub mod grep_tab; +pub mod log_tab; +pub mod palette; +pub mod panels; +pub mod text; + +use std::path::{Path, PathBuf}; +use std::sync::Arc; +use std::time::{Duration, Instant}; + +use egui::{Key, Modifiers, RichText}; + +use crate::job::Notify; +use crate::rules::RULES_FILE_EXT; +use crate::settings::Settings; +use grep_tab::{GrepAction, GrepTab}; +use log_tab::{LogTab, TabAction}; + +pub enum Tab { + Log(Box), + Grep(Box), +} + +impl Tab { + fn title(&self) -> String { + match self { + Tab::Log(t) => t.title.clone(), + Tab::Grep(g) => g.title(), + } + } + + fn close(&mut self) { + match self { + Tab::Log(t) => t.cancel_all(), + Tab::Grep(g) => g.cancel(), + } + } +} + +pub struct App { + tabs: Vec, + active: usize, + settings: Settings, + notify: Notify, + status: Option<(String, Instant)>, + show_keys: bool, + show_about: bool, +} + +impl App { + pub fn new(cc: &eframe::CreationContext<'_>, args: Vec) -> Self { + let ctx = cc.egui_ctx.clone(); + let notify: Notify = Arc::new(move || ctx.request_repaint()); + let settings = Settings::load(); + cc.egui_ctx.global_style_mut(|s| { + if let Some(f) = s.text_styles.get_mut(&egui::TextStyle::Monospace) { + f.size = settings.font_size; + } + }); + let mut app = + Self { tabs: Vec::new(), active: 0, settings, notify, status: None, show_keys: false, show_about: false }; + for a in args { + app.open_path(&a); + } + app + } + + fn set_status(&mut self, s: impl Into) { + self.status = Some((s.into(), Instant::now())); + } + + fn save_settings(&mut self) { + if let Err(e) = self.settings.save() { + self.set_status(format!("Cannot save settings: {e:#}")); + } + } + + /// Opens a file, a folder (as a grep tab) or a rule file. + pub fn open_path(&mut self, path: &Path) { + if path.is_dir() { + self.tabs.push(Tab::Grep(Box::new(GrepTab::new(Some(path.to_path_buf()), self.notify.clone())))); + self.active = self.tabs.len() - 1; + return; + } + if path.to_string_lossy().ends_with(RULES_FILE_EXT) { + if let Some(Tab::Log(t)) = self.tabs.get_mut(self.active) { + if let Some(TabAction::Status(s)) = panels::start_import(t, path) { + self.set_status(s); + } + } else { + self.set_status("Open a log file first, then drop the rule file on it"); + } + return; + } + self.open_file(path); + } + + /// Opens a file in a viewer tab, or switches to it if it is already open. + fn open_file(&mut self, path: &Path) -> Option { + let canon = std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf()); + if let Some(i) = self.tabs.iter().position(|t| match t { + Tab::Log(l) => std::fs::canonicalize(&l.path).unwrap_or_else(|_| l.path.clone()) == canon, + _ => false, + }) { + self.active = i; + return Some(i); + } + match LogTab::open(path, &self.settings, self.notify.clone()) { + Ok(tab) => { + self.settings.add_recent(path); + self.save_settings(); + self.tabs.push(Tab::Log(Box::new(tab))); + self.active = self.tabs.len() - 1; + Some(self.active) + } + Err(e) => { + self.set_status(format!("{e:#}")); + None + } + } + } + + fn close_tab(&mut self, i: usize) { + if i < self.tabs.len() { + self.tabs[i].close(); + self.tabs.remove(i); + if self.active >= self.tabs.len() { + self.active = self.tabs.len().saturating_sub(1); + } + } + } + + fn open_dialog(&mut self) { + if let Some(files) = rfd::FileDialog::new().pick_files() { + for f in files { + self.open_path(&f); + } + } + } + + fn menu(&mut self, ui: &mut egui::Ui) { + egui::MenuBar::new().ui(ui, |ui| { + ui.menu_button("File", |ui| { + if ui.button("Open… (Ctrl+O)").clicked() { + ui.close(); + self.open_dialog(); + } + if ui.button("Find in files… (Ctrl+Shift+F)").clicked() { + ui.close(); + self.tabs.push(Tab::Grep(Box::new(GrepTab::new(None, self.notify.clone())))); + self.active = self.tabs.len() - 1; + } + ui.menu_button("Recent files", |ui| { + let recent = self.settings.recent_files.clone(); + if recent.is_empty() { + ui.weak("(none)"); + } + for p in recent { + if ui.button(p.display().to_string()).clicked() { + ui.close(); + self.open_path(&p); + } + } + }); + ui.separator(); + let has_log = matches!(self.tabs.get(self.active), Some(Tab::Log(_))); + if ui.add_enabled(has_log, egui::Button::new("Import rules…")).clicked() { + ui.close(); + if let Some(p) = rfd::FileDialog::new().add_filter("Log rules", &["toml"]).pick_file() { + self.open_path(&p); + } + } + if ui.add_enabled(has_log, egui::Button::new("Export rules…")).clicked() { + ui.close(); + if let Some(Tab::Log(t)) = self.tabs.get_mut(self.active) { + t.rules_dialog = Some(panels::RulesDialog::Export { + what: crate::rules::ExportWhat::All, + selected: None, + include_pattern: false, + }); + } + } + if ui.add_enabled(has_log, egui::Button::new("Reload file")).clicked() { + ui.close(); + if let Some(Tab::Log(t)) = self.tabs.get_mut(self.active) { + t.reload(); + } + } + ui.separator(); + if ui.add_enabled(!self.tabs.is_empty(), egui::Button::new("Close tab (Ctrl+W)")).clicked() { + ui.close(); + self.close_tab(self.active); + } + if ui.button("Quit").clicked() { + ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close); + } + }); + ui.menu_button("View", |ui| { + let mut changed = false; + changed |= ui.checkbox(&mut self.settings.show_gutter, "Show gutter").changed(); + changed |= ui + .add_enabled( + self.settings.show_gutter, + egui::Checkbox::new(&mut self.settings.gutter_line_numbers, "Gutter shows line numbers"), + ) + .changed(); + ui.horizontal(|ui| { + ui.label("Font size"); + if ui.add(egui::Slider::new(&mut self.settings.font_size, 9.0..=24.0).step_by(1.0)).changed() { + let size = self.settings.font_size; + ui.ctx().global_style_mut(|s| { + if let Some(f) = s.text_styles.get_mut(&egui::TextStyle::Monospace) { + f.size = size; + } + }); + for t in &mut self.tabs { + if let Tab::Log(l) = t { + l.rules_changed(); + } + } + changed = true; + } + }); + ui.separator(); + egui::global_theme_preference_buttons(ui); + if changed { + self.save_settings(); + } + }); + ui.menu_button("Help", |ui| { + if ui.button("Keyboard shortcuts").clicked() { + self.show_keys = true; + ui.close(); + } + if ui.button("About").clicked() { + self.show_about = true; + ui.close(); + } + }); + }); + } + + fn tab_bar(&mut self, ui: &mut egui::Ui) { + let mut close = None; + ui.horizontal_wrapped(|ui| { + for (i, t) in self.tabs.iter().enumerate() { + let title = t.title(); + let r = ui.selectable_label(i == self.active, &title); + if let Tab::Log(l) = t { + r.clone().on_hover_text(l.path.display().to_string()); + } + if r.clicked() { + self.active = i; + } + if r.middle_clicked() { + close = Some(i); + } + if ui.small_button("✖").on_hover_text("Close").clicked() { + close = Some(i); + } + ui.separator(); + } + }); + if let Some(i) = close { + self.close_tab(i); + } + } + + fn global_keys(&mut self, ctx: &egui::Context) { + let cmd = Modifiers::COMMAND; + if ctx.input_mut(|i| i.consume_key(cmd, Key::O)) { + self.open_dialog(); + } + if ctx.input_mut(|i| i.consume_key(cmd | Modifiers::SHIFT, Key::F)) { + self.tabs.push(Tab::Grep(Box::new(GrepTab::new(None, self.notify.clone())))); + self.active = self.tabs.len() - 1; + } + if ctx.input_mut(|i| i.consume_key(cmd, Key::W)) && !self.tabs.is_empty() { + self.close_tab(self.active); + } + if ctx.input_mut(|i| i.consume_key(cmd, Key::Tab)) && !self.tabs.is_empty() { + self.active = (self.active + 1) % self.tabs.len(); + } + let dropped: Vec = ctx.input(|i| { + i.raw.dropped_files.iter().map(|f| f.path().to_path_buf()).filter(|p| !p.as_os_str().is_empty()).collect() + }); + for p in dropped { + self.open_path(&p); + } + // Check open files for truncation whenever the window regains focus. + if ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::WindowFocused(true)))) { + for t in &mut self.tabs { + if let Tab::Log(l) = t { + l.check_file(true); + } + } + } + } + + fn help_windows(&mut self, ctx: &egui::Context) { + egui::Window::new("Keyboard shortcuts").open(&mut self.show_keys).resizable(false).show(ctx, |ui| { + egui::Grid::new("keys").striped(true).show(ui, |ui| { + for (k, what) in [ + ("Ctrl/Cmd+O", "Open file"), + ("Ctrl/Cmd+Shift+F", "Find in files"), + ("Ctrl/Cmd+W", "Close tab"), + ("Ctrl/Cmd+Tab", "Next tab"), + ("Ctrl/Cmd+F", "Search"), + ("Enter / F3", "Next match"), + ("Shift+Enter / Shift+F3", "Previous match"), + ("Ctrl/Cmd+G", "Go to line"), + ("Alt+Z", "Toggle line wrap"), + ("Up / Down", "Select entry"), + ("Space / Right", "Expand entry"), + ("Left", "Collapse entry"), + ("Ctrl/Cmd+C", "Copy selected entry"), + ("PageUp / PageDown", "Scroll a page"), + ("Home / End", "Start / end of file"), + ] { + ui.label(RichText::new(k).monospace()); + ui.label(what); + ui.end_row(); + } + }); + }); + egui::Window::new("About").open(&mut self.show_about).resizable(false).show(ctx, |ui| { + ui.heading("logreadlite"); + ui.label(format!("Version {}", env!("CARGO_PKG_VERSION"))); + ui.label("A fast viewer for large log files."); + }); + } +} + +impl eframe::App for App { + fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) { + let ctx = ui.ctx().clone(); + debug_screenshot(&ctx); + debug::step(self, &ctx); + self.global_keys(&ctx); + + egui::Panel::top("menu").show(ui, |ui| self.menu(ui)); + if !self.tabs.is_empty() { + egui::Panel::top("tabs").show(ui, |ui| self.tab_bar(ui)); + } + if let Some((s, at)) = &self.status { + if at.elapsed() > Duration::from_secs(8) { + self.status = None; + } else { + let s = s.clone(); + egui::Panel::bottom("app_status").show(ui, |ui| { + ui.label(RichText::new(s).color(ui.visuals().warn_fg_color)); + }); + ctx.request_repaint_after(Duration::from_secs(1)); + } + } + + let mut tab_actions = Vec::new(); + let mut grep_actions = Vec::new(); + match self.tabs.get_mut(self.active) { + None => { + egui::CentralPanel::default().show(ui, |ui| { + ui.vertical_centered(|ui| { + ui.add_space(ui.available_height() / 3.0); + ui.heading("logreadlite"); + ui.label("Open a log file (Ctrl+O), drop files or a folder here, or pick a recent file."); + ui.add_space(8.0); + if ui.button("Open file…").clicked() { + tab_actions.push(TabAction::Status("__open".into())); + } + for p in self.settings.recent_files.iter().take(8) { + if ui.link(p.display().to_string()).clicked() { + grep_actions.push(GrepAction::Open { + path: p.clone(), + offset: u64::MAX, + query: Default::default(), + }); + } + } + }); + }); + } + Some(Tab::Log(t)) => { + t.handle_keys(&ctx, &mut self.settings, &mut tab_actions); + tab_actions.extend(t.show(ui, &mut self.settings)); + } + Some(Tab::Grep(g)) => { + grep_actions.extend(g.show(ui)); + } + } + + for a in tab_actions { + match a { + TabAction::SaveSettings => self.save_settings(), + TabAction::Status(s) if s == "__open" => self.open_dialog(), + TabAction::Status(s) => self.set_status(s), + } + } + for a in grep_actions { + match a { + GrepAction::Open { path, offset, query } => { + if let Some(i) = self.open_file(&path) + && offset != u64::MAX + && let Tab::Log(t) = &mut self.tabs[i] + { + if !query.text.is_empty() { + t.set_search(&query); + } + t.jump_to_offset(offset, true); + } + } + GrepAction::Status(s) => self.set_status(s), + } + } + self.help_windows(&ctx); + + // Keep polling while background work runs; workers also request repaints. + let busy = self.tabs.iter().any(|t| match t { + Tab::Log(l) => !l.index.is_done(), + Tab::Grep(_) => false, + }); + ctx.request_repaint_after(if busy { Duration::from_millis(100) } else { Duration::from_secs(1) }); + } + + fn on_exit(&mut self) { + for t in &mut self.tabs { + t.close(); + } + let _ = self.settings.save(); + } +} + +/// Development aid: with `LOGREADLITE_SCREENSHOT=out.ppm`, saves a screenshot +/// after a couple of seconds (`LOGREADLITE_SCREENSHOT_DELAY`) and quits. +fn debug_screenshot(ctx: &egui::Context) { + let Ok(out) = std::env::var("LOGREADLITE_SCREENSHOT") else { return }; + let delay: f64 = std::env::var("LOGREADLITE_SCREENSHOT_DELAY").ok().and_then(|s| s.parse().ok()).unwrap_or(2.0); + let id = egui::Id::unique("debug_screenshot_sent"); + if ctx.input(|i| i.time) > delay && !ctx.data(|d| d.get_temp::(id).unwrap_or(false)) { + ctx.data_mut(|d| d.insert_temp(id, true)); + let c = ctx.clone(); + ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot(egui::ScreenshotCallback::new(move |img| { + let mut data = format!("P6\n{} {}\n255\n", img.size[0], img.size[1]).into_bytes(); + for p in &img.pixels { + data.extend_from_slice(&[p.r(), p.g(), p.b()]); + } + let _ = std::fs::write(&out, data); + c.send_viewport_cmd(egui::ViewportCommand::Close); + c.request_repaint(); + }))); + } + ctx.request_repaint_after(Duration::from_millis(100)); +} diff --git a/src/ui/palette.rs b/src/ui/palette.rs new file mode 100644 index 0000000..a4bc85d --- /dev/null +++ b/src/ui/palette.rs @@ -0,0 +1,63 @@ +//! Highlight colors with light and dark variants. + +use egui::Color32; + +pub const NAMES: &[&str] = &["red", "amber", "yellow", "green", "teal", "blue", "purple", "pink", "gray"]; + +fn base(name: &str) -> Option { + Some(match name { + "red" => Color32::from_rgb(0xe5, 0x48, 0x4d), + "amber" => Color32::from_rgb(0xf5, 0x9e, 0x0b), + "yellow" => Color32::from_rgb(0xea, 0xc5, 0x0c), + "green" => Color32::from_rgb(0x30, 0xa4, 0x6c), + "teal" => Color32::from_rgb(0x12, 0xa5, 0x94), + "blue" => Color32::from_rgb(0x3e, 0x63, 0xdd), + "purple" => Color32::from_rgb(0x8e, 0x4e, 0xc6), + "pink" => Color32::from_rgb(0xd6, 0x40, 0x9f), + "gray" => Color32::from_rgb(0x8b, 0x8d, 0x98), + hex => return parse_hex(hex), + }) +} + +pub fn parse_hex(s: &str) -> Option { + let h = s.strip_prefix('#')?; + if h.len() != 6 { + return None; + } + let v = u32::from_str_radix(h, 16).ok()?; + Some(Color32::from_rgb((v >> 16) as u8, (v >> 8) as u8, v as u8)) +} + +pub fn to_hex(c: Color32) -> String { + format!("#{:02x}{:02x}{:02x}", c.r(), c.g(), c.b()) +} + +fn mix(a: Color32, b: Color32, t: f32) -> Color32 { + let l = |x: u8, y: u8| (x as f32 + (y as f32 - x as f32) * t).round() as u8; + Color32::from_rgb(l(a.r(), b.r()), l(a.g(), b.g()), l(a.b(), b.b())) +} + +/// The swatch shown in pickers. +pub fn swatch(name: &str) -> Color32 { + base(name).unwrap_or(Color32::GRAY) +} + +/// Background tint for a whole entry. +pub fn row_tint(name: &str, dark: bool) -> Color32 { + let c = swatch(name); + if dark { mix(Color32::from_rgb(0x0c, 0x0c, 0x0c), c, 0.16) } else { mix(Color32::WHITE, c, 0.16) } +} + +/// Background and text color for matched text. +pub fn match_colors(name: &str, dark: bool) -> (Color32, Color32) { + let c = swatch(name); + if dark { (mix(Color32::BLACK, c, 0.65), Color32::WHITE) } else { (mix(Color32::WHITE, c, 0.45), Color32::BLACK) } +} + +pub fn search_match(dark: bool) -> Color32 { + if dark { Color32::from_rgb(0x6b, 0x5a, 0x10) } else { Color32::from_rgb(0xff, 0xec, 0x8c) } +} + +pub fn current_match(dark: bool) -> Color32 { + if dark { Color32::from_rgb(0xc2, 0x5e, 0x00) } else { Color32::from_rgb(0xff, 0x9f, 0x1c) } +} diff --git a/src/ui/panels.rs b/src/ui/panels.rs new file mode 100644 index 0000000..942d9dc --- /dev/null +++ b/src/ui/panels.rs @@ -0,0 +1,501 @@ +//! Side panels and dialogs of a log tab: the pattern editor, highlight rules, +//! and rule-file import/export. + +use std::path::{Path, PathBuf}; + +use egui::{RichText, Ui}; + +use crate::pattern::{self, PatternDef, Sample, Scored}; +use crate::rules::{self, ExportWhat, Rule, RuleKind, RulesFile, Scope}; +use crate::settings::{self, Settings}; +use crate::ui::log_tab::{LogTab, TabAction}; +use crate::ui::palette; + +const PREVIEW_LINES: usize = 40; + +// ----- pattern editor ----- + +pub struct PatternEditor { + name: String, + regex: String, + candidates: Vec, + sample: Vec>, + save_for_path: bool, + save_glob: bool, + glob: String, +} + +impl PatternEditor { + pub fn new(tab: &LogTab, settings: &Settings) -> Self { + let sample: Vec> = Sample::take(tab.bytes()).lines.into_iter().map(|l| l.to_vec()).collect(); + let refs: Vec<&[u8]> = sample.iter().map(|l| l.as_slice()).collect(); + let candidates = match &tab.detection { + Some(d) => d.scores.clone(), + None => pattern::detect_lines(&refs, &settings.extra_patterns).scores, + }; + let glob = + tab.path.extension().map(|e| format!("*.{}", e.to_string_lossy())).unwrap_or_else(|| tab.title.clone()); + Self { + name: tab.pattern.name.clone(), + regex: tab.pattern.regex.clone(), + candidates, + sample, + save_for_path: true, + save_glob: false, + glob, + } + } +} + +pub fn pattern_panel(tab: &mut LogTab, ui: &mut Ui, settings: &mut Settings) -> Option { + let mut ed = tab.pattern_editor.take()?; + let mut close = false; + let mut action = None; + ui.heading("Entry start pattern"); + ui.label("A line that matches starts a new entry; other lines continue the entry above."); + ui.add_space(4.0); + + let mut choice: Option = None; + egui::ComboBox::from_label("Preset").selected_text(&ed.name).width(300.0).show_ui(ui, |ui| { + for c in &ed.candidates { + let text = format!("{} ({:.2})", c.def.name, c.score); + if ui.selectable_label(c.def.regex == ed.regex, text).clicked() { + choice = Some(c.def.clone()); + } + } + for def in [pattern::every_non_indented_line(), pattern::every_line()] { + if ui.selectable_label(def.regex == ed.regex, &def.name).clicked() { + choice = Some(def); + } + } + }); + if let Some(def) = choice { + ed.name = def.name; + ed.regex = def.regex; + } + ui.horizontal(|ui| { + ui.label(RichText::new("^").monospace()); + let r = ui.add( + egui::TextEdit::singleline(&mut ed.regex).font(egui::TextStyle::Monospace).desired_width(f32::INFINITY), + ); + if r.changed() { + ed.name = "Custom".into(); + } + }); + + let compiled = pattern::compile_anchored(&ed.regex); + match &compiled { + Err(e) => { + ui.colored_label(ui.visuals().error_fg_color, e.to_string()); + } + Ok(re) => { + let refs: Vec<&[u8]> = ed.sample.iter().map(|l| l.as_slice()).collect(); + let starts = refs.iter().filter(|l| re.is_match(&l[..l.len().min(pattern::MATCH_PREFIX)])).count(); + ui.label(format!( + "{} entries in sample of {} lines · score {:.2}", + starts, + refs.len(), + pattern::score(re, &refs) + )); + } + } + + ui.separator(); + ui.checkbox(&mut ed.save_for_path, "Remember for this file"); + ui.horizontal(|ui| { + ui.checkbox(&mut ed.save_glob, "Also for files named"); + ui.add_enabled(ed.save_glob, egui::TextEdit::singleline(&mut ed.glob).desired_width(140.0)); + }); + ui.horizontal(|ui| { + if ui.add_enabled(compiled.is_ok(), egui::Button::new("Apply")).clicked() { + let def = PatternDef { name: ed.name.clone(), regex: ed.regex.clone() }; + if ed.save_for_path { + settings.file_mut(&tab.path).pattern = Some(def.clone()); + } + if ed.save_glob && !ed.glob.trim().is_empty() { + settings.save_glob_pattern(ed.glob.trim(), def.clone()); + } + tab.reindex(def); + action = Some(TabAction::SaveSettings); + close = true; + } + if ui.button("Re-detect").clicked() { + let refs: Vec<&[u8]> = ed.sample.iter().map(|l| l.as_slice()).collect(); + let d = pattern::detect_lines(&refs, &settings.extra_patterns); + ed.name = d.chosen.name; + ed.regex = d.chosen.regex; + ed.candidates = d.scores; + } + if ui.button("Close").clicked() { + close = true; + } + }); + + ui.separator(); + ui.label(RichText::new("Preview").strong()); + egui::ScrollArea::both().auto_shrink(false).show(ui, |ui| { + let Ok(re) = &compiled else { return }; + let dim = ui.visuals().weak_text_color(); + for line in ed.sample.iter().take(PREVIEW_LINES) { + let text = String::from_utf8_lossy(&line[..line.len().min(400)]).into_owned(); + if re.is_match(&line[..line.len().min(pattern::MATCH_PREFIX)]) { + ui.separator(); + ui.add(egui::Label::new(RichText::new(text).monospace()).wrap_mode(egui::TextWrapMode::Extend)); + } else { + ui.horizontal(|ui| { + ui.add_space(18.0); + ui.add( + egui::Label::new(RichText::new(text).monospace().color(dim)) + .wrap_mode(egui::TextWrapMode::Extend), + ); + }); + } + } + }); + + if !close { + tab.pattern_editor = Some(ed); + } + action +} + +// ----- highlight rules panel ----- + +fn color_picker(ui: &mut Ui, id: impl egui::AsIdSalt, color: &mut Option) -> bool { + let current = color.clone().unwrap_or_else(|| "amber".into()); + let mut changed = false; + let swatch = palette::swatch(¤t); + egui::ComboBox::from_id_salt(id) + .width(80.0) + .selected_text(RichText::new("■ ".to_string() + ¤t).color(swatch)) + .show_ui(ui, |ui| { + for name in palette::NAMES { + let label = RichText::new(format!("■ {name}")).color(palette::swatch(name)); + if ui.selectable_label(current == *name, label).clicked() { + *color = Some(name.to_string()); + changed = true; + } + } + ui.separator(); + let mut c = palette::parse_hex(¤t).unwrap_or(swatch); + ui.horizontal(|ui| { + ui.label("Custom"); + if ui.color_edit_button_srgba(&mut c).changed() { + *color = Some(palette::to_hex(c)); + changed = true; + } + }); + }); + changed +} + +pub fn rules_panel(tab: &mut LogTab, ui: &mut Ui, settings: &mut Settings) -> Vec { + let mut actions = Vec::new(); + ui.heading("Highlight rules"); + ui.label("First matching row rule tints the entry; all match rules color their text."); + let mut changed = false; + let hl: Vec = (0..tab.rules.len()).filter(|&i| tab.rules[i].kind == RuleKind::Highlight).collect(); + let mut swap: Option<(usize, usize)> = None; + let mut remove = None; + egui::ScrollArea::vertical().max_height(ui.available_height() * 0.6).show(ui, |ui| { + for (k, &i) in hl.iter().enumerate() { + let r = &mut tab.rules[i]; + ui.horizontal(|ui| { + changed |= ui.checkbox(&mut r.enabled, "").changed(); + changed |= ui.add(egui::TextEdit::singleline(&mut r.pattern).desired_width(110.0)).changed(); + changed |= ui.toggle_value(&mut r.regex, ".*").on_hover_text("Regex").changed(); + changed |= ui.toggle_value(&mut r.case_sensitive, "Aa").on_hover_text("Case sensitive").changed(); + }); + ui.horizontal(|ui| { + ui.add_space(24.0); + changed |= color_picker(ui, ("hlcolor", i), &mut r.color); + let mut scope = r.scope.unwrap_or_default(); + egui::ComboBox::from_id_salt(("hlscope", i)) + .width(70.0) + .selected_text(if scope == Scope::Row { "row" } else { "match" }) + .show_ui(ui, |ui| { + changed |= ui.selectable_value(&mut scope, Scope::Row, "row").changed(); + changed |= ui.selectable_value(&mut scope, Scope::Match, "match").changed(); + }); + r.scope = Some(scope); + if k > 0 && ui.small_button("⏶").clicked() { + swap = Some((i, hl[k - 1])); + } + if k + 1 < hl.len() && ui.small_button("⏷").clicked() { + swap = Some((i, hl[k + 1])); + } + if ui.small_button("✖").clicked() { + remove = Some(i); + } + if let Err(e) = r.validate() { + ui.colored_label(ui.visuals().error_fg_color, "⚠").on_hover_text(e); + } + }); + ui.add_space(2.0); + } + }); + if let Some((a, b)) = swap { + tab.rules.swap(a, b); + changed = true; + } + if let Some(i) = remove { + tab.rules.remove(i); + changed = true; + } + if ui.button("+ Add rule").clicked() { + tab.rules.push(Rule::highlight("keyword", "blue", Scope::Match)); + changed = true; + } + if changed { + tab.rules_changed(); + } + + ui.separator(); + ui.label(RichText::new("Rule files").strong()); + ui.horizontal(|ui| { + if ui.button("Import…").clicked() + && let Some(p) = rfd::FileDialog::new().add_filter("Log rules", &["toml"]).pick_file() + { + actions.extend(start_import(tab, &p)); + } + if ui.button("Export…").clicked() { + tab.rules_dialog = + Some(RulesDialog::Export { what: ExportWhat::All, selected: None, include_pattern: false }); + } + }); + ui.horizontal(|ui| { + if ui.button("Save as global default").on_hover_text("Rules for newly opened files").clicked() { + settings.rules = tab.rules.clone(); + actions.push(TabAction::SaveSettings); + actions.push(TabAction::Status("Saved rules as the global default".into())); + } + }); + let glob_id = ui.scope_id().with("rules_glob"); + let mut glob: String = ui + .data(|d| d.get_temp(glob_id)) + .unwrap_or_else(|| tab.path.extension().map(|e| format!("*.{}", e.to_string_lossy())).unwrap_or_default()); + ui.horizontal(|ui| { + ui.add(egui::TextEdit::singleline(&mut glob).desired_width(100.0)); + if ui.button("Save for files matching").clicked() && !glob.trim().is_empty() { + let g = glob.trim().to_string(); + settings.glob_rules.retain(|x| x.glob != g); + settings.glob_rules.push(settings::GlobRules { glob: g.clone(), rules: tab.rules.clone() }); + actions.push(TabAction::SaveSettings); + actions.push(TabAction::Status(format!("Saved rules for {g}"))); + } + }); + ui.data_mut(|d| d.insert_temp(glob_id, glob)); + + ui.separator(); + ui.label(RichText::new("Named rule sets").strong()); + let sets = settings::list_rulesets(); + let name_id = ui.scope_id().with("ruleset_name"); + let mut name: String = ui.data(|d| d.get_temp(name_id)).unwrap_or_default(); + ui.horizontal(|ui| { + egui::ComboBox::from_id_salt("rulesets") + .selected_text(if sets.is_empty() { "(none saved)" } else { "Switch to…" }) + .show_ui(ui, |ui| { + for s in &sets { + if ui.selectable_label(false, s).clicked() { + match settings::load_ruleset(s) { + Ok((file, errors)) => { + tab.set_rules(file.rules); + if let Some(p) = file.pattern { + tab.reindex(p); + } + let mut msg = format!("Loaded rule set {s}"); + if !errors.is_empty() { + msg.push_str(&format!(" ({} invalid rules skipped)", errors.len())); + } + actions.push(TabAction::Status(msg)); + } + Err(e) => actions.push(TabAction::Status(format!("Cannot load {s}: {e:#}"))), + } + } + } + }); + }); + ui.horizontal(|ui| { + ui.add(egui::TextEdit::singleline(&mut name).hint_text("name, e.g. Java service").desired_width(140.0)); + if ui.button("Save set").clicked() && !name.trim().is_empty() { + let file = RulesFile::new(tab.rules.clone(), None); + match settings::save_ruleset(name.trim(), &file) { + Ok(()) => actions.push(TabAction::Status(format!("Saved rule set {}", name.trim()))), + Err(e) => actions.push(TabAction::Status(format!("Cannot save: {e:#}"))), + } + } + }); + ui.data_mut(|d| d.insert_temp(name_id, name)); + actions +} + +// ----- import / export dialogs ----- + +pub enum RulesDialog { + Import { + path: PathBuf, + file: RulesFile, + errors: Vec, + replace: bool, + global: bool, + apply_pattern: bool, + }, + Export { + what: ExportWhat, + /// `Some` when exporting a hand-picked selection. + selected: Option>, + include_pattern: bool, + }, +} + +/// Reads a rule file and opens the import dialog for it. +pub fn start_import(tab: &mut LogTab, path: &Path) -> Option { + let text = match std::fs::read_to_string(path) { + Ok(t) => t, + Err(e) => return Some(TabAction::Status(format!("Cannot read {}: {e}", path.display()))), + }; + match RulesFile::parse(&text) { + Ok((file, errors)) => { + let apply_pattern = file.pattern.is_some(); + tab.rules_dialog = Some(RulesDialog::Import { + path: path.into(), + file, + errors, + replace: false, + global: false, + apply_pattern, + }); + None + } + Err(e) => Some(TabAction::Status(format!("Not a rule file: {e:#}"))), + } +} + +pub fn rules_dialog(tab: &mut LogTab, ctx: &egui::Context, settings: &mut Settings) -> Vec { + let mut actions = Vec::new(); + let Some(mut dlg) = tab.rules_dialog.take() else { return actions }; + let mut close = false; + egui::Modal::new(egui::Id::unique("rules_dialog")).show(ctx, |ui| { + ui.set_width(460.0); + match &mut dlg { + RulesDialog::Import { path, file, errors, replace, global, apply_pattern } => { + ui.heading("Import rules"); + ui.label(format!("{} — {} rules", path.display(), file.rules.len())); + if !errors.is_empty() { + ui.colored_label( + ui.visuals().warn_fg_color, + format!("{} invalid rules will be skipped:", errors.len()), + ); + egui::ScrollArea::vertical().max_height(100.0).show(ui, |ui| { + for e in errors.iter() { + ui.label(RichText::new(e).small()); + } + }); + } + ui.horizontal(|ui| { + ui.radio_value(replace, false, "Merge (skip duplicates)"); + ui.radio_value(replace, true, "Replace"); + }); + ui.horizontal(|ui| { + ui.radio_value(global, false, "Apply to this tab"); + ui.radio_value(global, true, "Save as global default"); + }); + if let Some(p) = &file.pattern { + ui.add_enabled( + !*global, + egui::Checkbox::new(apply_pattern, format!("Use entry-start pattern “{}”", p.name)), + ); + } + ui.horizontal(|ui| { + if ui.button("Import").clicked() { + let target = if *global { settings.rules.clone() } else { tab.rules.clone() }; + let new = if *replace { + file.rules.clone() + } else { + let mut t = target; + rules::merge(&mut t, file.rules.clone()); + t + }; + if *global { + settings.rules = new; + actions.push(TabAction::SaveSettings); + } else { + tab.set_rules(new); + if *apply_pattern && let Some(p) = file.pattern.clone() { + tab.reindex(p); + } + } + actions.push(TabAction::Status(format!("Imported {} rules", file.rules.len()))); + close = true; + } + if ui.button("Cancel").clicked() { + close = true; + } + }); + } + RulesDialog::Export { what, selected, include_pattern } => { + ui.heading("Export rules"); + ui.horizontal(|ui| { + let mut pick = |ui: &mut Ui, w: ExportWhat, label: &str| { + if ui.radio(selected.is_none() && *what == w, label).clicked() { + *what = w; + *selected = None; + } + }; + pick(ui, ExportWhat::All, "Everything"); + pick(ui, ExportWhat::FiltersOnly, "Filters"); + pick(ui, ExportWhat::HighlightsOnly, "Highlights"); + if ui.radio(selected.is_some(), "Selected").clicked() && selected.is_none() { + *selected = Some(vec![true; tab.rules.len()]); + } + }); + if let Some(sel) = selected { + sel.resize(tab.rules.len(), false); + egui::ScrollArea::vertical().max_height(200.0).show(ui, |ui| { + for (r, s) in tab.rules.iter().zip(sel.iter_mut()) { + ui.checkbox(s, format!("{:?}: {}", r.kind, r.pattern)); + } + }); + } + ui.checkbox(include_pattern, format!("Include entry-start pattern “{}”", tab.pattern.name)); + ui.horizontal(|ui| { + if ui.button("Save…").clicked() { + let pattern = include_pattern.then(|| tab.pattern.clone()); + let file = match selected { + Some(sel) => RulesFile::new( + tab.rules.iter().zip(sel.iter()).filter(|(_, s)| **s).map(|(r, _)| r.clone()), + pattern, + ), + None => RulesFile::select(&tab.rules, *what, pattern), + }; + if let Some(p) = rfd::FileDialog::new() + .set_file_name(format!("rules.{}", rules::RULES_FILE_EXT)) + .add_filter("Log rules", &["toml"]) + .save_file() + { + match std::fs::write(&p, file.to_toml()) { + Ok(()) => actions.push(TabAction::Status(format!( + "Exported {} rules to {}", + file.rules.len(), + p.display() + ))), + Err(e) => actions.push(TabAction::Status(format!("Cannot write {}: {e}", p.display()))), + } + close = true; + } + } + if ui.button("Cancel").clicked() { + close = true; + } + }); + } + } + if ui.input(|i| i.key_pressed(egui::Key::Escape)) { + close = true; + } + }); + if !close { + tab.rules_dialog = Some(dlg); + } + actions +} diff --git a/src/ui/text.rs b/src/ui/text.rs new file mode 100644 index 0000000..604b9e8 --- /dev/null +++ b/src/ui/text.rs @@ -0,0 +1,160 @@ +//! Turns one line of the log into a `LayoutJob` with search and highlight colors. + +use egui::text::LayoutJob; +use egui::{Color32, FontId, Stroke, TextFormat}; + +use crate::passes::Match; +use crate::rules::{CompiledHighlight, Scope}; +use crate::ui::palette; + +/// Lines longer than this are cut for display; the detail pane shows them in full. +pub const MAX_LINE_SHOWN: usize = 64 * 1024; + +pub struct LineSpec<'a> { + /// The line without its line terminator, already cut to `MAX_LINE_SHOWN`. + pub bytes: &'a [u8], + pub file_offset: u64, + pub truncated: bool, + /// Search matches overlapping this line. + pub matches: &'a [Match], + pub current: Option, + /// "+N lines" badge for a collapsed multi-line entry. + pub badge: Option, + pub continuation: bool, +} + +pub struct Style { + pub font: FontId, + pub dark: bool, + pub text: Color32, + pub dim: Color32, + pub wrap_width: Option, +} + +#[derive(Clone, Copy, Default)] +struct Deco { + hl_bg: Option<(Color32, Color32)>, + search: u8, // 0 none, 1 match, 2 current +} + +/// Lossily decodes `bytes`, keeping a map from source cut points to display offsets. +fn decode_with_cuts(bytes: &[u8], cuts: &[usize]) -> (String, Vec<(usize, usize)>) { + let mut out = String::with_capacity(bytes.len()); + let mut map = Vec::with_capacity(cuts.len()); + let mut prev = 0; + for &c in cuts { + out.push_str(&String::from_utf8_lossy(&bytes[prev..c])); + map.push((c, out.len())); + prev = c; + } + out.push_str(&String::from_utf8_lossy(&bytes[prev..])); + (out, map) +} + +fn floor_boundary(s: &str, mut i: usize) -> usize { + i = i.min(s.len()); + while !s.is_char_boundary(i) { + i -= 1; + } + i +} + +pub fn build_job(spec: &LineSpec<'_>, hl: &[CompiledHighlight], style: &Style) -> LayoutJob { + let len = spec.bytes.len(); + let rel = |m: &Match| -> (usize, usize) { + let s = m.offset.saturating_sub(spec.file_offset).min(len as u64) as usize; + let e = m.end().saturating_sub(spec.file_offset).min(len as u64) as usize; + (s, e) + }; + let mut cuts: Vec = spec + .matches + .iter() + .flat_map(|m| { + let (s, e) = rel(m); + [s, e] + }) + .collect(); + cuts.sort_unstable(); + cuts.dedup(); + let (text, map) = decode_with_cuts(spec.bytes, &cuts); + let to_dst = |src: usize| map.iter().find(|(s, _)| *s == src).map(|(_, d)| *d).unwrap_or(0); + + // Collect styled ranges on the display string. + let mut ranges: Vec<(usize, usize, Deco)> = Vec::new(); + // Later rules are drawn under earlier ones, so add them first. + for rule in hl.iter().rev().filter(|r| r.scope == Scope::Match) { + let colors = palette::match_colors(&rule.color, style.dark); + for m in rule.re.find_iter(text.as_bytes()) { + if !m.is_empty() { + ranges.push((m.start(), m.end(), Deco { hl_bg: Some(colors), search: 0 })); + } + } + } + for m in spec.matches { + let (s, e) = rel(m); + if s < e { + let kind = if Some(*m) == spec.current { 2 } else { 1 }; + ranges.push((to_dst(s), to_dst(e), Deco { hl_bg: None, search: kind })); + } + } + + let mut points: Vec = vec![0, text.len()]; + for (s, e, _) in &ranges { + points.push(floor_boundary(&text, *s)); + points.push(floor_boundary(&text, *e)); + } + points.sort_unstable(); + points.dedup(); + + let base_color = if spec.continuation { style.dim } else { style.text }; + let base = TextFormat::simple(style.font.clone(), base_color); + let mut job = LayoutJob::default(); + for w in points.windows(2) { + let (a, b) = (w[0], w[1]); + if a == b { + continue; + } + let mut deco = Deco::default(); + for (s, e, d) in &ranges { + if *s <= a && b <= *e { + if d.hl_bg.is_some() { + deco.hl_bg = d.hl_bg; + } + deco.search = deco.search.max(d.search); + } + } + let mut f = base.clone(); + if let Some((bg, fg)) = deco.hl_bg { + f.background = bg; + f.color = fg; + } + match deco.search { + 2 => { + f.background = palette::current_match(style.dark); + f.color = if style.dark { Color32::WHITE } else { Color32::BLACK }; + } + 1 => { + f.background = palette::search_match(style.dark); + f.underline = Stroke::new(1.0, palette::current_match(style.dark)); + } + _ => {} + } + job.append(&text[a..b], 0.0, f); + } + + let muted = TextFormat { italics: true, ..TextFormat::simple(style.font.clone(), style.dim) }; + if spec.truncated { + job.append(" … line cut at 64 KB, right-click → Show full entry", 0.0, muted.clone()); + } + if let Some(n) = spec.badge { + let mut f = muted; + f.background = if style.dark { Color32::from_gray(0x33) } else { Color32::from_gray(0xe6) }; + job.append(&format!(" +{n} lines "), 12.0, f); + } + if job.text.is_empty() { + job.append(" ", 0.0, base); + } + job.wrap.max_width = style.wrap_width.unwrap_or(f32::INFINITY); + job.break_on_newline = false; + job +} diff --git a/tests/detection.rs b/tests/detection.rs new file mode 100644 index 0000000..72d7546 --- /dev/null +++ b/tests/detection.rs @@ -0,0 +1,170 @@ +//! Entry-start detection across common real-world log formats. +//! Each sample must be detected and must split into the expected entries. + +use logreadlite::index::{SharedIndex, build}; +use logreadlite::job::{Token, no_notify}; +use logreadlite::pattern::detect; +use logreadlite::source::{ByteSource, VecSource}; + +fn check(name: &str, text: &str, expect_pattern: &str, expect_entries: usize) { + let det = detect(text.as_bytes(), &[]); + assert_eq!(det.chosen.name, expect_pattern, "{name}: chose {:?}", det.chosen); + let src = VecSource(text.as_bytes().to_vec()); + let shared = SharedIndex::new(src.len()); + build(&src, &det.chosen.compile().unwrap(), &shared, &Token::detached(), &no_notify()); + let n = shared.index.read().unwrap().len(); + assert_eq!(n, expect_entries, "{name}: {n} entries"); +} + +#[test] +fn java_logback_with_stack_traces() { + check( + "logback", + "2026-10-21 05:06:48,123 INFO [main] c.e.App - Starting\n\ + 2026-10-21 05:06:49,001 ERROR [http-1] c.e.Api - Request failed\n\ + java.lang.NullPointerException: null\n\ + \tat com.example.Api.handle(Api.java:42)\n\ + \tat com.example.Server.run(Server.java:7)\n\ + Caused by: java.io.IOException: reset\n\ + \t... 3 more\n\ + 2026-10-21 05:06:50,000 INFO [main] c.e.App - Done\n", + "ISO 8601 timestamp", + 3, + ); +} + +#[test] +fn bracketed_iso() { + check( + "bracketed", + "[2026-10-21T05:06:48.123Z] info: a\n[2026-10-21T05:06:49.000Z] warn: b\n detail\n", + "ISO 8601 timestamp", + 2, + ); +} + +#[test] +fn syslog() { + check( + "syslog", + "Oct 21 05:06:48 host sshd[42]: Accepted key\nOct 21 05:06:49 host CRON[7]: job\nOct 1 05:06:50 host kernel: x\n", + "Syslog", + 3, + ); +} + +#[test] +fn nginx_access() { + check( + "nginx", + "10.0.0.1 - - [21/Oct/2026:05:06:48 +0000] \"GET / HTTP/1.1\" 200 612 \"-\" \"curl\"\n\ + 10.0.0.2 - alice [21/Oct/2026:05:06:49 +0000] \"POST /api HTTP/1.1\" 201 12 \"-\" \"x\"\n", + "Apache / nginx access", + 2, + ); +} + +#[test] +fn dotnet_slash_date_with_exception() { + check( + ".NET", + "10/21/2026 5:06:48 AM Information: Service started\n\ + 10/21/2026 5:06:49 AM Error: Unhandled exception\n\ + System.InvalidOperationException: Sequence contains no elements\n \ + at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)\n \ + at App.Program.Main(String[] args) in C:\\src\\Program.cs:line 12\n\ + 10/21/2026 5:06:50 AM Information: Recovered\n", + "Slash date", + 3, + ); +} + +#[test] +fn time_only() { + check( + "time only", + "05:06:48.123 [main] INFO start\n05:06:49.001 [main] WARN slow\n at x\n05:06:50.000 [main] INFO ok\n", + "Time only", + 3, + ); +} + +#[test] +fn level_first() { + check( + "level first", + "INFO [db] connected\nERROR [db] connection lost\n retrying\nWARN [db] slow query\n", + "Level first", + 3, + ); +} + +#[test] +fn epoch_seconds() { + check( + "epoch", + "1792472808.123 worker started\n1792472809.456 job 1 done\n1792472810 job 2 done\n", + "Epoch seconds", + 3, + ); +} + +#[test] +fn json_lines() { + check( + "json", + "{\"ts\":\"2026-10-21T05:06:48Z\",\"level\":\"info\",\"msg\":\"a\"}\n\ + {\"ts\":\"2026-10-21T05:06:49Z\",\"level\":\"error\",\"msg\":\"b\"}\n", + "JSON lines", + 2, + ); +} + +#[test] +fn go_log_package_by_shape() { + check( + "go", + "2026/10/21 05:06:48 server listening on :8080\n\ + 2026/10/21 05:06:49 http: panic serving 1.2.3.4: boom\n\ + goroutine 7 [running]:\n\ + main.handler()\n\ + \t/src/main.go:12 +0x1d\n\ + 2026/10/21 05:06:50 shutting down\n", + "Inferred from line shapes", + 3, + ); +} + +#[test] +fn rails_logger_by_shape() { + check( + "rails", + "I, [2026-10-21T05:06:48.123456 #4242] INFO -- : Started GET \"/\"\n\ + E, [2026-10-21T05:06:49.000001 #4242] ERROR -- : boom\n\ + app/models/user.rb:12:in `save'\n\ + I, [2026-10-21T05:06:50.000002 #4242] INFO -- : Completed 200\n", + "Inferred from line shapes", + 3, + ); +} + +#[test] +fn python_traceback() { + check( + "python", + "2026-10-21 05:06:48,123 - app - INFO - start\n\ + 2026-10-21 05:06:49,000 - app - ERROR - failed\n\ + Traceback (most recent call last):\n \ + File \"app.py\", line 3, in \n \ + main()\n\ + ValueError: bad\n\ + 2026-10-21 05:06:50,000 - app - INFO - end\n", + "ISO 8601 timestamp", + 3, + ); +} + +#[test] +fn plain_text_falls_back_to_non_indented() { + check("plain", "first thing\n indented detail\nsecond thing\n", "Every line not starting with whitespace", 2); +}