commit 8151aa71c00ba6beda0f5f9df3ef60a71ab37d6b Author: astar76 Date: Fri Nov 6 17:05:28 2026 -0600 Damson: a Material You code editor in Rust Runs Kate's syntax definitions directly, on a hand-written editor core. Spring-driven UI with a pop-out scrolling preview, baked-in terminal grown from a morphing button, jelly tabs, command palette, side panels, git, language servers and hot exit. Co-Authored-By: Claude Opus 5.5 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e652bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +/dist +/releases +*.swp diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..fc48085 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,4512 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "accesskit" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e883d1d28c5fd5568c79ed2d2bd48d9f2fd3945c8974ed0f53690ceddb051be" +dependencies = [ + "uuid", +] + +[[package]] +name = "accesskit_atspi_common" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24f5baf62e34a4a6c30e3d697e4782f821a7337049c44c3b40576a27dfbb580d" +dependencies = [ + "accesskit", + "accesskit_consumer", + "atspi-common", + "phf", + "serde", + "zvariant", +] + +[[package]] +name = "accesskit_consumer" +version = "0.39.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3da8f27636015191b2264ee1df681503170a632cafd832fdc1edfdd4e3a2fd3" +dependencies = [ + "accesskit", + "hashbrown 0.17.1", +] + +[[package]] +name = "accesskit_ios" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5280724673bbfa8b30a838c013500b719392989be3b97c5a9964062c252c232" +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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "123828ceeec755b05255e3976cb0852993202de98a0626c97dd8d34246991f84" +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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d5192871228c54f1b0fb4a85cef000e11a3804f25d2165f14afa0daa67f3f6" +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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498668b90da9995302a0055aaecad4756932333da2ddef6baee1c00844c430fc" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.17.1", + "static_assertions", + "windows", + "windows-core", +] + +[[package]] +name = "accesskit_winit" +version = "0.34.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd4ab4437b520ff03088fbe48676a11e7d44a929535e64b31432c1073e48dbcc" +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 = "alacritty_terminal" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda177466b9524d59f1b12f0dd30b68696788e9992a7e959021c4a0ed96fcf59" +dependencies = [ + "base64", + "bitflags 2.13.2", + "home", + "libc", + "log", + "miow", + "parking_lot", + "piper", + "polling", + "regex-automata", + "rustix 1.1.6", + "rustix-openpty", + "serde", + "signal-hook", + "unicode-width", + "vte", + "windows-sys 0.59.0", +] + +[[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 = "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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +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.6", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" +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.6", +] + +[[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.6", + "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 = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec 0.8.0", +] + +[[package]] +name = "bit-set" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" +dependencies = [ + "bit-vec 0.9.1", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[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" +dependencies = [ + "serde_core", +] + +[[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 = "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.6", + "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.6", + "wayland-backend", + "wayland-client", +] + +[[package]] +name = "cc" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff2a8126fff0f8c839080d619675a585e61720bb12d2baceae45769fd66f155" +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 = "clipboard-win" +version = "5.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" +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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f97d3416d5337d15c4b0d78c8c91df922ca143f57ec20e2d1c188333047ef04" +dependencies = [ + "cfg-if", +] + +[[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 = "damson" +version = "0.1.0" +dependencies = [ + "alacritty_terminal", + "dirs", + "eframe", + "egui_kittest", + "encoding_rs", + "fancy-regex", + "regex", + "resvg", + "rfd", + "ropey", + "roxmltree 0.21.2", + "serde", + "serde_json", + "unicode-width", + "walkdir", +] + +[[package]] +name = "data-url" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +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 = "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", + "glow", + "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", + "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", + "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_kittest" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0979c2e37860fcf13a2bea77508607f067a9a6a84ba9bd47b5e298582fb59b86" +dependencies = [ + "eframe", + "egui", + "egui-wgpu", + "image", + "kittest", + "log", + "pollster 1.0.1", + "serde", + "toml", + "wgpu", +] + +[[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.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[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 = "fancy-regex" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20ed7f62ce0ae0da1a8b93c3c7104ab7e0760a74491e097c701fff966e945390" +dependencies = [ + "bit-set 0.8.0", + "regex-automata", + "regex-syntax", +] + +[[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.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + +[[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 = "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 = "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.6", + "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", + "skrifa", + "smallvec", + "vello_common", +] + +[[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 = "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 = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[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 0.18.1", + "tiff", +] + +[[package]] +name = "imagesize" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285" + +[[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.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.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +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 = "kittest" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb81a721ba76aa095b7f45deb180504f786904e56ca4b8e141f66eb89a78b75" +dependencies = [ + "accesskit", + "accesskit_consumer", +] + +[[package]] +name = "kurbo" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62026ae44756f8a599ba21140f350303d4f08dcdcc71b5ad9c9bb8128c13c62" +dependencies = [ + "arrayvec", + "euclid", + "smallvec", +] + +[[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 = "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.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[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.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +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 = "miow" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08" +dependencies = [ + "windows-sys 0.61.2", +] + +[[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 0.10.0", + "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-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 = "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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +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 = "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 = "peniko" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839c8299360d2e998bdb106dc0a6cd71dcc5f4df51df1b620361bf50e283cca6" +dependencies = [ + "bytemuck", + "color", + "kurbo 0.13.1", + "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 = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + +[[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 = "png" +version = "0.17.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[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 = "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.6", + "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 = "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 = "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 = "resvg" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8928798c0a55e03c9ca6c4c6846f76377427d2c1e1f7e6de3c06ae57942df43" +dependencies = [ + "log", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia", + "usvg", +] + +[[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", + "web-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "ropey" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93411e420bcd1a75ddd1dc3caf18c23155eda2c090631a85af21ba19e97093b5" +dependencies = [ + "smallvec", + "str_indices", +] + +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + +[[package]] +name = "roxmltree" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" +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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustix-openpty" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de16c7c59892b870a6336f185dc10943517f1327447096bbb7bb32cd85e2393" +dependencies = [ + "errno", + "libc", + "rustix 1.1.6", +] + +[[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 = "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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +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" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f7447afd772ca79ad17ae0a3972a6b0df0cb4b80990fd82707593e9e012a74" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[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 = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[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.6", + "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 = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "str_indices" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08889ec5408683408db66ad89e0e1f93dff55c73a4ccc71c427d5b277ee47e6" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] + +[[package]] +name = "svgtypes" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" +dependencies = [ + "kurbo 0.11.3", + "siphasher", +] + +[[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 = "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.6", + "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", + "png 0.17.16", + "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 = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml" +version = "1.2.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5755c51863cdac711f1956baf8eb9588e060755f7d3c4c979e70ea1e1f32cd7" +dependencies = [ + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +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 = "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 = "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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993ad287eb20e8ba755312801cfe1413e0f25d604075863acaddca10b04c1833" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + +[[package]] +name = "usvg" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80be9b06fbae3b8b303400ab20778c80bbaf338f563afe567cf3c9eea17b47ef" +dependencies = [ + "base64", + "data-url", + "flate2", + "imagesize", + "kurbo 0.11.3", + "log", + "pico-args", + "roxmltree 0.20.0", + "simplecss", + "siphasher", + "strict-num", + "svgtypes", + "tiny-skia-path", + "xmlwriter", +] + +[[package]] +name = "uuid" +version = "1.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" +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", + "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", + "vello_common", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vte" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "cursor-icon", + "log", + "memchr", + "serde", +] + +[[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.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +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.6", + "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.6", + "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.6", + "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.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +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 = "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 0.10.0", + "bit-vec 0.9.1", + "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 0.10.0", + "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-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 = "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", + "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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "959c7ac3b8afde864f7a7448ac16f29b2b83350b7eccbf77fb781c3999aa6848" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix 1.1.6", + "thiserror 2.0.21", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[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.6", + "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 = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" + +[[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.6", + "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.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920" +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 = "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..3157146 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "damson" +version = "0.1.0" +edition = "2021" +description = "A Material You code editor that reads Kate's syntax definitions" +license = "MIT" + +[lib] +name = "damson" +path = "src/lib.rs" + +[[bin]] +name = "damson" +path = "src/main.rs" + +[dependencies] +eframe = { version = "0.37", default-features = false, features = ["glow", "wayland", "x11", "clipboard", "default_fonts"] } +ropey = "1" +fancy-regex = "0.20" +regex = "1" +roxmltree = "0.21" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +dirs = "6" +unicode-width = "0.2" +encoding_rs = "0.8" +resvg = { version = "0.45", default-features = false } +rfd = { version = "0.17", default-features = false, features = ["xdg-portal", "pollster"] } +walkdir = "2" +alacritty_terminal = "0.26" + +[profile.release] +opt-level = 3 +lto = "thin" +codegen-units = 4 +strip = true + +[profile.dev.package."*"] +opt-level = 2 + +[dev-dependencies] +egui_kittest = { version = "0.37", features = ["wgpu", "eframe"] } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e9abb26 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Damson contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..30cdc3d --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +

Damson icon

+ +

Damson

+ +

A Material You code editor in Rust that reads Kate's own syntax definitions, with motion +at the centre of how it works.

+ +![The editor](docs/screenshots/01-editor.png) + +## What's different + +- **Scrolling preview that pops out.** Press the rail and it widens over the code while lines near the + pointer swell like a lens, and a card of real, readable code bursts out and follows you on a spring. + Drag to scroll. Hold **Shift** to only peek: let go and you're back where you were. +- **Terminal baked in.** A full terminal (alacritty's emulator) grows out of the Terminal button, and + its prompt icon morphs into a hide chevron. The cursor glides between cells. +- **Everything is on springs.** Scrolling, the caret, the current-line bubble, tabs, panels and menus all + use Material 3 Expressive's spring tokens. Settings has Off, Calm, Bouncy and Jelly. +- **Icons that morph between states**, and only where a button really has two: sun and moon, run and stop, + `+` and `−` for staging, maximize and restore. One-shot actions like Save stay still. +- **Jelly tabs** whose indicator edges are separate springs, so it stretches as it moves. +- **One box for everything.** `Ctrl+Shift+P`: type for files, `>` commands, `:` line, `@` symbol, `!` run. + +![The preview lens](docs/screenshots/03-preview-lens.png) + +## Syntax highlighting + +Damson runs Kate's KSyntaxHighlighting XML definitions directly, so it covers Kate's 460+ languages. +It looks in `/usr/share/org.kde.syntax-highlighting/`, so the `syntax-highlighting` package must be installed. +Drop your own `.xml` definition into `~/.local/share/org.kde.syntax-highlighting/syntax/` and it takes +priority over the system one. Folding and comment tokens come from the same definitions. + +59 of about 7,100 regexes in those definitions use PCRE features the Rust engine doesn't have, such as +recursion. Those single rules are skipped, so a few constructs in some languages stay uncoloured. + +## Also included + +Multi-cursor (`Ctrl+Alt+Up/Down`, `Alt+J`, Ctrl+click, Alt+drag for a block), folding, bookmarks, word +wrap, bracket pairing and matching, split view, zen mode (`F11`), find and replace with regex, search in +files, outline, a git panel (stage, commit, pull, push, diffs, changed lines in the gutter and preview), +hot exit (unsaved text survives a crash or quit), and language servers for completion, hover, go to +definition and diagnostics when they're installed (`clangd`, `rust-analyzer`, `pylsp`, `gopls`, +`typescript-language-server`, `bash-language-server`, `lua-language-server`). + +Colours come from your Caelestia scheme or KDE accent, or a colour you pick, and follow live changes. + +![Light mode](docs/screenshots/12-other-mode.png) + +## Not done yet + +Vi mode, spell checking, snippets, reopening a file with a chosen encoding, and Kate's C++ plugins, which +can't load into a Rust app. Long lines are not virtualised. It runs one window per launch. Linux only for now. + +## Build + +```bash +./install.sh # builds and installs to ~/.local +``` + +Needs Rust and the `syntax-highlighting` package. No other KDE parts are needed at runtime. + +## Tests + +```bash +cargo test --lib +cargo test --test syntax_all -- --nocapture +DAMSON_SHOTS=/tmp/shots cargo test --test shots -- --test-threads=1 +``` + +The last one drives the real app with no window, using real input events, and saves a screenshot of each +screen. `DAMSON_SMOKE=/some/dir damson` runs the real window for 120 frames, saves `window.png` and +`status.txt`, then quits. + +## Licence + +MIT. Rubik is under the SIL Open Font License; the icons are Material Symbols (Apache 2.0). diff --git a/assets/Rubik.ttf b/assets/Rubik.ttf new file mode 100644 index 0000000..a59aeb6 Binary files /dev/null and b/assets/Rubik.ttf differ diff --git a/assets/damson.svg b/assets/damson.svg new file mode 100644 index 0000000..154577c --- /dev/null +++ b/assets/damson.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/docs/releases/README.md b/docs/releases/README.md new file mode 100644 index 0000000..8af614d --- /dev/null +++ b/docs/releases/README.md @@ -0,0 +1 @@ +Release notes live here as `.md`. diff --git a/docs/screenshots/01-editor.png b/docs/screenshots/01-editor.png new file mode 100644 index 0000000..1e77f52 Binary files /dev/null and b/docs/screenshots/01-editor.png differ diff --git a/docs/screenshots/03-preview-lens.png b/docs/screenshots/03-preview-lens.png new file mode 100644 index 0000000..9e7e216 Binary files /dev/null and b/docs/screenshots/03-preview-lens.png differ diff --git a/docs/screenshots/12-other-mode.png b/docs/screenshots/12-other-mode.png new file mode 100644 index 0000000..27d51bc Binary files /dev/null and b/docs/screenshots/12-other-mode.png differ diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..87d7119 --- /dev/null +++ b/install.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Builds Damson and installs it for this user, in ~/.local. +set -euo pipefail +cd "$(dirname "$0")" +cargo build --release +install -Dm755 target/release/damson "$HOME/.local/bin/damson" +install -Dm644 packaging/damson.desktop "$HOME/.local/share/applications/damson.desktop" +install -Dm644 packaging/damson.svg "$HOME/.local/share/icons/hicolor/scalable/apps/damson.svg" +echo "Installed. Run: damson [file[:line]] [folder]" diff --git a/packaging/damson.desktop b/packaging/damson.desktop new file mode 100644 index 0000000..b8b72db --- /dev/null +++ b/packaging/damson.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Type=Application +Name=Damson +GenericName=Text Editor +Comment=A Material You code editor +Exec=damson %F +Icon=damson +Terminal=false +Categories=Development;TextEditor;Utility; +MimeType=text/plain;text/x-csrc;text/x-c++src;text/x-python;text/rust;text/x-shellscript;text/markdown;application/json;application/xml; +StartupWMClass=damson diff --git a/packaging/damson.svg b/packaging/damson.svg new file mode 100644 index 0000000..154577c --- /dev/null +++ b/packaging/damson.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..ad176be --- /dev/null +++ b/src/app.rs @@ -0,0 +1,1500 @@ +//! The application: state, layout and command handling. + +use crate::config::{config_dir, Settings}; +use crate::git::{self, GitState}; +use crate::lsp::{self, Client, CompletionItem, Diag, LspEvent}; +use crate::motion::{self, spring, Preset}; +use crate::syntax::Registry; +use crate::text::commands::Prefs; +use crate::text::{Doc, EditKind, Sel}; +use crate::theme::{self, alpha, Theme}; +use crate::ui::commands::Cmd; +use crate::ui::editor::Tab; +use crate::ui::find::Find; +use crate::ui::menu::{Act, Dialog, Menu}; +use crate::ui::palette::Palette; +use crate::ui::preview::Mini; +use crate::ui::sidebar::Side; +use crate::ui::terminal::Session; +use crate::ui::morph::{self, Morph}; +use crate::ui::{fonts, icons, status::FAB_W, widgets::*}; +use eframe::egui::{self, pos2, vec2, Align2, Color32, Id, Key, Modifiers, Pos2, Rect, ResizeDirection, Sense, Stroke, Ui, ViewportCommand}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::path::{Path, PathBuf}; +use std::sync::mpsc::{channel, Receiver, Sender}; +use std::sync::Arc; +use std::time::{Duration, Instant, SystemTime}; + +pub enum Msg { + Search(Vec<(PathBuf, usize, String)>), + Git(Box), + Note(&'static str, String), +} + +pub struct Pane { + pub tabs: Vec, + pub active: usize, + pub mini: Mini, + pub dragging_mini: bool, + pub peek_from: Option, + pub lens_line: f32, + pub lens_y: f32, + pub tab_scroll: f32, + pub reveal_tab: bool, + pub tab_drag: Option<(usize, f32)>, + pub seq: u64, +} + +impl Pane { + fn new(seq: u64) -> Pane { + Pane { tabs: vec![], active: 0, mini: Mini::default(), dragging_mini: false, peek_from: None, lens_line: 0.0, lens_y: 0.0, tab_scroll: 0.0, reveal_tab: false, tab_drag: None, seq } + } +} + +pub struct Toast { + pub ic: &'static str, + pub text: String, + pub born: f64, + pub seq: u64, +} + +pub struct Completion { + pub items: Vec, + pub sel: usize, + pub start: usize, + pub seq: u64, +} + +#[derive(Serialize, Deserialize, Default)] +struct SessionFile { + root: Option, + files: Vec, + active: usize, +} + +#[derive(Serialize, Deserialize)] +struct SavedFile { + path: Option, + line: usize, + col: usize, + scroll: f32, + /// Recovery copy of unsaved text. + backup: Option, +} + +pub struct App { + pub s: Settings, + pub t: Arc, + pub theme_stamp: u32, + pub reg: Registry, + pub docs: HashMap, + pub panes: Vec, + pub focus_pane: usize, + pub split_vertical: bool, + pub split: f32, + next_id: u64, + pub root: Option, + pub reveal: bool, + pub last_input: f64, + pub side: usize, + pub side_open: bool, + pub side_state: Side, + pub settings_open: bool, + pub settings_tab: usize, + pub logo_spin: f32, + pub logo_clock: f32, + pub theme_wave: Option<(Pos2, f64)>, + pub git: GitState, + pub diags: HashMap>, + pub terms: Vec, + pub term_cur: usize, + pub next_term: u64, + pub term_open: bool, + pub term_busy: bool, + pub term_want_focus: bool, + pub term_height: f32, + pub fab_rect: Rect, + pub palette: Palette, + pub find: Find, + pub menu: Option, + pub menu_seq: u64, + pub dialog: Option, + pub toasts: Vec, + toast_seq: u64, + closed: Vec, + zen: bool, + pub tx: Sender, + rx: Receiver, + lsp_tx: Sender<(String, serde_json::Value)>, + lsp_rx: Receiver<(String, serde_json::Value)>, + pub lsp: HashMap, + lsp_sent: HashMap, + pub complete: Option, + pub hover: Option<(String, Pos2, u64)>, + complete_seq: u64, + pub caret_pos: Pos2, + hover_copied: f64, + smoke_frames: u64, + last_time: Option, + last_poll: Instant, + last_session: Instant, + last_git: Instant, + last_stamp: Option, + saved_settings: Settings, + pub quit_now: bool, +} + +impl App { + pub fn new(cc: &eframe::CreationContext, files: Vec) -> App { + Self::build(&cc.egui_ctx, files) + } + + pub fn build(ctx: &egui::Context, files: Vec) -> App { + let s = Settings::load(); + fonts::install(ctx, &s.mono_font); + let (tx, rx) = channel(); + let (lsp_tx, lsp_rx) = channel(); + let t = Arc::new(Theme::build(&s)); + let mut a = App { + t, theme_stamp: 1, reg: Registry::scan(), docs: HashMap::new(), panes: vec![Pane::new(0)], focus_pane: 0, split_vertical: false, + split: 0.5, next_id: 1, root: None, reveal: false, last_input: 0.0, side: 0, side_open: false, side_state: Side::default(), + settings_open: false, settings_tab: 0, logo_spin: 0.0, logo_clock: 0.0, theme_wave: None, git: GitState::default(), diags: HashMap::new(), + terms: vec![], term_cur: 0, next_term: 0, term_open: false, term_busy: false, term_want_focus: false, term_height: 300.0, fab_rect: Rect::from_min_size(pos2(0.0, 0.0), vec2(FAB_W, 44.0)), + palette: Palette::default(), find: Find::default(), menu: None, menu_seq: 0, dialog: None, toasts: vec![], toast_seq: 0, closed: vec![], + zen: false, tx, rx, lsp_tx, lsp_rx, lsp: HashMap::new(), lsp_sent: HashMap::new(), complete: None, hover: None, complete_seq: 0, caret_pos: pos2(200.0, 200.0), hover_copied: f64::MIN, smoke_frames: 0, + last_time: None, last_poll: Instant::now(), last_session: Instant::now(), last_git: Instant::now() - Duration::from_secs(60), + last_stamp: theme::source_stamp(), saved_settings: s.clone(), s, quit_now: false, + }; + a.apply_style(ctx); + if a.s.restore_session && files.is_empty() { + a.restore_session(ctx); + } + for f in files { + let (path, line) = split_line(&f); + if path.is_dir() { a.set_root(path) } else { a.open_path(ctx, path, line) } + } + a + } + + fn apply_style(&self, ctx: &egui::Context) { + let t = &self.t; + let mut v = if t.dark { egui::Visuals::dark() } else { egui::Visuals::light() }; + v.panel_fill = Color32::TRANSPARENT; + v.window_fill = t.high; + v.override_text_color = Some(t.on_surface); + v.selection.bg_fill = alpha(t.primary, 0.32); + v.text_cursor.stroke = Stroke::new(2.0, t.primary); + v.widgets.noninteractive.bg_stroke = Stroke::NONE; + ctx.set_visuals(v); + ctx.global_style_mut(|s| s.interaction.tooltip_delay = 0.45); + } + + pub fn refresh_theme(&mut self, ctx: &egui::Context) { + self.t = Arc::new(Theme::build(&self.s)); + self.theme_stamp += 1; + self.apply_style(ctx); + } + + pub fn settings_changed(&mut self, ctx: &egui::Context, old: &Settings) { + let s = &self.s; + if (&s.mode, &s.color_source, &s.scheme, &s.custom_color) != (&old.mode, &old.color_source, &old.scheme, &old.custom_color) { + self.refresh_theme(ctx); + } + } + + // ---------------------------------------------------------------- documents + + pub fn pane_focus_id(&self, pane: usize) -> Id { + Id::unique(("editor", self.panes[pane].seq)) + } + + pub fn cur_doc_id(&self) -> Option { + let p = self.panes.get(self.focus_pane)?; + p.tabs.get(p.active).map(|t| t.doc) + } + + pub fn cur_doc(&self) -> Option<&Doc> { + self.docs.get(&self.cur_doc_id()?) + } + + pub fn cur_doc_mut(&mut self) -> Option<&mut Doc> { + let id = self.cur_doc_id()?; + self.docs.get_mut(&id) + } + + pub fn focus_editor(&mut self, ctx: &egui::Context) { + let id = self.pane_focus_id(self.focus_pane.min(self.panes.len() - 1)); + ctx.memory_mut(|m| m.request_focus(id)); + } + + fn add_doc(&mut self, ctx: &egui::Context, doc: Doc) { + let now = ctx.input(|i| i.time); + let (pane, id) = (self.focus_pane, doc.id); + self.docs.insert(id, doc); + self.lsp_open(id); + let p = &mut self.panes[pane]; + p.tabs.push(Tab::new(id, now)); + p.active = p.tabs.len() - 1; + p.reveal_tab = true; + self.focus_editor(ctx); + } + + pub fn open_path(&mut self, ctx: &egui::Context, path: PathBuf, line: Option) { + let path = std::fs::canonicalize(&path).unwrap_or(path); + let found = self.panes[self.focus_pane].tabs.iter().position(|t| self.docs.get(&t.doc).is_some_and(|d| d.path.as_ref() == Some(&path))); + if let Some(i) = found { + let now = ctx.input(|i| i.time); + self.activate_tab(self.focus_pane, i, now); + } else { + // the same file open in another split shares its document + let shared = self.docs.values().find(|d| d.path.as_ref() == Some(&path)).map(|d| d.id); + if let Some(id) = shared { + let now = ctx.input(|i| i.time); + let p = &mut self.panes[self.focus_pane]; + p.tabs.push(Tab::new(id, now)); + p.active = p.tabs.len() - 1; + p.reveal_tab = true; + } else { + let id = self.next_id; + self.next_id += 1; + match Doc::open(id, path.clone(), &mut self.reg) { + Ok(d) => { + self.s.note_recent(&path.to_string_lossy()); + if self.root.is_none() { self.adopt_root(&path) } + self.add_doc(ctx, d); + } + Err(e) => return self.toast("error", format!("Couldn't open {}: {e}", path.display())), + } + } + } + if let Some(l) = line { + self.jump_to_line(ctx, l); + } + } + + /// Takes the enclosing git repository, if any, as the project folder. + fn adopt_root(&mut self, file: &Path) { + if let Some(dir) = file.parent() { + if let Ok(out) = git::run(dir, &["rev-parse", "--show-toplevel"]) { + self.set_root(PathBuf::from(out.trim())); + } + } + } + + pub fn set_root(&mut self, p: PathBuf) { + self.root = Some(p); + self.side_state.dirs.clear(); + self.side_state.expanded.clear(); + self.palette.files_root = None; + self.refresh_git(); + } + + pub fn jump_to_line(&mut self, ctx: &egui::Context, line: usize) { + let now = ctx.input(|i| i.time); + let m_h = (self.s.font_size * 1.55).round(); + let pane = self.focus_pane; + let Some(id) = self.cur_doc_id() else { return }; + let d = self.docs.get_mut(&id).unwrap(); + let line = line.min(d.buf.lines() - 1); + d.sync_edits(); + if d.buf.sels.iter().all(|s| d.buf.pos(s.head).0 != line) { + let at = d.buf.at(line, 0); + d.buf.set_cursor(at); + } + let p = &mut self.panes[pane]; + let a = p.active; + let tb = &mut p.tabs[a]; + let row = tb.rows.row_of(line, 0); + tb.scroll.target = (row as f32 * m_h - 240.0).max(0.0); + tb.beacon = Some((line, now)); + self.focus_editor(ctx); + } + + pub fn activate_tab(&mut self, pane: usize, i: usize, _now: f64) { + self.focus_pane = pane; + let p = &mut self.panes[pane]; + if i < p.tabs.len() { + p.active = i; + p.reveal_tab = true; + } + } + + pub fn close_tab(&mut self, pane: usize, i: usize) { + let Some(tab) = self.panes[pane].tabs.get(i) else { return }; + let doc = tab.doc; + let shared = self.panes.iter().flat_map(|p| &p.tabs).filter(|t| t.doc == doc).count() > 1; + let d = &self.docs[&doc]; + if d.buf.is_modified() && !shared && !d.buf.rope.len_chars().eq(&0) { + self.dialog = Some(Dialog::Confirm { title: format!("Save {}?", d.title()), body: "Your changes will be lost if you don't save them.".into(), pane, tab: i }); + return; + } + self.force_close(pane, i); + } + + pub fn force_close(&mut self, pane: usize, i: usize) { + let p = &mut self.panes[pane]; + if i >= p.tabs.len() { return } + let doc = p.tabs.remove(i).doc; + if p.active >= i && p.active > 0 { p.active -= 1 } + if p.tabs.is_empty() && self.panes.len() > 1 { + self.panes.remove(pane); + self.focus_pane = 0; + } + if !self.panes.iter().flat_map(|p| &p.tabs).any(|t| t.doc == doc) { + if let Some(d) = self.docs.remove(&doc) { + if let Some(path) = d.path { + self.lsp_close(&path); + self.closed.push(path); + } + } + } + } + + fn save_doc(&mut self, ctx: &egui::Context, id: u64) { + if self.docs.get(&id).is_some_and(|d| d.path.is_none()) { + let Some(p) = rfd::FileDialog::new().save_file() else { return }; + let d = self.docs.get_mut(&id).unwrap(); + d.path = Some(p.clone()); + let name = d.file_name(); + let first = d.buf.line_text(0); + if let Some(l) = self.reg.detect(&name, &first).map(str::to_string) { + d.set_language(&l, &mut self.reg); + } + self.s.note_recent(&p.to_string_lossy()); + self.lsp_open(id); + } + let trim = self.s.trim_on_save; + let d = self.docs.get_mut(&id).unwrap(); + if trim { d.buf.trim_trailing() } + match d.save() { + Ok(()) => { + d.saved_at = ctx.input(|i| i.time); + let path = d.path.clone(); + for (i, _) in self.panes.iter().enumerate() { + motion::spring(format!("tabs/{i}/save"), 0.0, motion::FAST); + motion::kick(format!("tabs/{i}/save"), 16.0); + } + if let Some(p) = path { self.lsp_saved(&p) } + self.refresh_git(); + ctx.request_repaint(); + } + Err(e) => self.toast("error", format!("Couldn't save: {e}")), + } + } + + pub fn toast(&mut self, ic: &'static str, text: String) { + self.toast_seq += 1; + self.toasts.push(Toast { ic, text, born: -1.0, seq: self.toast_seq }); + if self.toasts.len() > 3 { self.toasts.remove(0); } + } + + pub fn trash(&mut self, p: &Path) { + let ok = std::process::Command::new("gio").arg("trash").arg(p).status().is_ok_and(|s| s.success()); + if ok { + self.side_state.dirs.clear(); + self.toast("delete", "Moved to the trash".to_string()); + } else { + self.toast("error", "Couldn't move it to the trash".to_string()); + } + } + + pub fn prompt_done(&mut self, ctx: &egui::Context, act: Act, value: String) { + if value.trim().is_empty() { return } + let res = match act { + Act::NewFile(dir) => { + let p = dir.join(&value); + let r = std::fs::write(&p, ""); + if r.is_ok() { self.open_path(ctx, p, None) } + r + } + Act::NewFolder(dir) => std::fs::create_dir_all(dir.join(&value)), + Act::Rename(p) => { + let to = p.with_file_name(&value); + let r = std::fs::rename(&p, &to); + if r.is_ok() { + for d in self.docs.values_mut() { + if d.path.as_ref() == Some(&p) { d.path = Some(to.clone()) } + } + } + r + } + _ => Ok(()), + }; + if let Err(e) = res { self.toast("error", e.to_string()) } + self.side_state.dirs.clear(); + } + + pub fn act(&mut self, ctx: &egui::Context, a: Act) { + match a { + Act::Cmd(c) => self.run(ctx, c), + Act::CloseTabAt(p, i) => self.close_tab(p, i), + Act::CloseOthers(p, i) => { + let n = self.panes[p].tabs.len(); + for j in (0..n).rev() { + if j != i && !self.docs[&self.panes[p].tabs[j].doc].buf.is_modified() { self.force_close(p, j) } + } + } + Act::NewFile(_) | Act::NewFolder(_) => { + let title = if matches!(a, Act::NewFile(_)) { "New file" } else { "New folder" }; + self.dialog = Some(Dialog::Prompt { title: title.to_string(), value: String::new(), act: a }); + } + Act::Rename(ref p) => { + let value = p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); + self.dialog = Some(Dialog::Prompt { title: "Rename".to_string(), value, act: a }); + } + Act::Trash(p) => self.dialog = Some(Dialog::ConfirmTrash(p)), + Act::CopyPath(p) => ctx.copy_text(p.to_string_lossy().into_owned()), + Act::TerminalAt(d) => { + self.new_terminal(ctx, Some(d)); + self.term_open = true; + self.term_want_focus = true; + } + Act::SetRoot(p) => self.set_root(p), + Act::OpenRecent(p) => self.open_path(ctx, p, None), + } + } + + pub fn run_in_terminal(&mut self, ctx: &egui::Context, cmd: &str) { + if self.terms.is_empty() { self.new_terminal(ctx, None) } + self.term_open = true; + // the shell retitles the terminal when the command ends, which is how Stop turns back into Run + if let Some(s) = self.terms.get_mut(self.term_cur) { + s.running = true; + s.write(format!("{cmd}; printf '\\033]2;{}\\007'\r", crate::ui::terminal::RUN_DONE)); + } + self.term_want_focus = true; + } + + fn file_runner(d: &Doc) -> Option { + let p = d.path.as_ref()?; + let q = format!("'{}'", p.to_string_lossy().replace('\'', r"'\''")); + Some(match d.language.as_str() { + "Python" => format!("python3 {q}"), + "Bash" | "Zsh" => format!("bash {q}"), + "Fish" => format!("fish {q}"), + "JavaScript" => format!("node {q}"), + "Lua" => format!("lua {q}"), + "Ruby" => format!("ruby {q}"), + "Perl" => format!("perl {q}"), + "PHP (HTML)" | "PHP/PHP" => format!("php {q}"), + "Go" => format!("go run {q}"), + "Rust" => "cargo run".to_string(), + _ => return None, + }) + } + + // ---------------------------------------------------------------- git + + pub fn refresh_git(&mut self) { + let Some(dir) = self.root.clone() else { return }; + self.last_git = Instant::now(); + let tx = self.tx.clone(); + std::thread::spawn(move || { let _ = tx.send(Msg::Git(Box::new(git::scan(&dir)))); }); + } + + pub fn git_commit(&mut self) { + let msg = self.side_state.commit.trim().to_string(); + let Some(root) = self.git.root.clone() else { return }; + if msg.is_empty() { return self.toast("edit", "Write a commit message first".to_string()) } + match git::run(&root, &["commit", "-m", &msg]) { + Ok(_) => { self.side_state.commit.clear(); self.toast("commit", "Committed".to_string()) } + Err(e) => self.toast("error", e.lines().next().unwrap_or("Commit failed").to_string()), + } + self.refresh_git(); + } + + pub fn git_stage(&mut self, path: &str, staged: bool) { + let Some(root) = self.git.root.clone() else { return }; + let r = if staged { git::run(&root, &["restore", "--staged", "--", path]) } else { git::run(&root, &["add", "--", path]) }; + if let Err(e) = r { self.toast("error", e) } + self.refresh_git(); + } + + pub fn git_remote(&mut self, verb: &'static str) { + let Some(root) = self.git.root.clone() else { return }; + self.toast("sync", format!("Running git {verb}…")); + let tx = self.tx.clone(); + std::thread::spawn(move || { + let _ = tx.send(match git::run(&root, &[verb]) { + Ok(_) => Msg::Note("check_circle", format!("git {verb} finished")), + Err(e) => Msg::Note("error", e.lines().last().unwrap_or("Failed").to_string()), + }); + }); + } + + pub fn open_diff(&mut self, ctx: &egui::Context, root: &Path, rel: &str) { + let text = git::run(root, &["diff", "HEAD", "--", rel]).unwrap_or_default(); + let id = self.next_id; + self.next_id += 1; + let mut d = Doc::new(id, &text, None, &mut self.reg); + d.set_language("Diff", &mut self.reg); + self.add_doc(ctx, d); + } + + // ---------------------------------------------------------------- language servers + + fn lsp_for(&mut self, id: u64) -> Option<(String, &'static str)> { + if !self.s.lsp { return None } + let d = self.docs.get(&id)?; + d.path.as_ref()?; + let (bin, args, lang) = lsp::server_for(&d.language)?; + if !self.lsp.contains_key(bin) { + let root = self.root.clone().or_else(|| d.path.as_ref()?.parent().map(PathBuf::from))?; + let c = Client::start(bin, args, &root, bin.to_string(), self.lsp_tx.clone())?; + self.lsp.insert(bin.to_string(), c); + } + Some((bin.to_string(), lang)) + } + + fn lsp_open(&mut self, id: u64) { + let Some((bin, lang)) = self.lsp_for(id) else { return }; + let d = &self.docs[&id]; + let (Some(p), v, text) = (d.path.clone(), d.buf.version as i64, d.buf.rope.to_string()) else { return }; + if let Some(c) = self.lsp.get_mut(&bin) { c.did_open(&p, lang, v, &text) } + self.lsp_sent.insert(id, d.buf.version); + } + + fn lsp_close(&mut self, p: &Path) { + self.diags.remove(p); + } + + fn lsp_saved(&mut self, p: &Path) { + for c in self.lsp.values_mut() { c.did_save(p) } + } + + fn lsp_sync(&mut self) { + let ids: Vec = self.docs.keys().copied().collect(); + for id in ids { + let v = self.docs[&id].buf.version; + if self.lsp_sent.get(&id) == Some(&v) { continue } + let Some((bin, _)) = self.lsp_for(id) else { continue }; + let d = &self.docs[&id]; + let (Some(p), text) = (d.path.clone(), d.buf.rope.to_string()) else { continue }; + if let Some(c) = self.lsp.get_mut(&bin) { c.did_change(&p, v as i64, &text) } + self.lsp_sent.insert(id, v); + } + } + + fn lsp_at(&mut self, f: impl FnOnce(&mut Client, &Path, usize, usize)) -> bool { + let Some(id) = self.cur_doc_id() else { return false }; + let Some((bin, _)) = self.lsp_for(id) else { return false }; + self.lsp_sync(); + let d = &self.docs[&id]; + let (l, c) = d.buf.pos(d.buf.head()); + let Some(p) = d.path.clone() else { return false }; + match self.lsp.get_mut(&bin) { + Some(cl) => { f(cl, &p, l, c); true } + None => false, + } + } + + fn pump_lsp(&mut self, ctx: &egui::Context) { + while let Ok((key, v)) = self.lsp_rx.try_recv() { + let Some(ev) = self.lsp.get_mut(&key).and_then(|c| c.handle(v)) else { continue }; + match ev { + LspEvent::Diagnostics(p, d) => { + if d.is_empty() { self.diags.remove(&p); } else { self.diags.insert(p, d); } + } + LspEvent::Completion(items) => self.show_completion(items), + LspEvent::Hover(text) => { + self.complete_seq += 1; + self.hover = self.caret_screen().map(|p| (text, p, self.complete_seq)); + } + LspEvent::Definition(p, l, _) => self.open_path(ctx, p, Some(l)), + LspEvent::Ready(_) => {} + } + ctx.request_repaint(); + } + } + + fn caret_screen(&self) -> Option { + Some(self.caret_pos) + } + + fn show_completion(&mut self, mut items: Vec) { + let Some(d) = self.cur_doc() else { return }; + let word = d.buf.word_at(d.buf.head()); + let prefix = d.buf.text(word.start..d.buf.head()).to_lowercase(); + items.retain(|i| i.label.to_lowercase().starts_with(&prefix)); + if items.is_empty() { + self.complete = None; + return; + } + self.complete_seq += 1; + self.complete = Some(Completion { items, sel: 0, start: word.start, seq: self.complete_seq }); + } + + /// Words already in the file, for when no language server is running. + fn word_completion(&mut self) { + let Some(d) = self.cur_doc() else { return }; + let r = d.buf.word_at(d.buf.head()); + let prefix = d.buf.text(r.start..d.buf.head()); + if prefix.is_empty() { return } + let text = d.buf.rope.to_string(); + let re = regex::Regex::new(r"[\p{L}_][\p{L}\p{N}_]+").unwrap(); + let mut seen = std::collections::BTreeSet::new(); + for m in re.find_iter(&text).take(200_000) { + if m.as_str().starts_with(&prefix) && m.as_str() != prefix { seen.insert(m.as_str().to_string()); } + } + let items = seen.into_iter().take(40).map(|w| CompletionItem { label: w.clone(), insert: w, detail: String::new(), kind: 1 }).collect(); + self.show_completion(items); + } + + fn accept_completion(&mut self) { + let Some(c) = self.complete.take() else { return }; + let Some(item) = c.items.get(c.sel) else { return }; + let insert = item.insert.clone(); + if let Some(d) = self.cur_doc_mut() { + let head = d.buf.head(); + d.buf.apply(vec![(c.start..head, insert)], EditKind::Other, |_, st, n| Sel::cursor(st + n)); + } + } + + fn completion_ui(&mut self, ctx: &egui::Context) { + let t = self.t.clone(); + if let Some(c) = &self.complete { + let key = format!("comp/{}", c.seq); + let k = motion::spring_from(&key, 0.0, 1.0, Preset { stiffness: 900.0, damping: 0.66 }); + let row = 30.0; + let shown = c.items.len().min(8); + let sel = c.sel; + let first = sel.saturating_sub(shown - 1); + let w = 340.0; + let h = shown as f32 * row + 12.0; + let lh = (self.s.font_size * 1.55).round(); + let mut pos = self.caret_pos + vec2(-8.0, lh + 4.0); + let screen = ctx.content_rect(); + if pos.y + h > screen.bottom() - 8.0 { pos.y = self.caret_pos.y - h - 4.0 } + pos.x = pos.x.min(screen.right() - w - 8.0); + let rect = Rect::from_min_size(pos, vec2(w, h)); + let visible: Vec<(String, String, u8)> = c.items.iter().skip(first).take(shown).map(|i| (i.label.clone(), i.detail.clone(), i.kind)).collect(); + let mut clicked = None; + let area = egui::Area::new(Id::unique("completion")).order(egui::Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| { + ui.set_min_size(rect.size()); + let p = ui.painter().clone(); + shadow(&p, rect, 18.0, 0.9, t.dark); + p.rect_filled(rect, cr(18.0), t.high); + let sy = spring("comp/y", (sel - first) as f32 * row, Preset { stiffness: 1400.0, damping: 0.78 }); + p.rect_filled(Rect::from_min_size(rect.min + vec2(6.0, 6.0 + sy), vec2(w - 12.0, row)), cr(12.0), t.secondary_container); + for (i, (label, detail, kind)) in visible.iter().enumerate() { + let r = Rect::from_min_size(rect.min + vec2(6.0, 6.0 + i as f32 * row), vec2(w - 12.0, row)); + if ui.interact(r, Id::unique(("comp", i)), Sense::click()).clicked() { clicked = Some(first + i) } + let ic = match kind { 2 | 3 | 4 => "code", 5 | 10 => "tag", 7 | 8 | 22 => "data_object", _ => "text_fields" }; + icons::paint(ctx, &p, r.left_center() + vec2(16.0, 0.0), 15.0, ic, t.primary); + p.with_clip_rect(r).text(r.left_center() + vec2(32.0, 0.0), Align2::LEFT_CENTER, label, fonts::mono(12.5), if first + i == sel { t.on_secondary_container } else { t.on_surface }); + p.with_clip_rect(r).text(r.right_center() - vec2(10.0, 0.0), Align2::RIGHT_CENTER, detail.chars().take(26).collect::(), fonts::ui(11.0), t.outline); + } + }); + let a = pos; + let s = 0.8 + 0.2 * k; + ctx.set_transform_layer(area.response.layer_id, egui::emath::TSTransform::from_translation(a.to_vec2()) * egui::emath::TSTransform::from_scaling(s) * egui::emath::TSTransform::from_translation(-a.to_vec2())); + if let Some(i) = clicked { + if let Some(c) = self.complete.as_mut() { c.sel = i } + self.accept_completion(); + } + } + if let Some((text, pos, seq)) = self.hover.clone() { + let k = motion::spring_from(format!("hover/{seq}"), 0.0, 1.0, motion::DEFAULT); + let screen = ctx.content_rect(); + let lines: Vec<&str> = text.lines().take(14).collect(); + let w = 520.0_f32.min(screen.width() - 40.0); + let h = lines.len() as f32 * 18.0 + 22.0; + let mut pp = pos + vec2(0.0, -h - 8.0); + if pp.y < 8.0 { pp.y = pos.y + 28.0 } + pp.x = pp.x.min(screen.right() - w - 8.0); + let rect = Rect::from_min_size(pp, vec2(w, h)); + let area = egui::Area::new(Id::unique("hover")).order(egui::Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| { + ui.set_min_size(rect.size()); + let p = ui.painter().clone(); + shadow(&p, rect, 18.0, 0.9, t.dark); + p.rect_filled(rect, cr(18.0), t.high); + let pc = p.with_clip_rect(rect.shrink(8.0)); + for (i, l) in lines.iter().enumerate() { + pc.text(rect.left_top() + vec2(14.0, 11.0 + i as f32 * 18.0), Align2::LEFT_TOP, *l, fonts::mono(12.0), t.on_surface); + } + let b = Rect::from_center_size(rect.right_top() + vec2(-20.0, 20.0), vec2(28.0, 28.0)); + let done = ctx.input(|i| i.time) - self.hover_copied < 1.2; + if morph::button(ui, &t, b, "hover/copy", Morph::CopyCheck, done, "Copy", t.high).clicked() { + ctx.copy_text(text.clone()); + self.hover_copied = ctx.input(|i| i.time); + } + if done { motion::keep_alive() } + }); + let s = 0.86 + 0.14 * k; + ctx.set_transform_layer(area.response.layer_id, egui::emath::TSTransform::from_translation(pos.to_vec2()) * egui::emath::TSTransform::from_scaling(s) * egui::emath::TSTransform::from_translation(-pos.to_vec2())); + let away = ctx.input(|i| i.pointer.any_pressed() && !i.pointer.interact_pos().is_some_and(|p| rect.contains(p))); + if away || ctx.input(|i| i.key_pressed(Key::Escape) || i.events.iter().any(|e| matches!(e, egui::Event::Text(_)))) { self.hover = None } + } + } + + pub fn problem_count(&self) -> usize { + self.diags.values().map(Vec::len).sum() + } + + pub fn problem_totals(&self) -> (usize, usize) { + let mut e = (0, 0); + for d in self.diags.values().flatten() { + if d.severity == 1 { e.0 += 1 } else if d.severity == 2 { e.1 += 1 } + } + e + } + + pub fn preview_marks(&self, id: u64) -> Vec<(usize, Color32)> { + let t = &self.t; + let Some(d) = self.docs.get(&id) else { return vec![] }; + let mut v = vec![]; + if let Some(p) = &d.path { + if let Some(h) = self.git.marks.get(p) { + for (l, n, k) in h { + let c = [t.added, t.changed, t.removed][*k as usize]; + for i in (0..*n).step_by((*n / 8).max(1)) { v.push((l + i, c)) } + } + } + if let Some(ds) = self.diags.get(p) { + for x in ds { v.push((x.line, if x.severity == 1 { t.error } else { t.syntax[crate::syntax::DefStyle::Warning as usize] })) } + } + } + for b in &d.bookmarks { v.push((*b, t.tertiary)) } + if self.find.open { + let step = (self.find.hits.len() / 400).max(1); + for h in self.find.hits.iter().step_by(step) { + if h.0 <= d.buf.len() { v.push((d.buf.rope.char_to_line(h.0), t.tertiary)) } + } + } + v + } + + /// Change bars and problem dots in the gutter. + pub fn gutter_marks(&self, p: &egui::Painter, d: &Doc, line: usize, at: Pos2, lh: f32) { + let t = &self.t; + let Some(path) = &d.path else { return }; + if let Some(h) = self.git.marks.get(path) { + if let Some((_, _, k)) = h.iter().find(|(l, n, _)| line >= *l && line < *l + *n) { + let c = [t.added, t.changed, t.removed][*k as usize]; + p.rect_filled(Rect::from_min_size(at + vec2(0.0, 2.0), vec2(3.0, lh - 4.0)), cr(1.5), c); + } + } + if let Some(ds) = self.diags.get(path) { + if let Some(x) = ds.iter().filter(|x| x.line == line).min_by_key(|x| x.severity) { + let c = if x.severity == 1 { t.error } else { t.syntax[crate::syntax::DefStyle::Warning as usize] }; + p.circle_filled(at + vec2(-4.0, lh / 2.0 - 8.0), 2.5, c); + } + } + } + + // ---------------------------------------------------------------- commands + + pub fn run(&mut self, ctx: &egui::Context, c: Cmd) { + use Cmd::*; + let prefs = Prefs { tab_width: self.s.tab_width, spaces: self.s.spaces, auto_close: self.s.auto_close }; + self.reveal = true; + match c { + New => { + let id = self.next_id; + self.next_id += 1; + let d = Doc::new(id, "", None, &mut self.reg); + self.add_doc(ctx, d); + } + Open => { + if let Some(files) = rfd::FileDialog::new().pick_files() { + for f in files { self.open_path(ctx, f, None) } + } + } + OpenFolder => { + if let Some(d) = rfd::FileDialog::new().pick_folder() { + self.set_root(d); + self.side = 0; + self.side_open = true; + } + } + Save => if let Some(id) = self.cur_doc_id() { self.save_doc(ctx, id) }, + SaveAs => if let Some(id) = self.cur_doc_id() { + if let Some(p) = rfd::FileDialog::new().save_file() { + self.docs.get_mut(&id).unwrap().path = Some(p); + self.save_doc(ctx, id); + } + }, + SaveAll => { + let ids: Vec = self.docs.values().filter(|d| d.buf.is_modified() && d.path.is_some()).map(|d| d.id).collect(); + for id in ids { self.save_doc(ctx, id) } + } + CloseTab => { let p = self.focus_pane; let a = self.panes[p].active; self.close_tab(p, a) } + ReopenClosed => if let Some(p) = self.closed.pop() { self.open_path(ctx, p, None) }, + Reload => self.reload_current(), + Quit => self.request_quit(ctx), + Undo => if let Some(d) = self.cur_doc_mut() { d.buf.undo(); }, + Redo => if let Some(d) = self.cur_doc_mut() { d.buf.redo(); }, + Copy | Cut => if let Some(d) = self.cur_doc_mut() { + let t = d.buf.selected_text(); + if !t.is_empty() { + ctx.copy_text(t); + if c == Cut { d.buf.insert("", EditKind::Other) } + } + }, + Paste => ctx.send_viewport_cmd(ViewportCommand::RequestPaste), + SelectAll => if let Some(d) = self.cur_doc_mut() { d.buf.select_all() }, + Comment => if let Some(d) = self.cur_doc_mut() { + let (l, b) = (d.meta.line_comment.clone(), d.meta.block_comment.clone()); + d.buf.toggle_comment(l.as_deref(), b.as_ref().map(|x| (x.0.as_str(), x.1.as_str()))); + }, + DuplicateLines => if let Some(d) = self.cur_doc_mut() { d.buf.duplicate_lines() }, + DeleteLines => if let Some(d) = self.cur_doc_mut() { d.buf.delete_lines() }, + MoveLinesUp => if let Some(d) = self.cur_doc_mut() { d.buf.move_lines(true) }, + MoveLinesDown => if let Some(d) = self.cur_doc_mut() { d.buf.move_lines(false) }, + JoinLines => if let Some(d) = self.cur_doc_mut() { d.buf.join_lines() }, + Indent => if let Some(d) = self.cur_doc_mut() { d.buf.indent(&prefs) }, + Unindent => if let Some(d) = self.cur_doc_mut() { d.buf.unindent(&prefs) }, + Upper => if let Some(d) = self.cur_doc_mut() { d.buf.transform(|s| s.to_uppercase()) }, + Lower => if let Some(d) = self.cur_doc_mut() { d.buf.transform(|s| s.to_lowercase()) }, + Capitalize => if let Some(d) = self.cur_doc_mut() { + d.buf.transform(|s| { + let mut c = s.chars(); + c.next().map(|f| f.to_uppercase().chain(c.flat_map(char::to_lowercase)).collect()).unwrap_or_default() + }) + }, + SortLines => if let Some(d) = self.cur_doc_mut() { d.buf.sort_lines() }, + TrimTrailing => if let Some(d) = self.cur_doc_mut() { d.buf.trim_trailing() }, + CursorAbove => if let Some(d) = self.cur_doc_mut() { d.buf.add_cursor_vertical(false) }, + CursorBelow => if let Some(d) = self.cur_doc_mut() { d.buf.add_cursor_vertical(true) }, + SelectNext => if let Some(d) = self.cur_doc_mut() { d.buf.select_next() }, + Find | Replace => { + self.find.open = true; + self.find.focus = true; + self.find.replace = c == Replace; + if let Some(d) = self.cur_doc() { + let s = d.buf.selected_text(); + if !s.is_empty() && !s.contains('\n') { self.find.query = s } + } + } + FindInFiles => { + self.side = 1; + self.side_open = true; + self.side_state.search_focus = true; + if let Some(d) = self.cur_doc() { + let s = d.buf.selected_text(); + if !s.is_empty() && !s.contains('\n') { self.side_state.search = s } + } + } + GotoLine => self.open_palette(ctx, ":", false), + Palette => self.open_palette(ctx, ">", false), + QuickOpen => self.open_palette(ctx, "", false), + Languages => self.open_palette(ctx, "", true), + Symbols => self.open_palette(ctx, "@", false), + ToggleTerminal => { + if self.terms.is_empty() { self.new_terminal(ctx, None) } + self.term_open = !self.term_open && !self.terms.is_empty(); + if self.term_open { self.term_want_focus = true } else { self.focus_editor(ctx) } + } + NewTerminal => { + self.new_terminal(ctx, None); + self.term_open = !self.terms.is_empty(); + self.term_want_focus = true; + } + RunFile => { + let id = self.cur_doc_id(); + if let Some(id) = id { if self.docs[&id].buf.is_modified() { self.save_doc(ctx, id) } } + match self.cur_doc().and_then(Self::file_runner) { + Some(c) => self.run_in_terminal(ctx, &c), + None => self.toast("info", "No run command known for this language".to_string()), + } + } + TerminalHere => { + let dir = self.cur_doc().and_then(|d| d.path.as_ref()?.parent().map(PathBuf::from)); + self.new_terminal(ctx, dir); + self.term_open = !self.terms.is_empty(); + self.term_want_focus = true; + } + ToggleSidebar => self.side_open = !self.side_open, + Side(i) => { + if self.side == i && self.side_open { self.side_open = false } + else { self.side = i; self.side_open = true } + } + SplitRight | SplitDown => { + self.split_vertical = c == SplitDown; + self.split = 0.5; + if self.panes.len() < 2 { + let doc = self.cur_doc_id(); + let seq = self.panes.iter().map(|p| p.seq).max().unwrap_or(0) + 1; + let mut p = Pane::new(seq); + if let Some(id) = doc { + p.tabs.push(Tab::new(id, ctx.input(|i| i.time))); + } + self.panes.push(p); + self.focus_pane = 1; + self.focus_editor(ctx); + } + } + CloseSplit => { + if self.panes.len() > 1 { + let p = self.focus_pane; + let n = self.panes[p].tabs.len(); + if (0..n).all(|i| !self.docs[&self.panes[p].tabs[i].doc].buf.is_modified() || self.panes.iter().enumerate().any(|(j, o)| j != p && o.tabs.iter().any(|t| t.doc == self.panes[p].tabs[i].doc))) { + for j in (0..n).rev() { if self.panes.len() > 1 { self.force_close(p, j) } } + } + self.focus_pane = 0; + } + } + FocusNextPane => { + self.focus_pane = (self.focus_pane + 1) % self.panes.len(); + self.focus_editor(ctx); + } + Zen => self.zen = !self.zen, + ToggleWrap => self.s.word_wrap ^= true, + ToggleWhitespace => self.s.show_whitespace ^= true, + ToggleNumbers => self.s.line_numbers ^= true, + TogglePreview => self.s.preview ^= true, + ToggleLens => self.s.lens ^= true, + ZoomIn => self.s.font_size = (self.s.font_size + 1.0).min(40.0), + ZoomOut => self.s.font_size = (self.s.font_size - 1.0).max(8.0), + ZoomReset => self.s.font_size = 14.0, + FoldHere => if let Some(d) = self.cur_doc_mut() { + let l = d.buf.pos(d.buf.head()).0; + let start = d.fold_ends.iter().filter(|(s, e)| **s <= l && l <= **e).map(|(s, _)| *s).max(); + if let Some(s) = start { d.toggle_fold(s) } + }, + FoldAll => if let Some(d) = self.cur_doc_mut() { + let v: Vec = d.fold_ends.keys().copied().collect(); + d.folded.extend(v); + }, + UnfoldAll => if let Some(d) = self.cur_doc_mut() { d.folded.clear() }, + ToggleBookmark => if let Some(d) = self.cur_doc_mut() { + let l = d.buf.pos(d.buf.head()).0; + if !d.bookmarks.remove(&l) { d.bookmarks.insert(l); } + }, + NextBookmark | PrevBookmark => { + let target = self.cur_doc().and_then(|d| { + let l = d.buf.pos(d.buf.head()).0; + if c == NextBookmark { d.bookmarks.range(l + 1..).next().or(d.bookmarks.iter().next()).copied() } + else { d.bookmarks.range(..l).next_back().or(d.bookmarks.iter().next_back()).copied() } + }); + if let Some(l) = target { self.jump_to_line(ctx, l) } + } + GotoDefinition => { if !self.lsp_at(|c, p, l, col| c.definition(p, l, col)) { self.toast("info", "No language server for this file".to_string()) } } + Hover => { if !self.lsp_at(|c, p, l, col| c.hover(p, l, col)) { self.toast("info", "No language server for this file".to_string()) } } + Complete => { if !self.lsp_at(|c, p, l, col| c.completion(p, l, col)) { self.word_completion() } } + NextProblem => { + let list = self.cur_doc().and_then(|d| Some((d.buf.pos(d.buf.head()).0, self.diags.get(d.path.as_ref()?)?.clone()))); + if let Some((l, mut ds)) = list { + ds.sort_by_key(|x| x.line); + if let Some(x) = ds.iter().find(|x| x.line > l).or(ds.first()) { self.jump_to_line(ctx, x.line) } + } + } + ToggleDark => { + self.s.mode = if self.t.dark { "light".into() } else { "dark".into() }; + self.refresh_theme(ctx); + } + Settings => self.settings_open = !self.settings_open, + About => self.toast("info", format!("Damson {}: {} syntax definitions loaded from Kate", env!("CARGO_PKG_VERSION"), self.reg.languages.len())), + NextTab | PrevTab => { + let p = &mut self.panes[self.focus_pane]; + let n = p.tabs.len(); + if n > 0 { + p.active = if c == NextTab { (p.active + 1) % n } else { (p.active + n - 1) % n }; + p.reveal_tab = true; + } + } + TabAt(i) => { let p = self.focus_pane; self.activate_tab(p, i, 0.0) } + GitRefresh => self.refresh_git(), + } + } + + fn reload_current(&mut self) { + let Some(id) = self.cur_doc_id() else { return }; + if let Err(e) = self.docs.get_mut(&id).unwrap().reload() { + self.toast("error", format!("Couldn't reload: {e}")); + } + } + + fn request_quit(&mut self, ctx: &egui::Context) { + if self.docs.values().any(|d| d.buf.is_modified()) { + self.dialog = Some(Dialog::ConfirmQuit); + } else { + self.quit_now = true; + ctx.send_viewport_cmd(ViewportCommand::Close); + } + } + + fn shortcuts(&mut self, ctx: &egui::Context) { + use Cmd::*; + const C: Modifiers = Modifiers::COMMAND; + const CS: Modifiers = Modifiers { shift: true, ..Modifiers::COMMAND }; + const CA: Modifiers = Modifiers { alt: true, ..Modifiers::COMMAND }; + const CAS: Modifiers = Modifiers { alt: true, shift: true, ..Modifiers::COMMAND }; + const A: Modifiers = Modifiers::ALT; + const N: Modifiers = Modifiers::NONE; + + // these work everywhere, even with the terminal focused + let global: &[(Modifiers, Key, Cmd)] = &[ + (N, Key::F4, ToggleTerminal), (C, Key::Backtick, ToggleTerminal), (N, Key::F11, Zen), (CS, Key::P, Palette), (CS, Key::Backtick, NewTerminal), + ]; + let table: &[(Modifiers, Key, Cmd)] = &[ + (C, Key::N, New), (C, Key::O, Open), (CS, Key::O, OpenFolder), (C, Key::S, Save), (CS, Key::S, SaveAs), (C, Key::L, SaveAll), + (C, Key::W, CloseTab), (CS, Key::T, ReopenClosed), (N, Key::F5, Reload), (C, Key::Q, Quit), + (C, Key::Z, Undo), (C, Key::Y, Redo), (CS, Key::Z, Redo), (C, Key::A, SelectAll), + (C, Key::Slash, Comment), (C, Key::D, Comment), (CAS, Key::ArrowDown, DuplicateLines), (C, Key::K, DeleteLines), + (CS, Key::ArrowUp, MoveLinesUp), (CS, Key::ArrowDown, MoveLinesDown), (C, Key::J, JoinLines), + (C, Key::U, Upper), (CS, Key::U, Lower), (CA, Key::U, Capitalize), (CA, Key::ArrowUp, CursorAbove), (CA, Key::ArrowDown, CursorBelow), + (A, Key::J, SelectNext), (C, Key::F, Find), (C, Key::R, Replace), (CS, Key::F, FindInFiles), (C, Key::G, GotoLine), + (C, Key::P, QuickOpen), (CS, Key::R, Symbols), (C, Key::F5, RunFile), (C, Key::B, ToggleSidebar), + (A, Key::Num1, Side(0)), (A, Key::Num2, Side(1)), (A, Key::Num3, Side(2)), (A, Key::Num4, Side(3)), (A, Key::Num5, Side(4)), + (CS, Key::L, SplitRight), (N, Key::F10, ToggleWrap), (C, Key::Equals, ZoomIn), (C, Key::Plus, ZoomIn), (C, Key::Minus, ZoomOut), (C, Key::Num0, ZoomReset), + (CS, Key::Minus, FoldHere), (CS, Key::OpenBracket, FoldAll), (CS, Key::CloseBracket, UnfoldAll), + (CS, Key::B, ToggleBookmark), (A, Key::PageDown, NextBookmark), (A, Key::PageUp, PrevBookmark), + (N, Key::F12, GotoDefinition), (C, Key::I, Hover), (C, Key::Space, Complete), (N, Key::F8, NextProblem), (C, Key::Comma, Settings), + (C, Key::Tab, NextTab), (CS, Key::Tab, PrevTab), + ]; + let term_focus = ctx.memory(|m| m.focused()) == Some(self.term_focus_id()); + let mut hit = vec![]; + ctx.input_mut(|i| { + for (m, k, c) in global { + if i.consume_key(*m, *k) { hit.push(c.clone()) } + } + if !term_focus { + // order the wider chords first, or Ctrl alone would swallow Ctrl+Shift + let mut sorted: Vec<&(Modifiers, Key, Cmd)> = table.iter().collect(); + sorted.sort_by_key(|(m, _, _)| -(m.shift as i32 + m.alt as i32)); + for (m, k, c) in sorted { + if i.consume_key(*m, *k) { hit.push(c.clone()) } + } + } + }); + if !term_focus { + // the completion list takes the keys it needs before the editor sees them + if let Some(n) = self.complete.as_ref().map(|c| c.items.len()) { + let (up, down, accept, esc) = ctx.input_mut(|i| (i.consume_key(N, Key::ArrowUp), i.consume_key(N, Key::ArrowDown), i.consume_key(N, Key::Enter) || i.consume_key(N, Key::Tab), i.consume_key(N, Key::Escape))); + if let Some(c) = &mut self.complete { + if up { c.sel = (c.sel + n - 1) % n } + if down { c.sel = (c.sel + 1) % n } + } + if accept { self.accept_completion() } + if esc { self.complete = None } + } + } + for c in hit { self.run(ctx, c) } + } + + // ---------------------------------------------------------------- housekeeping + + fn background(&mut self, ctx: &egui::Context) { + while let Ok(m) = self.rx.try_recv() { + match m { + Msg::Search(r) => { + self.side_state.results = r; + self.side_state.searching = false; + } + Msg::Git(g) => self.git = *g, + Msg::Note(ic, t) => self.toast(ic, t), + } + } + self.pump_terminals(ctx); + self.pump_lsp(ctx); + + // colours for the rest of each file, a slice per frame + let start = Instant::now(); + let ids: Vec = self.docs.keys().copied().collect(); + for id in ids { + let d = self.docs.get_mut(&id).unwrap(); + while d.highlight_pending() && start.elapsed() < Duration::from_millis(5) { + d.highlight(&self.reg, 0, 96); + } + if d.highlight_pending() { motion::keep_alive() } + } + + let now = Instant::now(); + if now - self.last_poll > Duration::from_millis(1500) { + self.last_poll = now; + self.lsp_sync(); + self.check_external(); + let st = theme::source_stamp(); + if st != self.last_stamp { + self.last_stamp = st; + if self.s.color_source != "custom" { self.refresh_theme(ctx) } + } + if self.s != self.saved_settings { + self.s.save(); + self.saved_settings = self.s.clone(); + } + } + if now - self.last_git > Duration::from_secs(12) { self.refresh_git() } + if now - self.last_session > Duration::from_secs(8) { + self.last_session = now; + self.save_session(); + } + } + + /// Picks up files changed by something else; unsaved ones are left alone with a note. + fn check_external(&mut self) { + let mut reload = vec![]; + for d in self.docs.values_mut() { + let (Some(p), Some(old)) = (&d.path, d.mtime) else { continue }; + let Some(new) = std::fs::metadata(p).and_then(|m| m.modified()).ok() else { continue }; + if new != old { + d.mtime = Some(new); + reload.push((d.id, d.buf.is_modified(), d.title())); + } + } + for (id, modified, name) in reload { + if modified { + self.toast("warning", format!("{name} changed on disk. Reload with F5.")); + } else { + let _ = self.docs.get_mut(&id).unwrap().reload(); + } + } + } + + fn session_path() -> PathBuf { + config_dir().join("session.json") + } + + pub fn save_session(&self) { + let dir = config_dir().join("recovery"); + let _ = std::fs::create_dir_all(&dir); + let mut keep = vec![]; + let pane = &self.panes[0]; + let mut files = vec![]; + let mut seen = std::collections::HashSet::new(); + for tb in self.panes.iter().flat_map(|p| &p.tabs) { + if !seen.insert(tb.doc) { continue } + let Some(d) = self.docs.get(&tb.doc) else { continue }; + let backup = d.buf.is_modified().then(|| { + let p = dir.join(format!("{}.txt", d.id)); + let _ = std::fs::write(&p, d.buf.rope.to_string()); + keep.push(p.clone()); + p + }); + if d.path.is_none() && backup.is_none() { continue } + let (line, col) = d.buf.pos(d.buf.head()); + files.push(SavedFile { path: d.path.clone(), line, col, scroll: tb.scroll.x, backup }); + } + if let Ok(rd) = std::fs::read_dir(&dir) { + for e in rd.flatten() { + if !keep.contains(&e.path()) { let _ = std::fs::remove_file(e.path()); } + } + } + let s = SessionFile { root: self.root.clone(), files, active: pane.active }; + if let Ok(j) = serde_json::to_vec_pretty(&s) { + let _ = std::fs::create_dir_all(config_dir()); + let _ = std::fs::write(Self::session_path(), j); + } + } + + fn restore_session(&mut self, ctx: &egui::Context) { + let Some(s) = std::fs::read(Self::session_path()).ok().and_then(|b| serde_json::from_slice::(&b).ok()) else { return }; + if let Some(r) = s.root.filter(|r| r.is_dir()) { self.set_root(r) } + for f in s.files { + let backup = f.backup.as_ref().and_then(|p| std::fs::read_to_string(p).ok()); + match (&f.path, backup) { + (Some(p), None) if p.is_file() => self.open_path(ctx, p.clone(), None), + (Some(p), Some(text)) => { + if p.is_file() { self.open_path(ctx, p.clone(), None) } else { + let id = self.next_id; + self.next_id += 1; + let d = Doc::new(id, "", Some(p.clone()), &mut self.reg); + self.add_doc(ctx, d); + } + if let Some(d) = self.cur_doc_mut() { + d.buf.select_all(); + d.buf.insert(&text, EditKind::Other); + } + } + (None, Some(text)) => { + self.run(ctx, Cmd::New); + if let Some(d) = self.cur_doc_mut() { d.buf.insert(&text, EditKind::Other) } + } + _ => continue, + } + if let Some(d) = self.cur_doc_mut() { + let at = d.buf.at(f.line, f.col); + d.buf.set_cursor(at); + } + let p = &mut self.panes[0]; + if let Some(tb) = p.tabs.last_mut() { tb.scroll.snap(f.scroll) } + } + let p = &mut self.panes[0]; + p.active = s.active.min(p.tabs.len().saturating_sub(1)); + } + + // ---------------------------------------------------------------- the frame + + pub fn ui(&mut self, ui: &mut Ui) { + let ctx = ui.ctx().clone(); + let now = Instant::now(); + let dt = self.last_time.map_or(1.0 / 60.0, |t| (now - t).as_secs_f32()); + self.last_time = Some(now); + motion::begin_frame(dt, self.s.motion); + self.background(&ctx); + if ctx.memory(|m| m.focused()).is_none() && !self.palette.open && self.dialog.is_none() && !self.settings_open && !self.term_open { + self.focus_editor(&ctx); + } + self.shortcuts(&ctx); + if ctx.input(|i| i.viewport().close_requested()) && !self.quit_now { + self.save_session(); + if self.docs.values().any(|d| d.buf.is_modified()) { + ctx.send_viewport_cmd(ViewportCommand::CancelClose); + self.dialog = Some(Dialog::ConfirmQuit); + } + } + // typing refreshes an open completion list + if self.complete.is_some() && ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::Text(_)) || matches!(e, egui::Event::Key { key: Key::Backspace, pressed: true, .. }))) { + self.run(&ctx, Cmd::Complete); + } + self.layout(ui); + self.palette_ui(&ctx); + self.menu_ui(&ctx); + self.dialog_ui(&ctx); + self.settings_ui(&ctx); + self.completion_ui(&ctx); + self.toasts_ui(&ctx); + self.theme_wave_ui(&ctx); + self.smoke(&ctx); + if motion::busy() { ctx.request_repaint() } + else { ctx.request_repaint_after(Duration::from_millis(500)) } + } + + /// With DAMSON_SMOKE=dir set: run a little, screenshot the real window, write a status, quit. + fn smoke(&mut self, ctx: &egui::Context) { + let Some(dir) = std::env::var_os("DAMSON_SMOKE").map(PathBuf::from) else { return }; + self.smoke_frames += 1; + ctx.request_repaint(); + match self.smoke_frames { + 20 => self.run(ctx, Cmd::Side(0)), + 45 => self.run(ctx, Cmd::ToggleTerminal), + 120 => { + let status = format!("frames=120 docs={} terminals={} defs={} renderer=glow\n", self.docs.len(), self.terms.len(), self.reg.languages.len()); + let ctx2 = ctx.clone(); + ctx.send_viewport_cmd(ViewportCommand::Screenshot(egui::ScreenshotCallback::new(move |img| { + let (w, h) = (img.size[0] as u32, img.size[1] as u32); + let bytes: Vec = img.pixels.iter().flat_map(|c| c.to_array()).collect(); + if let Some(pm) = resvg::tiny_skia::Pixmap::from_vec(bytes, resvg::tiny_skia::IntSize::from_wh(w, h).unwrap()) { + let _ = pm.save_png(dir.join("window.png")); + } + let _ = std::fs::write(dir.join("status.txt"), status); + ctx2.send_viewport_cmd(ViewportCommand::Close); + }))); + } + _ => {} + } + } + + fn layout(&mut self, ui: &mut Ui) { + let ctx = ui.ctx().clone(); + let t = self.t.clone(); + let full = ui.max_rect(); + let maxed = ctx.input(|i| i.viewport().maximized.unwrap_or(false) || i.viewport().fullscreen.unwrap_or(false)); + let p = ui.painter().clone(); + p.rect_filled(full, cr(if maxed { 0.0 } else { 18.0 }), t.surface); + + let z = spring("zen", self.zen as u8 as f32, motion::DEFAULT); + let zk = z.clamp(0.0, 1.0); + self.window_edges(ui, full, maxed); + + let rail_w = 78.0 * (1.0 - zk); + if rail_w > 1.0 { + let r = Rect::from_min_size(pos2(full.left() - 78.0 * z + 2.0, full.top() + 6.0), vec2(74.0, full.height() - 12.0)); + self.rail(ui, r); + } + let side_k = spring("side/k", (self.side_open && !self.zen) as u8 as f32, Preset { stiffness: 620.0, damping: 0.72 }); + let side_w = 296.0 * side_k.max(0.0); + let pad = 8.0; + let status_h = 48.0 * (1.0 - zk); + let body = Rect::from_min_max(pos2(full.left() + rail_w + pad * z.clamp(0.0, 1.0) + 2.0, full.top() + 8.0), pos2(full.right() - 10.0, full.bottom() - status_h - 8.0 * zk)); + if side_k > 0.01 { + let r = Rect::from_min_size(body.min, vec2(side_w - 8.0, body.height())); + let mut sub = ui.new_child(egui::UiBuilder::new().max_rect(r)); + sub.set_clip_rect(r.intersect(ui.clip_rect())); + self.side_panel(&mut sub, Rect::from_min_size(r.min, vec2(288.0, r.height()))); + } + let stage = Rect::from_min_max(pos2(body.left() + side_w, body.top()), body.max); + + let term_k = spring("term/k", self.term_open as u8 as f32, Preset { stiffness: 480.0, damping: 0.7 }); + let reserved = (self.term_height + 8.0) * term_k.clamp(0.0, 1.0); + let editors = Rect::from_min_max(stage.min, pos2(stage.right(), stage.bottom() - reserved)); + + let n = self.panes.len(); + let gap = 8.0; + let mut rects = vec![editors]; + if n > 1 { + if self.split_vertical { + let y = editors.top() + editors.height() * self.split; + rects = vec![Rect::from_min_max(editors.min, pos2(editors.right(), y - gap / 2.0)), Rect::from_min_max(pos2(editors.left(), y + gap / 2.0), editors.max)]; + } else { + let x = editors.left() + editors.width() * self.split; + rects = vec![Rect::from_min_max(editors.min, pos2(x - gap / 2.0, editors.bottom())), Rect::from_min_max(pos2(x + gap / 2.0, editors.top()), editors.max)]; + } + let bar = if self.split_vertical { Rect::from_center_size(pos2(editors.center().x, rects[0].bottom() + gap / 2.0), vec2(editors.width(), gap + 4.0)) } else { Rect::from_center_size(pos2(rects[0].right() + gap / 2.0, editors.center().y), vec2(gap + 4.0, editors.height())) }; + let resp = ui.interact(bar, ui.scope_id().with("split-bar"), Sense::drag()); + if resp.hovered() || resp.dragged() { ctx.set_cursor_icon(if self.split_vertical { egui::CursorIcon::ResizeVertical } else { egui::CursorIcon::ResizeHorizontal }) } + if resp.dragged() { + let d = resp.drag_delta(); + self.split = (self.split + if self.split_vertical { d.y / editors.height() } else { d.x / editors.width() }).clamp(0.2, 0.8); + } + } + let mut find_card = None; + for (i, r) in rects.iter().enumerate() { + let has_controls = (r.right() - full.right()).abs() < 30.0 && (r.top() - editors.top()).abs() < 1.0; + let tab_h = 46.0 * (1.0 - zk); + let strip = Rect::from_min_max(r.min, pos2(r.right() - if has_controls { 118.0 } else { 0.0 }, r.top() + 44.0)); + if tab_h > 8.0 { + // the strip's empty space moves the window; tabs are added after, so they sit on top + let bar = ui.interact(strip, ui.scope_id().with(("titlebar", i)), Sense::click_and_drag()); + if bar.drag_started() { ctx.send_viewport_cmd(ViewportCommand::StartDrag) } + if bar.double_clicked() { ctx.send_viewport_cmd(ViewportCommand::Maximized(!maxed)) } + let mut sub = ui.new_child(egui::UiBuilder::new().max_rect(strip.translate(vec2(0.0, -46.0 * zk)))); + self.tabstrip(&mut sub, i, strip.translate(vec2(0.0, -46.0 * zk))); + } + let card = Rect::from_min_max(pos2(r.left(), r.top() + tab_h), r.max); + let focused = i == self.focus_pane; + p.rect_filled(card, cr(24.0), t.low); + if n > 1 && focused { + p.rect_stroke(card, cr(24.0), Stroke::new(1.5, alpha(t.primary, 0.5)), egui::StrokeKind::Inside); + } + if self.panes[i].tabs.is_empty() { + self.welcome(ui, card); + continue; + } + let mini_w = if self.s.preview { 92.0 } else { 0.0 }; + let code = Rect::from_min_max(card.min, pos2(card.right() - mini_w - if mini_w > 0.0 { 8.0 } else { 0.0 }, card.bottom())); + self.editor(ui, i, code.shrink2(vec2(0.0, 2.0))); + if self.s.preview { + let rail = Rect::from_min_max(pos2(card.right() - mini_w - 6.0, card.top() + 6.0), pos2(card.right() - 6.0, card.bottom() - 6.0)); + self.preview(ui, i, rail); + } + if focused { + find_card = Some(card); + self.caret_pos = self.caret_screen_of(ui, i, code); + } + } + if let Some(c) = find_card { self.find_bar(ui, c) } + + self.window_buttons(ui, full); + + if term_k.abs() > 0.004 { + let target = Rect::from_min_max(pos2(stage.left(), stage.bottom() - self.term_height), stage.max); + self.terminal_card(ui, target, term_k); + } + if status_h > 2.0 { + let r = Rect::from_min_max(pos2(body.left(), full.bottom() - 48.0 + 48.0 * zk), pos2(full.right() - 12.0, full.bottom() - 2.0 + 48.0 * zk)); + self.status(ui, r); + } + } + + fn caret_screen_of(&self, ui: &Ui, pane: usize, code: Rect) -> Pos2 { + let m = self.metrics(ui); + let p = &self.panes[pane]; + let Some(tb) = p.tabs.get(p.active) else { return code.min }; + let digits = self.docs[&tb.doc].buf.lines().to_string().len().max(3); + let gutter = if self.s.line_numbers { digits as f32 * m.cw * 0.92 + 42.0 } else { 34.0 }; + pos2(code.left() + gutter + 6.0 + tb.caret[0].x - tb.scroll_x, code.top() + 8.0 + tb.caret[1].x - tb.scroll.x) + } + + fn window_edges(&mut self, ui: &mut Ui, full: Rect, maxed: bool) { + if maxed { return } + let ctx = ui.ctx().clone(); + let m = 5.0; + let edges: [(Rect, ResizeDirection, egui::CursorIcon); 4] = [ + (Rect::from_min_max(full.left_top(), pos2(full.right(), full.top() + m)), ResizeDirection::North, egui::CursorIcon::ResizeVertical), + (Rect::from_min_max(pos2(full.left(), full.bottom() - m), full.right_bottom()), ResizeDirection::South, egui::CursorIcon::ResizeVertical), + (Rect::from_min_max(full.left_top(), pos2(full.left() + m, full.bottom())), ResizeDirection::West, egui::CursorIcon::ResizeHorizontal), + (Rect::from_min_max(pos2(full.right() - m, full.top()), full.right_bottom()), ResizeDirection::East, egui::CursorIcon::ResizeHorizontal), + ]; + for (i, (r, dir, cursor)) in edges.into_iter().enumerate() { + let resp = ui.interact(r, ui.scope_id().with(("edge", i)), Sense::drag()); + if resp.hovered() { ctx.set_cursor_icon(cursor) } + if resp.drag_started() { ctx.send_viewport_cmd(ViewportCommand::BeginResize(dir)) } + } + } + + fn window_buttons(&mut self, ui: &mut Ui, full: Rect) { + let t = self.t.clone(); + let ctx = ui.ctx().clone(); + let y = full.top() + 30.0; + let x = full.right() - 30.0; + let z = spring("zen", self.zen as u8 as f32, motion::DEFAULT).clamp(0.0, 1.0); + let y = y - 60.0 * z; + let maxed = ctx.input(|i| i.viewport().maximized.unwrap_or(false)); + if icon_btn(ui, &t, Rect::from_center_size(pos2(x, y), vec2(32.0, 32.0)), "win/close", "close", "Close", false).clicked() { ctx.send_viewport_cmd(ViewportCommand::Close) } + if morph::button(ui, &t, Rect::from_center_size(pos2(x - 36.0, y), vec2(32.0, 32.0)), "win/max", Morph::MaxRestore, maxed, "Maximize", t.surface).clicked() { ctx.send_viewport_cmd(ViewportCommand::Maximized(!maxed)) } + if icon_btn(ui, &t, Rect::from_center_size(pos2(x - 72.0, y), vec2(32.0, 32.0)), "win/min", "minimize", "Minimize", false).clicked() { ctx.send_viewport_cmd(ViewportCommand::Minimized(true)) } + } + + fn toasts_ui(&mut self, ctx: &egui::Context) { + let t = self.t.clone(); + let now = ctx.input(|i| i.time); + for x in &mut self.toasts { if x.born < 0.0 { x.born = now } } + self.toasts.retain(|x| now - x.born < 3.6); + let screen = ctx.content_rect(); + let mut y = screen.bottom() - 64.0; + for x in self.toasts.iter().rev() { + let age = (now - x.born) as f32; + let out = age > 3.2; + let k = motion::spring_from(format!("toast/{}", x.seq), 0.0, if out { 0.0 } else { 1.0 }, motion::DEFAULT); + let w = 66.0 + ctx.fonts_mut(|f| f.layout_no_wrap(x.text.clone(), fonts::ui(13.5), t.on_surface).size().x); + let size = vec2(lerp(44.0, w, k.clamp(0.0, 1.1)), 44.0); + let r = Rect::from_min_size(pos2(screen.center().x - size.x / 2.0, y + (1.0 - k) * 60.0 - 44.0), size); + let inv = (t.on_surface, t.surface); + egui::Area::new(Id::unique(("toast", x.seq))).order(egui::Order::Tooltip).fixed_pos(r.min).interactable(false).show(ctx, |ui| { + let p = ui.painter().with_clip_rect(ctx.content_rect()); + shadow(&p, r, 22.0, k.clamp(0.0, 1.0) * 0.8, t.dark); + p.rect_filled(r, cr(22.0), inv.0); + icons::paint(ctx, &p, r.left_center() + vec2(23.0, 0.0), 19.0, x.ic, alpha(inv.1, k.clamp(0.0, 1.0))); + if k > 0.5 { + p.with_clip_rect(r).text(r.left_center() + vec2(42.0, 0.0), Align2::LEFT_CENTER, &x.text, fonts::ui(13.5), alpha(inv.1, (k * 2.0 - 1.0).clamp(0.0, 1.0))); + } + }); + y -= 52.0 * k.clamp(0.0, 1.0); + motion::keep_alive(); + } + } + + fn theme_wave_ui(&mut self, ctx: &egui::Context) { + let Some((c, born)) = self.theme_wave else { return }; + let age = (ctx.input(|i| i.time) - born) as f32; + if age > 0.7 { + self.theme_wave = None; + return; + } + let k = age / 0.7; + let e = 1.0 - (1.0 - k).powi(3); + let radius = ctx.content_rect().size().length() * e; + let p = ctx.layer_painter(egui::LayerId::new(egui::Order::Foreground, Id::unique("wave"))); + p.circle_filled(c, radius, alpha(self.t.primary, 0.24 * (1.0 - k))); + motion::keep_alive(); + } +} + +impl eframe::App for App { + fn ui(&mut self, ui: &mut Ui, _frame: &mut eframe::Frame) { + App::ui(self, ui); + } + + fn clear_color(&self, _: &egui::Visuals) -> [f32; 4] { + [0.0, 0.0, 0.0, 0.0] + } + + fn on_exit(&mut self, _: Option<&eframe::glow::Context>) { + self.save_session(); + self.s.save(); + } +} + +/// `path:line` from the command line. +fn split_line(arg: &str) -> (PathBuf, Option) { + if let Some((p, l)) = arg.rsplit_once(':') { + if let Ok(n) = l.parse::() { + return (PathBuf::from(p), Some(n.saturating_sub(1))); + } + } + (PathBuf::from(arg), None) +} + +#[cfg(test)] +mod tests { + use super::split_line; + + #[test] + fn line_suffix_is_optional() { + assert_eq!(split_line("a/b.rs:12").1, Some(11)); + assert_eq!(split_line("a/b.rs").1, None); + } +} diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..2a608f5 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,73 @@ +//! Settings, stored as JSON in ~/.config/damson/settings.json. + +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +pub const APP_NAME: &str = "Damson"; + +#[derive(Serialize, Deserialize, Clone, PartialEq)] +#[serde(default)] +pub struct Settings { + pub color_source: String, // "auto", "caelestia", "kde", "custom" + pub custom_color: String, + pub mode: String, // "auto", "dark", "light" + pub scheme: String, // "tonal", "vibrant", "expressive", "mono" + pub motion: u8, // 0 off, 1 calm, 2 bouncy, 3 jelly + pub font_size: f32, + pub mono_font: String, + pub tab_width: usize, + pub spaces: bool, + pub auto_close: bool, + pub word_wrap: bool, + pub line_numbers: bool, + pub show_whitespace: bool, + pub indent_guides: bool, + pub preview: bool, + pub lens: bool, + pub trim_on_save: bool, + pub restore_session: bool, + pub shell: String, + pub terminal_font: f32, + pub lsp: bool, + pub recent: Vec, + pub win: [f32; 2], +} + +impl Default for Settings { + fn default() -> Self { + Settings { + color_source: "auto".into(), custom_color: "#7f5fc4".into(), mode: "auto".into(), scheme: "tonal".into(), + motion: 2, font_size: 14.0, mono_font: String::new(), tab_width: 4, spaces: true, auto_close: true, + word_wrap: false, line_numbers: true, show_whitespace: false, indent_guides: true, preview: true, + lens: true, trim_on_save: false, restore_session: true, shell: String::new(), terminal_font: 13.0, + lsp: true, recent: vec![], win: [1400.0, 900.0], + } + } +} + +pub fn config_dir() -> PathBuf { + dirs::config_dir().unwrap_or_else(|| PathBuf::from(".")).join("damson") +} + +impl Settings { + pub fn load() -> Settings { + std::fs::read(config_dir().join("settings.json")).ok().and_then(|b| serde_json::from_slice(&b).ok()).unwrap_or_default() + } + + pub fn save(&self) { + let dir = config_dir(); + let _ = std::fs::create_dir_all(&dir); + if let Ok(j) = serde_json::to_vec_pretty(self) { + let tmp = dir.join("settings.json.tmp"); + if std::fs::write(&tmp, j).is_ok() { + let _ = std::fs::rename(tmp, dir.join("settings.json")); + } + } + } + + pub fn note_recent(&mut self, path: &str) { + self.recent.retain(|p| p != path); + self.recent.insert(0, path.to_string()); + self.recent.truncate(16); + } +} diff --git a/src/git.rs b/src/git.rs new file mode 100644 index 0000000..dd905a7 --- /dev/null +++ b/src/git.rs @@ -0,0 +1,102 @@ +//! Git, by running `git`: branch and file status for the panel, changed lines for the gutter. + +use std::collections::HashMap; +use std::path::{Path, PathBuf}; +use std::process::Command; + +#[derive(Default, Clone)] +pub struct GitState { + pub root: Option, + pub branch: String, + pub ahead: String, + /// (index status, worktree status, path relative to root) + pub files: Vec<(char, char, String)>, + /// Per file: first line, line count, kind (0 add, 1 change, 2 delete). + pub marks: HashMap>, +} + +fn git(dir: &Path, args: &[&str]) -> Option { + let o = Command::new("git").arg("-C").arg(dir).args(args).output().ok()?; + o.status.success().then(|| String::from_utf8_lossy(&o.stdout).into_owned()) +} + +pub fn run(dir: &Path, args: &[&str]) -> Result { + let o = Command::new("git").arg("-C").arg(dir).args(args).output().map_err(|e| e.to_string())?; + if o.status.success() { Ok(String::from_utf8_lossy(&o.stdout).into_owned()) } else { Err(String::from_utf8_lossy(&o.stderr).trim().to_string()) } +} + +/// Reads hunks from `git diff -U0` output. +pub fn parse_hunks(diff: &str) -> Vec<(usize, usize, u8)> { + let mut v = vec![]; + for l in diff.lines() { + let Some(rest) = l.strip_prefix("@@ -") else { continue }; + let mut parts = rest.split(' '); + let (Some(old), Some(new)) = (parts.next(), parts.next()) else { continue }; + let num = |s: &str| -> (usize, usize) { + let mut it = s.trim_start_matches(['+', '-']).split(','); + let a = it.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let b = it.next().and_then(|x| x.parse().ok()).unwrap_or(1); + (a, b) + }; + let ((_, oc), (ns, nc)) = (num(old), num(new)); + if nc == 0 { + v.push((ns, 1, 2)); + } else { + v.push((ns.saturating_sub(1), nc, if oc == 0 { 0 } else { 1 })); + } + } + v +} + +pub fn scan(dir: &Path) -> GitState { + let mut st = GitState::default(); + let Some(root) = git(dir, &["rev-parse", "--show-toplevel"]) else { return st }; + let root = PathBuf::from(root.trim()); + st.branch = git(&root, &["branch", "--show-current"]).unwrap_or_default().trim().to_string(); + if st.branch.is_empty() { + st.branch = git(&root, &["rev-parse", "--short", "HEAD"]).unwrap_or_default().trim().to_string(); + } + if let Some(s) = git(&root, &["rev-list", "--left-right", "--count", "@{u}...HEAD"]) { + let mut p = s.split_whitespace(); + let (b, a) = (p.next().unwrap_or("0"), p.next().unwrap_or("0")); + st.ahead = match (a, b) { ("0", "0") => String::new(), ("0", b) => format!("↓{b}"), (a, "0") => format!("↑{a}"), (a, b) => format!("↑{a} ↓{b}") }; + } + for l in git(&root, &["status", "--porcelain=v1", "-uall"]).unwrap_or_default().lines() { + let cs: Vec = l.chars().collect(); + if cs.len() > 3 { + let path: String = cs[3..].iter().collect(); + let path = path.rsplit(" -> ").next().unwrap_or("").trim_matches('"').to_string(); + st.files.push((cs[0], cs[1], path)); + } + } + let diff = git(&root, &["diff", "-U0", "--no-color", "--no-ext-diff"]).unwrap_or_default(); + let mut cur: Option = None; + let mut chunk = String::new(); + let flush = |p: &Option, c: &mut String, m: &mut HashMap>| { + if let Some(p) = p { m.insert(p.clone(), parse_hunks(c)); } + c.clear(); + }; + for l in diff.lines() { + if let Some(f) = l.strip_prefix("+++ b/") { + flush(&cur, &mut chunk, &mut st.marks); + cur = Some(root.join(f)); + } else if l.starts_with("@@") { + chunk.push_str(l); + chunk.push('\n'); + } + } + flush(&cur, &mut chunk, &mut st.marks); + st.root = Some(root); + st +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn hunks_become_added_changed_and_deleted() { + let d = "@@ -3,0 +4,2 @@\n@@ -9 +11 @@\n@@ -20,2 +21,0 @@\n"; + assert_eq!(parse_hunks(d), vec![(3, 2, 0), (10, 1, 1), (21, 1, 2)]); + } +} diff --git a/src/icondata.rs b/src/icondata.rs new file mode 100644 index 0000000..bca23c5 --- /dev/null +++ b/src/icondata.rs @@ -0,0 +1,146 @@ +//! Material Symbols Rounded (Apache 2.0) path data, viewBox 0 -960 960 960. Generated by tools/gen_icons.py. + +pub const ICONS: &[(&str, &str)] = &[ + ("account_tree", "M600 -200V-240H520Q487 -240 463.5 -263.5Q440 -287 440 -320V-640H360V-600Q360 -567 336.5 -543.5Q313 -520 280 -520H160Q127 -520 103.5 -543.5Q80 -567 80 -600V-760Q80 -793 103.5 -816.5Q127 -840 160 -840H280Q313 -840 336.5 -816.5Q360 -793 360 -760V-720H600V-760Q600 -793 623.5 -816.5Q647 -840 680 -840H800Q833 -840 856.5 -816.5Q880 -793 880 -760V-600Q880 -567 856.5 -543.5Q833 -520 800 -520H680Q647 -520 623.5 -543.5Q600 -567 600 -600V-640H520V-320Q520 -320 520 -320Q520 -320 520 -320H600V-360Q600 -393 623.5 -416.5Q647 -440 680 -440H800Q833 -440 856.5 -416.5Q880 -393 880 -360V-200Q880 -167 856.5 -143.5Q833 -120 800 -120H680Q647 -120 623.5 -143.5Q600 -167 600 -200ZM160 -760V-600ZM680 -360V-200ZM680 -760V-600ZM680 -600H800V-760H680ZM680 -200H800V-360H680ZM160 -600H280V-760H160Z"), + ("account_tree_fill", "M600 -200V-240H520Q487 -240 463.5 -263.5Q440 -287 440 -320V-640H360V-600Q360 -567 336.5 -543.5Q313 -520 280 -520H160Q127 -520 103.5 -543.5Q80 -567 80 -600V-760Q80 -793 103.5 -816.5Q127 -840 160 -840H280Q313 -840 336.5 -816.5Q360 -793 360 -760V-720H600V-760Q600 -793 623.5 -816.5Q647 -840 680 -840H800Q833 -840 856.5 -816.5Q880 -793 880 -760V-600Q880 -567 856.5 -543.5Q833 -520 800 -520H680Q647 -520 623.5 -543.5Q600 -567 600 -600V-640H520V-320Q520 -320 520 -320Q520 -320 520 -320H600V-360Q600 -393 623.5 -416.5Q647 -440 680 -440H800Q833 -440 856.5 -416.5Q880 -393 880 -360V-200Q880 -167 856.5 -143.5Q833 -120 800 -120H680Q647 -120 623.5 -143.5Q600 -167 600 -200ZM160 -760H280V-600H160ZM680 -360H800V-200H680ZM680 -760H800V-600H680ZM680 -600H800V-760H680ZM680 -200H800V-360H680ZM160 -600H280V-760H160Z"), + ("add", "M440 -440H240Q223 -440 211.5 -451.5Q200 -463 200 -480Q200 -497 211.5 -508.5Q223 -520 240 -520H440V-720Q440 -737 451.5 -748.5Q463 -760 480 -760Q497 -760 508.5 -748.5Q520 -737 520 -720V-520H720Q737 -520 748.5 -508.5Q760 -497 760 -480Q760 -463 748.5 -451.5Q737 -440 720 -440H520V-240Q520 -223 508.5 -211.5Q497 -200 480 -200Q463 -200 451.5 -211.5Q440 -223 440 -240Z"), + ("arrow_back", "M313 -440 509 -244Q521 -232 520.5 -216Q520 -200 508 -188Q496 -177 480 -176.5Q464 -176 452 -188L188 -452Q182 -458 179.5 -465Q177 -472 177 -480Q177 -488 179.5 -495Q182 -502 188 -508L452 -772Q463 -783 479.5 -783Q496 -783 508 -772Q520 -760 520 -743.5Q520 -727 508 -715L313 -520H760Q777 -520 788.5 -508.5Q800 -497 800 -480Q800 -463 788.5 -451.5Q777 -440 760 -440Z"), + ("arrow_downward", "M440 -313V-760Q440 -777 451.5 -788.5Q463 -800 480 -800Q497 -800 508.5 -788.5Q520 -777 520 -760V-313L716 -509Q728 -521 744 -520.5Q760 -520 772 -508Q783 -496 783.5 -480Q784 -464 772 -452L508 -188Q502 -182 495 -179.5Q488 -177 480 -177Q472 -177 465 -179.5Q458 -182 452 -188L188 -452Q177 -463 177 -479.5Q177 -496 188 -508Q200 -520 216.5 -520Q233 -520 245 -508Z"), + ("arrow_forward", "M647 -440H200Q183 -440 171.5 -451.5Q160 -463 160 -480Q160 -497 171.5 -508.5Q183 -520 200 -520H647L451 -716Q439 -728 439.5 -744Q440 -760 452 -772Q464 -783 480 -783.5Q496 -784 508 -772L772 -508Q778 -502 780.5 -495Q783 -488 783 -480Q783 -472 780.5 -465Q778 -458 772 -452L508 -188Q497 -177 480.5 -177Q464 -177 452 -188Q440 -200 440 -216.5Q440 -233 452 -245Z"), + ("arrow_upward", "M440 -647 244 -451Q232 -439 216 -439.5Q200 -440 188 -452Q177 -464 176.5 -480Q176 -496 188 -508L452 -772Q458 -778 465 -780.5Q472 -783 480 -783Q488 -783 495 -780.5Q502 -778 508 -772L772 -508Q783 -497 783 -480.5Q783 -464 772 -452Q760 -440 743.5 -440Q727 -440 715 -452L520 -647V-200Q520 -183 508.5 -171.5Q497 -160 480 -160Q463 -160 451.5 -171.5Q440 -183 440 -200Z"), + ("article", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM320 -280H520Q537 -280 548.5 -291.5Q560 -303 560 -320Q560 -337 548.5 -348.5Q537 -360 520 -360H320Q303 -360 291.5 -348.5Q280 -337 280 -320Q280 -303 291.5 -291.5Q303 -280 320 -280ZM320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM320 -600H640Q657 -600 668.5 -611.5Q680 -623 680 -640Q680 -657 668.5 -668.5Q657 -680 640 -680H320Q303 -680 291.5 -668.5Q280 -657 280 -640Q280 -623 291.5 -611.5Q303 -600 320 -600Z"), + ("article_fill", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760H760Q760 -760 760 -760Q760 -760 760 -760V-200Q760 -200 760 -200Q760 -200 760 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM320 -280H520Q537 -280 548.5 -291.5Q560 -303 560 -320Q560 -337 548.5 -348.5Q537 -360 520 -360H320Q303 -360 291.5 -348.5Q280 -337 280 -320Q280 -303 291.5 -291.5Q303 -280 320 -280ZM320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM320 -600H640Q657 -600 668.5 -611.5Q680 -623 680 -640Q680 -657 668.5 -668.5Q657 -680 640 -680H320Q303 -680 291.5 -668.5Q280 -657 280 -640Q280 -623 291.5 -611.5Q303 -600 320 -600Z"), + ("bolt", "M422 -232 629 -480H469L498 -707L313 -440H452ZM360 -360H236Q212 -360 200.5 -381.5Q189 -403 203 -423L502 -853Q512 -867 528 -872.5Q544 -878 561 -872Q578 -866 586 -851Q594 -836 592 -819L560 -560H715Q741 -560 751.5 -537Q762 -514 745 -494L416 -100Q405 -87 389 -83Q373 -79 358 -86Q343 -93 334.5 -107.5Q326 -122 328 -139ZM471 -470Z"), + ("bolt_fill", "M422 -232 629 -480H469L498 -707L313 -440H452ZM360 -360H236Q212 -360 200.5 -381.5Q189 -403 203 -423L502 -853Q512 -867 528 -872.5Q544 -878 561 -872Q578 -866 586 -851Q594 -836 592 -819L560 -560H715Q741 -560 751.5 -537Q762 -514 745 -494L416 -100Q405 -87 389 -83Q373 -79 358 -86Q343 -93 334.5 -107.5Q326 -122 328 -139ZM422 -232 452 -440H313L498 -707L469 -480H629Z"), + ("bookmark", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H680Q713 -840 736.5 -816.5Q760 -793 760 -760V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -328 680 -242Q680 -242 680 -242Q680 -242 680 -242V-760Q680 -760 680 -760Q680 -760 680 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242ZM480 -760H280Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760H680Q680 -760 680 -760Q680 -760 680 -760Q680 -760 680 -760Q680 -760 680 -760Z"), + ("bookmark_add", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H480Q497 -840 508.5 -828.5Q520 -817 520 -800Q520 -783 508.5 -771.5Q497 -760 480 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242L480 -328L680 -242Q680 -242 680 -242Q680 -242 680 -242V-480Q680 -497 691.5 -508.5Q703 -520 720 -520Q737 -520 748.5 -508.5Q760 -497 760 -480V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -760H280Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760H520Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760ZM680 -680H640Q623 -680 611.5 -691.5Q600 -703 600 -720Q600 -737 611.5 -748.5Q623 -760 640 -760H680V-800Q680 -817 691.5 -828.5Q703 -840 720 -840Q737 -840 748.5 -828.5Q760 -817 760 -800V-760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680H760V-640Q760 -623 748.5 -611.5Q737 -600 720 -600Q703 -600 691.5 -611.5Q680 -623 680 -640Z"), + ("bookmark_add_fill", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H498Q518 -840 529 -822.5Q540 -805 531 -785Q529 -779 527.5 -773Q526 -767 524 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242L480 -328L680 -242Q680 -242 680 -242Q680 -242 680 -242V-524Q692 -522 701.5 -521.5Q711 -521 720 -521Q737 -521 748.5 -510.5Q760 -500 760 -484V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -328 280 -242Q280 -242 280 -242Q280 -242 280 -242V-760Q280 -760 280 -760Q280 -760 280 -760H524Q522 -750 521 -740.5Q520 -731 520 -720Q520 -648 565.5 -593Q611 -538 680 -524V-242Q680 -242 680 -242Q680 -242 680 -242ZM680 -680H640Q623 -680 611.5 -691.5Q600 -703 600 -720Q600 -737 611.5 -748.5Q623 -760 640 -760H680V-800Q680 -817 691.5 -828.5Q703 -840 720 -840Q737 -840 748.5 -828.5Q760 -817 760 -800V-760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680H760V-640Q760 -623 748.5 -611.5Q737 -600 720 -600Q703 -600 691.5 -611.5Q680 -623 680 -640Z"), + ("bookmark_fill", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H680Q713 -840 736.5 -816.5Q760 -793 760 -760V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -328 680 -242Q680 -242 680 -242Q680 -242 680 -242V-760Q680 -760 680 -760Q680 -760 680 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242ZM480 -328 280 -242Q280 -242 280 -242Q280 -242 280 -242V-760Q280 -760 280 -760Q280 -760 280 -760H680Q680 -760 680 -760Q680 -760 680 -760V-242Q680 -242 680 -242Q680 -242 680 -242Z"), + ("build", "M360 -360Q260 -360 190 -430Q120 -500 120 -600Q120 -620 123 -640Q126 -660 134 -678Q139 -688 146.5 -693Q154 -698 163 -700Q172 -702 181.5 -699.5Q191 -697 199 -689L304 -584L376 -656L271 -761Q263 -769 260.5 -778.5Q258 -788 260 -797Q262 -806 267 -813.5Q272 -821 282 -826Q300 -834 320 -837Q340 -840 360 -840Q460 -840 530 -770Q600 -700 600 -600Q600 -577 596 -556.5Q592 -536 584 -516L786 -316Q815 -287 815 -245Q815 -203 786 -174Q757 -145 715 -145Q673 -145 644 -175L444 -376Q424 -368 403.5 -364Q383 -360 360 -360ZM360 -440Q386 -440 412 -448Q438 -456 459 -473L702 -230Q707 -225 715.5 -225.5Q724 -226 729 -231Q734 -236 734 -244.5Q734 -253 729 -258L486 -500Q504 -520 512 -546.5Q520 -573 520 -600Q520 -660 481.5 -704.5Q443 -749 386 -758L460 -684Q472 -672 472 -656Q472 -640 460 -628L332 -500Q320 -488 304 -488Q288 -488 276 -500L202 -574Q211 -517 255.5 -478.5Q300 -440 360 -440ZM469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Z"), + ("build_fill", "M360 -360Q260 -360 190 -430Q120 -500 120 -600Q120 -620 123 -640Q126 -660 134 -678Q139 -688 146.5 -693Q154 -698 163 -700Q172 -702 181.5 -699.5Q191 -697 199 -689L304 -584L376 -656L271 -761Q263 -769 260.5 -778.5Q258 -788 260 -797Q262 -806 267 -813.5Q272 -821 282 -826Q300 -834 320 -837Q340 -840 360 -840Q460 -840 530 -770Q600 -700 600 -600Q600 -577 596 -556.5Q592 -536 584 -516L786 -316Q815 -287 815 -245Q815 -203 786 -174Q757 -145 715 -145Q673 -145 644 -175L444 -376Q424 -368 403.5 -364Q383 -360 360 -360ZM360 -440Q386 -440 412 -448Q438 -456 459 -473L702 -230Q707 -225 715.5 -225.5Q724 -226 729 -231Q734 -236 734 -244.5Q734 -253 729 -258L486 -500Q504 -520 512 -546.5Q520 -573 520 -600Q520 -660 481.5 -704.5Q443 -749 386 -758L460 -684Q472 -672 472 -656Q472 -640 460 -628L332 -500Q320 -488 304 -488Q288 -488 276 -500L202 -574Q211 -517 255.5 -478.5Q300 -440 360 -440ZM360 -440Q300 -440 255.5 -478.5Q211 -517 202 -574L276 -500Q288 -488 304 -488Q320 -488 332 -500L460 -628Q472 -640 472 -656Q472 -672 460 -684L386 -758Q443 -749 481.5 -704.5Q520 -660 520 -600Q520 -573 512 -546.5Q504 -520 486 -500L728 -258Q733 -253 733 -244.5Q733 -236 728 -231Q723 -226 715 -225.5Q707 -225 702 -230L459 -473Q438 -456 412 -448Q386 -440 360 -440Z"), + ("call_split", "M240 -664V-600Q240 -583 228.5 -571.5Q217 -560 200 -560Q183 -560 171.5 -571.5Q160 -583 160 -600V-760Q160 -777 171.5 -788.5Q183 -800 200 -800H360Q377 -800 388.5 -788.5Q400 -777 400 -760Q400 -743 388.5 -731.5Q377 -720 360 -720H296L497 -519Q508 -508 514 -493.5Q520 -479 520 -463V-200Q520 -183 508.5 -171.5Q497 -160 480 -160Q463 -160 451.5 -171.5Q440 -183 440 -200V-464Q440 -464 440 -464Q440 -464 440 -464ZM720 -664 622 -565Q610 -553 593.5 -553Q577 -553 565 -565Q553 -577 553 -594Q553 -611 565 -623L664 -720H600Q583 -720 571.5 -731.5Q560 -743 560 -760Q560 -777 571.5 -788.5Q583 -800 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760V-600Q800 -583 788.5 -571.5Q777 -560 760 -560Q743 -560 731.5 -571.5Q720 -583 720 -600Z"), + ("check", "M382 -354 721 -693Q733 -705 749 -705Q765 -705 777 -693Q789 -681 789 -664.5Q789 -648 777 -636L410 -268Q398 -256 382 -256Q366 -256 354 -268L182 -440Q170 -452 170.5 -468.5Q171 -485 183 -497Q195 -509 211.5 -509Q228 -509 240 -497Z"), + ("check_circle", "M424 -408 338 -494Q327 -505 310 -505Q293 -505 282 -494Q271 -483 271 -466Q271 -449 282 -438L396 -324Q408 -312 424 -312Q440 -312 452 -324L678 -550Q689 -561 689 -578Q689 -595 678 -606Q667 -617 650 -617Q633 -617 622 -606ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"), + ("check_circle_fill", "M424 -408 338 -494Q327 -505 310 -505Q293 -505 282 -494Q271 -483 271 -466Q271 -449 282 -438L396 -324Q408 -312 424 -312Q440 -312 452 -324L678 -550Q689 -561 689 -578Q689 -595 678 -606Q667 -617 650 -617Q633 -617 622 -606ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"), + ("chevron_left", "M432 -480 588 -324Q599 -313 599 -296Q599 -279 588 -268Q577 -257 560 -257Q543 -257 532 -268L348 -452Q342 -458 339.5 -465Q337 -472 337 -480Q337 -488 339.5 -495Q342 -502 348 -508L532 -692Q543 -703 560 -703Q577 -703 588 -692Q599 -681 599 -664Q599 -647 588 -636Z"), + ("chevron_right", "M504 -480 348 -636Q337 -647 337 -664Q337 -681 348 -692Q359 -703 376 -703Q393 -703 404 -692L588 -508Q594 -502 596.5 -495Q599 -488 599 -480Q599 -472 596.5 -465Q594 -458 588 -452L404 -268Q393 -257 376 -257Q359 -257 348 -268Q337 -279 337 -296Q337 -313 348 -324Z"), + ("close", "M480 -424 284 -228Q273 -217 256 -217Q239 -217 228 -228Q217 -239 217 -256Q217 -273 228 -284L424 -480L228 -676Q217 -687 217 -704Q217 -721 228 -732Q239 -743 256 -743Q273 -743 284 -732L480 -536L676 -732Q687 -743 704 -743Q721 -743 732 -732Q743 -721 743 -704Q743 -687 732 -676L536 -480L732 -284Q743 -273 743 -256Q743 -239 732 -228Q721 -217 704 -217Q687 -217 676 -228Z"), + ("close_fullscreen", "M400 -344 164 -108Q153 -97 136 -97Q119 -97 108 -108Q97 -119 97 -136Q97 -153 108 -164L344 -400H200Q183 -400 171.5 -411.5Q160 -423 160 -440Q160 -457 171.5 -468.5Q183 -480 200 -480H440Q457 -480 468.5 -468.5Q480 -457 480 -440V-200Q480 -183 468.5 -171.5Q457 -160 440 -160Q423 -160 411.5 -171.5Q400 -183 400 -200ZM616 -560H760Q777 -560 788.5 -548.5Q800 -537 800 -520Q800 -503 788.5 -491.5Q777 -480 760 -480H520Q503 -480 491.5 -491.5Q480 -503 480 -520V-760Q480 -777 491.5 -788.5Q503 -800 520 -800Q537 -800 548.5 -788.5Q560 -777 560 -760V-616L796 -852Q807 -863 824 -863Q841 -863 852 -852Q863 -841 863 -824Q863 -807 852 -796Z"), + ("code", "M193 -479 348 -324Q359 -313 359 -296Q359 -279 348 -268Q337 -257 320 -257Q303 -257 292 -268L108 -452Q102 -458 99.5 -465Q97 -472 97 -480Q97 -488 99.5 -495Q102 -502 108 -508L292 -692Q304 -704 320.5 -704Q337 -704 349 -692Q361 -680 361 -663.5Q361 -647 349 -635ZM767 -481 612 -636Q601 -647 601 -664Q601 -681 612 -692Q623 -703 640 -703Q657 -703 668 -692L852 -508Q858 -502 860.5 -495Q863 -488 863 -480Q863 -472 860.5 -465Q858 -458 852 -452L668 -268Q656 -256 640 -256.5Q624 -257 612 -269Q600 -281 600 -297.5Q600 -314 612 -326Z"), + ("commit", "M284 -440H120Q103 -440 91.5 -451.5Q80 -463 80 -480Q80 -497 91.5 -508.5Q103 -520 120 -520H284Q298 -589 352.5 -634.5Q407 -680 480 -680Q553 -680 607.5 -634.5Q662 -589 676 -520H840Q857 -520 868.5 -508.5Q880 -497 880 -480Q880 -463 868.5 -451.5Q857 -440 840 -440H676Q662 -371 607.5 -325.5Q553 -280 480 -280Q407 -280 352.5 -325.5Q298 -371 284 -440ZM480 -360Q530 -360 565 -395Q600 -430 600 -480Q600 -530 565 -565Q530 -600 480 -600Q430 -600 395 -565Q360 -530 360 -480Q360 -430 395 -395Q430 -360 480 -360Z"), + ("content_copy", "M360 -240Q327 -240 303.5 -263.5Q280 -287 280 -320V-800Q280 -833 303.5 -856.5Q327 -880 360 -880H720Q753 -880 776.5 -856.5Q800 -833 800 -800V-320Q800 -287 776.5 -263.5Q753 -240 720 -240ZM360 -320H720Q720 -320 720 -320Q720 -320 720 -320V-800Q720 -800 720 -800Q720 -800 720 -800H360Q360 -800 360 -800Q360 -800 360 -800V-320Q360 -320 360 -320Q360 -320 360 -320ZM200 -80Q167 -80 143.5 -103.5Q120 -127 120 -160V-680Q120 -697 131.5 -708.5Q143 -720 160 -720Q177 -720 188.5 -708.5Q200 -697 200 -680V-160Q200 -160 200 -160Q200 -160 200 -160H600Q617 -160 628.5 -148.5Q640 -137 640 -120Q640 -103 628.5 -91.5Q617 -80 600 -80ZM360 -320Q360 -320 360 -320Q360 -320 360 -320V-800Q360 -800 360 -800Q360 -800 360 -800Q360 -800 360 -800Q360 -800 360 -800V-320Q360 -320 360 -320Q360 -320 360 -320Z"), + ("content_copy_fill", "M360 -240Q327 -240 303.5 -263.5Q280 -287 280 -320V-800Q280 -833 303.5 -856.5Q327 -880 360 -880H720Q753 -880 776.5 -856.5Q800 -833 800 -800V-320Q800 -287 776.5 -263.5Q753 -240 720 -240ZM360 -320H720Q720 -320 720 -320Q720 -320 720 -320V-800Q720 -800 720 -800Q720 -800 720 -800H360Q360 -800 360 -800Q360 -800 360 -800V-320Q360 -320 360 -320Q360 -320 360 -320ZM200 -80Q167 -80 143.5 -103.5Q120 -127 120 -160V-680Q120 -697 131.5 -708.5Q143 -720 160 -720Q177 -720 188.5 -708.5Q200 -697 200 -680V-160Q200 -160 200 -160Q200 -160 200 -160H600Q617 -160 628.5 -148.5Q640 -137 640 -120Q640 -103 628.5 -91.5Q617 -80 600 -80ZM360 -320Q360 -320 360 -320Q360 -320 360 -320V-800Q360 -800 360 -800Q360 -800 360 -800H720Q720 -800 720 -800Q720 -800 720 -800V-320Q720 -320 720 -320Q720 -320 720 -320Z"), + ("content_cut", "M480 -400 386 -306Q394 -291 397 -274Q400 -257 400 -240Q400 -174 353 -127Q306 -80 240 -80Q174 -80 127 -127Q80 -174 80 -240Q80 -306 127 -353Q174 -400 240 -400Q257 -400 274 -397Q291 -394 306 -386L400 -480L306 -574Q291 -566 274 -563Q257 -560 240 -560Q174 -560 127 -607Q80 -654 80 -720Q80 -786 127 -833Q174 -880 240 -880Q306 -880 353 -833Q400 -786 400 -720Q400 -703 397 -686Q394 -669 386 -654L824 -216Q851 -189 836 -154.5Q821 -120 783 -120Q772 -120 761.5 -124.5Q751 -129 743 -137ZM600 -520 520 -600 743 -823Q751 -831 761.5 -835.5Q772 -840 783 -840Q821 -840 835.5 -805Q850 -770 823 -743ZM240 -640Q273 -640 296.5 -663.5Q320 -687 320 -720Q320 -753 296.5 -776.5Q273 -800 240 -800Q207 -800 183.5 -776.5Q160 -753 160 -720Q160 -687 183.5 -663.5Q207 -640 240 -640ZM480 -460Q488 -460 494 -466Q500 -472 500 -480Q500 -488 494 -494Q488 -500 480 -500Q472 -500 466 -494Q460 -488 460 -480Q460 -472 466 -466Q472 -460 480 -460ZM240 -160Q273 -160 296.5 -183.5Q320 -207 320 -240Q320 -273 296.5 -296.5Q273 -320 240 -320Q207 -320 183.5 -296.5Q160 -273 160 -240Q160 -207 183.5 -183.5Q207 -160 240 -160Z"), + ("content_paste", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H367Q378 -875 410 -897.5Q442 -920 480 -920Q520 -920 551.5 -897.5Q583 -875 594 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H680V-680Q680 -663 668.5 -651.5Q657 -640 640 -640H320Q303 -640 291.5 -651.5Q280 -663 280 -680V-760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM480 -760Q497 -760 508.5 -771.5Q520 -783 520 -800Q520 -817 508.5 -828.5Q497 -840 480 -840Q463 -840 451.5 -828.5Q440 -817 440 -800Q440 -783 451.5 -771.5Q463 -760 480 -760Z"), + ("contrast", "M480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM520 -163Q639 -178 719.5 -267.5Q800 -357 800 -480Q800 -603 719.5 -692.5Q639 -782 520 -797Z"), + ("dark_mode", "M480 -120Q329 -120 224.5 -224.5Q120 -329 120 -480Q120 -618 210 -719.5Q300 -821 440 -838Q453 -840 463 -834.5Q473 -829 479 -820Q485 -811 485.5 -799Q486 -787 478 -776Q461 -750 452.5 -721Q444 -692 444 -660Q444 -570 507 -507Q570 -444 660 -444Q691 -444 721.5 -453Q752 -462 776 -478Q787 -485 798.5 -484.5Q810 -484 819 -479Q829 -474 834.5 -464Q840 -454 838 -440Q824 -302 720.5 -211Q617 -120 480 -120ZM480 -200Q568 -200 638 -248.5Q708 -297 740 -375Q720 -370 700 -367Q680 -364 660 -364Q537 -364 450.5 -450.5Q364 -537 364 -660Q364 -680 367 -700Q370 -720 375 -740Q297 -708 248.5 -638Q200 -568 200 -480Q200 -364 282 -282Q364 -200 480 -200ZM470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Z"), + ("dark_mode_fill", "M480 -120Q329 -120 224.5 -224.5Q120 -329 120 -480Q120 -618 210 -719.5Q300 -821 440 -838Q453 -840 463 -834.5Q473 -829 479 -820Q485 -811 485.5 -799Q486 -787 478 -776Q461 -750 452.5 -721Q444 -692 444 -660Q444 -570 507 -507Q570 -444 660 -444Q691 -444 721.5 -453Q752 -462 776 -478Q787 -485 798.5 -484.5Q810 -484 819 -479Q829 -474 834.5 -464Q840 -454 838 -440Q824 -302 720.5 -211Q617 -120 480 -120ZM480 -200Q568 -200 638 -248.5Q708 -297 740 -375Q720 -370 700 -367Q680 -364 660 -364Q537 -364 450.5 -450.5Q364 -537 364 -660Q364 -680 367 -700Q370 -720 375 -740Q297 -708 248.5 -638Q200 -568 200 -480Q200 -364 282 -282Q364 -200 480 -200ZM480 -200Q364 -200 282 -282Q200 -364 200 -480Q200 -568 248.5 -638Q297 -708 375 -740Q370 -720 367 -700Q364 -680 364 -660Q364 -537 450.5 -450.5Q537 -364 660 -364Q680 -364 700 -367Q720 -370 740 -375Q708 -297 638 -248.5Q568 -200 480 -200Z"), + ("data_object", "M600 -160Q583 -160 571.5 -171.5Q560 -183 560 -200Q560 -217 571.5 -228.5Q583 -240 600 -240H680Q697 -240 708.5 -251.5Q720 -263 720 -280V-360Q720 -398 742 -429Q764 -460 800 -473V-487Q764 -500 742 -531Q720 -562 720 -600V-680Q720 -697 708.5 -708.5Q697 -720 680 -720H600Q583 -720 571.5 -731.5Q560 -743 560 -760Q560 -777 571.5 -788.5Q583 -800 600 -800H680Q730 -800 765 -765Q800 -730 800 -680V-600Q800 -583 811.5 -571.5Q823 -560 840 -560Q857 -560 868.5 -548.5Q880 -537 880 -520V-440Q880 -423 868.5 -411.5Q857 -400 840 -400Q823 -400 811.5 -388.5Q800 -377 800 -360V-280Q800 -230 765 -195Q730 -160 680 -160ZM280 -160Q230 -160 195 -195Q160 -230 160 -280V-360Q160 -377 148.5 -388.5Q137 -400 120 -400Q103 -400 91.5 -411.5Q80 -423 80 -440V-520Q80 -537 91.5 -548.5Q103 -560 120 -560Q137 -560 148.5 -571.5Q160 -583 160 -600V-680Q160 -730 195 -765Q230 -800 280 -800H360Q377 -800 388.5 -788.5Q400 -777 400 -760Q400 -743 388.5 -731.5Q377 -720 360 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -562 218 -531Q196 -500 160 -487V-473Q196 -460 218 -429Q240 -398 240 -360V-280Q240 -263 251.5 -251.5Q263 -240 280 -240H360Q377 -240 388.5 -228.5Q400 -217 400 -200Q400 -183 388.5 -171.5Q377 -160 360 -160Z"), + ("delete", "M280 -120Q247 -120 223.5 -143.5Q200 -167 200 -200V-720Q183 -720 171.5 -731.5Q160 -743 160 -760Q160 -777 171.5 -788.5Q183 -800 200 -800H360Q360 -817 371.5 -828.5Q383 -840 400 -840H560Q577 -840 588.5 -828.5Q600 -817 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760Q800 -743 788.5 -731.5Q777 -720 760 -720V-200Q760 -167 736.5 -143.5Q713 -120 680 -120ZM680 -720H280V-200Q280 -200 280 -200Q280 -200 280 -200H680Q680 -200 680 -200Q680 -200 680 -200ZM440 -320V-600Q440 -617 428.5 -628.5Q417 -640 400 -640Q383 -640 371.5 -628.5Q360 -617 360 -600V-320Q360 -303 371.5 -291.5Q383 -280 400 -280Q417 -280 428.5 -291.5Q440 -303 440 -320ZM600 -320V-600Q600 -617 588.5 -628.5Q577 -640 560 -640Q543 -640 531.5 -628.5Q520 -617 520 -600V-320Q520 -303 531.5 -291.5Q543 -280 560 -280Q577 -280 588.5 -291.5Q600 -303 600 -320ZM280 -720V-200Q280 -200 280 -200Q280 -200 280 -200Q280 -200 280 -200Q280 -200 280 -200Z"), + ("delete_fill", "M280 -120Q247 -120 223.5 -143.5Q200 -167 200 -200V-720Q183 -720 171.5 -731.5Q160 -743 160 -760Q160 -777 171.5 -788.5Q183 -800 200 -800H360Q360 -817 371.5 -828.5Q383 -840 400 -840H560Q577 -840 588.5 -828.5Q600 -817 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760Q800 -743 788.5 -731.5Q777 -720 760 -720V-200Q760 -167 736.5 -143.5Q713 -120 680 -120ZM680 -720H280V-200Q280 -200 280 -200Q280 -200 280 -200H680Q680 -200 680 -200Q680 -200 680 -200ZM440 -320V-600Q440 -617 428.5 -628.5Q417 -640 400 -640Q383 -640 371.5 -628.5Q360 -617 360 -600V-320Q360 -303 371.5 -291.5Q383 -280 400 -280Q417 -280 428.5 -291.5Q440 -303 440 -320ZM600 -320V-600Q600 -617 588.5 -628.5Q577 -640 560 -640Q543 -640 531.5 -628.5Q520 -617 520 -600V-320Q520 -303 531.5 -291.5Q543 -280 560 -280Q577 -280 588.5 -291.5Q600 -303 600 -320ZM280 -720H680V-200Q680 -200 680 -200Q680 -200 680 -200H280Q280 -200 280 -200Q280 -200 280 -200Z"), + ("description", "M360 -240H600Q617 -240 628.5 -251.5Q640 -263 640 -280Q640 -297 628.5 -308.5Q617 -320 600 -320H360Q343 -320 331.5 -308.5Q320 -297 320 -280Q320 -263 331.5 -251.5Q343 -240 360 -240ZM360 -400H600Q617 -400 628.5 -411.5Q640 -423 640 -440Q640 -457 628.5 -468.5Q617 -480 600 -480H360Q343 -480 331.5 -468.5Q320 -457 320 -440Q320 -423 331.5 -411.5Q343 -400 360 -400ZM240 -80Q207 -80 183.5 -103.5Q160 -127 160 -160V-800Q160 -833 183.5 -856.5Q207 -880 240 -880H527Q543 -880 557.5 -874Q572 -868 583 -857L777 -663Q788 -652 794 -637.5Q800 -623 800 -607V-160Q800 -127 776.5 -103.5Q753 -80 720 -80ZM520 -640V-800H240Q240 -800 240 -800Q240 -800 240 -800V-160Q240 -160 240 -160Q240 -160 240 -160H720Q720 -160 720 -160Q720 -160 720 -160V-600H560Q543 -600 531.5 -611.5Q520 -623 520 -640ZM240 -800V-640Q240 -623 240 -611.5Q240 -600 240 -600V-800V-640Q240 -623 240 -611.5Q240 -600 240 -600V-160Q240 -160 240 -160Q240 -160 240 -160Q240 -160 240 -160Q240 -160 240 -160V-800Q240 -800 240 -800Q240 -800 240 -800Z"), + ("description_fill", "M360 -240H600Q617 -240 628.5 -251.5Q640 -263 640 -280Q640 -297 628.5 -308.5Q617 -320 600 -320H360Q343 -320 331.5 -308.5Q320 -297 320 -280Q320 -263 331.5 -251.5Q343 -240 360 -240ZM360 -400H600Q617 -400 628.5 -411.5Q640 -423 640 -440Q640 -457 628.5 -468.5Q617 -480 600 -480H360Q343 -480 331.5 -468.5Q320 -457 320 -440Q320 -423 331.5 -411.5Q343 -400 360 -400ZM240 -80Q207 -80 183.5 -103.5Q160 -127 160 -160V-800Q160 -833 183.5 -856.5Q207 -880 240 -880H527Q543 -880 557.5 -874Q572 -868 583 -857L777 -663Q788 -652 794 -637.5Q800 -623 800 -607V-160Q800 -127 776.5 -103.5Q753 -80 720 -80ZM520 -640V-800H240Q240 -800 240 -800Q240 -800 240 -800V-160Q240 -160 240 -160Q240 -160 240 -160H720Q720 -160 720 -160Q720 -160 720 -160V-600H560Q543 -600 531.5 -611.5Q520 -623 520 -640ZM240 -800H520V-640Q520 -623 531.5 -611.5Q543 -600 560 -600H720L520 -800V-640Q520 -623 531.5 -611.5Q543 -600 560 -600H720V-160Q720 -160 720 -160Q720 -160 720 -160H240Q240 -160 240 -160Q240 -160 240 -160V-800Q240 -800 240 -800Q240 -800 240 -800Z"), + ("difference", "M500 -600V-560Q500 -543 511.5 -531.5Q523 -520 540 -520Q557 -520 568.5 -531.5Q580 -543 580 -560V-600H620Q637 -600 648.5 -611.5Q660 -623 660 -640Q660 -657 648.5 -668.5Q637 -680 620 -680H580V-720Q580 -737 568.5 -748.5Q557 -760 540 -760Q523 -760 511.5 -748.5Q500 -737 500 -720V-680H460Q443 -680 431.5 -668.5Q420 -657 420 -640Q420 -623 431.5 -611.5Q443 -600 460 -600ZM460 -360H620Q637 -360 648.5 -371.5Q660 -383 660 -400Q660 -417 648.5 -428.5Q637 -440 620 -440H460Q443 -440 431.5 -428.5Q420 -417 420 -400Q420 -383 431.5 -371.5Q443 -360 460 -360ZM320 -200Q287 -200 263.5 -223.5Q240 -247 240 -280V-840Q240 -873 263.5 -896.5Q287 -920 320 -920H567Q583 -920 597.5 -914Q612 -908 623 -897L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM320 -280H760Q760 -280 760 -280Q760 -280 760 -280V-640L560 -840H320Q320 -840 320 -840Q320 -840 320 -840V-280Q320 -280 320 -280Q320 -280 320 -280ZM160 -40Q127 -40 103.5 -63.5Q80 -87 80 -120V-640Q80 -657 91.5 -668.5Q103 -680 120 -680Q137 -680 148.5 -668.5Q160 -657 160 -640V-120Q160 -120 160 -120Q160 -120 160 -120H560Q577 -120 588.5 -108.5Q600 -97 600 -80Q600 -63 588.5 -51.5Q577 -40 560 -40ZM320 -280Q320 -280 320 -280Q320 -280 320 -280V-840Q320 -840 320 -840Q320 -840 320 -840V-640V-280Q320 -280 320 -280Q320 -280 320 -280Z"), + ("difference_fill", "M500 -600V-560Q500 -543 511.5 -531.5Q523 -520 540 -520Q557 -520 568.5 -531.5Q580 -543 580 -560V-600H620Q637 -600 648.5 -611.5Q660 -623 660 -640Q660 -657 648.5 -668.5Q637 -680 620 -680H580V-720Q580 -737 568.5 -748.5Q557 -760 540 -760Q523 -760 511.5 -748.5Q500 -737 500 -720V-680H460Q443 -680 431.5 -668.5Q420 -657 420 -640Q420 -623 431.5 -611.5Q443 -600 460 -600ZM460 -360H620Q637 -360 648.5 -371.5Q660 -383 660 -400Q660 -417 648.5 -428.5Q637 -440 620 -440H460Q443 -440 431.5 -428.5Q420 -417 420 -400Q420 -383 431.5 -371.5Q443 -360 460 -360ZM320 -200Q287 -200 263.5 -223.5Q240 -247 240 -280V-840Q240 -873 263.5 -896.5Q287 -920 320 -920H567Q583 -920 597.5 -914Q612 -908 623 -897L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM320 -280H760Q760 -280 760 -280Q760 -280 760 -280V-640L560 -840H320Q320 -840 320 -840Q320 -840 320 -840V-280Q320 -280 320 -280Q320 -280 320 -280ZM160 -40Q127 -40 103.5 -63.5Q80 -87 80 -120V-640Q80 -657 91.5 -668.5Q103 -680 120 -680Q137 -680 148.5 -668.5Q160 -657 160 -640V-120Q160 -120 160 -120Q160 -120 160 -120H560Q577 -120 588.5 -108.5Q600 -97 600 -80Q600 -63 588.5 -51.5Q577 -40 560 -40ZM320 -280Q320 -280 320 -280Q320 -280 320 -280V-840Q320 -840 320 -840Q320 -840 320 -840H560L760 -640V-280Q760 -280 760 -280Q760 -280 760 -280Z"), + ("do_not_disturb_on", "M320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"), + ("do_not_disturb_on_fill", "M320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"), + ("download", "M452 -348 308 -492Q296 -504 296.5 -520Q297 -536 308 -548Q320 -560 336.5 -560.5Q353 -561 365 -549L440 -474V-760Q440 -777 451.5 -788.5Q463 -800 480 -800Q497 -800 508.5 -788.5Q520 -777 520 -760V-474L595 -549Q607 -561 623.5 -560.5Q640 -560 652 -548Q663 -536 663.5 -520Q664 -504 652 -492L508 -348Q502 -342 495 -339.5Q488 -337 480 -337Q472 -337 465 -339.5Q458 -342 452 -348ZM240 -160Q207 -160 183.5 -183.5Q160 -207 160 -240V-320Q160 -337 171.5 -348.5Q183 -360 200 -360Q217 -360 228.5 -348.5Q240 -337 240 -320V-240Q240 -240 240 -240Q240 -240 240 -240H720Q720 -240 720 -240Q720 -240 720 -240V-320Q720 -337 731.5 -348.5Q743 -360 760 -360Q777 -360 788.5 -348.5Q800 -337 800 -320V-240Q800 -207 776.5 -183.5Q753 -160 720 -160Z"), + ("edit", "M200 -200H257L648 -591L591 -648L200 -257ZM160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160V-257Q120 -273 126 -287.5Q132 -302 143 -313L648 -817Q660 -828 674.5 -834Q689 -840 705 -840Q721 -840 736 -834Q751 -828 762 -816L817 -760Q829 -749 834.5 -734Q840 -719 840 -704Q840 -688 834.5 -673.5Q829 -659 817 -647L313 -143Q302 -132 287.5 -126Q273 -120 257 -120ZM760 -704 704 -760ZM619 -619 591 -648 648 -591Z"), + ("edit_fill", "M200 -200H257L648 -591L591 -648L200 -257ZM160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160V-257Q120 -273 126 -287.5Q132 -302 143 -313L648 -817Q660 -828 674.5 -834Q689 -840 705 -840Q721 -840 736 -834Q751 -828 762 -816L817 -760Q829 -749 834.5 -734Q840 -719 840 -704Q840 -688 834.5 -673.5Q829 -659 817 -647L313 -143Q302 -132 287.5 -126Q273 -120 257 -120ZM704 -648 760 -704 704 -760 648 -704ZM200 -200V-257L591 -648L648 -591L257 -200Z"), + ("error", "M480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320Q520 -337 508.5 -348.5Q497 -360 480 -360Q463 -360 451.5 -348.5Q440 -337 440 -320Q440 -303 451.5 -291.5Q463 -280 480 -280ZM520 -480V-640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640V-480Q440 -463 451.5 -451.5Q463 -440 480 -440Q497 -440 508.5 -451.5Q520 -463 520 -480ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"), + ("error_fill", "M480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320Q520 -337 508.5 -348.5Q497 -360 480 -360Q463 -360 451.5 -348.5Q440 -337 440 -320Q440 -303 451.5 -291.5Q463 -280 480 -280ZM520 -480V-640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640V-480Q440 -463 451.5 -451.5Q463 -440 480 -440Q497 -440 508.5 -451.5Q520 -463 520 -480ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"), + ("expand_less", "M480 -529 324 -373Q313 -362 296 -362Q279 -362 268 -373Q257 -384 257 -401Q257 -418 268 -429L452 -613Q458 -619 465 -621.5Q472 -624 480 -624Q488 -624 495 -621.5Q502 -619 508 -613L692 -429Q703 -418 703 -401Q703 -384 692 -373Q681 -362 664 -362Q647 -362 636 -373Z"), + ("expand_more", "M452 -373 268 -557Q257 -568 257 -585Q257 -602 268 -613Q279 -624 296 -624Q313 -624 324 -613L480 -457L636 -613Q647 -624 664 -624Q681 -624 692 -613Q703 -602 703 -585Q703 -568 692 -557L508 -373Q502 -367 495 -364.5Q488 -362 480 -362Q472 -362 465 -364.5Q458 -367 452 -373Z"), + ("find_replace", "M440 -720Q377 -720 326.5 -685.5Q276 -651 254 -595Q248 -580 234.5 -572.5Q221 -565 205 -568Q189 -571 179.5 -583.5Q170 -596 175 -610Q202 -694 274 -747Q346 -800 440 -800Q499 -800 550.5 -777.5Q602 -755 640 -716V-760Q640 -777 651.5 -788.5Q663 -800 680 -800Q697 -800 708.5 -788.5Q720 -777 720 -760V-600Q720 -583 708.5 -571.5Q697 -560 680 -560H520Q503 -560 491.5 -571.5Q480 -583 480 -600Q480 -617 491.5 -628.5Q503 -640 520 -640H600Q571 -676 530.5 -698Q490 -720 440 -720ZM440 -240Q381 -240 329.5 -262.5Q278 -285 240 -324V-280Q240 -263 228.5 -251.5Q217 -240 200 -240Q183 -240 171.5 -251.5Q160 -263 160 -280V-440Q160 -457 171.5 -468.5Q183 -480 200 -480H360Q377 -480 388.5 -468.5Q400 -457 400 -440Q400 -423 388.5 -411.5Q377 -400 360 -400H280Q309 -364 349.5 -342Q390 -320 440 -320Q502 -320 551.5 -353Q601 -386 624 -440Q631 -456 644.5 -465.5Q658 -475 675 -472Q692 -468 700 -454Q708 -440 703 -424Q696 -404 686.5 -386.5Q677 -369 664 -352L812 -204Q823 -193 823 -176Q823 -159 812 -148Q801 -137 784 -137Q767 -137 756 -148L608 -296Q572 -269 529.5 -254.5Q487 -240 440 -240Z"), + ("folder", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H447L367 -720Q367 -720 367 -720Q367 -720 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720V-640Q160 -640 160 -640Q160 -640 160 -640V-240Q160 -240 160 -240Q160 -240 160 -240Z"), + ("folder_fill", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H447L367 -720Q367 -720 367 -720Q367 -720 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-720Q160 -720 160 -720Q160 -720 160 -720H367Q367 -720 367 -720Q367 -720 367 -720L447 -640H800Q800 -640 800 -640Q800 -640 800 -640V-240Q800 -240 800 -240Q800 -240 800 -240Z"), + ("folder_open", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H840Q857 -720 868.5 -708.5Q880 -697 880 -680Q880 -663 868.5 -651.5Q857 -640 840 -640H447L367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240L239 -503Q247 -529 268.5 -544.5Q290 -560 316 -560H832Q873 -560 896.5 -527.5Q920 -495 909 -457L837 -217Q829 -191 807.5 -175.5Q786 -160 760 -160ZM244 -240H760Q760 -240 760 -240Q760 -240 760 -240L832 -480Q832 -480 832 -480Q832 -480 832 -480H316Q316 -480 316 -480Q316 -480 316 -480ZM160 -502V-720Q160 -720 160 -720Q160 -720 160 -720V-640Q160 -640 160 -601Q160 -562 160 -502ZM244 -240 316 -480Q316 -480 316 -480Q316 -480 316 -480Q316 -480 316 -480Q316 -480 316 -480L244 -240Q244 -240 244 -240Q244 -240 244 -240Z"), + ("folder_open_fill", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H840Q857 -720 868.5 -708.5Q880 -697 880 -680Q880 -663 868.5 -651.5Q857 -640 840 -640H447L367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240L239 -503Q247 -529 268.5 -544.5Q290 -560 316 -560H832Q873 -560 896.5 -527.5Q920 -495 909 -457L837 -217Q829 -191 807.5 -175.5Q786 -160 760 -160ZM244 -240H760Q760 -240 760 -240Q760 -240 760 -240L832 -480Q832 -480 832 -480Q832 -480 832 -480H316Q316 -480 316 -480Q316 -480 316 -480ZM160 -502V-720Q160 -720 160 -720Q160 -720 160 -720H367L447 -640H314Q252 -640 206 -601Q160 -562 160 -502ZM244 -240 316 -480Q316 -480 316 -480Q316 -480 316 -480H832Q832 -480 832 -480Q832 -480 832 -480L760 -240Q760 -240 760 -240Q760 -240 760 -240Z"), + ("folder_zip", "M640 -480V-560H720V-480ZM640 -400H560V-480H640ZM640 -320V-400H720V-320ZM447 -640 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240H560V-320H640V-240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H640V-560H560V-640ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-640Q160 -640 160 -640Q160 -640 160 -640V-720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"), + ("folder_zip_fill", "M640 -480V-560H720V-480ZM640 -400H560V-480H640ZM640 -320V-400H720V-320ZM447 -640 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240H560V-320H640V-240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H640V-560H560V-640ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H447L367 -720Q367 -720 367 -720Q367 -720 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"), + ("format_align_left", "M160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160Q120 -177 131.5 -188.5Q143 -200 160 -200H800Q817 -200 828.5 -188.5Q840 -177 840 -160Q840 -143 828.5 -131.5Q817 -120 800 -120ZM160 -280Q143 -280 131.5 -291.5Q120 -303 120 -320Q120 -337 131.5 -348.5Q143 -360 160 -360H560Q577 -360 588.5 -348.5Q600 -337 600 -320Q600 -303 588.5 -291.5Q577 -280 560 -280ZM160 -440Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM160 -600Q143 -600 131.5 -611.5Q120 -623 120 -640Q120 -657 131.5 -668.5Q143 -680 160 -680H560Q577 -680 588.5 -668.5Q600 -657 600 -640Q600 -623 588.5 -611.5Q577 -600 560 -600ZM160 -760Q143 -760 131.5 -771.5Q120 -783 120 -800Q120 -817 131.5 -828.5Q143 -840 160 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800Q840 -783 828.5 -771.5Q817 -760 800 -760Z"), + ("format_indent_increase", "M160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160Q120 -177 131.5 -188.5Q143 -200 160 -200H800Q817 -200 828.5 -188.5Q840 -177 840 -160Q840 -143 828.5 -131.5Q817 -120 800 -120ZM480 -280Q463 -280 451.5 -291.5Q440 -303 440 -320Q440 -337 451.5 -348.5Q463 -360 480 -360H800Q817 -360 828.5 -348.5Q840 -337 840 -320Q840 -303 828.5 -291.5Q817 -280 800 -280ZM480 -440Q463 -440 451.5 -451.5Q440 -463 440 -480Q440 -497 451.5 -508.5Q463 -520 480 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM480 -600Q463 -600 451.5 -611.5Q440 -623 440 -640Q440 -657 451.5 -668.5Q463 -680 480 -680H800Q817 -680 828.5 -668.5Q840 -657 840 -640Q840 -623 828.5 -611.5Q817 -600 800 -600ZM160 -760Q143 -760 131.5 -771.5Q120 -783 120 -800Q120 -817 131.5 -828.5Q143 -840 160 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800Q840 -783 828.5 -771.5Q817 -760 800 -760ZM154 -354Q144 -344 132 -349Q120 -354 120 -368V-592Q120 -606 132 -611Q144 -616 154 -606L266 -494Q272 -488 272 -480Q272 -472 266 -466Z"), + ("format_list_bulleted", "M400 -200Q383 -200 371.5 -211.5Q360 -223 360 -240Q360 -257 371.5 -268.5Q383 -280 400 -280H800Q817 -280 828.5 -268.5Q840 -257 840 -240Q840 -223 828.5 -211.5Q817 -200 800 -200ZM400 -440Q383 -440 371.5 -451.5Q360 -463 360 -480Q360 -497 371.5 -508.5Q383 -520 400 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM400 -680Q383 -680 371.5 -691.5Q360 -703 360 -720Q360 -737 371.5 -748.5Q383 -760 400 -760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680ZM200 -160Q167 -160 143.5 -183.5Q120 -207 120 -240Q120 -273 143.5 -296.5Q167 -320 200 -320Q233 -320 256.5 -296.5Q280 -273 280 -240Q280 -207 256.5 -183.5Q233 -160 200 -160ZM200 -400Q167 -400 143.5 -423.5Q120 -447 120 -480Q120 -513 143.5 -536.5Q167 -560 200 -560Q233 -560 256.5 -536.5Q280 -513 280 -480Q280 -447 256.5 -423.5Q233 -400 200 -400ZM200 -640Q167 -640 143.5 -663.5Q120 -687 120 -720Q120 -753 143.5 -776.5Q167 -800 200 -800Q233 -800 256.5 -776.5Q280 -753 280 -720Q280 -687 256.5 -663.5Q233 -640 200 -640Z"), + ("fullscreen", "M200 -200H280Q297 -200 308.5 -188.5Q320 -177 320 -160Q320 -143 308.5 -131.5Q297 -120 280 -120H160Q143 -120 131.5 -131.5Q120 -143 120 -160V-280Q120 -297 131.5 -308.5Q143 -320 160 -320Q177 -320 188.5 -308.5Q200 -297 200 -280ZM760 -200V-280Q760 -297 771.5 -308.5Q783 -320 800 -320Q817 -320 828.5 -308.5Q840 -297 840 -280V-160Q840 -143 828.5 -131.5Q817 -120 800 -120H680Q663 -120 651.5 -131.5Q640 -143 640 -160Q640 -177 651.5 -188.5Q663 -200 680 -200ZM200 -760V-680Q200 -663 188.5 -651.5Q177 -640 160 -640Q143 -640 131.5 -651.5Q120 -663 120 -680V-800Q120 -817 131.5 -828.5Q143 -840 160 -840H280Q297 -840 308.5 -828.5Q320 -817 320 -800Q320 -783 308.5 -771.5Q297 -760 280 -760ZM760 -760H680Q663 -760 651.5 -771.5Q640 -783 640 -800Q640 -817 651.5 -828.5Q663 -840 680 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800V-680Q840 -663 828.5 -651.5Q817 -640 800 -640Q783 -640 771.5 -651.5Q760 -663 760 -680Z"), + ("history", "M480 -120Q354 -120 257 -196.5Q160 -273 131 -392Q127 -407 137 -419.5Q147 -432 164 -434Q180 -436 193 -428Q206 -420 211 -404Q235 -314 310 -257Q385 -200 480 -200Q597 -200 678.5 -281.5Q760 -363 760 -480Q760 -597 678.5 -678.5Q597 -760 480 -760Q411 -760 351 -728Q291 -696 250 -640H320Q337 -640 348.5 -628.5Q360 -617 360 -600Q360 -583 348.5 -571.5Q337 -560 320 -560H160Q143 -560 131.5 -571.5Q120 -583 120 -600V-760Q120 -777 131.5 -788.5Q143 -800 160 -800Q177 -800 188.5 -788.5Q200 -777 200 -760V-706Q251 -770 324.5 -805Q398 -840 480 -840Q555 -840 620.5 -811.5Q686 -783 734.5 -734.5Q783 -686 811.5 -620.5Q840 -555 840 -480Q840 -405 811.5 -339.5Q783 -274 734.5 -225.5Q686 -177 620.5 -148.5Q555 -120 480 -120ZM520 -496 620 -396Q631 -385 631 -368Q631 -351 620 -340Q609 -329 592 -329Q575 -329 564 -340L452 -452Q446 -458 443 -465.5Q440 -473 440 -481V-640Q440 -657 451.5 -668.5Q463 -680 480 -680Q497 -680 508.5 -668.5Q520 -657 520 -640Z"), + ("home", "M240 -200H360V-400Q360 -417 371.5 -428.5Q383 -440 400 -440H560Q577 -440 588.5 -428.5Q600 -417 600 -400V-200H720V-560Q720 -560 720 -560Q720 -560 720 -560L480 -740Q480 -740 480 -740Q480 -740 480 -740L240 -560Q240 -560 240 -560Q240 -560 240 -560ZM160 -200V-560Q160 -579 168.5 -596Q177 -613 192 -624L432 -804Q453 -820 480 -820Q507 -820 528 -804L768 -624Q783 -613 791.5 -596Q800 -579 800 -560V-200Q800 -167 776.5 -143.5Q753 -120 720 -120H560Q543 -120 531.5 -131.5Q520 -143 520 -160V-360Q520 -360 520 -360Q520 -360 520 -360H440Q440 -360 440 -360Q440 -360 440 -360V-160Q440 -143 428.5 -131.5Q417 -120 400 -120H240Q207 -120 183.5 -143.5Q160 -167 160 -200ZM480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Z"), + ("home_fill", "M240 -200H360V-400Q360 -417 371.5 -428.5Q383 -440 400 -440H560Q577 -440 588.5 -428.5Q600 -417 600 -400V-200H720V-560Q720 -560 720 -560Q720 -560 720 -560L480 -740Q480 -740 480 -740Q480 -740 480 -740L240 -560Q240 -560 240 -560Q240 -560 240 -560ZM160 -200V-560Q160 -579 168.5 -596Q177 -613 192 -624L432 -804Q453 -820 480 -820Q507 -820 528 -804L768 -624Q783 -613 791.5 -596Q800 -579 800 -560V-200Q800 -167 776.5 -143.5Q753 -120 720 -120H600Q583 -120 571.5 -131.5Q560 -143 560 -160V-360Q560 -377 548.5 -388.5Q537 -400 520 -400H440Q423 -400 411.5 -388.5Q400 -377 400 -360V-160Q400 -143 388.5 -131.5Q377 -120 360 -120H240Q207 -120 183.5 -143.5Q160 -167 160 -200ZM240 -200V-560L480 -740Q480 -740 480 -740Q480 -740 480 -740L720 -560V-200H600V-400Q600 -417 588.5 -428.5Q577 -440 560 -440H400Q383 -440 371.5 -428.5Q360 -417 360 -400V-200Z"), + ("info", "M520 -320V-480Q520 -497 508.5 -508.5Q497 -520 480 -520Q463 -520 451.5 -508.5Q440 -497 440 -480V-320Q440 -303 451.5 -291.5Q463 -280 480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320ZM520 -640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640Q440 -623 451.5 -611.5Q463 -600 480 -600Q497 -600 508.5 -611.5Q520 -623 520 -640ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"), + ("info_fill", "M520 -320V-480Q520 -497 508.5 -508.5Q497 -520 480 -520Q463 -520 451.5 -508.5Q440 -497 440 -480V-320Q440 -303 451.5 -291.5Q463 -280 480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320ZM520 -640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640Q440 -623 451.5 -611.5Q463 -600 480 -600Q497 -600 508.5 -611.5Q520 -623 520 -640ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"), + ("keyboard_arrow_down", "M452 -372 268 -556Q257 -567 257 -584Q257 -601 268 -612Q279 -623 296 -623Q313 -623 324 -612L480 -456L636 -612Q647 -623 664 -623Q681 -623 692 -612Q703 -601 703 -584Q703 -567 692 -556L508 -372Q502 -366 495 -363.5Q488 -361 480 -361Q472 -361 465 -363.5Q458 -366 452 -372Z"), + ("keyboard_arrow_right", "M504 -480 348 -636Q337 -647 337 -664Q337 -681 348 -692Q359 -703 376 -703Q393 -703 404 -692L588 -508Q594 -502 596.5 -495Q599 -488 599 -480Q599 -472 596.5 -465Q594 -458 588 -452L404 -268Q393 -257 376 -257Q359 -257 348 -268Q337 -279 337 -296Q337 -313 348 -324Z"), + ("keyboard_arrow_up", "M480 -528 324 -372Q313 -361 296 -361Q279 -361 268 -372Q257 -383 257 -400Q257 -417 268 -428L452 -612Q464 -624 480 -624Q496 -624 508 -612L692 -428Q703 -417 703 -400Q703 -383 692 -372Q681 -361 664 -361Q647 -361 636 -372Z"), + ("keyboard_command_key", "M260 -120Q202 -120 161 -161Q120 -202 120 -260Q120 -318 161 -359Q202 -400 260 -400H320V-560H260Q202 -560 161 -601Q120 -642 120 -700Q120 -758 161 -799Q202 -840 260 -840Q318 -840 359 -799Q400 -758 400 -700V-640H560V-700Q560 -758 601 -799Q642 -840 700 -840Q758 -840 799 -799Q840 -758 840 -700Q840 -642 799 -601Q758 -560 700 -560H640V-400H700Q758 -400 799 -359Q840 -318 840 -260Q840 -202 799 -161Q758 -120 700 -120Q642 -120 601 -161Q560 -202 560 -260V-320H400V-260Q400 -202 359 -161Q318 -120 260 -120ZM260 -200Q285 -200 302.5 -217.5Q320 -235 320 -260V-320H260Q235 -320 217.5 -302.5Q200 -285 200 -260Q200 -235 217.5 -217.5Q235 -200 260 -200ZM700 -200Q725 -200 742.5 -217.5Q760 -235 760 -260Q760 -285 742.5 -302.5Q725 -320 700 -320H640V-260Q640 -235 657.5 -217.5Q675 -200 700 -200ZM400 -400H560V-560H400ZM260 -640H320V-700Q320 -725 302.5 -742.5Q285 -760 260 -760Q235 -760 217.5 -742.5Q200 -725 200 -700Q200 -675 217.5 -657.5Q235 -640 260 -640ZM640 -640H700Q725 -640 742.5 -657.5Q760 -675 760 -700Q760 -725 742.5 -742.5Q725 -760 700 -760Q675 -760 657.5 -742.5Q640 -725 640 -700Z"), + ("language", "M480.5 -80Q398 -80 325 -111.5Q252 -143 197.5 -197.5Q143 -252 111.5 -325Q80 -398 80 -480.5Q80 -563 111.5 -635.5Q143 -708 197.5 -762.5Q252 -817 325 -848.5Q398 -880 480.5 -880Q563 -880 635.5 -848.5Q708 -817 762.5 -762.5Q817 -708 848.5 -635.5Q880 -563 880 -480.5Q880 -398 848.5 -325Q817 -252 762.5 -197.5Q708 -143 635.5 -111.5Q563 -80 480.5 -80ZM480 -162Q506 -198 525 -237Q544 -276 556 -320H404Q416 -276 435 -237Q454 -198 480 -162ZM376 -178Q358 -211 344.5 -246.5Q331 -282 322 -320H204Q233 -270 276.5 -233Q320 -196 376 -178ZM584 -178Q640 -196 683.5 -233Q727 -270 756 -320H638Q629 -282 615.5 -246.5Q602 -211 584 -178ZM170 -400H306Q303 -420 301.5 -439.5Q300 -459 300 -480Q300 -501 301.5 -520.5Q303 -540 306 -560H170Q165 -540 162.5 -520.5Q160 -501 160 -480Q160 -459 162.5 -439.5Q165 -420 170 -400ZM386 -400H574Q577 -420 578.5 -439.5Q580 -459 580 -480Q580 -501 578.5 -520.5Q577 -540 574 -560H386Q383 -540 381.5 -520.5Q380 -501 380 -480Q380 -459 381.5 -439.5Q383 -420 386 -400ZM654 -400H790Q795 -420 797.5 -439.5Q800 -459 800 -480Q800 -501 797.5 -520.5Q795 -540 790 -560H654Q657 -540 658.5 -520.5Q660 -501 660 -480Q660 -459 658.5 -439.5Q657 -420 654 -400ZM638 -640H756Q727 -690 683.5 -727Q640 -764 584 -782Q602 -749 615.5 -713.5Q629 -678 638 -640ZM404 -640H556Q544 -684 525 -723Q506 -762 480 -798Q454 -762 435 -723Q416 -684 404 -640ZM204 -640H322Q331 -678 344.5 -713.5Q358 -749 376 -782Q320 -764 276.5 -727Q233 -690 204 -640Z"), + ("light_mode", "M480 -360Q530 -360 565 -395Q600 -430 600 -480Q600 -530 565 -565Q530 -600 480 -600Q430 -600 395 -565Q360 -530 360 -480Q360 -430 395 -395Q430 -360 480 -360ZM480 -280Q397 -280 338.5 -338.5Q280 -397 280 -480Q280 -563 338.5 -621.5Q397 -680 480 -680Q563 -680 621.5 -621.5Q680 -563 680 -480Q680 -397 621.5 -338.5Q563 -280 480 -280ZM80 -440Q63 -440 51.5 -451.5Q40 -463 40 -480Q40 -497 51.5 -508.5Q63 -520 80 -520H160Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM800 -440Q783 -440 771.5 -451.5Q760 -463 760 -480Q760 -497 771.5 -508.5Q783 -520 800 -520H880Q897 -520 908.5 -508.5Q920 -497 920 -480Q920 -463 908.5 -451.5Q897 -440 880 -440ZM440 -800V-880Q440 -897 451.5 -908.5Q463 -920 480 -920Q497 -920 508.5 -908.5Q520 -897 520 -880V-800Q520 -783 508.5 -771.5Q497 -760 480 -760Q463 -760 451.5 -771.5Q440 -783 440 -800ZM440 -80V-160Q440 -177 451.5 -188.5Q463 -200 480 -200Q497 -200 508.5 -188.5Q520 -177 520 -160V-80Q520 -63 508.5 -51.5Q497 -40 480 -40Q463 -40 451.5 -51.5Q440 -63 440 -80ZM226 -678 183 -720Q171 -731 171.5 -748Q172 -765 183 -777Q195 -789 212 -789Q229 -789 240 -777L282 -734Q293 -722 293 -706Q293 -690 282 -678Q271 -666 254.5 -666.5Q238 -667 226 -678ZM720 -183 678 -226Q667 -238 667 -254.5Q667 -271 678 -282Q689 -294 705.5 -293.5Q722 -293 734 -282L777 -240Q789 -229 788.5 -212Q788 -195 777 -183Q765 -171 748 -171Q731 -171 720 -183ZM678 -678Q666 -689 666.5 -705.5Q667 -722 678 -734L720 -777Q731 -789 748 -788.5Q765 -788 777 -777Q789 -765 789 -748Q789 -731 777 -720L734 -678Q722 -667 706 -667Q690 -667 678 -678ZM183 -183Q171 -195 171 -212Q171 -229 183 -240L226 -282Q238 -293 254.5 -293Q271 -293 282 -282Q294 -271 293.5 -254.5Q293 -238 282 -226L240 -183Q229 -171 212 -171.5Q195 -172 183 -183ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"), + ("light_mode_fill", "M480 -360Q530 -360 565 -395Q600 -430 600 -480Q600 -530 565 -565Q530 -600 480 -600Q430 -600 395 -565Q360 -530 360 -480Q360 -430 395 -395Q430 -360 480 -360ZM480 -280Q397 -280 338.5 -338.5Q280 -397 280 -480Q280 -563 338.5 -621.5Q397 -680 480 -680Q563 -680 621.5 -621.5Q680 -563 680 -480Q680 -397 621.5 -338.5Q563 -280 480 -280ZM80 -440Q63 -440 51.5 -451.5Q40 -463 40 -480Q40 -497 51.5 -508.5Q63 -520 80 -520H160Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM800 -440Q783 -440 771.5 -451.5Q760 -463 760 -480Q760 -497 771.5 -508.5Q783 -520 800 -520H880Q897 -520 908.5 -508.5Q920 -497 920 -480Q920 -463 908.5 -451.5Q897 -440 880 -440ZM440 -800V-880Q440 -897 451.5 -908.5Q463 -920 480 -920Q497 -920 508.5 -908.5Q520 -897 520 -880V-800Q520 -783 508.5 -771.5Q497 -760 480 -760Q463 -760 451.5 -771.5Q440 -783 440 -800ZM440 -80V-160Q440 -177 451.5 -188.5Q463 -200 480 -200Q497 -200 508.5 -188.5Q520 -177 520 -160V-80Q520 -63 508.5 -51.5Q497 -40 480 -40Q463 -40 451.5 -51.5Q440 -63 440 -80ZM226 -678 183 -720Q171 -731 171.5 -748Q172 -765 183 -777Q195 -789 212 -789Q229 -789 240 -777L282 -734Q293 -722 293 -706Q293 -690 282 -678Q271 -666 254.5 -666.5Q238 -667 226 -678ZM720 -183 678 -226Q667 -238 667 -254.5Q667 -271 678 -282Q689 -294 705.5 -293.5Q722 -293 734 -282L777 -240Q789 -229 788.5 -212Q788 -195 777 -183Q765 -171 748 -171Q731 -171 720 -183ZM678 -678Q666 -689 666.5 -705.5Q667 -722 678 -734L720 -777Q731 -789 748 -788.5Q765 -788 777 -777Q789 -765 789 -748Q789 -731 777 -720L734 -678Q722 -667 706 -667Q690 -667 678 -678ZM183 -183Q171 -195 171 -212Q171 -229 183 -240L226 -282Q238 -293 254.5 -293Q271 -293 282 -282Q294 -271 293.5 -254.5Q293 -238 282 -226L240 -183Q229 -171 212 -171.5Q195 -172 183 -183ZM480 -360Q430 -360 395 -395Q360 -430 360 -480Q360 -530 395 -565Q430 -600 480 -600Q530 -600 565 -565Q600 -530 600 -480Q600 -430 565 -395Q530 -360 480 -360Z"), + ("line_end", "M780 -380Q749 -380 724 -397Q699 -414 688 -440H120Q103 -440 91.5 -451.5Q80 -463 80 -480Q80 -497 91.5 -508.5Q103 -520 120 -520H688Q699 -546 724 -563Q749 -580 780 -580Q822 -580 851 -551Q880 -522 880 -480Q880 -438 851 -409Q822 -380 780 -380Z"), + ("list", "M320 -600Q303 -600 291.5 -611.5Q280 -623 280 -640Q280 -657 291.5 -668.5Q303 -680 320 -680H800Q817 -680 828.5 -668.5Q840 -657 840 -640Q840 -623 828.5 -611.5Q817 -600 800 -600ZM320 -440Q303 -440 291.5 -451.5Q280 -463 280 -480Q280 -497 291.5 -508.5Q303 -520 320 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM320 -280Q303 -280 291.5 -291.5Q280 -303 280 -320Q280 -337 291.5 -348.5Q303 -360 320 -360H800Q817 -360 828.5 -348.5Q840 -337 840 -320Q840 -303 828.5 -291.5Q817 -280 800 -280ZM160 -600Q143 -600 131.5 -611.5Q120 -623 120 -640Q120 -657 131.5 -668.5Q143 -680 160 -680Q177 -680 188.5 -668.5Q200 -657 200 -640Q200 -623 188.5 -611.5Q177 -600 160 -600ZM160 -440Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM160 -280Q143 -280 131.5 -291.5Q120 -303 120 -320Q120 -337 131.5 -348.5Q143 -360 160 -360Q177 -360 188.5 -348.5Q200 -337 200 -320Q200 -303 188.5 -291.5Q177 -280 160 -280Z"), + ("looks_one", "M480 -600V-320Q480 -303 491.5 -291.5Q503 -280 520 -280Q537 -280 548.5 -291.5Q560 -303 560 -320V-640Q560 -657 548.5 -668.5Q537 -680 520 -680H440Q423 -680 411.5 -668.5Q400 -657 400 -640Q400 -623 411.5 -611.5Q423 -600 440 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760Z"), + ("looks_one_fill", "M480 -600V-320Q480 -303 491.5 -291.5Q503 -280 520 -280Q537 -280 548.5 -291.5Q560 -303 560 -320V-640Q560 -657 548.5 -668.5Q537 -680 520 -680H440Q423 -680 411.5 -668.5Q400 -657 400 -640Q400 -623 411.5 -611.5Q423 -600 440 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760H760Q760 -760 760 -760Q760 -760 760 -760V-200Q760 -200 760 -200Q760 -200 760 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760Z"), + ("manage_search", "M120 -200Q103 -200 91.5 -211.5Q80 -223 80 -240Q80 -257 91.5 -268.5Q103 -280 120 -280H440Q457 -280 468.5 -268.5Q480 -257 480 -240Q480 -223 468.5 -211.5Q457 -200 440 -200ZM120 -400Q103 -400 91.5 -411.5Q80 -423 80 -440Q80 -457 91.5 -468.5Q103 -480 120 -480H240Q257 -480 268.5 -468.5Q280 -457 280 -440Q280 -423 268.5 -411.5Q257 -400 240 -400ZM120 -600Q103 -600 91.5 -611.5Q80 -623 80 -640Q80 -657 91.5 -668.5Q103 -680 120 -680H240Q257 -680 268.5 -668.5Q280 -657 280 -640Q280 -623 268.5 -611.5Q257 -600 240 -600ZM560 -320Q477 -320 418.5 -378.5Q360 -437 360 -520Q360 -603 418.5 -661.5Q477 -720 560 -720Q643 -720 701.5 -661.5Q760 -603 760 -520Q760 -491 751.5 -462.5Q743 -434 726 -410L852 -284Q863 -273 863 -256Q863 -239 852 -228Q841 -217 824 -217Q807 -217 796 -228L670 -354Q646 -337 617.5 -328.5Q589 -320 560 -320ZM560 -400Q610 -400 645 -435Q680 -470 680 -520Q680 -570 645 -605Q610 -640 560 -640Q510 -640 475 -605Q440 -570 440 -520Q440 -470 475 -435Q510 -400 560 -400Z"), + ("map", "M574 -129 360 -204 174 -132Q164 -128 154.5 -129.5Q145 -131 137 -136Q129 -141 124.5 -149.5Q120 -158 120 -169V-730Q120 -743 127.5 -753Q135 -763 148 -768L334 -831Q340 -833 346.5 -834Q353 -835 360 -835Q367 -835 373.5 -834Q380 -833 386 -831L600 -756L786 -828Q796 -832 805.5 -830.5Q815 -829 823 -824Q831 -819 835.5 -810.5Q840 -802 840 -791V-230Q840 -217 832.5 -207Q825 -197 812 -192L626 -129Q620 -127 613.5 -126Q607 -125 600 -125Q593 -125 586.5 -126Q580 -127 574 -129ZM560 -218V-686L400 -742V-274ZM640 -218 760 -258V-732L640 -686ZM200 -228 320 -274V-742L200 -702ZM640 -686V-218ZM320 -742V-274Z"), + ("map_fill", "M574 -129 360 -204 174 -132Q164 -128 154.5 -129.5Q145 -131 137 -136Q129 -141 124.5 -149.5Q120 -158 120 -169V-730Q120 -743 127.5 -753Q135 -763 148 -768L334 -831Q340 -833 346.5 -834Q353 -835 360 -835Q367 -835 373.5 -834Q380 -833 386 -831L600 -756L786 -828Q796 -832 805.5 -830.5Q815 -829 823 -824Q831 -819 835.5 -810.5Q840 -802 840 -791V-230Q840 -217 832.5 -207Q825 -197 812 -192L626 -129Q620 -127 613.5 -126Q607 -125 600 -125Q593 -125 586.5 -126Q580 -127 574 -129ZM560 -218V-686L400 -742V-274ZM640 -218 760 -258V-732L640 -686ZM200 -228 320 -274V-742L200 -702ZM640 -686 760 -732V-258L640 -218ZM200 -702 320 -742V-274L200 -228Z"), + ("match_case", "M247 -364 215 -275Q211 -264 202 -258Q193 -252 182 -252Q163 -252 152.5 -267.5Q142 -283 149 -300L287 -668Q291 -679 300.5 -685.5Q310 -692 321 -692H349Q360 -692 370 -685.5Q380 -679 384 -668L522 -299Q529 -282 518 -267Q507 -252 489 -252Q478 -252 469 -258.5Q460 -265 456 -276L425 -364ZM270 -428H401L337 -610H333ZM665 -242Q614 -242 584 -269.5Q554 -297 554 -342Q554 -386 588.5 -414.5Q623 -443 677 -443Q700 -443 722 -439Q744 -435 760 -428V-440Q760 -469 739.5 -487Q719 -505 685 -505Q670 -505 655.5 -500.5Q641 -496 629 -487Q616 -477 604.5 -480Q593 -483 586 -491Q579 -499 579 -510Q579 -521 590 -529Q610 -545 635 -552.5Q660 -560 686 -560Q755 -560 789 -527.5Q823 -495 823 -430V-283Q823 -270 813.5 -261Q804 -252 791 -252Q778 -252 769 -261.5Q760 -271 760 -284V-289H756Q742 -266 718 -254Q694 -242 665 -242ZM677 -296Q712 -296 736.5 -320Q761 -344 761 -376Q747 -384 727.5 -388.5Q708 -393 689 -393Q657 -393 639 -379Q621 -365 621 -342Q621 -322 637 -309Q653 -296 677 -296Z"), + ("memory", "M360 -400V-560Q360 -577 371.5 -588.5Q383 -600 400 -600H560Q577 -600 588.5 -588.5Q600 -577 600 -560V-400Q600 -383 588.5 -371.5Q577 -360 560 -360H400Q383 -360 371.5 -371.5Q360 -383 360 -400ZM440 -440H520V-520H440ZM360 -160V-200H280Q247 -200 223.5 -223.5Q200 -247 200 -280V-360H160Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H200V-520H160Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H200V-680Q200 -713 223.5 -736.5Q247 -760 280 -760H360V-800Q360 -817 371.5 -828.5Q383 -840 400 -840Q417 -840 428.5 -828.5Q440 -817 440 -800V-760H520V-800Q520 -817 531.5 -828.5Q543 -840 560 -840Q577 -840 588.5 -828.5Q600 -817 600 -800V-760H680Q713 -760 736.5 -736.5Q760 -713 760 -680V-600H800Q817 -600 828.5 -588.5Q840 -577 840 -560Q840 -543 828.5 -531.5Q817 -520 800 -520H760V-440H800Q817 -440 828.5 -428.5Q840 -417 840 -400Q840 -383 828.5 -371.5Q817 -360 800 -360H760V-280Q760 -247 736.5 -223.5Q713 -200 680 -200H600V-160Q600 -143 588.5 -131.5Q577 -120 560 -120Q543 -120 531.5 -131.5Q520 -143 520 -160V-200H440V-160Q440 -143 428.5 -131.5Q417 -120 400 -120Q383 -120 371.5 -131.5Q360 -143 360 -160ZM680 -280Q680 -280 680 -280Q680 -280 680 -280V-680Q680 -680 680 -680Q680 -680 680 -680H280Q280 -680 280 -680Q280 -680 280 -680V-280Q280 -280 280 -280Q280 -280 280 -280ZM480 -480Z"), + ("memory_fill", "M360 -400V-560Q360 -577 371.5 -588.5Q383 -600 400 -600H560Q577 -600 588.5 -588.5Q600 -577 600 -560V-400Q600 -383 588.5 -371.5Q577 -360 560 -360H400Q383 -360 371.5 -371.5Q360 -383 360 -400ZM440 -440H520V-520H440ZM360 -160V-200H280Q247 -200 223.5 -223.5Q200 -247 200 -280V-360H160Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H200V-520H160Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H200V-680Q200 -713 223.5 -736.5Q247 -760 280 -760H360V-800Q360 -817 371.5 -828.5Q383 -840 400 -840Q417 -840 428.5 -828.5Q440 -817 440 -800V-760H520V-800Q520 -817 531.5 -828.5Q543 -840 560 -840Q577 -840 588.5 -828.5Q600 -817 600 -800V-760H680Q713 -760 736.5 -736.5Q760 -713 760 -680V-600H800Q817 -600 828.5 -588.5Q840 -577 840 -560Q840 -543 828.5 -531.5Q817 -520 800 -520H760V-440H800Q817 -440 828.5 -428.5Q840 -417 840 -400Q840 -383 828.5 -371.5Q817 -360 800 -360H760V-280Q760 -247 736.5 -223.5Q713 -200 680 -200H600V-160Q600 -143 588.5 -131.5Q577 -120 560 -120Q543 -120 531.5 -131.5Q520 -143 520 -160V-200H440V-160Q440 -143 428.5 -131.5Q417 -120 400 -120Q383 -120 371.5 -131.5Q360 -143 360 -160ZM680 -280Q680 -280 680 -280Q680 -280 680 -280V-680Q680 -680 680 -680Q680 -680 680 -680H280Q280 -680 280 -680Q280 -680 280 -680V-280Q280 -280 280 -280Q280 -280 280 -280ZM440 -440V-520H520V-440Z"), + ("merge", "M480 -344 284 -148Q273 -137 256.5 -136.5Q240 -136 228 -148Q217 -159 217 -176Q217 -193 228 -204L393 -370Q416 -393 428 -422Q440 -451 440 -483V-687L404 -651Q393 -640 376.5 -640Q360 -640 348 -652Q337 -663 337 -680Q337 -697 348 -708L452 -812Q464 -824 480 -824Q496 -824 508 -812L612 -708Q623 -697 623.5 -680.5Q624 -664 612 -652Q601 -641 584 -641Q567 -641 556 -652L520 -687V-483Q520 -451 532 -422Q544 -393 567 -370L732 -204Q743 -193 743.5 -176.5Q744 -160 732 -148Q721 -137 704 -137Q687 -137 676 -148Z"), + ("minimize", "M280 -120Q263 -120 251.5 -131.5Q240 -143 240 -160Q240 -177 251.5 -188.5Q263 -200 280 -200H680Q697 -200 708.5 -188.5Q720 -177 720 -160Q720 -143 708.5 -131.5Q697 -120 680 -120Z"), + ("more_horiz", "M240 -400Q207 -400 183.5 -423.5Q160 -447 160 -480Q160 -513 183.5 -536.5Q207 -560 240 -560Q273 -560 296.5 -536.5Q320 -513 320 -480Q320 -447 296.5 -423.5Q273 -400 240 -400ZM480 -400Q447 -400 423.5 -423.5Q400 -447 400 -480Q400 -513 423.5 -536.5Q447 -560 480 -560Q513 -560 536.5 -536.5Q560 -513 560 -480Q560 -447 536.5 -423.5Q513 -400 480 -400ZM720 -400Q687 -400 663.5 -423.5Q640 -447 640 -480Q640 -513 663.5 -536.5Q687 -560 720 -560Q753 -560 776.5 -536.5Q800 -513 800 -480Q800 -447 776.5 -423.5Q753 -400 720 -400Z"), + ("more_vert", "M480 -160Q447 -160 423.5 -183.5Q400 -207 400 -240Q400 -273 423.5 -296.5Q447 -320 480 -320Q513 -320 536.5 -296.5Q560 -273 560 -240Q560 -207 536.5 -183.5Q513 -160 480 -160ZM480 -400Q447 -400 423.5 -423.5Q400 -447 400 -480Q400 -513 423.5 -536.5Q447 -560 480 -560Q513 -560 536.5 -536.5Q560 -513 560 -480Q560 -447 536.5 -423.5Q513 -400 480 -400ZM480 -640Q447 -640 423.5 -663.5Q400 -687 400 -720Q400 -753 423.5 -776.5Q447 -800 480 -800Q513 -800 536.5 -776.5Q560 -753 560 -720Q560 -687 536.5 -663.5Q513 -640 480 -640Z"), + ("motion_mode", "M200 -766V-194Q183 -211 168 -230Q153 -249 140 -269V-691Q153 -711 168 -730Q183 -749 200 -766ZM360 -862V-98Q339 -105 319 -113.5Q299 -122 280 -133V-827Q299 -838 319 -846.5Q339 -855 360 -862ZM640 -113V-847Q746 -800 813 -702Q880 -604 880 -480Q880 -356 813 -258Q746 -160 640 -113ZM480 -80Q470 -80 460 -80.5Q450 -81 440 -82V-878Q450 -879 460 -879.5Q470 -880 480 -880Q500 -880 520 -878Q540 -876 560 -872V-88Q540 -84 520 -82Q500 -80 480 -80Z"), + ("move_up", "M320 -160Q203 -160 121.5 -241.5Q40 -323 40 -440Q40 -547 110.5 -626.5Q181 -706 287 -718L251 -756Q240 -768 240 -784Q240 -800 251 -811Q263 -823 280 -823Q297 -823 308 -812L412 -708Q424 -696 424 -680Q424 -664 412 -652L309 -549Q297 -537 280.5 -537Q264 -537 252 -549Q241 -561 241 -577.5Q241 -594 252 -605L283 -636Q212 -622 166 -567Q120 -512 120 -440Q120 -357 178.5 -298.5Q237 -240 320 -240H400Q417 -240 428.5 -228.5Q440 -217 440 -200Q440 -183 428.5 -171.5Q417 -160 400 -160ZM560 -520Q543 -520 531.5 -531.5Q520 -543 520 -560V-760Q520 -777 531.5 -788.5Q543 -800 560 -800H840Q857 -800 868.5 -788.5Q880 -777 880 -760V-560Q880 -543 868.5 -531.5Q857 -520 840 -520ZM560 -160Q543 -160 531.5 -171.5Q520 -183 520 -200V-400Q520 -417 531.5 -428.5Q543 -440 560 -440H840Q857 -440 868.5 -428.5Q880 -417 880 -400V-200Q880 -183 868.5 -171.5Q857 -160 840 -160ZM600 -240H800V-360H600Z"), + ("new_window", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H400Q417 -840 428.5 -828.5Q440 -817 440 -800Q440 -783 428.5 -771.5Q417 -760 400 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-400Q760 -417 771.5 -428.5Q783 -440 800 -440Q817 -440 828.5 -428.5Q840 -417 840 -400V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM640 -640H560Q543 -640 531.5 -651.5Q520 -663 520 -680Q520 -697 531.5 -708.5Q543 -720 560 -720H640V-800Q640 -817 651.5 -828.5Q663 -840 680 -840Q697 -840 708.5 -828.5Q720 -817 720 -800V-720H800Q817 -720 828.5 -708.5Q840 -697 840 -680Q840 -663 828.5 -651.5Q817 -640 800 -640H720V-560Q720 -543 708.5 -531.5Q697 -520 680 -520Q663 -520 651.5 -531.5Q640 -543 640 -560Z"), + ("open_in_full", "M160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160V-400Q120 -417 131.5 -428.5Q143 -440 160 -440Q177 -440 188.5 -428.5Q200 -417 200 -400V-256L704 -760H560Q543 -760 531.5 -771.5Q520 -783 520 -800Q520 -817 531.5 -828.5Q543 -840 560 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800V-560Q840 -543 828.5 -531.5Q817 -520 800 -520Q783 -520 771.5 -531.5Q760 -543 760 -560V-704L256 -200H400Q417 -200 428.5 -188.5Q440 -177 440 -160Q440 -143 428.5 -131.5Q417 -120 400 -120Z"), + ("open_in_new", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H440Q457 -840 468.5 -828.5Q480 -817 480 -800Q480 -783 468.5 -771.5Q457 -760 440 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-440Q760 -457 771.5 -468.5Q783 -480 800 -480Q817 -480 828.5 -468.5Q840 -457 840 -440V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM760 -704 416 -360Q405 -349 388 -349Q371 -349 360 -360Q349 -371 349 -388Q349 -405 360 -416L704 -760H600Q583 -760 571.5 -771.5Q560 -783 560 -800Q560 -817 571.5 -828.5Q583 -840 600 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800V-600Q840 -583 828.5 -571.5Q817 -560 800 -560Q783 -560 771.5 -571.5Q760 -583 760 -600Z"), + ("palette", "M480 -80Q398 -80 325 -111.5Q252 -143 197.5 -197.5Q143 -252 111.5 -325Q80 -398 80 -480Q80 -563 112.5 -636Q145 -709 200.5 -763Q256 -817 330 -848.5Q404 -880 488 -880Q568 -880 639 -852.5Q710 -825 763.5 -776.5Q817 -728 848.5 -661.5Q880 -595 880 -518Q880 -403 810 -341.5Q740 -280 640 -280H566Q557 -280 553.5 -275Q550 -270 550 -264Q550 -252 565 -229.5Q580 -207 580 -178Q580 -128 552.5 -104Q525 -80 480 -80ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480ZM260 -440Q286 -440 303 -457Q320 -474 320 -500Q320 -526 303 -543Q286 -560 260 -560Q234 -560 217 -543Q200 -526 200 -500Q200 -474 217 -457Q234 -440 260 -440ZM380 -600Q406 -600 423 -617Q440 -634 440 -660Q440 -686 423 -703Q406 -720 380 -720Q354 -720 337 -703Q320 -686 320 -660Q320 -634 337 -617Q354 -600 380 -600ZM580 -600Q606 -600 623 -617Q640 -634 640 -660Q640 -686 623 -703Q606 -720 580 -720Q554 -720 537 -703Q520 -686 520 -660Q520 -634 537 -617Q554 -600 580 -600ZM700 -440Q726 -440 743 -457Q760 -474 760 -500Q760 -526 743 -543Q726 -560 700 -560Q674 -560 657 -543Q640 -526 640 -500Q640 -474 657 -457Q674 -440 700 -440ZM480 -160Q489 -160 494.5 -165Q500 -170 500 -178Q500 -192 485 -211Q470 -230 470 -268Q470 -310 499 -335Q528 -360 570 -360H640Q706 -360 753 -398.5Q800 -437 800 -518Q800 -639 707.5 -719.5Q615 -800 488 -800Q352 -800 256 -707Q160 -614 160 -480Q160 -347 253.5 -253.5Q347 -160 480 -160Z"), + ("palette_fill", "M480 -80Q398 -80 325 -111.5Q252 -143 197.5 -197.5Q143 -252 111.5 -325Q80 -398 80 -480Q80 -563 112.5 -636Q145 -709 200.5 -763Q256 -817 330 -848.5Q404 -880 488 -880Q568 -880 639 -852.5Q710 -825 763.5 -776.5Q817 -728 848.5 -661.5Q880 -595 880 -518Q880 -403 810 -341.5Q740 -280 640 -280H566Q557 -280 553.5 -275Q550 -270 550 -264Q550 -252 565 -229.5Q580 -207 580 -178Q580 -128 552.5 -104Q525 -80 480 -80ZM480 -160Q347 -160 253.5 -253.5Q160 -347 160 -480Q160 -614 256 -707Q352 -800 488 -800Q615 -800 707.5 -719.5Q800 -639 800 -518Q800 -437 753 -398.5Q706 -360 640 -360H570Q528 -360 499 -335Q470 -310 470 -268Q470 -230 485 -211Q500 -192 500 -178Q500 -170 494.5 -165Q489 -160 480 -160ZM260 -440Q286 -440 303 -457Q320 -474 320 -500Q320 -526 303 -543Q286 -560 260 -560Q234 -560 217 -543Q200 -526 200 -500Q200 -474 217 -457Q234 -440 260 -440ZM380 -600Q406 -600 423 -617Q440 -634 440 -660Q440 -686 423 -703Q406 -720 380 -720Q354 -720 337 -703Q320 -686 320 -660Q320 -634 337 -617Q354 -600 380 -600ZM580 -600Q606 -600 623 -617Q640 -634 640 -660Q640 -686 623 -703Q606 -720 580 -720Q554 -720 537 -703Q520 -686 520 -660Q520 -634 537 -617Q554 -600 580 -600ZM700 -440Q726 -440 743 -457Q760 -474 760 -500Q760 -526 743 -543Q726 -560 700 -560Q674 -560 657 -543Q640 -526 640 -500Q640 -474 657 -457Q674 -440 700 -440ZM480 -160Q489 -160 494.5 -165Q500 -170 500 -178Q500 -192 485 -211Q470 -230 470 -268Q470 -310 499 -335Q528 -360 570 -360H640Q706 -360 753 -398.5Q800 -437 800 -518Q800 -639 707.5 -719.5Q615 -800 488 -800Q352 -800 256 -707Q160 -614 160 -480Q160 -347 253.5 -253.5Q347 -160 480 -160Z"), + ("pin_drop", "M480 -301Q579 -381 629.5 -455Q680 -529 680 -594Q680 -684 624 -742Q568 -800 480 -800Q392 -800 336 -742Q280 -684 280 -594Q280 -529 330.5 -455Q381 -381 480 -301ZM434 -235Q316 -329 258 -418.5Q200 -508 200 -594Q200 -719 278 -799.5Q356 -880 480 -880Q604 -880 682 -799.5Q760 -719 760 -594Q760 -508 702 -418.5Q644 -329 526 -235Q516 -227 504 -223Q492 -219 480 -219Q468 -219 456 -223Q444 -227 434 -235ZM480 -520Q513 -520 536.5 -543.5Q560 -567 560 -600Q560 -633 536.5 -656.5Q513 -680 480 -680Q447 -680 423.5 -656.5Q400 -633 400 -600Q400 -567 423.5 -543.5Q447 -520 480 -520ZM240 -80Q223 -80 211.5 -91.5Q200 -103 200 -120Q200 -137 211.5 -148.5Q223 -160 240 -160H720Q737 -160 748.5 -148.5Q760 -137 760 -120Q760 -103 748.5 -91.5Q737 -80 720 -80ZM480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Z"), + ("pin_drop_fill", "M480 -301Q579 -381 629.5 -455Q680 -529 680 -594Q680 -684 624 -742Q568 -800 480 -800Q392 -800 336 -742Q280 -684 280 -594Q280 -529 330.5 -455Q381 -381 480 -301ZM434 -235Q316 -329 258 -418.5Q200 -508 200 -594Q200 -719 278 -799.5Q356 -880 480 -880Q604 -880 682 -799.5Q760 -719 760 -594Q760 -508 702 -418.5Q644 -329 526 -235Q516 -227 504 -223Q492 -219 480 -219Q468 -219 456 -223Q444 -227 434 -235ZM480 -520Q513 -520 536.5 -543.5Q560 -567 560 -600Q560 -633 536.5 -656.5Q513 -680 480 -680Q447 -680 423.5 -656.5Q400 -633 400 -600Q400 -567 423.5 -543.5Q447 -520 480 -520ZM240 -80Q223 -80 211.5 -91.5Q200 -103 200 -120Q200 -137 211.5 -148.5Q223 -160 240 -160H720Q737 -160 748.5 -148.5Q760 -137 760 -120Q760 -103 748.5 -91.5Q737 -80 720 -80ZM480 -301Q381 -381 330.5 -455Q280 -529 280 -594Q280 -684 336 -742Q392 -800 480 -800Q568 -800 624 -742Q680 -684 680 -594Q680 -529 629.5 -455Q579 -381 480 -301Z"), + ("play_arrow", "M320 -273V-687Q320 -704 332 -715.5Q344 -727 360 -727Q365 -727 370.5 -725.5Q376 -724 381 -721L707 -514Q716 -508 720.5 -499Q725 -490 725 -480Q725 -470 720.5 -461Q716 -452 707 -446L381 -239Q376 -236 370.5 -234.5Q365 -233 360 -233Q344 -233 332 -244.5Q320 -256 320 -273ZM400 -480ZM400 -346 610 -480 400 -614Z"), + ("play_arrow_fill", "M320 -273V-687Q320 -704 332 -715.5Q344 -727 360 -727Q365 -727 370.5 -725.5Q376 -724 381 -721L707 -514Q716 -508 720.5 -499Q725 -490 725 -480Q725 -470 720.5 -461Q716 -452 707 -446L381 -239Q376 -236 370.5 -234.5Q365 -233 360 -233Q344 -233 332 -244.5Q320 -256 320 -273ZM400 -614 610 -480 400 -346ZM400 -346 610 -480 400 -614Z"), + ("push_pin", "M640 -760V-480L708 -412Q714 -406 717 -398.5Q720 -391 720 -383V-360Q720 -343 708.5 -331.5Q697 -320 680 -320H520V-86Q520 -69 508.5 -57.5Q497 -46 480 -46Q463 -46 451.5 -57.5Q440 -69 440 -86V-320H280Q263 -320 251.5 -331.5Q240 -343 240 -360V-383Q240 -391 243 -398.5Q246 -406 252 -412L320 -480V-760Q303 -760 291.5 -771.5Q280 -783 280 -800Q280 -817 291.5 -828.5Q303 -840 320 -840H640Q657 -840 668.5 -828.5Q680 -817 680 -800Q680 -783 668.5 -771.5Q657 -760 640 -760ZM354 -400H606L560 -446V-760H400V-446ZM480 -400Z"), + ("push_pin_fill", "M640 -760V-480L708 -412Q714 -406 717 -398.5Q720 -391 720 -383V-360Q720 -343 708.5 -331.5Q697 -320 680 -320H520V-86Q520 -69 508.5 -57.5Q497 -46 480 -46Q463 -46 451.5 -57.5Q440 -69 440 -86V-320H280Q263 -320 251.5 -331.5Q240 -343 240 -360V-383Q240 -391 243 -398.5Q246 -406 252 -412L320 -480V-760Q303 -760 291.5 -771.5Q280 -783 280 -800Q280 -817 291.5 -828.5Q303 -840 320 -840H640Q657 -840 668.5 -828.5Q680 -817 680 -800Q680 -783 668.5 -771.5Q657 -760 640 -760ZM354 -400H606L560 -446V-760H400V-446ZM354 -400 400 -446V-760H560V-446L606 -400Z"), + ("redo", "M648 -560H396Q333 -560 286.5 -520Q240 -480 240 -420Q240 -360 286.5 -320Q333 -280 396 -280H640Q657 -280 668.5 -268.5Q680 -257 680 -240Q680 -223 668.5 -211.5Q657 -200 640 -200H396Q299 -200 229.5 -263Q160 -326 160 -420Q160 -514 229.5 -577Q299 -640 396 -640H648L572 -716Q561 -727 561 -744Q561 -761 572 -772Q583 -783 600 -783Q617 -783 628 -772L772 -628Q778 -622 780.5 -615Q783 -608 783 -600Q783 -592 780.5 -585Q778 -578 772 -572L628 -428Q617 -417 600 -417Q583 -417 572 -428Q561 -439 561 -456Q561 -473 572 -484Z"), + ("refresh", "M480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q549 -800 612 -771.5Q675 -743 720 -690V-760Q720 -777 731.5 -788.5Q743 -800 760 -800Q777 -800 788.5 -788.5Q800 -777 800 -760V-560Q800 -543 788.5 -531.5Q777 -520 760 -520H560Q543 -520 531.5 -531.5Q520 -543 520 -560Q520 -577 531.5 -588.5Q543 -600 560 -600H688Q656 -656 600.5 -688Q545 -720 480 -720Q380 -720 310 -650Q240 -580 240 -480Q240 -380 310 -310Q380 -240 480 -240Q548 -240 604.5 -274.5Q661 -309 692 -367Q700 -381 714.5 -386.5Q729 -392 744 -387Q760 -382 767 -366Q774 -350 766 -336Q725 -256 649 -208Q573 -160 480 -160Z"), + ("regular_expression", "M80 -482Q80 -551 102.5 -615.5Q125 -680 169 -734Q180 -747 196.5 -748Q213 -749 225 -737Q237 -725 237.5 -708.5Q238 -692 227 -678Q194 -636 177 -586Q160 -536 160 -482Q160 -428 178 -378Q196 -328 228 -286Q239 -272 238.5 -256Q238 -240 226 -228Q214 -216 197.5 -216.5Q181 -217 170 -230Q127 -284 103.5 -348.5Q80 -413 80 -482ZM380 -240Q355 -240 337.5 -257.5Q320 -275 320 -300Q320 -325 337.5 -342.5Q355 -360 380 -360Q405 -360 422.5 -342.5Q440 -325 440 -300Q440 -275 422.5 -257.5Q405 -240 380 -240ZM519 -480V-511L493 -495Q479 -487 462.5 -491.5Q446 -496 438 -510Q430 -524 434.5 -540.5Q439 -557 453 -565L479 -580L452 -595Q438 -603 434 -619.5Q430 -636 438 -650Q446 -665 462.5 -668.5Q479 -672 493 -664L519 -649V-680Q519 -697 530.5 -708.5Q542 -720 559 -720Q576 -720 587.5 -708.5Q599 -697 599 -680V-649L625 -665Q639 -673 655.5 -668.5Q672 -664 680 -650Q688 -636 683.5 -619.5Q679 -603 665 -595L639 -580L666 -565Q680 -557 684 -540.5Q688 -524 680 -510Q672 -495 655.5 -491.5Q639 -488 625 -496L599 -511V-480Q599 -463 587.5 -451.5Q576 -440 559 -440Q542 -440 530.5 -451.5Q519 -463 519 -480ZM880 -482Q880 -413 857.5 -348.5Q835 -284 791 -230Q780 -217 763.5 -216.5Q747 -216 735 -228Q723 -240 722.5 -256Q722 -272 733 -286Q766 -328 783 -378Q800 -428 800 -482Q800 -536 782 -586Q764 -636 732 -678Q721 -692 722 -708.5Q723 -725 735 -737Q747 -749 763 -748Q779 -747 790 -734Q833 -680 856.5 -615.5Q880 -551 880 -482Z"), + ("remove", "M240 -440Q223 -440 211.5 -451.5Q200 -463 200 -480Q200 -497 211.5 -508.5Q223 -520 240 -520H720Q737 -520 748.5 -508.5Q760 -497 760 -480Q760 -463 748.5 -451.5Q737 -440 720 -440Z"), + ("restart_alt", "M393 -132Q290 -161 225 -245.5Q160 -330 160 -440Q160 -497 179 -548.5Q198 -600 233 -643Q244 -655 260 -655.5Q276 -656 289 -643Q300 -632 300.5 -616Q301 -600 290 -586Q266 -555 253 -518Q240 -481 240 -440Q240 -359 287.5 -295.5Q335 -232 410 -209Q423 -205 431.5 -194Q440 -183 440 -170Q440 -150 426 -138.5Q412 -127 393 -132ZM567 -132Q548 -127 534 -139Q520 -151 520 -171Q520 -183 528.5 -194Q537 -205 550 -209Q625 -233 672.5 -296Q720 -359 720 -440Q720 -540 650 -610Q580 -680 480 -680H477L493 -664Q504 -653 504 -636Q504 -619 493 -608Q482 -597 465 -597Q448 -597 437 -608L353 -692Q347 -698 344.5 -705Q342 -712 342 -720Q342 -728 344.5 -735Q347 -742 353 -748L437 -832Q448 -843 465 -843Q482 -843 493 -832Q504 -821 504 -804Q504 -787 493 -776L477 -760H480Q614 -760 707 -667Q800 -574 800 -440Q800 -331 735 -246Q670 -161 567 -132Z"), + ("rocket_launch", "M284 -506Q298 -534 313 -560Q328 -586 346 -612L290 -623Q290 -623 290 -623Q290 -623 290 -623L206 -539Q206 -539 206 -539Q206 -539 206 -539ZM766 -781Q696 -779 616.5 -740Q537 -701 472 -636Q430 -594 397 -546Q364 -498 348 -456Q348 -456 348 -456Q348 -456 348 -456L462 -343Q462 -343 462 -343Q462 -343 462 -343Q504 -359 552 -392Q600 -425 642 -467Q707 -532 746 -611Q785 -690 787 -760Q787 -764 785.5 -768Q784 -772 781 -775Q778 -778 774 -779.5Q770 -781 766 -781ZM546 -541Q523 -564 523 -597.5Q523 -631 546 -654Q569 -677 603 -677Q637 -677 660 -654Q683 -631 683 -597.5Q683 -564 660 -541Q637 -518 603 -518Q569 -518 546 -541ZM512 -279 545 -200Q545 -200 545 -200Q545 -200 545 -200L629 -284Q629 -284 629 -284Q629 -284 629 -284L618 -340Q592 -322 566 -307.5Q540 -293 512 -279ZM863 -813Q871 -703 827 -598.5Q783 -494 688 -399Q688 -399 688 -399Q688 -399 688 -399L708 -300Q712 -280 706 -261Q700 -242 686 -228L560 -102Q545 -87 524 -90.5Q503 -94 495 -114L434 -257L263 -428L120 -489Q100 -497 96 -518Q92 -539 107 -554L233 -680Q247 -694 266.5 -700Q286 -706 306 -702L405 -682Q405 -682 405 -682Q405 -682 405 -682Q500 -777 604.5 -821Q709 -865 819 -857Q827 -856 835 -852.5Q843 -849 849 -843Q855 -837 858.5 -829Q862 -821 863 -813ZM157 -321Q192 -356 242.5 -356.5Q293 -357 328 -322Q363 -287 362.5 -236.5Q362 -186 327 -151Q279 -103 213.5 -94Q148 -85 82 -76Q91 -142 100 -207.5Q109 -273 157 -321ZM214 -265Q197 -248 190.5 -224Q184 -200 180 -175Q205 -179 229 -185Q253 -191 270 -208Q282 -220 283 -237Q284 -254 272 -266Q260 -278 243 -277.5Q226 -277 214 -265Z"), + ("rocket_launch_fill", "M245 -474Q271 -540 307.5 -601Q344 -662 390 -716L338 -727Q318 -731 299 -725Q280 -719 266 -705L140 -579Q125 -564 128.5 -543Q132 -522 152 -514ZM833 -864Q727 -869 631.5 -823Q536 -777 461.3 -702.3Q413 -654 376.5 -598Q340 -542 313 -480Q308 -467 308 -453.5Q308 -440 318 -430L443 -305Q453 -295 466.5 -295Q480 -295 493 -300Q555 -327 611 -363.5Q667 -400 715.3 -448.3Q790 -523 836 -618.5Q882 -714 877 -820Q877 -828 873 -836Q869 -844 863 -850Q857 -856 849 -860Q841 -864 833 -864ZM579 -566Q556 -589 556 -622.5Q556 -656 579 -679Q602 -702 635.5 -702Q669 -702 692 -679Q715 -656 715 -622.5Q715 -589 692 -566Q669 -543 635.5 -543Q602 -543 579 -566ZM487 -232 527 -139Q535 -119 556 -115Q577 -111 592 -126L718 -252Q732 -266 738 -285.5Q744 -305 740 -325L730 -377Q675 -331 614.5 -294.5Q554 -258 487 -232ZM635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622ZM162 -318Q196.8 -353 247.1 -353.5Q297.3 -354 332.2 -319Q367 -284 367 -234Q367 -184 332 -149Q284 -101 218.5 -92Q153 -83 87 -74Q96 -140 105.5 -205.5Q115 -271 162 -318ZM239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Z"), + ("save", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM760 -646 646 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200ZM480 -240Q530 -240 565 -275Q600 -310 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM200 -646V-200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760Z"), + ("save_as", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-520Q840 -503 828.5 -491.5Q817 -480 800 -480Q783 -480 771.5 -491.5Q760 -503 760 -520V-647L647 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H400Q417 -200 428.5 -188.5Q440 -177 440 -160Q440 -143 428.5 -131.5Q417 -120 400 -120ZM200 -760V-647V-478Q200 -475 200 -465.5Q200 -456 200 -441V-200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM520 -80V-146Q520 -154 523 -161.5Q526 -169 532 -175L741 -383Q750 -392 761 -396Q772 -400 783 -400Q795 -400 806 -395.5Q817 -391 826 -382L863 -345Q871 -336 875.5 -325Q880 -314 880 -303Q880 -292 876 -280.5Q872 -269 863 -260L655 -52Q649 -46 641.5 -43Q634 -40 626 -40H560Q543 -40 531.5 -51.5Q520 -63 520 -80ZM820 -303 783 -340ZM580 -100H618L739 -222L721 -241L702 -259L580 -138ZM721 -241 702 -259 739 -222ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM480 -240Q481 -240 482 -240Q483 -240 484 -240L600 -355Q600 -357 600 -357.5Q600 -358 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240Z"), + ("save_as_fill", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-513Q840 -496 826.5 -486Q813 -476 796 -479Q787 -480 778 -480Q769 -480 760 -478V-647L647 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H444Q443 -199 442 -198Q441 -197 440 -196Q440 -177 440 -158Q440 -139 440 -120ZM647 -760 760 -647V-478Q740 -475 721 -465.5Q702 -456 686 -441L444 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM520 -80V-146Q520 -154 523 -161.5Q526 -169 532 -175L741 -383Q750 -392 761 -396Q772 -400 783 -400Q795 -400 806 -395.5Q817 -391 826 -382L863 -345Q871 -336 875.5 -325Q880 -314 880 -303Q880 -292 876 -280.5Q872 -269 863 -260L655 -52Q649 -46 641.5 -43Q634 -40 626 -40H560Q543 -40 531.5 -51.5Q520 -63 520 -80ZM783 -264 820 -303 783 -340 745 -302ZM580 -100H618L739 -222L721 -241L702 -259L580 -138ZM580 -100V-138L702 -259L739 -222L618 -100ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM480 -240Q481 -240 482 -240Q483 -240 484 -240L600 -355Q600 -357 600 -357.5Q600 -358 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240Z"), + ("save_fill", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM760 -646 646 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200ZM480 -240Q530 -240 565 -275Q600 -310 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM760 -646V-200Q760 -200 760 -200Q760 -200 760 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760H646Z"), + ("search", "M380 -320Q271 -320 195.5 -395.5Q120 -471 120 -580Q120 -689 195.5 -764.5Q271 -840 380 -840Q489 -840 564.5 -764.5Q640 -689 640 -580Q640 -536 626 -497Q612 -458 588 -428L812 -204Q823 -193 823 -176Q823 -159 812 -148Q801 -137 784 -137Q767 -137 756 -148L532 -372Q502 -348 463 -334Q424 -320 380 -320ZM380 -400Q455 -400 507.5 -452.5Q560 -505 560 -580Q560 -655 507.5 -707.5Q455 -760 380 -760Q305 -760 252.5 -707.5Q200 -655 200 -580Q200 -505 252.5 -452.5Q305 -400 380 -400Z"), + ("segment", "M400 -240Q383 -240 371.5 -251.5Q360 -263 360 -280Q360 -297 371.5 -308.5Q383 -320 400 -320H800Q817 -320 828.5 -308.5Q840 -297 840 -280Q840 -263 828.5 -251.5Q817 -240 800 -240ZM400 -440Q383 -440 371.5 -451.5Q360 -463 360 -480Q360 -497 371.5 -508.5Q383 -520 400 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM160 -640Q143 -640 131.5 -651.5Q120 -663 120 -680Q120 -697 131.5 -708.5Q143 -720 160 -720H800Q817 -720 828.5 -708.5Q840 -697 840 -680Q840 -663 828.5 -651.5Q817 -640 800 -640Z"), + ("select_all", "M160 -760Q143 -760 131.5 -771.5Q120 -783 120 -800Q120 -817 131.5 -828.5Q143 -840 160 -840Q177 -840 188.5 -828.5Q200 -817 200 -800Q200 -783 188.5 -771.5Q177 -760 160 -760ZM320 -760Q303 -760 291.5 -771.5Q280 -783 280 -800Q280 -817 291.5 -828.5Q303 -840 320 -840Q337 -840 348.5 -828.5Q360 -817 360 -800Q360 -783 348.5 -771.5Q337 -760 320 -760ZM480 -760Q463 -760 451.5 -771.5Q440 -783 440 -800Q440 -817 451.5 -828.5Q463 -840 480 -840Q497 -840 508.5 -828.5Q520 -817 520 -800Q520 -783 508.5 -771.5Q497 -760 480 -760ZM640 -760Q623 -760 611.5 -771.5Q600 -783 600 -800Q600 -817 611.5 -828.5Q623 -840 640 -840Q657 -840 668.5 -828.5Q680 -817 680 -800Q680 -783 668.5 -771.5Q657 -760 640 -760ZM800 -760Q783 -760 771.5 -771.5Q760 -783 760 -800Q760 -817 771.5 -828.5Q783 -840 800 -840Q817 -840 828.5 -828.5Q840 -817 840 -800Q840 -783 828.5 -771.5Q817 -760 800 -760ZM160 -600Q143 -600 131.5 -611.5Q120 -623 120 -640Q120 -657 131.5 -668.5Q143 -680 160 -680Q177 -680 188.5 -668.5Q200 -657 200 -640Q200 -623 188.5 -611.5Q177 -600 160 -600ZM800 -600Q783 -600 771.5 -611.5Q760 -623 760 -640Q760 -657 771.5 -668.5Q783 -680 800 -680Q817 -680 828.5 -668.5Q840 -657 840 -640Q840 -623 828.5 -611.5Q817 -600 800 -600ZM160 -440Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM800 -440Q783 -440 771.5 -451.5Q760 -463 760 -480Q760 -497 771.5 -508.5Q783 -520 800 -520Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM160 -280Q143 -280 131.5 -291.5Q120 -303 120 -320Q120 -337 131.5 -348.5Q143 -360 160 -360Q177 -360 188.5 -348.5Q200 -337 200 -320Q200 -303 188.5 -291.5Q177 -280 160 -280ZM800 -280Q783 -280 771.5 -291.5Q760 -303 760 -320Q760 -337 771.5 -348.5Q783 -360 800 -360Q817 -360 828.5 -348.5Q840 -337 840 -320Q840 -303 828.5 -291.5Q817 -280 800 -280ZM160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160Q120 -177 131.5 -188.5Q143 -200 160 -200Q177 -200 188.5 -188.5Q200 -177 200 -160Q200 -143 188.5 -131.5Q177 -120 160 -120ZM320 -120Q303 -120 291.5 -131.5Q280 -143 280 -160Q280 -177 291.5 -188.5Q303 -200 320 -200Q337 -200 348.5 -188.5Q360 -177 360 -160Q360 -143 348.5 -131.5Q337 -120 320 -120ZM480 -120Q463 -120 451.5 -131.5Q440 -143 440 -160Q440 -177 451.5 -188.5Q463 -200 480 -200Q497 -200 508.5 -188.5Q520 -177 520 -160Q520 -143 508.5 -131.5Q497 -120 480 -120ZM640 -120Q623 -120 611.5 -131.5Q600 -143 600 -160Q600 -177 611.5 -188.5Q623 -200 640 -200Q657 -200 668.5 -188.5Q680 -177 680 -160Q680 -143 668.5 -131.5Q657 -120 640 -120ZM800 -120Q783 -120 771.5 -131.5Q760 -143 760 -160Q760 -177 771.5 -188.5Q783 -200 800 -200Q817 -200 828.5 -188.5Q840 -177 840 -160Q840 -143 828.5 -131.5Q817 -120 800 -120ZM360 -280Q327 -280 303.5 -303.5Q280 -327 280 -360V-600Q280 -633 303.5 -656.5Q327 -680 360 -680H600Q633 -680 656.5 -656.5Q680 -633 680 -600V-360Q680 -327 656.5 -303.5Q633 -280 600 -280ZM360 -360H600Q600 -360 600 -360Q600 -360 600 -360V-600Q600 -600 600 -600Q600 -600 600 -600H360Q360 -600 360 -600Q360 -600 360 -600V-360Q360 -360 360 -360Q360 -360 360 -360Z"), + ("settings", "M433 -80Q406 -80 386.5 -98Q367 -116 363 -142L354 -208Q341 -213 329.5 -220Q318 -227 307 -235L245 -209Q220 -198 195 -207Q170 -216 156 -239L109 -321Q95 -344 101 -370Q107 -396 128 -413L181 -453Q180 -460 180 -466.5Q180 -473 180 -480Q180 -487 180 -493.5Q180 -500 181 -507L128 -547Q107 -564 101 -590Q95 -616 109 -639L156 -721Q170 -744 195 -753Q220 -762 245 -751L307 -725Q318 -733 330 -740Q342 -747 354 -752L363 -818Q367 -844 386.5 -862Q406 -880 433 -880H527Q554 -880 573.5 -862Q593 -844 597 -818L606 -752Q619 -747 630.5 -740Q642 -733 653 -725L715 -751Q740 -762 765 -753Q790 -744 804 -721L851 -639Q865 -616 859 -590Q853 -564 832 -547L779 -507Q780 -500 780 -493.5Q780 -487 780 -480Q780 -473 780 -466.5Q780 -460 778 -453L831 -413Q852 -396 858 -370Q864 -344 850 -321L802 -239Q788 -216 763 -207Q738 -198 713 -209L653 -235Q642 -227 630 -220Q618 -213 606 -208L597 -142Q593 -116 573.5 -98Q554 -80 527 -80ZM440 -160H519L533 -266Q564 -274 590.5 -289.5Q617 -305 639 -327L738 -286L777 -354L691 -419Q696 -433 698 -448.5Q700 -464 700 -480Q700 -496 698 -511.5Q696 -527 691 -541L777 -606L738 -674L639 -632Q617 -655 590.5 -670.5Q564 -686 533 -694L520 -800H441L427 -694Q396 -686 369.5 -670.5Q343 -655 321 -633L222 -674L183 -606L269 -542Q264 -527 262 -512Q260 -497 260 -480Q260 -464 262 -449Q264 -434 269 -419L183 -354L222 -286L321 -328Q343 -305 369.5 -289.5Q396 -274 427 -266ZM482 -340Q540 -340 581 -381Q622 -422 622 -480Q622 -538 581 -579Q540 -620 482 -620Q423 -620 382.5 -579Q342 -538 342 -480Q342 -422 382.5 -381Q423 -340 482 -340ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"), + ("settings_fill", "M433 -80Q406 -80 386.5 -98Q367 -116 363 -142L354 -208Q341 -213 329.5 -220Q318 -227 307 -235L245 -209Q220 -198 195 -207Q170 -216 156 -239L109 -321Q95 -344 101 -370Q107 -396 128 -413L181 -453Q180 -460 180 -466.5Q180 -473 180 -480Q180 -487 180 -493.5Q180 -500 181 -507L128 -547Q107 -564 101 -590Q95 -616 109 -639L156 -721Q170 -744 195 -753Q220 -762 245 -751L307 -725Q318 -733 330 -740Q342 -747 354 -752L363 -818Q367 -844 386.5 -862Q406 -880 433 -880H527Q554 -880 573.5 -862Q593 -844 597 -818L606 -752Q619 -747 630.5 -740Q642 -733 653 -725L715 -751Q740 -762 765 -753Q790 -744 804 -721L851 -639Q865 -616 859 -590Q853 -564 832 -547L779 -507Q780 -500 780 -493.5Q780 -487 780 -480Q780 -473 780 -466.5Q780 -460 778 -453L831 -413Q852 -396 858 -370Q864 -344 850 -321L802 -239Q788 -216 763 -207Q738 -198 713 -209L653 -235Q642 -227 630 -220Q618 -213 606 -208L597 -142Q593 -116 573.5 -98Q554 -80 527 -80ZM440 -160H519L533 -266Q564 -274 590.5 -289.5Q617 -305 639 -327L738 -286L777 -354L691 -419Q696 -433 698 -448.5Q700 -464 700 -480Q700 -496 698 -511.5Q696 -527 691 -541L777 -606L738 -674L639 -632Q617 -655 590.5 -670.5Q564 -686 533 -694L520 -800H441L427 -694Q396 -686 369.5 -670.5Q343 -655 321 -633L222 -674L183 -606L269 -542Q264 -527 262 -512Q260 -497 260 -480Q260 -464 262 -449Q264 -434 269 -419L183 -354L222 -286L321 -328Q343 -305 369.5 -289.5Q396 -274 427 -266ZM482 -340Q540 -340 581 -381Q622 -422 622 -480Q622 -538 581 -579Q540 -620 482 -620Q423 -620 382.5 -579Q342 -538 342 -480Q342 -422 382.5 -381Q423 -340 482 -340ZM440 -160 427 -266Q396 -274 369.5 -289.5Q343 -305 321 -328L222 -286L183 -354L269 -419Q264 -434 262 -449Q260 -464 260 -480Q260 -497 262 -512Q264 -527 269 -542L183 -606L222 -674L321 -633Q343 -655 369.5 -670.5Q396 -686 427 -694L441 -800H520L533 -694Q564 -686 590.5 -670.5Q617 -655 639 -632L738 -674L777 -606L691 -541Q696 -527 698 -511.5Q700 -496 700 -480Q700 -464 698 -448.5Q696 -433 691 -419L777 -354L738 -286L639 -327Q617 -305 590.5 -289.5Q564 -274 533 -266L519 -160Z"), + ("splitscreen", "M200 -520Q167 -520 143.5 -543.5Q120 -567 120 -600V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-600Q840 -567 816.5 -543.5Q793 -520 760 -520ZM200 -600H760Q760 -600 760 -600Q760 -600 760 -600V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-600Q200 -600 200 -600Q200 -600 200 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-360Q120 -393 143.5 -416.5Q167 -440 200 -440H760Q793 -440 816.5 -416.5Q840 -393 840 -360V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-360Q760 -360 760 -360Q760 -360 760 -360H200Q200 -360 200 -360Q200 -360 200 -360V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -600Q200 -600 200 -600Q200 -600 200 -600V-760Q200 -760 200 -760Q200 -760 200 -760Q200 -760 200 -760Q200 -760 200 -760V-600Q200 -600 200 -600Q200 -600 200 -600ZM200 -200Q200 -200 200 -200Q200 -200 200 -200V-360Q200 -360 200 -360Q200 -360 200 -360Q200 -360 200 -360Q200 -360 200 -360V-200Q200 -200 200 -200Q200 -200 200 -200Z"), + ("splitscreen_fill", "M200 -520Q167 -520 143.5 -543.5Q120 -567 120 -600V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-600Q840 -567 816.5 -543.5Q793 -520 760 -520ZM200 -600H760Q760 -600 760 -600Q760 -600 760 -600V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-600Q200 -600 200 -600Q200 -600 200 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-360Q120 -393 143.5 -416.5Q167 -440 200 -440H760Q793 -440 816.5 -416.5Q840 -393 840 -360V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-360Q760 -360 760 -360Q760 -360 760 -360H200Q200 -360 200 -360Q200 -360 200 -360V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -600Q200 -600 200 -600Q200 -600 200 -600V-760Q200 -760 200 -760Q200 -760 200 -760H760Q760 -760 760 -760Q760 -760 760 -760V-600Q760 -600 760 -600Q760 -600 760 -600ZM200 -200Q200 -200 200 -200Q200 -200 200 -200V-360Q200 -360 200 -360Q200 -360 200 -360H760Q760 -360 760 -360Q760 -360 760 -360V-200Q760 -200 760 -200Q760 -200 760 -200Z"), + ("splitscreen_right", "M600 -120Q567 -120 543.5 -143.5Q520 -167 520 -200V-760Q520 -793 543.5 -816.5Q567 -840 600 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H360Q393 -840 416.5 -816.5Q440 -793 440 -760V-200Q440 -167 416.5 -143.5Q393 -120 360 -120ZM200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H360Q360 -200 360 -200Q360 -200 360 -200V-760Q360 -760 360 -760Q360 -760 360 -760H200Q200 -760 200 -760Q200 -760 200 -760Z"), + ("stop", "M240 -320V-640Q240 -673 263.5 -696.5Q287 -720 320 -720H640Q673 -720 696.5 -696.5Q720 -673 720 -640V-320Q720 -287 696.5 -263.5Q673 -240 640 -240H320Q287 -240 263.5 -263.5Q240 -287 240 -320ZM320 -320H640Q640 -320 640 -320Q640 -320 640 -320V-640Q640 -640 640 -640Q640 -640 640 -640H320Q320 -640 320 -640Q320 -640 320 -640V-320Q320 -320 320 -320Q320 -320 320 -320ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"), + ("stop_fill", "M240 -320V-640Q240 -673 263.5 -696.5Q287 -720 320 -720H640Q673 -720 696.5 -696.5Q720 -673 720 -640V-320Q720 -287 696.5 -263.5Q673 -240 640 -240H320Q287 -240 263.5 -263.5Q240 -287 240 -320ZM320 -320H640Q640 -320 640 -320Q640 -320 640 -320V-640Q640 -640 640 -640Q640 -640 640 -640H320Q320 -640 320 -640Q320 -640 320 -640V-320Q320 -320 320 -320Q320 -320 320 -320ZM320 -320Q320 -320 320 -320Q320 -320 320 -320V-640Q320 -640 320 -640Q320 -640 320 -640H640Q640 -640 640 -640Q640 -640 640 -640V-320Q640 -320 640 -320Q640 -320 640 -320Z"), + ("swap_vert", "M320 -480V-727L245 -652Q234 -641 217.5 -641Q201 -641 189 -652Q177 -664 177 -680.5Q177 -697 189 -709L332 -852Q338 -858 345 -860.5Q352 -863 360 -863Q368 -863 375 -860.5Q382 -858 388 -852L532 -708Q544 -696 543.5 -680Q543 -664 531 -652Q519 -641 503 -640.5Q487 -640 475 -652L400 -727V-480Q400 -463 388.5 -451.5Q377 -440 360 -440Q343 -440 331.5 -451.5Q320 -463 320 -480ZM572 -108 428 -252Q416 -264 416.5 -280Q417 -296 429 -308Q441 -319 457 -319.5Q473 -320 485 -308L560 -233V-480Q560 -497 571.5 -508.5Q583 -520 600 -520Q617 -520 628.5 -508.5Q640 -497 640 -480V-233L715 -308Q726 -319 742.5 -319Q759 -319 771 -308Q783 -296 783 -279.5Q783 -263 771 -251L628 -108Q622 -102 615 -99.5Q608 -97 600 -97Q592 -97 585 -99.5Q578 -102 572 -108Z"), + ("sync", "M240 -478Q240 -433 257 -390.5Q274 -348 310 -312L320 -302V-360Q320 -377 331.5 -388.5Q343 -400 360 -400Q377 -400 388.5 -388.5Q400 -377 400 -360V-200Q400 -183 388.5 -171.5Q377 -160 360 -160H200Q183 -160 171.5 -171.5Q160 -183 160 -200Q160 -217 171.5 -228.5Q183 -240 200 -240H270L254 -254Q202 -300 181 -359Q160 -418 160 -478Q160 -572 208 -648.5Q256 -725 337 -766Q351 -774 366.5 -767Q382 -760 387 -744Q392 -729 386.5 -714Q381 -699 367 -691Q309 -659 274.5 -602.5Q240 -546 240 -478ZM720 -482Q720 -527 703 -569.5Q686 -612 650 -648L640 -658V-600Q640 -583 628.5 -571.5Q617 -560 600 -560Q583 -560 571.5 -571.5Q560 -583 560 -600V-760Q560 -777 571.5 -788.5Q583 -800 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760Q800 -743 788.5 -731.5Q777 -720 760 -720H690L706 -706Q755 -657 777.5 -599.5Q800 -542 800 -482Q800 -388 752 -311.5Q704 -235 623 -194Q609 -186 593.5 -193Q578 -200 573 -216Q568 -231 573.5 -246Q579 -261 593 -269Q651 -301 685.5 -357.5Q720 -414 720 -482Z"), + ("tab", "M160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-560H560Q543 -560 531.5 -571.5Q520 -583 520 -600V-720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"), + ("tab_fill", "M160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-560H560Q543 -560 531.5 -571.5Q520 -583 520 -600V-720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM800 -240Q800 -240 800 -240Q800 -240 800 -240V-720Q800 -720 800 -720Q800 -720 800 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"), + ("tag", "M360 -320 327 -189Q324 -176 314 -168Q304 -160 290 -160Q271 -160 259 -175Q247 -190 252 -208L280 -320H171Q151 -320 139 -335.5Q127 -351 132 -370Q135 -384 146 -392Q157 -400 171 -400H300L340 -560H231Q211 -560 199 -575.5Q187 -591 192 -610Q195 -624 206 -632Q217 -640 231 -640H360L393 -771Q396 -784 406 -792Q416 -800 430 -800Q449 -800 461 -785Q473 -770 468 -752L440 -640H600L633 -771Q636 -784 646 -792Q656 -800 670 -800Q689 -800 701 -785Q713 -770 708 -752L680 -640H789Q809 -640 821 -624.5Q833 -609 828 -590Q825 -576 814 -568Q803 -560 789 -560H660L620 -400H729Q749 -400 761 -384.5Q773 -369 768 -350Q765 -336 754 -328Q743 -320 729 -320H600L567 -189Q564 -176 554 -168Q544 -160 530 -160Q511 -160 499 -175Q487 -190 492 -208L520 -320ZM380 -400H540L580 -560H420Z"), + ("terminal", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640H160V-240Q160 -240 160 -240Q160 -240 160 -240ZM347 -440 271 -516Q259 -528 259.5 -544Q260 -560 272 -572Q284 -583 300 -583.5Q316 -584 328 -572L432 -468Q444 -456 444 -440Q444 -424 432 -412L328 -308Q317 -297 300.5 -296.5Q284 -296 272 -308Q261 -319 261 -336Q261 -353 272 -364ZM520 -280Q503 -280 491.5 -291.5Q480 -303 480 -320Q480 -337 491.5 -348.5Q503 -360 520 -360H680Q697 -360 708.5 -348.5Q720 -337 720 -320Q720 -303 708.5 -291.5Q697 -280 680 -280Z"), + ("text_fields", "M280 -220V-680H140Q115 -680 97.5 -697.5Q80 -715 80 -740Q80 -765 97.5 -782.5Q115 -800 140 -800H540Q565 -800 582.5 -782.5Q600 -765 600 -740Q600 -715 582.5 -697.5Q565 -680 540 -680H400V-220Q400 -195 382.5 -177.5Q365 -160 340 -160Q315 -160 297.5 -177.5Q280 -195 280 -220ZM640 -220V-480H580Q555 -480 537.5 -497.5Q520 -515 520 -540Q520 -565 537.5 -582.5Q555 -600 580 -600H820Q845 -600 862.5 -582.5Q880 -565 880 -540Q880 -515 862.5 -497.5Q845 -480 820 -480H760V-220Q760 -195 742.5 -177.5Q725 -160 700 -160Q675 -160 657.5 -177.5Q640 -195 640 -220Z"), + ("tune", "M440 -160V-320Q440 -337 451.5 -348.5Q463 -360 480 -360Q497 -360 508.5 -348.5Q520 -337 520 -320V-280H800Q817 -280 828.5 -268.5Q840 -257 840 -240Q840 -223 828.5 -211.5Q817 -200 800 -200H520V-160Q520 -143 508.5 -131.5Q497 -120 480 -120Q463 -120 451.5 -131.5Q440 -143 440 -160ZM160 -200Q143 -200 131.5 -211.5Q120 -223 120 -240Q120 -257 131.5 -268.5Q143 -280 160 -280H320Q337 -280 348.5 -268.5Q360 -257 360 -240Q360 -223 348.5 -211.5Q337 -200 320 -200ZM280 -400V-440H160Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520H280V-560Q280 -577 291.5 -588.5Q303 -600 320 -600Q337 -600 348.5 -588.5Q360 -577 360 -560V-400Q360 -383 348.5 -371.5Q337 -360 320 -360Q303 -360 291.5 -371.5Q280 -383 280 -400ZM480 -440Q463 -440 451.5 -451.5Q440 -463 440 -480Q440 -497 451.5 -508.5Q463 -520 480 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM600 -640V-800Q600 -817 611.5 -828.5Q623 -840 640 -840Q657 -840 668.5 -828.5Q680 -817 680 -800V-760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680H680V-640Q680 -623 668.5 -611.5Q657 -600 640 -600Q623 -600 611.5 -611.5Q600 -623 600 -640ZM160 -680Q143 -680 131.5 -691.5Q120 -703 120 -720Q120 -737 131.5 -748.5Q143 -760 160 -760H480Q497 -760 508.5 -748.5Q520 -737 520 -720Q520 -703 508.5 -691.5Q497 -680 480 -680Z"), + ("undo", "M320 -200Q303 -200 291.5 -211.5Q280 -223 280 -240Q280 -257 291.5 -268.5Q303 -280 320 -280H564Q627 -280 673.5 -320Q720 -360 720 -420Q720 -480 673.5 -520Q627 -560 564 -560H312L388 -484Q399 -473 399 -456Q399 -439 388 -428Q377 -417 360 -417Q343 -417 332 -428L188 -572Q182 -578 179.5 -585Q177 -592 177 -600Q177 -608 179.5 -615Q182 -622 188 -628L332 -772Q343 -783 360 -783Q377 -783 388 -772Q399 -761 399 -744Q399 -727 388 -716L312 -640H564Q661 -640 730.5 -577Q800 -514 800 -420Q800 -326 730.5 -263Q661 -200 564 -200Z"), + ("unfold_less", "M480 -284 384 -188Q373 -177 356 -177Q339 -177 328 -188Q317 -199 317 -216Q317 -233 328 -244L452 -368Q458 -374 465 -376.5Q472 -379 480 -379Q488 -379 495 -376.5Q502 -374 508 -368L632 -244Q643 -233 643 -216Q643 -199 632 -188Q621 -177 604 -177Q587 -177 576 -188ZM480 -676 576 -772Q587 -783 604 -783Q621 -783 632 -772Q643 -761 643 -744Q643 -727 632 -716L508 -592Q502 -586 495 -583.5Q488 -581 480 -581Q472 -581 465 -583.5Q458 -586 452 -592L328 -716Q317 -727 317 -744Q317 -761 328 -772Q339 -783 356 -783Q373 -783 384 -772Z"), + ("unfold_more", "M480 -236 573 -329Q585 -341 602 -341Q619 -341 631 -329Q643 -317 643 -300Q643 -283 631 -271L508 -148Q502 -142 495 -139.5Q488 -137 480 -137Q472 -137 465 -139.5Q458 -142 452 -148L329 -271Q317 -283 317 -300Q317 -317 329 -329Q341 -341 358 -341Q375 -341 387 -329ZM480 -720 387 -627Q375 -615 358 -615Q341 -615 329 -627Q317 -639 317 -656Q317 -673 329 -685L452 -808Q458 -814 465 -816.5Q472 -819 480 -819Q488 -819 495 -816.5Q502 -814 508 -808L631 -685Q643 -673 643 -656Q643 -639 631 -627Q619 -615 602 -615Q585 -615 573 -627Z"), + ("upload", "M240 -160Q207 -160 183.5 -183.5Q160 -207 160 -240V-320Q160 -337 171.5 -348.5Q183 -360 200 -360Q217 -360 228.5 -348.5Q240 -337 240 -320V-240Q240 -240 240 -240Q240 -240 240 -240H720Q720 -240 720 -240Q720 -240 720 -240V-320Q720 -337 731.5 -348.5Q743 -360 760 -360Q777 -360 788.5 -348.5Q800 -337 800 -320V-240Q800 -207 776.5 -183.5Q753 -160 720 -160ZM440 -646 365 -571Q353 -559 336.5 -559.5Q320 -560 308 -572Q297 -584 296.5 -600Q296 -616 308 -628L452 -772Q458 -778 465 -780.5Q472 -783 480 -783Q488 -783 495 -780.5Q502 -778 508 -772L652 -628Q664 -616 663.5 -600Q663 -584 652 -572Q640 -560 623.5 -559.5Q607 -559 595 -571L520 -646V-360Q520 -343 508.5 -331.5Q497 -320 480 -320Q463 -320 451.5 -331.5Q440 -343 440 -360Z"), + ("vertical_split", "M160 -360Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H400Q417 -440 428.5 -428.5Q440 -417 440 -400Q440 -383 428.5 -371.5Q417 -360 400 -360ZM160 -200Q143 -200 131.5 -211.5Q120 -223 120 -240Q120 -257 131.5 -268.5Q143 -280 160 -280H400Q417 -280 428.5 -268.5Q440 -257 440 -240Q440 -223 428.5 -211.5Q417 -200 400 -200ZM160 -520Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H400Q417 -600 428.5 -588.5Q440 -577 440 -560Q440 -543 428.5 -531.5Q417 -520 400 -520ZM160 -680Q143 -680 131.5 -691.5Q120 -703 120 -720Q120 -737 131.5 -748.5Q143 -760 160 -760H400Q417 -760 428.5 -748.5Q440 -737 440 -720Q440 -703 428.5 -691.5Q417 -680 400 -680ZM600 -200Q567 -200 543.5 -223.5Q520 -247 520 -280V-680Q520 -713 543.5 -736.5Q567 -760 600 -760H760Q793 -760 816.5 -736.5Q840 -713 840 -680V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM600 -280H760Q760 -280 760 -280Q760 -280 760 -280V-680Q760 -680 760 -680Q760 -680 760 -680H600Q600 -680 600 -680Q600 -680 600 -680V-280Q600 -280 600 -280Q600 -280 600 -280ZM680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Z"), + ("vertical_split_fill", "M160 -360Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H400Q417 -440 428.5 -428.5Q440 -417 440 -400Q440 -383 428.5 -371.5Q417 -360 400 -360ZM160 -200Q143 -200 131.5 -211.5Q120 -223 120 -240Q120 -257 131.5 -268.5Q143 -280 160 -280H400Q417 -280 428.5 -268.5Q440 -257 440 -240Q440 -223 428.5 -211.5Q417 -200 400 -200ZM160 -520Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H400Q417 -600 428.5 -588.5Q440 -577 440 -560Q440 -543 428.5 -531.5Q417 -520 400 -520ZM160 -680Q143 -680 131.5 -691.5Q120 -703 120 -720Q120 -737 131.5 -748.5Q143 -760 160 -760H400Q417 -760 428.5 -748.5Q440 -737 440 -720Q440 -703 428.5 -691.5Q417 -680 400 -680ZM600 -200Q567 -200 543.5 -223.5Q520 -247 520 -280V-680Q520 -713 543.5 -736.5Q567 -760 600 -760H760Q793 -760 816.5 -736.5Q840 -713 840 -680V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM600 -280H760Q760 -280 760 -280Q760 -280 760 -280V-680Q760 -680 760 -680Q760 -680 760 -680H600Q600 -680 600 -680Q600 -680 600 -680V-280Q600 -280 600 -280Q600 -280 600 -280ZM600 -280Q600 -280 600 -280Q600 -280 600 -280V-680Q600 -680 600 -680Q600 -680 600 -680H760Q760 -680 760 -680Q760 -680 760 -680V-280Q760 -280 760 -280Q760 -280 760 -280Z"), + ("view_sidebar", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM700 -613H800Q800 -613 800 -613Q800 -613 800 -613V-720Q800 -720 800 -720Q800 -720 800 -720H700Q700 -720 700 -720Q700 -720 700 -720V-613Q700 -613 700 -613Q700 -613 700 -613ZM700 -427H800Q800 -427 800 -427Q800 -427 800 -427V-533Q800 -533 800 -533Q800 -533 800 -533H700Q700 -533 700 -533Q700 -533 700 -533V-427Q700 -427 700 -427Q700 -427 700 -427ZM160 -240H620Q620 -240 620 -240Q620 -240 620 -240V-720Q620 -720 620 -720Q620 -720 620 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM700 -240H800Q800 -240 800 -240Q800 -240 800 -240V-347Q800 -347 800 -347Q800 -347 800 -347H700Q700 -347 700 -347Q700 -347 700 -347V-240Q700 -240 700 -240Q700 -240 700 -240Z"), + ("view_sidebar_fill", "M480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480ZM780 -640H820Q845 -640 862.5 -657.5Q880 -675 880 -700V-740Q880 -765 862.5 -782.5Q845 -800 820 -800H780Q755 -800 737.5 -782.5Q720 -765 720 -740V-700Q720 -675 737.5 -657.5Q755 -640 780 -640ZM780 -400H820Q845 -400 862.5 -417.5Q880 -435 880 -460V-500Q880 -525 862.5 -542.5Q845 -560 820 -560H780Q755 -560 737.5 -542.5Q720 -525 720 -500V-460Q720 -435 737.5 -417.5Q755 -400 780 -400ZM160 -160H560Q593 -160 616.5 -183.5Q640 -207 640 -240V-720Q640 -753 616.5 -776.5Q593 -800 560 -800H160Q127 -800 103.5 -776.5Q80 -753 80 -720V-240Q80 -207 103.5 -183.5Q127 -160 160 -160ZM780 -160H820Q845 -160 862.5 -177.5Q880 -195 880 -220V-260Q880 -285 862.5 -302.5Q845 -320 820 -320H780Q755 -320 737.5 -302.5Q720 -285 720 -260V-220Q720 -195 737.5 -177.5Q755 -160 780 -160Z"), + ("visibility", "M480 -320Q555 -320 607.5 -372.5Q660 -425 660 -500Q660 -575 607.5 -627.5Q555 -680 480 -680Q405 -680 352.5 -627.5Q300 -575 300 -500Q300 -425 352.5 -372.5Q405 -320 480 -320ZM480 -392Q435 -392 403.5 -423.5Q372 -455 372 -500Q372 -545 403.5 -576.5Q435 -608 480 -608Q525 -608 556.5 -576.5Q588 -545 588 -500Q588 -455 556.5 -423.5Q525 -392 480 -392ZM61 -462Q56 -471 53.5 -480.5Q51 -490 51 -500Q51 -510 53.5 -519.5Q56 -529 61 -538Q125 -656 235.5 -728Q346 -800 480 -800Q614 -800 724.5 -728Q835 -656 899 -538Q904 -529 906.5 -519.5Q909 -510 909 -500Q909 -490 906.5 -480.5Q904 -471 899 -462Q835 -344 724.5 -272Q614 -200 480 -200Q346 -200 235.5 -272Q125 -344 61 -462ZM480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500ZM832 -500Q782 -601 687.5 -660.5Q593 -720 480 -720Q367 -720 272.5 -660.5Q178 -601 128 -500Q178 -399 272.5 -339.5Q367 -280 480 -280Q593 -280 687.5 -339.5Q782 -399 832 -500Z"), + ("visibility_fill", "M480 -320Q555 -320 607.5 -372.5Q660 -425 660 -500Q660 -575 607.5 -627.5Q555 -680 480 -680Q405 -680 352.5 -627.5Q300 -575 300 -500Q300 -425 352.5 -372.5Q405 -320 480 -320ZM480 -392Q435 -392 403.5 -423.5Q372 -455 372 -500Q372 -545 403.5 -576.5Q435 -608 480 -608Q525 -608 556.5 -576.5Q588 -545 588 -500Q588 -455 556.5 -423.5Q525 -392 480 -392ZM61 -462Q56 -471 53.5 -480.5Q51 -490 51 -500Q51 -510 53.5 -519.5Q56 -529 61 -538Q125 -656 235.5 -728Q346 -800 480 -800Q614 -800 724.5 -728Q835 -656 899 -538Q904 -529 906.5 -519.5Q909 -510 909 -500Q909 -490 906.5 -480.5Q904 -471 899 -462Q835 -344 724.5 -272Q614 -200 480 -200Q346 -200 235.5 -272Q125 -344 61 -462ZM128 -500Q178 -601 272.5 -660.5Q367 -720 480 -720Q593 -720 687.5 -660.5Q782 -601 832 -500Q782 -399 687.5 -339.5Q593 -280 480 -280Q367 -280 272.5 -339.5Q178 -399 128 -500ZM832 -500Q782 -601 687.5 -660.5Q593 -720 480 -720Q367 -720 272.5 -660.5Q178 -601 128 -500Q178 -399 272.5 -339.5Q367 -280 480 -280Q593 -280 687.5 -339.5Q782 -399 832 -500Z"), + ("warning", "M109 -120Q98 -120 89 -125.5Q80 -131 75 -140Q70 -149 69.5 -159.5Q69 -170 75 -180L445 -820Q451 -830 460.5 -835Q470 -840 480 -840Q490 -840 499.5 -835Q509 -830 515 -820L885 -180Q891 -170 890.5 -159.5Q890 -149 885 -140Q880 -131 871 -125.5Q862 -120 851 -120ZM178 -200H782L480 -720ZM480 -240Q497 -240 508.5 -251.5Q520 -263 520 -280Q520 -297 508.5 -308.5Q497 -320 480 -320Q463 -320 451.5 -308.5Q440 -297 440 -280Q440 -263 451.5 -251.5Q463 -240 480 -240ZM520 -400V-520Q520 -537 508.5 -548.5Q497 -560 480 -560Q463 -560 451.5 -548.5Q440 -537 440 -520V-400Q440 -383 451.5 -371.5Q463 -360 480 -360Q497 -360 508.5 -371.5Q520 -383 520 -400ZM480 -460Z"), + ("warning_fill", "M109 -120Q98 -120 89 -125.5Q80 -131 75 -140Q70 -149 69.5 -159.5Q69 -170 75 -180L445 -820Q451 -830 460.5 -835Q470 -840 480 -840Q490 -840 499.5 -835Q509 -830 515 -820L885 -180Q891 -170 890.5 -159.5Q890 -149 885 -140Q880 -131 871 -125.5Q862 -120 851 -120ZM178 -200H782L480 -720ZM480 -240Q497 -240 508.5 -251.5Q520 -263 520 -280Q520 -297 508.5 -308.5Q497 -320 480 -320Q463 -320 451.5 -308.5Q440 -297 440 -280Q440 -263 451.5 -251.5Q463 -240 480 -240ZM520 -400V-520Q520 -537 508.5 -548.5Q497 -560 480 -560Q463 -560 451.5 -548.5Q440 -537 440 -520V-400Q440 -383 451.5 -371.5Q463 -360 480 -360Q497 -360 508.5 -371.5Q520 -383 520 -400ZM178 -200 480 -720 782 -200Z"), + ("wrap_text", "M200 -460Q183 -460 171.5 -471.5Q160 -483 160 -500Q160 -517 171.5 -528.5Q183 -540 200 -540H690Q753 -540 796.5 -496.5Q840 -453 840 -390Q840 -327 796.5 -283.5Q753 -240 690 -240H594L616 -218Q628 -206 627.5 -190Q627 -174 616 -162Q604 -150 587.5 -149.5Q571 -149 559 -161L468 -252Q462 -258 459.5 -265Q457 -272 457 -280Q457 -288 459.5 -295Q462 -302 468 -308L559 -399Q571 -411 587.5 -411Q604 -411 616 -399Q627 -387 627.5 -370.5Q628 -354 616 -342L594 -320H690Q719 -320 739.5 -340.5Q760 -361 760 -390Q760 -419 739.5 -439.5Q719 -460 690 -460ZM200 -240Q183 -240 171.5 -251.5Q160 -263 160 -280Q160 -297 171.5 -308.5Q183 -320 200 -320H320Q337 -320 348.5 -308.5Q360 -297 360 -280Q360 -263 348.5 -251.5Q337 -240 320 -240ZM200 -680Q183 -680 171.5 -691.5Q160 -703 160 -720Q160 -737 171.5 -748.5Q183 -760 200 -760H760Q777 -760 788.5 -748.5Q800 -737 800 -720Q800 -703 788.5 -691.5Q777 -680 760 -680Z"), +]; diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8f3e0d7 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,10 @@ +pub mod app; +pub mod config; +pub mod git; +pub mod icondata; +pub mod lsp; +pub mod motion; +pub mod syntax; +pub mod text; +pub mod theme; +pub mod ui; diff --git a/src/lsp.rs b/src/lsp.rs new file mode 100644 index 0000000..a511400 --- /dev/null +++ b/src/lsp.rs @@ -0,0 +1,293 @@ +//! A small Language Server Protocol client: diagnostics, completion, hover and go-to-definition. +//! One server runs per language, found on PATH; every message comes back through the app's channel. + +use serde_json::{json, Value}; +use std::collections::HashMap; +use std::io::{BufRead, BufReader, Read, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Child, ChildStdin, Command, Stdio}; +use std::sync::mpsc::Sender; + +#[derive(Clone, Debug, PartialEq)] +pub struct Diag { + pub line: usize, + pub col: usize, + pub end_col: usize, + pub severity: u8, + pub msg: String, +} + +#[derive(Clone, Debug)] +pub struct CompletionItem { + pub label: String, + pub insert: String, + pub detail: String, + pub kind: u8, +} + +pub enum LspEvent { + Diagnostics(PathBuf, Vec), + Completion(Vec), + Hover(String), + Definition(PathBuf, usize, usize), + Ready(String), +} + +/// The server to run for a Kate language name. +pub fn server_for(lang: &str) -> Option<(&'static str, &'static [&'static str], &'static str)> { + Some(match lang { + "Rust" => ("rust-analyzer", &[], "rust"), + "C" => ("clangd", &[], "c"), + "C++" | "ISO C++" => ("clangd", &[], "cpp"), + "Python" => ("pylsp", &[], "python"), + "Go" => ("gopls", &[], "go"), + "TypeScript" => ("typescript-language-server", &["--stdio"], "typescript"), + "JavaScript" => ("typescript-language-server", &["--stdio"], "javascript"), + "Bash" => ("bash-language-server", &["start"], "shellscript"), + "Lua" => ("lua-language-server", &[], "lua"), + _ => return None, + }) +} + +fn on_path(bin: &str) -> bool { + std::env::var_os("PATH").is_some_and(|p| std::env::split_paths(&p).any(|d| d.join(bin).is_file())) +} + +pub fn uri(p: &Path) -> String { + let mut s = String::from("file://"); + for b in p.to_string_lossy().bytes() { + if b.is_ascii_alphanumeric() || b"/-_.~".contains(&b) { s.push(b as char) } else { s.push_str(&format!("%{b:02X}")) } + } + s +} + +pub fn path_of(uri: &str) -> Option { + let raw = uri.strip_prefix("file://")?.as_bytes(); + let (mut out, mut i) = (vec![], 0); + while i < raw.len() { + if raw[i] == b'%' && i + 2 < raw.len() { + if let Ok(v) = u8::from_str_radix(&String::from_utf8_lossy(&raw[i + 1..i + 3]), 16) { + out.push(v); + i += 3; + continue; + } + } + out.push(raw[i]); + i += 1; + } + Some(PathBuf::from(String::from_utf8_lossy(&out).into_owned())) +} + +#[derive(Clone, Copy, PartialEq)] +enum Pending { Init, Completion, Hover, Definition } + +pub struct Client { + pub bin: String, + stdin: ChildStdin, + child: Child, + next: i64, + pending: HashMap, + ready: bool, + queue: Vec, +} + +impl Client { + /// Starts a server; replies arrive on `tx` wrapped by `wrap`. + pub fn start(bin: &str, args: &[&str], root: &Path, key: String, tx: Sender<(String, Value)>) -> Option { + if !on_path(bin) { + return None; + } + let mut child = Command::new(bin).args(args).current_dir(root).stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::null()).spawn().ok()?; + let stdin = child.stdin.take()?; + let stdout = child.stdout.take()?; + std::thread::spawn(move || { + let mut r = BufReader::new(stdout); + loop { + let mut len = 0usize; + loop { + let mut l = String::new(); + if r.read_line(&mut l).ok().filter(|n| *n > 0).is_none() { return } + let l = l.trim(); + if l.is_empty() { break } + if let Some(v) = l.strip_prefix("Content-Length:") { len = v.trim().parse().unwrap_or(0) } + } + let mut buf = vec![0; len]; + if r.read_exact(&mut buf).is_err() { return } + if let Ok(v) = serde_json::from_slice::(&buf) { + if tx.send((key.clone(), v)).is_err() { return } + } + } + }); + let mut c = Client { bin: bin.to_string(), stdin, child, next: 1, pending: HashMap::new(), ready: false, queue: vec![] }; + c.pending.insert(0, Pending::Init); + c.raw(&json!({"jsonrpc": "2.0", "id": 0, "method": "initialize", "params": { + "processId": std::process::id(), + "rootUri": uri(root), + "capabilities": {"textDocument": { + "publishDiagnostics": {}, + "completion": {"completionItem": {"snippetSupport": false}}, + "hover": {"contentFormat": ["plaintext", "markdown"]}, + "definition": {}, + "synchronization": {"didSave": true}, + }}, + }})); + Some(c) + } + + fn raw(&mut self, v: &Value) { + let body = v.to_string(); + let _ = write!(self.stdin, "Content-Length: {}\r\n\r\n{}", body.len(), body); + let _ = self.stdin.flush(); + } + + fn send(&mut self, v: Value) { + if self.ready { self.raw(&v) } else { self.queue.push(v) } + } + + pub fn notify(&mut self, method: &str, params: Value) { + self.send(json!({"jsonrpc": "2.0", "method": method, "params": params})); + } + + fn request(&mut self, method: &str, params: Value, kind: Pending) { + let id = self.next; + self.next += 1; + self.pending.insert(id, kind); + self.send(json!({"jsonrpc": "2.0", "id": id, "method": method, "params": params})); + } + + pub fn did_open(&mut self, path: &Path, lang: &str, version: i64, text: &str) { + self.notify("textDocument/didOpen", json!({"textDocument": {"uri": uri(path), "languageId": lang, "version": version, "text": text}})); + } + + pub fn did_change(&mut self, path: &Path, version: i64, text: &str) { + self.notify("textDocument/didChange", json!({"textDocument": {"uri": uri(path), "version": version}, "contentChanges": [{"text": text}]})); + } + + pub fn did_save(&mut self, path: &Path) { + self.notify("textDocument/didSave", json!({"textDocument": {"uri": uri(path)}})); + } + + fn at(path: &Path, line: usize, col: usize) -> Value { + json!({"textDocument": {"uri": uri(path)}, "position": {"line": line, "character": col}}) + } + + pub fn completion(&mut self, path: &Path, line: usize, col: usize) { + self.request("textDocument/completion", Self::at(path, line, col), Pending::Completion); + } + + pub fn hover(&mut self, path: &Path, line: usize, col: usize) { + self.request("textDocument/hover", Self::at(path, line, col), Pending::Hover); + } + + pub fn definition(&mut self, path: &Path, line: usize, col: usize) { + self.request("textDocument/definition", Self::at(path, line, col), Pending::Definition); + } + + /// Turns a raw server message into an event, answering anything that needs an answer. + pub fn handle(&mut self, v: Value) -> Option { + if let Some(id) = v.get("id").and_then(Value::as_i64) { + if v.get("method").is_some() { + // a request from the server: nothing here needs more than an empty reply + self.raw(&json!({"jsonrpc": "2.0", "id": id, "result": Value::Null})); + return None; + } + let kind = self.pending.remove(&id)?; + let res = v.get("result").cloned().unwrap_or(Value::Null); + return match kind { + Pending::Init => { + self.raw(&json!({"jsonrpc": "2.0", "method": "initialized", "params": {}})); + self.ready = true; + for m in std::mem::take(&mut self.queue) { self.raw(&m) } + Some(LspEvent::Ready(self.bin.clone())) + } + Pending::Completion => Some(LspEvent::Completion(parse_completion(&res))), + Pending::Hover => parse_hover(&res).map(LspEvent::Hover), + Pending::Definition => parse_definition(&res), + }; + } + if v.get("method").and_then(Value::as_str) == Some("textDocument/publishDiagnostics") { + let p = v.get("params")?; + let path = path_of(p.get("uri")?.as_str()?)?; + return Some(LspEvent::Diagnostics(path, parse_diags(p))); + } + None + } +} + +impl Drop for Client { + fn drop(&mut self) { + let _ = self.child.kill(); + let _ = self.child.wait(); + } +} + +pub fn parse_diags(p: &Value) -> Vec { + let Some(list) = p.get("diagnostics").and_then(Value::as_array) else { return vec![] }; + list.iter().filter_map(|d| { + let s = d.get("range")?.get("start")?; + let e = d.get("range")?.get("end")?; + Some(Diag { + line: s.get("line")?.as_u64()? as usize, + col: s.get("character")?.as_u64()? as usize, + end_col: e.get("character")?.as_u64()? as usize, + severity: d.get("severity").and_then(Value::as_u64).unwrap_or(1) as u8, + msg: d.get("message")?.as_str()?.to_string(), + }) + }).collect() +} + +pub fn parse_completion(res: &Value) -> Vec { + let items = res.get("items").or(Some(res)).and_then(Value::as_array); + items.map(|v| v.iter().take(200).filter_map(|i| { + let label = i.get("label")?.as_str()?.trim().to_string(); + let edit = i.get("textEdit").and_then(|t| t.get("newText")).and_then(Value::as_str); + let insert = edit.or(i.get("insertText").and_then(Value::as_str)).unwrap_or(&label).to_string(); + let detail = i.get("detail").and_then(Value::as_str).unwrap_or("").to_string(); + Some(CompletionItem { label, insert, detail, kind: i.get("kind").and_then(Value::as_u64).unwrap_or(1) as u8 }) + }).collect()).unwrap_or_default() +} + +pub fn parse_hover(res: &Value) -> Option { + let c = res.get("contents")?; + let t = match c { + Value::String(s) => s.clone(), + Value::Array(a) => a.iter().filter_map(|x| x.as_str().map(str::to_string).or_else(|| x.get("value")?.as_str().map(str::to_string))).collect::>().join("\n"), + v => v.get("value")?.as_str()?.to_string(), + }; + let t = t.trim(); + (!t.is_empty()).then(|| t.to_string()) +} + +pub fn parse_definition(res: &Value) -> Option { + let first = if res.is_array() { res.get(0)? } else { res }; + let uri = first.get("uri").or(first.get("targetUri"))?.as_str()?; + let r = first.get("range").or(first.get("targetSelectionRange"))?; + let s = r.get("start")?; + Some(LspEvent::Definition(path_of(uri)?, s.get("line")?.as_u64()? as usize, s.get("character")?.as_u64()? as usize)) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn uris_round_trip_with_spaces_and_unicode() { + let p = Path::new("/home/a b/caffè.rs"); + assert_eq!(path_of(&uri(p)).unwrap(), p); + } + + #[test] + fn parses_server_replies() { + let c = json!({"isIncomplete": false, "items": [{"label": " push", "textEdit": {"newText": "push"}, "detail": "fn", "kind": 2}]}); + let v = parse_completion(&c); + assert_eq!((v[0].label.as_str(), v[0].insert.as_str()), ("push", "push")); + assert_eq!(parse_hover(&json!({"contents": {"kind": "markdown", "value": "fn a()"}})).unwrap(), "fn a()"); + let d = parse_diags(&json!({"diagnostics": [{"range": {"start": {"line": 3, "character": 1}, "end": {"line": 3, "character": 4}}, "severity": 2, "message": "m"}]})); + assert_eq!(d[0].line, 3); + assert_eq!(d[0].severity, 2); + match parse_definition(&json!([{"uri": "file:///a.rs", "range": {"start": {"line": 1, "character": 2}, "end": {"line": 1, "character": 3}}}])) { + Some(LspEvent::Definition(p, 1, 2)) => assert_eq!(p, PathBuf::from("/a.rs")), + _ => panic!(), + } + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..21768ed --- /dev/null +++ b/src/main.rs @@ -0,0 +1,34 @@ +use damson::{app::App, config}; +use eframe::egui; + +fn app_icon() -> egui::IconData { + let size = 256u32; + let mut pm = resvg::tiny_skia::Pixmap::new(size, size).unwrap(); + if let Ok(tree) = resvg::usvg::Tree::from_str(include_str!("../assets/damson.svg"), &resvg::usvg::Options::default()) { + let s = size as f32 / tree.size().width(); + resvg::render(&tree, resvg::tiny_skia::Transform::from_scale(s, s), &mut pm.as_mut()); + } + let mut rgba = pm.take(); + for px in rgba.chunks_exact_mut(4) { + let a = px[3] as u32; + if a > 0 && a < 255 { + for c in &mut px[..3] { *c = ((*c as u32 * 255 + a / 2) / a).min(255) as u8 } + } + } + egui::IconData { rgba, width: size, height: size } +} + +fn main() -> eframe::Result { + let files: Vec = std::env::args().skip(1).filter(|a| !a.starts_with("--")).collect(); + let [w, h] = config::Settings::load().win; + let viewport = egui::ViewportBuilder::default() + .with_title(config::APP_NAME) + .with_app_id("damson") + .with_inner_size([w.max(800.0), h.max(520.0)]) + .with_min_inner_size([760.0, 480.0]) + .with_decorations(false) + .with_transparent(true) + .with_icon(std::sync::Arc::new(app_icon())); + let options = eframe::NativeOptions { viewport, multisampling: 4, ..Default::default() }; + eframe::run_native(config::APP_NAME, options, Box::new(move |cc| Ok(Box::new(App::new(cc, files))))) +} diff --git a/src/motion.rs b/src/motion.rs new file mode 100644 index 0000000..31c8a9d --- /dev/null +++ b/src/motion.rs @@ -0,0 +1,200 @@ +//! Spring physics for all motion. `spring(id, target, preset)` is the immediate-mode form: call it +//! each frame with where the value should be and it gives back where it is now. +//! The presets are Material 3 Expressive's spatial tokens. + +use std::cell::{Cell, RefCell}; +use std::collections::HashMap; + +#[derive(Clone, Copy, Debug)] +pub struct Preset { + pub stiffness: f32, + pub damping: f32, +} + +pub const FAST: Preset = Preset { stiffness: 1400.0, damping: 0.62 }; +pub const DEFAULT: Preset = Preset { stiffness: 700.0, damping: 0.68 }; +pub const SLOW: Preset = Preset { stiffness: 300.0, damping: 0.74 }; +/// For colours, opacity and anything else that shouldn't overshoot. +pub const EFFECT: Preset = Preset { stiffness: 900.0, damping: 1.0 }; + +thread_local! { + static BUSY: Cell = const { Cell::new(false) }; + static LEVEL: Cell = const { Cell::new(2) }; + static DT: Cell = const { Cell::new(1.0 / 60.0) }; + static MAP: RefCell> = RefCell::new(HashMap::new()); +} + +struct Slot { + s: Spring, + frame: u64, +} + +thread_local! { + static FRAME: Cell = const { Cell::new(0) }; +} + +/// Starts a frame; `level` is the Settings motion choice. +pub fn begin_frame(dt: f32, level: u8) { + DT.with(|d| d.set(dt.clamp(0.001, 0.05))); + LEVEL.with(|l| l.set(level)); + BUSY.with(|b| b.set(false)); + FRAME.with(|f| f.set(f.get() + 1)); +} + +/// Did anything move this frame? If so the next frame must be drawn. +pub fn busy() -> bool { + BUSY.with(|b| b.get()) +} + +pub fn keep_alive() { + BUSY.with(|b| b.set(true)); +} + +pub fn dt() -> f32 { + DT.with(|d| d.get()) +} + +fn adjusted(p: Preset) -> Preset { + match LEVEL.with(|l| l.get()) { + 1 => Preset { stiffness: p.stiffness, damping: p.damping.max(1.0) }, + 3 => Preset { stiffness: p.stiffness * 0.8, damping: (p.damping * 0.62).min(1.0) }, + _ => p, + } +} + +#[derive(Clone, Copy, Debug)] +pub struct Spring { + pub x: f32, + pub v: f32, + pub target: f32, +} + +impl Spring { + pub fn new(x: f32) -> Spring { + Spring { x, v: 0.0, target: x } + } + + pub fn settled(&self) -> bool { + self.x == self.target + } + + pub fn snap(&mut self, x: f32) { + *self = Spring::new(x); + } + + /// Advances one frame, returning the new value. + pub fn step(&mut self, p: Preset) -> f32 { + if self.settled() { + return self.x; + } + if LEVEL.with(|l| l.get()) == 0 { + self.snap(self.target); + return self.x; + } + let p = adjusted(p); + let w = p.stiffness.sqrt(); + let c = 2.0 * p.damping * w; + let range = (self.target - self.x).abs().max(1.0); + let mut left = dt(); + while left > 0.0 { + let h = left.min(0.002); + let a = -p.stiffness * (self.x - self.target) - c * self.v; + self.v += a * h; + self.x += self.v * h; + left -= h; + } + if (self.x - self.target).abs() < 0.002 * range.min(50.0) && self.v.abs() < 0.05 * range.min(50.0) { + self.snap(self.target); + } else { + keep_alive(); + } + self.x + } +} + +/// The value of the spring called `id`, heading for `target`. +pub fn spring(id: impl AsRef, target: f32, p: Preset) -> f32 { + let frame = FRAME.with(|f| f.get()); + MAP.with(|m| { + let mut m = m.borrow_mut(); + if let Some(slot) = m.get_mut(id.as_ref()) { + slot.s.target = target; + if slot.frame != frame { + slot.frame = frame; + slot.s.step(p); + } + slot.s.x + } else { + m.insert(id.as_ref().to_string(), Slot { s: Spring::new(target), frame }); + target + } + }) +} + +/// Like `spring`, but a new id starts at `from` so the value animates in. +pub fn spring_from(id: impl AsRef, from: f32, target: f32, p: Preset) -> f32 { + let frame = FRAME.with(|f| f.get()); + MAP.with(|m| { + m.borrow_mut().entry(id.as_ref().to_string()).or_insert_with(|| Slot { s: Spring::new(from), frame: frame.saturating_sub(1) }); + }); + spring(id, target, p) +} + +/// Gives a spring a shove, for hits like a keypress or save. +pub fn kick(id: impl AsRef, velocity: f32) { + MAP.with(|m| { + if let Some(s) = m.borrow_mut().get_mut(id.as_ref()) { + s.s.v += velocity; + s.s.x += 0.0001; + } + }); +} + +/// Forgets a spring, so the next use starts fresh. +pub fn forget(id: impl AsRef) { + MAP.with(|m| { m.borrow_mut().remove(id.as_ref()); }); +} + +/// Eased 0..1 for staggered lists: `t` seconds since the start, `delay` for this item. +pub fn stagger(t: f32, delay: f32, dur: f32) -> f32 { + if LEVEL.with(|l| l.get()) == 0 { + return 1.0; + } + let x = ((t - delay) / dur).clamp(0.0, 1.0); + let c = 1.70158; + 1.0 + (c + 1.0) * (x - 1.0).powi(3) + c * (x - 1.0).powi(2) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn spring_overshoots_then_settles() { + begin_frame(1.0 / 60.0, 2); + let mut s = Spring::new(0.0); + s.target = 100.0; + let mut peak: f32 = 0.0; + for _ in 0..240 { + begin_frame(1.0 / 60.0, 2); + peak = peak.max(s.step(DEFAULT)); + } + assert!(peak > 100.5, "bouncy spring should overshoot, peak {peak}"); + assert!(s.settled()); + assert_eq!(s.x, 100.0); + } + + #[test] + fn calm_never_overshoots_and_off_snaps() { + let mut s = Spring::new(0.0); + s.target = 100.0; + for _ in 0..240 { + begin_frame(1.0 / 60.0, 1); + assert!(s.step(DEFAULT) <= 100.0); + } + let mut s = Spring::new(0.0); + s.target = 5.0; + begin_frame(1.0 / 60.0, 0); + assert_eq!(s.step(DEFAULT), 5.0); + } +} diff --git a/src/syntax/def.rs b/src/syntax/def.rs new file mode 100644 index 0000000..66a173b --- /dev/null +++ b/src/syntax/def.rs @@ -0,0 +1,237 @@ +//! Compiled form of a Kate syntax definition. All definitions live in one `Compiled` arena, because +//! rules include contexts from other definitions (`##Doxygen`, `##Comments`, …). + +use fancy_regex::Regex; +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; + +pub type StyleId = u16; +pub type CtxId = u32; + +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] +pub enum DefStyle { + Normal, Keyword, Function, Variable, ControlFlow, Operator, BuiltIn, Extension, Preprocessor, + Attribute, Char, SpecialChar, String, VerbatimString, SpecialString, Import, DataType, DecVal, + BaseN, Float, Constant, Comment, Documentation, Annotation, CommentVar, RegionMarker, + Information, Warning, Alert, Others, Error, +} + +impl DefStyle { + pub fn parse(s: &str) -> DefStyle { + use DefStyle::*; + match s.trim_start_matches("ds").to_ascii_lowercase().as_str() { + "keyword" => Keyword, "function" => Function, "variable" => Variable, + "controlflow" => ControlFlow, "operator" => Operator, "builtin" => BuiltIn, + "extension" => Extension, "preprocessor" => Preprocessor, "attribute" => Attribute, + "char" => Char, "specialchar" => SpecialChar, "string" => String, + "verbatimstring" => VerbatimString, "specialstring" => SpecialString, "import" => Import, + "datatype" => DataType, "decval" => DecVal, "basen" => BaseN, "float" => Float, + "constant" => Constant, "comment" => Comment, "documentation" => Documentation, + "annotation" => Annotation, "commentvar" => CommentVar, "regionmarker" => RegionMarker, + "information" => Information, "warning" => Warning, "alert" => Alert, "others" => Others, + "error" => Error, _ => Normal, + } + } + + /// The name Kate's `.theme` files use for this style. + pub fn theme_key(self) -> &'static str { + use DefStyle::*; + match self { + Normal => "Normal", Keyword => "Keyword", Function => "Function", Variable => "Variable", + ControlFlow => "ControlFlow", Operator => "Operator", BuiltIn => "BuiltIn", + Extension => "Extension", Preprocessor => "Preprocessor", Attribute => "Attribute", + Char => "Char", SpecialChar => "SpecialChar", String => "String", + VerbatimString => "VerbatimString", SpecialString => "SpecialString", Import => "Import", + DataType => "DataType", DecVal => "DecVal", BaseN => "BaseN", Float => "Float", + Constant => "Constant", Comment => "Comment", Documentation => "Documentation", + Annotation => "Annotation", CommentVar => "CommentVar", RegionMarker => "RegionMarker", + Information => "Information", Warning => "Warning", Alert => "Alert", Others => "Others", + Error => "Error", + } + } + + pub const ALL: [DefStyle; 31] = { + use DefStyle::*; + [Normal, Keyword, Function, Variable, ControlFlow, Operator, BuiltIn, Extension, Preprocessor, + Attribute, Char, SpecialChar, String, VerbatimString, SpecialString, Import, DataType, DecVal, + BaseN, Float, Constant, Comment, Documentation, Annotation, CommentVar, RegionMarker, + Information, Warning, Alert, Others, Error] + }; +} + +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct StyleInfo { + pub base: DefStyle, + pub bold: Option, + pub italic: Option, + pub underline: bool, +} + +/// What a rule (or a line end) does to the context stack. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct Switch { + pub pops: u8, + pub push: Option, +} + +impl Switch { + pub fn is_stay(&self) -> bool { + self.pops == 0 && self.push.is_none() + } +} + +pub enum Matcher { + DetectChar { c: char, dyn_idx: Option }, + Detect2Chars { a: char, b: char }, + AnyChar(Vec), + StringDetect { s: String, ci: bool, dynamic: bool }, + WordDetect { s: String, ci: bool }, + Regex { re: Option>, source: String, ci: bool, minimal: bool, dynamic: bool }, + Keyword { list: Arc, ci: bool }, + Int, Float, HlCOct, HlCHex, HlCStringChar, HlCChar, + RangeDetect { a: char, b: char }, + LineContinue { c: char }, + DetectSpaces, + DetectIdentifier, +} + +#[derive(Default)] +pub struct KeywordList { + pub cased: HashSet, + pub folded: HashSet, +} + +pub struct Rule { + pub matcher: Matcher, + pub style: Option, + pub switch: Switch, + pub look_ahead: bool, + pub first_non_space: bool, + pub column: Option, + pub begin_region: Option, + pub end_region: Option, + /// Bit set of the ASCII word delimiters of the owning definition. + pub delims: Arc, +} + +pub struct Delims(pub [bool; 128]); + +impl Delims { + pub fn new(weak: &str, extra: &str) -> Delims { + let mut d = [false; 128]; + for c in " \t.():!+,-<=>%&*/;?[]^{|}~\\".chars().chain(extra.chars()) { + if (c as usize) < 128 { + d[c as usize] = true; + } + } + for c in weak.chars() { + if (c as usize) < 128 { + d[c as usize] = false; + } + } + Delims(d) + } + + #[inline] + pub fn is(&self, c: u8) -> bool { + c < 128 && self.0[c as usize] + } +} + +pub struct Context { + pub style: StyleId, + pub rules: Vec, + pub line_end: Switch, + pub line_empty: Option, + pub fallthrough: Option, + pub dynamic: bool, +} + +/// Comment syntax and folding mode from a definition's `` block. +#[derive(Clone, Default, Debug)] +pub struct DefMeta { + pub line_comment: Option, + pub block_comment: Option<(String, String)>, + pub indent_fold: bool, +} + +#[derive(Default)] +pub struct Compiled { + pub contexts: Vec, + pub styles: Vec, + pub regions: HashMap, + pub bad_regexes: Vec<(String, String)>, +} + +/// Rewrites the PCRE syntax the regex crates don't take; returns the pattern to compile. +pub fn translate_regex(src: &str, ci: bool, minimal: bool) -> String { + let mut out = String::with_capacity(src.len() + 8); + if ci || minimal { + out.push_str("(?"); + if ci { out.push('i') } + if minimal { out.push('U') } + out.push(')'); + } + let cs: Vec = src.chars().collect(); + let (mut i, mut in_class) = (0, false); + while i < cs.len() { + let c = cs[i]; + if c == '\\' && i + 1 < cs.len() { + match cs[i + 1] { + 'h' => out.push_str(if in_class { " \\t" } else { "[ \\t]" }), + 'H' if !in_class => out.push_str("[^ \\t]"), + // a literal character the regex crate refuses to see escaped + '<' | '>' | '"' | '\'' | '`' | '=' | '!' | '%' | ';' | ':' | ',' | '@' | '/' | '_' => out.push(cs[i + 1]), + n => { out.push('\\'); out.push(n) } + } + i += 2; + continue; + } + if in_class { + if c == '[' && cs.get(i + 1) == Some(&':') { + out.push('['); + } else if c == '[' { + out.push_str("\\["); + } else { + if c == ']' { in_class = false } + out.push(c); + } + if c == '[' && cs.get(i + 1) == Some(&':') { + // copy a POSIX class whole so its closing bracket doesn't end the set + i += 1; + while i < cs.len() { + out.push(cs[i]); + if cs[i] == ']' { break } + i += 1; + } + } + i += 1; + continue; + } + match c { + '[' => { + in_class = true; + out.push('['); + if cs.get(i + 1) == Some(&'^') { out.push('^'); i += 1 } + if cs.get(i + 1) == Some(&']') { out.push_str("\\]"); i += 1 } + } + '(' if cs.get(i + 1) == Some(&'?') && cs.get(i + 2) == Some(&'#') => { + while i < cs.len() && cs[i] != ')' { i += 1 } + } + '(' if cs.get(i + 1) == Some(&'?') && cs.get(i + 2) == Some(&'|') => { + out.push_str("(?:"); + i += 2; + } + _ => out.push(c), + } + i += 1; + } + out +} + +pub fn compile_regex(src: &str, ci: bool, minimal: bool) -> Result { + fancy_regex::RegexBuilder::new(&translate_regex(src, ci, minimal)) + .backtrack_limit(20_000) + .build() + .map_err(|e| e.to_string()) +} diff --git a/src/syntax/engine.rs b/src/syntax/engine.rs new file mode 100644 index 0000000..2a6dd97 --- /dev/null +++ b/src/syntax/engine.rs @@ -0,0 +1,440 @@ +//! Walks one line through the compiled contexts, following the rules KSyntaxHighlighting uses. + +use super::def::*; +use std::collections::HashMap; +use std::sync::Arc; + +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct Frame { + pub ctx: CtxId, + pub captures: Option>>, +} + +/// The context stack at the end of a line. Equal states mean later lines need no re-highlighting. +#[derive(Clone, PartialEq, Eq, Debug, Default)] +pub struct State { + pub stack: Vec, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Span { + pub start: u32, + pub end: u32, + pub style: StyleId, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum FoldEvent { + Begin(u32), + End(u32), +} + +#[derive(Clone, Debug, Default, PartialEq)] +pub struct LineResult { + pub spans: Vec, + pub folds: Vec<(u32, FoldEvent)>, +} + +fn word_at(line: &[u8], at: usize, d: &Delims) -> bool { + at == 0 || d.is(line[at - 1]) +} + +fn word_end(line: &[u8], at: usize, d: &Delims) -> bool { + at >= line.len() || d.is(line[at]) +} + +fn char_at(text: &str, at: usize) -> Option { + text.get(at..)?.chars().next() +} + +fn starts_with_ci(hay: &str, needle: &str) -> Option { + let (mut h, mut n) = (hay.chars(), needle.chars()); + let mut used = 0; + loop { + let Some(nc) = n.next() else { return Some(used) }; + let hc = h.next()?; + if !hc.to_lowercase().eq(nc.to_lowercase()) { + return None; + } + used += hc.len_utf8(); + } +} + +fn is_ident_start(c: u8) -> bool { + c.is_ascii_alphabetic() || c == b'_' || c >= 128 +} + +fn is_ident(c: u8) -> bool { + c.is_ascii_alphanumeric() || c == b'_' || c >= 128 +} + +fn c_escape(l: &[u8], at: usize) -> Option { + if l.get(at) != Some(&b'\\') { + return None; + } + let n = *l.get(at + 1)?; + Some(match n { + b'a' | b'b' | b'e' | b'f' | b'n' | b'r' | b't' | b'v' | b'\'' | b'"' | b'\\' | b'?' => at + 2, + b'x' => { + let mut i = at + 2; + while i < l.len() && i < at + 4 && l[i].is_ascii_hexdigit() { i += 1 } + if i == at + 2 { return None } + i + } + b'0'..=b'7' => { + let mut i = at + 1; + while i < l.len() && i < at + 4 && (b'0'..=b'7').contains(&l[i]) { i += 1 } + i + } + _ => return None, + }) +} + +fn match_float(l: &[u8], at: usize, d: &Delims) -> Option { + if !word_at(l, at, d) { + return None; + } + let mut i = at; + let digits_a = { let s = i; while i < l.len() && l[i].is_ascii_digit() { i += 1 } i - s }; + let mut dot = false; + let mut digits_b = 0; + if l.get(i) == Some(&b'.') { + dot = true; + i += 1; + let s = i; + while i < l.len() && l[i].is_ascii_digit() { i += 1 } + digits_b = i - s; + } + if digits_a + digits_b == 0 { + return None; + } + let mut exp = false; + if matches!(l.get(i), Some(b'e' | b'E')) { + let mut j = i + 1; + if matches!(l.get(j), Some(b'+' | b'-')) { j += 1 } + let s = j; + while j < l.len() && l[j].is_ascii_digit() { j += 1 } + if j > s { + exp = true; + i = j; + } + } + (dot || exp).then_some(i) +} + +/// Per-line memo of where each regex rule next matches, so a miss is only searched for once. +#[derive(Default)] +struct RegexMemo { + next: HashMap<*const Rule, Option<(usize, usize, Arc>)>>, +} + +pub struct Highlighter<'a> { + pub c: &'a Compiled, + dyn_cache: HashMap>>, +} + +impl<'a> Highlighter<'a> { + pub fn new(c: &'a Compiled) -> Self { + Highlighter { c, dyn_cache: HashMap::new() } + } + + fn apply(&self, st: &mut State, sw: Switch, caps: Option>>) { + for _ in 0..sw.pops { + if st.stack.len() > 1 { + st.stack.pop(); + } + } + if let Some(p) = sw.push { + let keep = self.c.contexts[p as usize].dynamic; + st.stack.push(Frame { ctx: p, captures: if keep { caps } else { None } }); + } + } + + pub fn initial(root: CtxId) -> State { + State { stack: vec![Frame { ctx: root, captures: None }] } + } + + fn try_rule(&mut self, r: &Rule, text: &str, at: usize, first: usize, caps: &Option>>, memo: &mut RegexMemo) -> Option<(usize, Option>>)> { + if r.first_non_space && at != first { + return None; + } + if let Some(col) = r.column { + if col != at { + return None; + } + } + let l = text.as_bytes(); + let d = &*r.delims; + let end = match &r.matcher { + Matcher::DetectChar { c, dyn_idx } => { + let want = match dyn_idx { + Some(i) => caps.as_ref().and_then(|v| v.get(*i)).and_then(|s| s.chars().next())?, + None => *c, + }; + let h = char_at(text, at)?; + (h == want).then(|| at + h.len_utf8())? + } + Matcher::Detect2Chars { a, b } => { + let mut it = text[at..].chars(); + let (x, y) = (it.next()?, it.next()?); + (x == *a && y == *b).then(|| at + x.len_utf8() + y.len_utf8())? + } + Matcher::AnyChar(set) => { + let h = char_at(text, at)?; + set.contains(&h).then(|| at + h.len_utf8())? + } + Matcher::StringDetect { s, ci, dynamic } => { + let owned; + let needle: &str = if *dynamic { + owned = substitute(s, caps, false); + &owned + } else { + s + }; + if needle.is_empty() { + return None; + } + if *ci { + at + starts_with_ci(&text[at..], needle)? + } else { + text[at..].starts_with(needle).then(|| at + needle.len())? + } + } + Matcher::WordDetect { s, ci } => { + if !word_at(l, at, d) { + return None; + } + let e = if *ci { at + starts_with_ci(&text[at..], s)? } else { text[at..].starts_with(s.as_str()).then(|| at + s.len())? }; + if !word_end(l, e, d) { + return None; + } + e + } + Matcher::Keyword { list, ci } => { + if !word_at(l, at, d) { + return None; + } + let mut e = at; + while e < l.len() && !d.is(l[e]) { e += 1 } + if e == at { + return None; + } + let w = &text[at..e]; + let hit = if *ci { list.folded.contains(&w.to_lowercase()) } else { list.cased.contains(w) }; + if !hit { + return None; + } + e + } + Matcher::Int => { + if !word_at(l, at, d) { + return None; + } + let mut e = at; + while e < l.len() && l[e].is_ascii_digit() { e += 1 } + if e == at { + return None; + } + e + } + Matcher::Float => match_float(l, at, d)?, + Matcher::HlCOct => { + if !word_at(l, at, d) || l.get(at) != Some(&b'0') { + return None; + } + let mut e = at + 1; + while e < l.len() && (b'0'..=b'7').contains(&l[e]) { e += 1 } + if e == at + 1 { + return None; + } + e + } + Matcher::HlCHex => { + if !word_at(l, at, d) || l.get(at) != Some(&b'0') || !matches!(l.get(at + 1), Some(b'x' | b'X')) { + return None; + } + let mut e = at + 2; + while e < l.len() && l[e].is_ascii_hexdigit() { e += 1 } + if e == at + 2 { + return None; + } + e + } + Matcher::HlCStringChar => c_escape(l, at)?, + Matcher::HlCChar => { + if l.get(at) != Some(&b'\'') { + return None; + } + let inner = if l.get(at + 1) == Some(&b'\\') { c_escape(l, at + 1)? } else { at + 1 + char_at(text, at + 1).filter(|c| *c != '\'')?.len_utf8() }; + if l.get(inner) != Some(&b'\'') { + return None; + } + inner + 1 + } + Matcher::RangeDetect { a, b } => { + if char_at(text, at)? != *a { + return None; + } + let start = at + a.len_utf8(); + start + text[start..].find(*b)? + b.len_utf8() + } + Matcher::LineContinue { c } => { + let h = char_at(text, at)?; + (h == *c && at + h.len_utf8() == text.len()).then_some(text.len())? + } + Matcher::DetectSpaces => { + let mut e = at; + while e < l.len() && (l[e] == b' ' || l[e] == b'\t') { e += 1 } + if e == at { + return None; + } + e + } + Matcher::DetectIdentifier => { + if !is_ident_start(*l.get(at)?) { + return None; + } + let mut e = at + 1; + while e < l.len() && is_ident(l[e]) { e += 1 } + e + } + Matcher::Regex { re, source, ci, minimal, dynamic } => { + let re: Arc = if *dynamic { + let pat = substitute(source, caps, true); + self.dyn_cache + .entry(format!("{}{}{pat}", *ci as u8, *minimal as u8)) + .or_insert_with(|| compile_regex(&pat, *ci, *minimal).ok().map(Arc::new)) + .clone()? + } else { + re.clone()? + }; + let key = r as *const Rule; + if let Some(entry) = memo.next.get(&key) { + match entry { + None => return None, + Some((s, e, c)) if *s >= at => { + return (*s == at && *e > at).then(|| (*e, Some(c.clone()))); + } + _ => {} + } + } + let found = re.captures_from_pos(text, at).ok().flatten(); + let Some(m) = found else { + memo.next.insert(key, None); + return None; + }; + let whole = m.get(0)?; + let v: Vec = (0..m.len()).map(|i| m.get(i).map(|x| x.as_str().to_string()).unwrap_or_default()).collect(); + let v = Arc::new(v); + memo.next.insert(key, Some((whole.start(), whole.end(), v.clone()))); + if whole.start() != at || whole.end() == at { + return None; + } + return Some((whole.end(), Some(v))); + } + }; + Some((end, None)) + } + + /// Highlights `text` (no line break), moving `st` to the state at the end of the line. + pub fn line(&mut self, text: &str, st: &mut State) -> LineResult { + let mut out = LineResult::default(); + let c = self.c; + if st.stack.is_empty() { + return out; + } + let first = text.len() - text.trim_start_matches([' ', '\t']).len(); + let mut memo = RegexMemo::default(); + let mut at = 0usize; + let mut continued = false; + // lookahead and fallthrough switches consume nothing; this bounds a definition that loops + let mut idle = 0; + + if text.is_empty() { + let mut guard = 0; + loop { + let top = st.stack.last().unwrap().ctx as usize; + let Some(sw) = c.contexts[top].line_empty.or(Some(c.contexts[top].line_end)) else { break }; + if sw.is_stay() || guard > 32 { break } + self.apply(st, sw, None); + guard += 1; + if c.contexts[top].line_empty.is_some() { break } + } + return out; + } + + 'outer: while at < text.len() { + let top = st.stack.last().unwrap().clone(); + let ctx = &c.contexts[top.ctx as usize]; + for r in &ctx.rules { + let Some((end, caps)) = self.try_rule(r, text, at, first, &top.captures, &mut memo) else { continue }; + if let Some(id) = r.end_region { out.folds.push((at as u32, FoldEvent::End(id))) } + if let Some(id) = r.begin_region { out.folds.push((at as u32, FoldEvent::Begin(id))) } + if r.look_ahead { + if r.switch.is_stay() { continue } + self.apply(st, r.switch, caps); + idle += 1; + if idle > 64 { break } + continue 'outer; + } + self.apply(st, r.switch, caps); + let style = r.style.unwrap_or_else(|| c.contexts[st.stack.last().unwrap().ctx as usize].style); + push(&mut out.spans, at, end, style); + continued = matches!(r.matcher, Matcher::LineContinue { .. }); + at = end; + idle = 0; + continue 'outer; + } + if let Some(sw) = ctx.fallthrough { + if idle <= 64 { + self.apply(st, sw, None); + idle += 1; + continue; + } + } + let w = char_at(text, at).map_or(1, |x| x.len_utf8()); + push(&mut out.spans, at, at + w, ctx.style); + at += w; + continued = false; + idle = 0; + } + if !continued { + let mut guard = 0; + loop { + let sw = c.contexts[st.stack.last().unwrap().ctx as usize].line_end; + if sw.is_stay() || guard > 32 { break } + self.apply(st, sw, None); + guard += 1; + } + } + out + } +} + +fn push(v: &mut Vec, a: usize, b: usize, style: StyleId) { + if let Some(l) = v.last_mut() { + if l.style == style && l.end as usize == a { + l.end = b as u32; + return; + } + } + v.push(Span { start: a as u32, end: b as u32, style }); +} + +fn substitute(s: &str, caps: &Option>>, for_regex: bool) -> String { + let mut out = String::with_capacity(s.len()); + let cs: Vec = s.chars().collect(); + let mut i = 0; + while i < cs.len() { + if cs[i] == '%' && cs.get(i + 1).is_some_and(|c| c.is_ascii_digit()) { + let n = cs[i + 1].to_digit(10).unwrap() as usize; + let v = caps.as_ref().and_then(|c| c.get(n)).map(String::as_str).unwrap_or(""); + if for_regex { out.push_str(&fancy_regex::escape(v)) } else { out.push_str(v) } + i += 2; + } else { + out.push(cs[i]); + i += 1; + } + } + out +} diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs new file mode 100644 index 0000000..42f05e7 --- /dev/null +++ b/src/syntax/mod.rs @@ -0,0 +1,12 @@ +//! Runs Kate's own syntax definitions (the KSyntaxHighlighting XML format). +//! +//! `def` reads the XML into compiled contexts and rules, `engine` walks a line through them, and +//! `registry` finds definitions on disk and picks one for a file. + +pub mod def; +pub mod engine; +pub mod registry; + +pub use def::{DefStyle, StyleId}; +pub use engine::{FoldEvent, LineResult, Span, State}; +pub use registry::{Language, Registry}; diff --git a/src/syntax/registry.rs b/src/syntax/registry.rs new file mode 100644 index 0000000..ed61133 --- /dev/null +++ b/src/syntax/registry.rs @@ -0,0 +1,482 @@ +//! Finds syntax definitions, chooses one for a file, and compiles them on demand. + +use super::def::*; +use super::engine::{Highlighter, State}; +use std::collections::{HashMap, HashSet}; +use std::io::Read; +use std::path::{Path, PathBuf}; +use std::sync::Arc; + +#[derive(Clone, Debug)] +pub struct Language { + pub name: String, + pub alternatives: Vec, + pub section: String, + pub extensions: Vec, + pub mimetypes: Vec, + pub priority: i32, + pub hidden: bool, + pub path: PathBuf, +} + +struct Loaded { + root: CtxId, + meta: DefMeta, +} + +pub struct Registry { + pub languages: Vec, + by_name: HashMap, + loaded: HashMap, + pub compiled: Compiled, + lists: HashMap<(String, String), Arc>, +} + +pub fn search_dirs() -> Vec { + let mut v = vec![]; + if let Some(d) = dirs::data_dir() { + v.push(d.join("org.kde.syntax-highlighting/syntax")); + v.push(d.join("damson/syntax")); + } + let shared = std::env::var("XDG_DATA_DIRS").unwrap_or_else(|_| "/usr/local/share:/usr/share".into()); + for d in shared.split(':').filter(|s| !s.is_empty()) { + v.push(Path::new(d).join("org.kde.syntax-highlighting/syntax")); + v.push(Path::new(d).join("org.kde.syntax-highlighting/syntax-bundled")); + } + if let Ok(exe) = std::env::current_exe() { + if let Some(d) = exe.parent() { + v.push(d.join("syntax")); + v.push(d.join("../share/damson/syntax")); + } + } + v +} + +/// Pulls `name="…"` attributes out of the `` tag without parsing the whole file. +fn header_attrs(head: &str) -> HashMap { + let mut map = HashMap::new(); + let Some(start) = head.find(" q = Some(c), + (Some(x), _) if x == c => q = None, + (None, '>') => { end = i; break } + _ => {} + } + } + end + }; + let tag = &rest[..tag_end]; + let b = tag.as_bytes(); + let mut i = 0; + while i < b.len() { + while i < b.len() && b[i].is_ascii_whitespace() { i += 1 } + let ks = i; + while i < b.len() && b[i] != b'=' && !b[i].is_ascii_whitespace() { i += 1 } + let key = &tag[ks..i]; + while i < b.len() && (b[i] == b'=' || b[i].is_ascii_whitespace()) { i += 1 } + if i >= b.len() { break } + let q = b[i]; + if q != b'"' && q != b'\'' { i += 1; continue } + i += 1; + let vs = i; + while i < b.len() && b[i] != q { i += 1 } + map.insert(key.to_string(), tag[vs..i.min(tag.len())].replace("&", "&").replace("<", "<").replace(">", ">")); + i += 1; + } + map +} + +fn glob_match(pat: &str, name: &str) -> bool { + let p: Vec = pat.chars().collect(); + let n: Vec = name.chars().collect(); + let (mut i, mut j, mut star, mut mark) = (0, 0, None, 0); + while j < n.len() { + if i < p.len() && (p[i] == '?' || p[i] == n[j]) { + i += 1; + j += 1; + } else if i < p.len() && p[i] == '*' { + star = Some(i); + mark = j; + i += 1; + } else if let Some(s) = star { + i = s + 1; + mark += 1; + j = mark; + } else { + return false; + } + } + while i < p.len() && p[i] == '*' { i += 1 } + i == p.len() +} + +impl Registry { + pub fn scan() -> Registry { + Self::scan_dirs(&search_dirs()) + } + + pub fn scan_dirs(dirs: &[PathBuf]) -> Registry { + let mut languages: Vec = vec![]; + let mut by_name: HashMap = HashMap::new(); + for dir in dirs { + let Ok(rd) = std::fs::read_dir(dir) else { continue }; + let mut files: Vec = rd.flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|e| e == "xml")).collect(); + files.sort(); + for path in files { + // earlier folders win, so a definition in the user's folder replaces the system one + let mut buf = [0u8; 8192]; + let Ok(n) = std::fs::File::open(&path).and_then(|mut f| f.read(&mut buf)) else { continue }; + let head = String::from_utf8_lossy(&buf[..n]); + let a = header_attrs(&head); + let Some(name) = a.get("name").cloned() else { continue }; + if by_name.contains_key(&name) { continue } + let split = |k: &str| a.get(k).map(|s| s.split(';').map(|x| x.trim().to_string()).filter(|x| !x.is_empty()).collect()).unwrap_or_default(); + by_name.insert(name.clone(), languages.len()); + languages.push(Language { + alternatives: split("alternativeNames"), + section: a.get("section").cloned().unwrap_or_default(), + extensions: split("extensions"), + mimetypes: split("mimetype"), + priority: a.get("priority").and_then(|p| p.parse().ok()).unwrap_or(0), + hidden: a.get("hidden").is_some_and(|h| h == "true" || h == "1"), + path, + name, + }); + } + } + Registry { languages, by_name, loaded: HashMap::new(), compiled: Compiled::default(), lists: HashMap::new() } + } + + /// The definition for a file name, by Kate's rule: the highest priority among matching globs. + pub fn detect(&self, file_name: &str, first_line: &str) -> Option<&str> { + let best = self.languages.iter().filter(|l| !l.hidden && l.extensions.iter().any(|g| glob_match(g, file_name))).max_by_key(|l| l.priority); + if let Some(l) = best { + return Some(&l.name); + } + let s = first_line.trim_end(); + if let Some(rest) = s.strip_prefix("#!") { + let word = rest.trim().rsplit('/').next().unwrap_or(""); + let word = if word.starts_with("env") { rest.split_whitespace().nth(1).unwrap_or("") } else { word.split_whitespace().next().unwrap_or("") }; + let name = match word.trim_end_matches(|c: char| c.is_ascii_digit() || c == '.') { + "python" => "Python", + "bash" | "sh" | "zsh" | "dash" | "ksh" => "Bash", + "fish" => "Fish", + "node" | "deno" => "JavaScript", + "ruby" => "Ruby", + "perl" => "Perl", + "lua" => "Lua", + "php" => "PHP", + _ => return None, + }; + return self.by_name.contains_key(name).then_some(name); + } + None + } + + pub fn meta(&mut self, name: &str) -> DefMeta { + self.load(name); + self.loaded.get(name).map(|l| l.meta.clone()).unwrap_or_default() + } + + pub fn initial_state(&mut self, name: &str) -> Option { + self.load(name)?; + self.loaded.get(name).map(|l| Highlighter::initial(l.root)) + } + + fn intern_list(&mut self, def: &str, name: &str, doc: roxmltree::Node) -> Arc { + let key = (def.to_string(), name.to_string()); + if let Some(l) = self.lists.get(&key) { + return l.clone(); + } + let mut list = KeywordList::default(); + let mut seen = HashSet::new(); + self.collect_list(name, doc, &mut list, &mut seen); + let a = Arc::new(list); + self.lists.insert(key, a.clone()); + a + } + + fn collect_list(&self, name: &str, doc: roxmltree::Node, out: &mut KeywordList, seen: &mut HashSet) { + if !seen.insert(name.to_string()) { + return; + } + let Some(node) = doc.descendants().find(|n| n.has_tag_name("list") && n.attribute("name") == Some(name)) else { return }; + for ch in node.children().filter(|n| n.is_element()) { + match ch.tag_name().name() { + "item" => { + if let Some(t) = ch.text() { + let t = t.trim(); + out.cased.insert(t.to_string()); + out.folded.insert(t.to_lowercase()); + } + } + "include" => { + if let Some(t) = ch.text() { + self.collect_list(t.trim(), doc, out, seen); + } + } + _ => {} + } + } + } + + fn region(&mut self, def: &str, name: &str) -> u32 { + let n = self.compiled.regions.len() as u32; + *self.compiled.regions.entry(format!("{def}\0{name}")).or_insert(n) + } + + /// Compiles a definition and everything it includes. Returns its root context. + pub fn load(&mut self, name: &str) -> Option { + if let Some(l) = self.loaded.get(name) { + return Some(l.root); + } + let idx = *self.by_name.get(name)?; + let path = self.languages[idx].path.clone(); + let text = std::fs::read_to_string(&path).ok()?; + let opts = roxmltree::ParsingOptions { allow_dtd: true, ..Default::default() }; + let doc = roxmltree::Document::parse_with_options(&text, opts).ok()?; + let root_el = doc.root_element(); + let hl = root_el.children().find(|n| n.has_tag_name("highlighting"))?; + let general = root_el.children().find(|n| n.has_tag_name("general")); + + // styles + let mut style_of: HashMap = HashMap::new(); + if let Some(items) = hl.children().find(|n| n.has_tag_name("itemDatas")) { + for it in items.children().filter(|n| n.has_tag_name("itemData")) { + let info = StyleInfo { + base: DefStyle::parse(it.attribute("defStyleNum").unwrap_or("dsNormal")), + bold: it.attribute("bold").map(truthy), + italic: it.attribute("italic").map(truthy), + underline: it.attribute("underline").is_some_and(truthy), + }; + self.compiled.styles.push(info); + style_of.insert(it.attribute("name").unwrap_or("").to_string(), (self.compiled.styles.len() - 1) as StyleId); + } + } + if self.compiled.styles.is_empty() { + self.compiled.styles.push(StyleInfo { base: DefStyle::Normal, bold: None, italic: None, underline: false }); + } + let default_style = style_of.values().copied().min().unwrap_or(0); + + // reserve context ids first: contexts refer to each other, and other definitions to these + let ctxs: Vec = hl.children().find(|n| n.has_tag_name("contexts")).map(|c| c.children().filter(|n| n.has_tag_name("context")).collect()).unwrap_or_default(); + if ctxs.is_empty() { + return None; + } + let base = self.compiled.contexts.len() as CtxId; + let mut ids: HashMap = HashMap::new(); + for (i, c) in ctxs.iter().enumerate() { + ids.entry(c.attribute("name").unwrap_or("").to_string()).or_insert(base + i as CtxId); + let placeholder = Context { style: 0, rules: vec![], line_end: Switch::default(), line_empty: None, fallthrough: None, dynamic: false }; + self.compiled.contexts.push(placeholder); + } + let mut meta = DefMeta::default(); + if let Some(g) = general { + if let Some(cm) = g.children().find(|n| n.has_tag_name("comments")) { + for c in cm.children().filter(|n| n.has_tag_name("comment")) { + match c.attribute("name") { + Some("singleLine") => meta.line_comment = c.attribute("start").map(str::to_string), + Some("multiLine") => meta.block_comment = c.attribute("start").zip(c.attribute("end")).map(|(a, b)| (a.to_string(), b.to_string())), + _ => {} + } + } + } + if let Some(f) = g.children().find(|n| n.has_tag_name("folding")) { + meta.indent_fold = f.attribute("indentationsensitive").is_some_and(truthy); + } + } + self.loaded.insert(name.to_string(), Loaded { root: base, meta }); + + let kw = general.and_then(|g| g.children().find(|n| n.has_tag_name("keywords"))); + let default_ci = kw.and_then(|k| k.attribute("casesensitive")).is_some_and(|v| !truthy(v)); + let delims = Arc::new(Delims::new(kw.and_then(|k| k.attribute("weakDeliminator")).unwrap_or(""), kw.and_then(|k| k.attribute("additionalDeliminator")).unwrap_or(""))); + + // first pass: own rules, with include markers; second pass flattens the includes + let mut includes: Vec<(usize, usize, CtxId, bool)> = vec![]; + for (i, c) in ctxs.iter().enumerate() { + let cid = (base as usize) + i; + let style = c.attribute("attribute").and_then(|a| style_of.get(a).copied()).unwrap_or(default_style); + let line_end = self.switch(c.attribute("lineEndContext"), &ids, name); + let line_empty = c.attribute("lineEmptyContext").map(|s| self.switch(Some(s), &ids, name)); + let fall = if let Some(f) = c.attribute("fallthroughContext") { Some(self.switch(Some(f), &ids, name)) } else if c.attribute("fallthrough").is_some_and(truthy) { Some(Switch::default()) } else { None }; + let fall = fall.filter(|s| !s.is_stay()); + let mut rules = vec![]; + for r in c.children().filter(|n| n.is_element()) { + self.rule(r, &mut rules, &mut includes, cid, doc.root_element(), name, &ids, &style_of, default_ci, &delims); + } + let dynamic = c.attribute("dynamic").is_some_and(truthy); + self.compiled.contexts[cid] = Context { style, rules, line_end, line_empty, fallthrough: fall, dynamic }; + } + self.flatten(&includes); + Some(base) + } + + fn flatten(&mut self, includes: &[(usize, usize, CtxId, bool)]) { + // process in reverse so insertion indices of earlier includes in a context stay valid + for (cid, at, target, attrib) in includes.iter().rev() { + let mut seen = HashSet::from([*cid as CtxId]); + let extra = self.clone_rules(*target, &mut seen); + let ctx = &mut self.compiled.contexts[*cid]; + let at = (*at).min(ctx.rules.len()); + ctx.rules.splice(at..at, extra); + if *attrib { + let (s, f) = { let t = &self.compiled.contexts[*target as usize]; (t.style, t.fallthrough) }; + let ctx = &mut self.compiled.contexts[*cid]; + ctx.style = s; + if ctx.fallthrough.is_none() { ctx.fallthrough = f } + } + } + } + + fn clone_rules(&self, target: CtxId, _seen: &mut HashSet) -> Vec { + self.compiled.contexts[target as usize].rules.iter().map(clone_rule).collect() + } + + fn switch(&mut self, spec: Option<&str>, ids: &HashMap, def: &str) -> Switch { + let Some(mut s) = spec else { return Switch::default() }; + let mut out = Switch::default(); + s = s.trim(); + if s.is_empty() || s == "#stay" { + return out; + } + while let Some(r) = s.strip_prefix("#pop") { + out.pops += 1; + s = r; + } + let s = s.strip_prefix('!').unwrap_or(s); + if s.is_empty() { + return out; + } + out.push = self.resolve(s, ids, def); + out + } + + fn resolve(&mut self, s: &str, ids: &HashMap, def: &str) -> Option { + if let Some((ctx, other)) = s.split_once("##") { + let other = other.trim(); + if other == def { + return if ctx.is_empty() { ids.values().min().copied() } else { ids.get(ctx).copied() }; + } + let root = self.load(other)?; + if ctx.is_empty() { + return Some(root); + } + return self.find_ctx(other, ctx); + } + ids.get(s).copied() + } + + /// A named context of an already-loaded definition. Names are re-read from its file. + fn find_ctx(&self, def: &str, ctx: &str) -> Option { + let idx = *self.by_name.get(def)?; + let text = std::fs::read_to_string(&self.languages[idx].path).ok()?; + let opts = roxmltree::ParsingOptions { allow_dtd: true, ..Default::default() }; + let doc = roxmltree::Document::parse_with_options(&text, opts).ok()?; + let root = self.loaded.get(def)?.root; + let hl = doc.root_element().children().find(|n| n.has_tag_name("highlighting"))?; + let pos = hl.children().find(|n| n.has_tag_name("contexts"))?.children().filter(|n| n.has_tag_name("context")).position(|c| c.attribute("name") == Some(ctx))?; + Some(root + pos as CtxId) + } + + #[allow(clippy::too_many_arguments)] + fn rule(&mut self, r: roxmltree::Node, out: &mut Vec, inc: &mut Vec<(usize, usize, CtxId, bool)>, cid: usize, doc: roxmltree::Node, def: &str, ids: &HashMap, styles: &HashMap, default_ci: bool, delims: &Arc) { + let tag = r.tag_name().name(); + if tag == "IncludeRules" { + if let Some(t) = r.attribute("context").and_then(|s| self.resolve(s, ids, def)) { + inc.push((cid, out.len(), t, r.attribute("includeAttrib").is_some_and(truthy))); + } + return; + } + let a = |k: &str| r.attribute(k); + let ch = |k: &str| a(k).and_then(|s| s.chars().next()); + let ci = a("insensitive").map(truthy).unwrap_or(false); + let dynamic = a("dynamic").is_some_and(truthy); + let matcher = match tag { + "DetectChar" => { + let c = ch("char").unwrap_or('\0'); + let dyn_idx = (dynamic && c.is_ascii_digit()).then(|| c.to_digit(10).unwrap() as usize); + Matcher::DetectChar { c, dyn_idx } + } + "Detect2Chars" => Matcher::Detect2Chars { a: ch("char").unwrap_or('\0'), b: ch("char1").unwrap_or('\0') }, + "AnyChar" => Matcher::AnyChar(a("String").unwrap_or("").chars().collect()), + "StringDetect" => Matcher::StringDetect { s: a("String").unwrap_or("").to_string(), ci, dynamic }, + "WordDetect" => Matcher::WordDetect { s: a("String").unwrap_or("").to_string(), ci }, + "RegExpr" => { + let source = a("String").unwrap_or("").to_string(); + let minimal = a("minimal").is_some_and(truthy); + let re = if dynamic { None } else { + match compile_regex(&source, ci, minimal) { + Ok(r) => Some(Arc::new(r)), + Err(e) => { + self.compiled.bad_regexes.push((format!("{def}: {source}"), e)); + None + } + } + }; + Matcher::Regex { re, source, ci, minimal, dynamic } + } + "keyword" => { + let name = a("String").unwrap_or(""); + let list = self.intern_list(def, name, doc); + let ci = a("insensitive").map(truthy).unwrap_or(default_ci); + Matcher::Keyword { list, ci } + } + "Int" => Matcher::Int, + "Float" => Matcher::Float, + "HlCOct" => Matcher::HlCOct, + "HlCHex" => Matcher::HlCHex, + "HlCStringChar" => Matcher::HlCStringChar, + "HlCChar" => Matcher::HlCChar, + "RangeDetect" => Matcher::RangeDetect { a: ch("char").unwrap_or('\0'), b: ch("char1").unwrap_or('\0') }, + "LineContinue" => Matcher::LineContinue { c: ch("char").unwrap_or('\\') }, + "DetectSpaces" => Matcher::DetectSpaces, + "DetectIdentifier" => Matcher::DetectIdentifier, + _ => return, + }; + let switch = self.switch(a("context"), ids, def); + let begin_region = a("beginRegion").map(|n| self.region(def, n)); + let end_region = a("endRegion").map(|n| self.region(def, n)); + out.push(Rule { + matcher, + style: a("attribute").and_then(|s| styles.get(s).copied()), + switch, + look_ahead: a("lookAhead").is_some_and(truthy), + first_non_space: a("firstNonSpace").is_some_and(truthy), + column: a("column").and_then(|c| c.parse().ok()), + begin_region, + end_region, + delims: delims.clone(), + }); + } +} + +fn truthy(s: &str) -> bool { + matches!(s.to_ascii_lowercase().as_str(), "1" | "true") +} + +fn clone_rule(r: &Rule) -> Rule { + let matcher = match &r.matcher { + Matcher::DetectChar { c, dyn_idx } => Matcher::DetectChar { c: *c, dyn_idx: *dyn_idx }, + Matcher::Detect2Chars { a, b } => Matcher::Detect2Chars { a: *a, b: *b }, + Matcher::AnyChar(v) => Matcher::AnyChar(v.clone()), + Matcher::StringDetect { s, ci, dynamic } => Matcher::StringDetect { s: s.clone(), ci: *ci, dynamic: *dynamic }, + Matcher::WordDetect { s, ci } => Matcher::WordDetect { s: s.clone(), ci: *ci }, + Matcher::Regex { re, source, ci, minimal, dynamic } => Matcher::Regex { re: re.clone(), source: source.clone(), ci: *ci, minimal: *minimal, dynamic: *dynamic }, + Matcher::Keyword { list, ci } => Matcher::Keyword { list: list.clone(), ci: *ci }, + Matcher::Int => Matcher::Int, + Matcher::Float => Matcher::Float, + Matcher::HlCOct => Matcher::HlCOct, + Matcher::HlCHex => Matcher::HlCHex, + Matcher::HlCStringChar => Matcher::HlCStringChar, + Matcher::HlCChar => Matcher::HlCChar, + Matcher::RangeDetect { a, b } => Matcher::RangeDetect { a: *a, b: *b }, + Matcher::LineContinue { c } => Matcher::LineContinue { c: *c }, + Matcher::DetectSpaces => Matcher::DetectSpaces, + Matcher::DetectIdentifier => Matcher::DetectIdentifier, + }; + Rule { matcher, style: r.style, switch: r.switch, look_ahead: r.look_ahead, first_non_space: r.first_non_space, column: r.column, begin_region: r.begin_region, end_region: r.end_region, delims: r.delims.clone() } +} diff --git a/src/text/buffer.rs b/src/text/buffer.rs new file mode 100644 index 0000000..4b85d07 --- /dev/null +++ b/src/text/buffer.rs @@ -0,0 +1,264 @@ +//! The text itself: a rope, any number of selections, and grouped undo. + +use ropey::Rope; +use std::ops::Range; +use std::time::{Duration, Instant}; + +/// One selection; `anchor == head` is a plain cursor. Positions are char indices into the rope. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Sel { + pub anchor: usize, + pub head: usize, + /// Column to return to while moving through shorter lines. + pub want_col: Option, +} + +impl Sel { + pub fn cursor(at: usize) -> Sel { + Sel { anchor: at, head: at, want_col: None } + } + + pub fn range(&self) -> Range { + self.anchor.min(self.head)..self.anchor.max(self.head) + } + + pub fn is_empty(&self) -> bool { + self.anchor == self.head + } +} + +/// Typing runs of the same kind undo together. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum EditKind { + Typing, + Deleting, + Other, +} + +#[derive(Clone, Debug)] +struct Edit { + pos: usize, + del: String, + ins: String, +} + +#[derive(Clone, Debug)] +struct Group { + edits: Vec, + before: Vec, + after: Vec, + kind: EditKind, + at: Instant, +} + +/// Lines touched by an edit: `old` lines starting at `first` became `new` lines. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct LineChange { + pub first: usize, + pub old: usize, + pub new: usize, +} + +pub struct Buffer { + pub rope: Rope, + pub sels: Vec, + pub primary: usize, + undo: Vec, + redo: Vec, + /// Bumped on every text change. + pub version: u64, + saved_marker: Option, + /// Line changes since the document last looked; drained by `Doc`. + pub changes: Vec, +} + +const COALESCE: Duration = Duration::from_millis(900); + +impl Buffer { + pub fn new(text: &str) -> Buffer { + Buffer { rope: Rope::from_str(text), sels: vec![Sel::cursor(0)], primary: 0, undo: vec![], redo: vec![], version: 0, saved_marker: Some(0), changes: vec![] } + } + + pub fn mark_saved(&mut self) { + self.saved_marker = Some(self.undo.len()); + } + + pub fn is_modified(&self) -> bool { + self.saved_marker != Some(self.undo.len()) + } + + pub fn can_undo(&self) -> bool { + !self.undo.is_empty() + } + + pub fn can_redo(&self) -> bool { + !self.redo.is_empty() + } + + pub fn len(&self) -> usize { + self.rope.len_chars() + } + + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + pub fn lines(&self) -> usize { + self.rope.len_lines() + } + + pub fn head(&self) -> usize { + self.sels[self.primary.min(self.sels.len() - 1)].head + } + + /// (line, char column) of a position. + pub fn pos(&self, at: usize) -> (usize, usize) { + let at = at.min(self.len()); + let l = self.rope.char_to_line(at); + (l, at - self.rope.line_to_char(l)) + } + + pub fn at(&self, line: usize, col: usize) -> usize { + let line = line.min(self.lines() - 1); + self.rope.line_to_char(line) + col.min(self.line_len(line)) + } + + /// Length of a line in chars, without its line break. + pub fn line_len(&self, line: usize) -> usize { + let s = self.rope.line(line); + let mut n = s.len_chars(); + while n > 0 && matches!(s.char(n - 1), '\n' | '\r') { + n -= 1; + } + n + } + + pub fn line_text(&self, line: usize) -> String { + if line >= self.lines() { + return String::new(); + } + let mut s = self.rope.line(line).to_string(); + while s.ends_with('\n') || s.ends_with('\r') { + s.pop(); + } + s + } + + pub fn text(&self, r: Range) -> String { + self.rope.slice(r).to_string() + } + + /// Replaces ranges with texts. The ranges may come in any order but must not overlap. + /// `place` gets, for each change in order, where its new text starts and how long it is, and + /// returns the selection that should follow it. + pub fn apply(&mut self, mut changes: Vec<(Range, String)>, kind: EditKind, place: impl Fn(usize, usize, usize) -> Sel) { + changes.sort_by_key(|c| c.0.start); + let before = self.sels.clone(); + let mut delta = 0isize; + let mut after = vec![]; + for (i, (r, s)) in changes.iter().enumerate() { + let start = (r.start as isize + delta) as usize; + let n = s.chars().count(); + after.push(place(i, start, n)); + delta += n as isize - r.len() as isize; + } + // back to front, so earlier positions stay valid + let mut edits = vec![]; + for (r, s) in changes.into_iter().rev() { + if r.is_empty() && s.is_empty() { + continue; + } + let del = self.rope.slice(r.clone()).to_string(); + self.raw_edit(r.start, r.end, &s); + edits.push(Edit { pos: r.start, del, ins: s }); + } + self.set_sels(after); + if edits.is_empty() { + return; + } + self.redo.clear(); + let now = Instant::now(); + let saved_here = self.saved_marker == Some(self.undo.len()); + if let Some(g) = self.undo.last_mut() { + if kind != EditKind::Other && g.kind == kind && now - g.at < COALESCE && !saved_here { + g.edits.extend(edits); + g.after = self.sels.clone(); + g.at = now; + return; + } + } + if self.saved_marker.is_some_and(|m| m > self.undo.len()) { + self.saved_marker = None; + } + self.undo.push(Group { edits, before, after: self.sels.clone(), kind, at: now }); + } + + fn raw_edit(&mut self, start: usize, end: usize, ins: &str) { + let first = self.rope.char_to_line(start); + let last = self.rope.char_to_line(end); + self.rope.remove(start..end); + self.rope.insert(start, ins); + let new = ins.matches('\n').count(); + self.changes.push(LineChange { first, old: last - first + 1, new: new + 1 }); + self.version += 1; + } + + pub fn undo(&mut self) -> bool { + let Some(g) = self.undo.pop() else { return false }; + for e in g.edits.iter().rev() { + self.raw_edit(e.pos, e.pos + e.ins.chars().count(), &e.del); + } + self.set_sels(g.before.clone()); + self.redo.push(g); + true + } + + pub fn redo(&mut self) -> bool { + let Some(mut g) = self.redo.pop() else { return false }; + for e in g.edits.iter() { + self.raw_edit(e.pos, e.pos + e.del.chars().count(), &e.ins); + } + self.set_sels(g.after.clone()); + g.at = Instant::now() - COALESCE; + self.undo.push(g); + true + } + + /// Sets the selections, sorted, with overlapping ones merged. The last one becomes primary. + pub fn set_sels(&mut self, mut v: Vec) { + if v.is_empty() { + v.push(Sel::cursor(0)); + } + let len = self.len(); + for s in &mut v { + s.anchor = s.anchor.min(len); + s.head = s.head.min(len); + } + let last = v[v.len() - 1]; + v.sort_by_key(|s| s.range().start); + let mut out: Vec = vec![]; + for s in v { + if let Some(p) = out.last_mut() { + let (pr, sr) = (p.range(), s.range()); + if sr.start < pr.end || (sr.start == pr.end && (pr.is_empty() || sr.is_empty())) { + let (a, b) = (pr.start.min(sr.start), pr.end.max(sr.end)); + let backward = p.head < p.anchor; + *p = Sel { anchor: if backward { b } else { a }, head: if backward { a } else { b }, want_col: None }; + continue; + } + } + out.push(s); + } + self.primary = out.iter().position(|s| s.range().contains(&last.head) || s.head == last.head).unwrap_or(out.len() - 1); + self.sels = out; + } + + pub fn set_cursor(&mut self, at: usize) { + self.set_sels(vec![Sel::cursor(at)]); + } + + pub fn selected_text(&self) -> String { + let parts: Vec = self.sels.iter().filter(|s| !s.is_empty()).map(|s| self.text(s.range())).collect(); + parts.join("\n") + } +} diff --git a/src/text/commands.rs b/src/text/commands.rs new file mode 100644 index 0000000..8ca24e4 --- /dev/null +++ b/src/text/commands.rs @@ -0,0 +1,635 @@ +//! Editing commands on a `Buffer`. Every command works on all selections at once. + +use super::buffer::{Buffer, EditKind, Sel}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Move { + Left, Right, Up, Down, WordLeft, WordRight, Home, End, DocStart, DocEnd, PageUp(usize), PageDown(usize), +} + +fn is_word(c: char) -> bool { + c.is_alphanumeric() || c == '_' +} + +pub struct Prefs { + pub tab_width: usize, + pub spaces: bool, + pub auto_close: bool, +} + +impl Default for Prefs { + fn default() -> Self { + Prefs { tab_width: 4, spaces: true, auto_close: true } + } +} + +impl Buffer { + fn word_left(&self, mut at: usize) -> usize { + let c = |i: usize| self.rope.char(i); + while at > 0 && c(at - 1).is_whitespace() { at -= 1 } + if at == 0 { return 0 } + let word = is_word(c(at - 1)); + while at > 0 && !c(at - 1).is_whitespace() && is_word(c(at - 1)) == word { at -= 1 } + at + } + + fn word_right(&self, mut at: usize) -> usize { + let n = self.len(); + let c = |i: usize| self.rope.char(i); + while at < n && c(at).is_whitespace() { at += 1 } + if at == n { return n } + let word = is_word(c(at)); + while at < n && !c(at).is_whitespace() && is_word(c(at)) == word { at += 1 } + at + } + + /// The word around a position. + pub fn word_at(&self, at: usize) -> std::ops::Range { + let n = self.len(); + let (mut a, mut b) = (at.min(n), at.min(n)); + while a > 0 && is_word(self.rope.char(a - 1)) { a -= 1 } + while b < n && is_word(self.rope.char(b)) { b += 1 } + a..b + } + + fn first_text_col(&self, line: usize) -> usize { + self.rope.line(line).chars().take(self.line_len(line)).take_while(|c| *c == ' ' || *c == '\t').count() + } + + fn step(&self, s: &Sel, m: Move) -> (usize, Option) { + let (line, col) = self.pos(s.head); + let vertical = |lines: isize| { + let want = s.want_col.unwrap_or(col); + let target = (line as isize + lines).clamp(0, self.lines() as isize - 1) as usize; + if target == line { + let edge = if lines < 0 { 0 } else { self.len() }; + return (edge, None); + } + (self.at(target, want), Some(want)) + }; + match m { + Move::Left => (s.head.saturating_sub(1), None), + Move::Right => ((s.head + 1).min(self.len()), None), + Move::Up => vertical(-1), + Move::Down => vertical(1), + Move::PageUp(n) => vertical(-(n as isize)), + Move::PageDown(n) => vertical(n as isize), + Move::WordLeft => (self.word_left(s.head), None), + Move::WordRight => (self.word_right(s.head), None), + Move::Home => { + let t = self.first_text_col(line); + (self.at(line, if col == t { 0 } else { t }), None) + } + Move::End => (self.at(line, usize::MAX), None), + Move::DocStart => (0, None), + Move::DocEnd => (self.len(), None), + } + } + + pub fn move_cursors(&mut self, m: Move, extend: bool) { + let next: Vec = self.sels.iter().map(|s| { + // a selection collapses towards the direction of travel + if !extend && !s.is_empty() && matches!(m, Move::Left | Move::Right) { + let r = s.range(); + return Sel::cursor(if m == Move::Left { r.start } else { r.end }); + } + let (h, want) = self.step(s, m); + Sel { anchor: if extend { s.anchor } else { h }, head: h, want_col: want } + }).collect(); + self.set_sels(next); + } + + pub fn select_all(&mut self) { + self.set_sels(vec![Sel { anchor: 0, head: self.len(), want_col: None }]); + } + + /// Inserts text at every cursor; when the paste has one line per cursor, each gets its own. + pub fn insert(&mut self, text: &str, kind: EditKind) { + let parts: Vec<&str> = text.split('\n').collect(); + let per_cursor = self.sels.len() > 1 && parts.len() == self.sels.len(); + let changes = self.sels.iter().enumerate().map(|(i, s)| (s.range(), if per_cursor { parts[i].to_string() } else { text.to_string() })).collect(); + self.apply(changes, kind, |_, st, n| Sel::cursor(st + n)); + } + + /// Typed text: wraps selections in brackets, closes pairs and types over closers. + pub fn type_text(&mut self, text: &str, p: &Prefs) { + let mut cs = text.chars(); + let (Some(c), None) = (cs.next(), cs.next()) else { + return self.insert(text, EditKind::Typing); + }; + let close = match c { '(' => ')', '[' => ']', '{' => '}', '"' => '"', '\'' => '\'', '`' => '`', _ => '\0' }; + if p.auto_close { + if close != '\0' && self.sels.iter().all(|s| !s.is_empty()) { + let changes = self.sels.iter().map(|s| (s.range(), format!("{c}{}{close}", self.text(s.range())))).collect(); + return self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st + 1, head: st + n - 1, want_col: None }); + } + if matches!(c, ')' | ']' | '}' | '"' | '\'' | '`') && self.sels.iter().all(|s| s.is_empty() && s.head < self.len() && self.rope.char(s.head) == c) { + let next = self.sels.iter().map(|s| Sel::cursor(s.head + 1)).collect(); + return self.set_sels(next); + } + let boundary = |s: &Sel| { + let after = (s.head < self.len()).then(|| self.rope.char(s.head)); + let before = (s.head > 0).then(|| self.rope.char(s.head - 1)); + let free_after = after.is_none_or(|a| a.is_whitespace() || ")]}>,;:".contains(a)); + let quote = matches!(c, '"' | '\'' | '`'); + free_after && !(quote && before.is_some_and(is_word)) + }; + if close != '\0' && self.sels.iter().all(|s| s.is_empty() && boundary(s)) { + let changes = self.sels.iter().map(|s| (s.range(), format!("{c}{close}"))).collect(); + return self.apply(changes, EditKind::Typing, |_, st, _| Sel::cursor(st + 1)); + } + } + self.insert(text, EditKind::Typing); + } + + pub fn newline(&mut self, p: &Prefs) { + let items: Vec<(std::ops::Range, String, usize)> = self.sels.iter().map(|s| { + let r = s.range(); + let (line, col) = self.pos(r.start); + let lt = self.line_text(line); + let indent: String = lt.chars().take(col).take_while(|c| *c == ' ' || *c == '\t').collect(); + let before = lt.chars().take(col).collect::(); + let before = before.trim_end(); + let opens = before.ends_with(['{', '(', '[']) || before.ends_with(':'); + let closes = r.end < self.len() && matches!(self.rope.char(r.end), '}' | ')' | ']'); + let unit = if p.spaces { " ".repeat(p.tab_width) } else { "\t".to_string() }; + let mut t = format!("\n{indent}"); + let mut back = 0; + if opens { + t.push_str(&unit); + if closes && !before.ends_with(':') { + let tail = format!("\n{indent}"); + back = tail.chars().count(); + t.push_str(&tail); + } + } + (r, t, back) + }).collect(); + let backs: Vec = items.iter().map(|i| i.2).collect(); + let mut order: Vec = (0..items.len()).collect(); + order.sort_by_key(|i| items[*i].0.start); + let ordered_backs: Vec = order.iter().map(|i| backs[*i]).collect(); + self.apply(items.into_iter().map(|i| (i.0, i.1)).collect(), EditKind::Other, move |i, st, n| Sel::cursor(st + n - ordered_backs[i])); + } + + pub fn backspace(&mut self, p: &Prefs) { + let changes = self.sels.iter().map(|s| { + if !s.is_empty() { + return (s.range(), String::new()); + } + let at = s.head; + if at == 0 { + return (0..0, String::new()); + } + let (line, col) = self.pos(at); + let lead = self.first_text_col(line); + // inside indentation, remove back to the previous tab stop + if col > 0 && col <= lead && p.spaces && self.rope.char(at - 1) == ' ' { + let n = ((col - 1) % p.tab_width) + 1; + return (at - n..at, String::new()); + } + let prev = self.rope.char(at - 1); + let next = (at < self.len()).then(|| self.rope.char(at)); + let pair = matches!((prev, next), ('(', Some(')')) | ('[', Some(']')) | ('{', Some('}')) | ('"', Some('"')) | ('\'', Some('\'')) | ('`', Some('`'))); + (at - 1..if pair { at + 1 } else { at }, String::new()) + }).collect(); + self.apply(changes, EditKind::Deleting, |_, st, _| Sel::cursor(st)); + } + + pub fn delete_forward(&mut self) { + let n = self.len(); + let changes = self.sels.iter().map(|s| (if s.is_empty() { s.head..(s.head + 1).min(n) } else { s.range() }, String::new())).collect(); + self.apply(changes, EditKind::Deleting, |_, st, _| Sel::cursor(st)); + } + + pub fn delete_word(&mut self, forward: bool) { + let changes = self.sels.iter().map(|s| { + let r = if !s.is_empty() { s.range() } else if forward { s.head..self.word_right(s.head) } else { self.word_left(s.head)..s.head }; + (r, String::new()) + }).collect(); + self.apply(changes, EditKind::Deleting, |_, st, _| Sel::cursor(st)); + } + + /// Whole lines covered by the selections, merged, first to last. + fn covered_lines(&self) -> Vec<(usize, usize)> { + let mut v: Vec<(usize, usize)> = vec![]; + for s in &self.sels { + let r = s.range(); + let a = self.pos(r.start).0; + let (mut b, c) = self.pos(r.end); + if !s.is_empty() && c == 0 && b > a { b -= 1 } + match v.last_mut() { + Some(l) if a <= l.1 + 1 => l.1 = l.1.max(b), + _ => v.push((a, b)), + } + } + v + } + + fn line_start(&self, l: usize) -> usize { + self.rope.line_to_char(l) + } + + /// Runs `f` for each line's change, keeping selections on the same text. + fn edit_lines(&mut self, f: impl Fn(&Buffer, usize) -> Option<(std::ops::Range, String)>) { + let mut changes = vec![]; + for (a, b) in self.covered_lines() { + for l in a..=b { + if let Some(c) = f(self, l) { + changes.push(c); + } + } + } + let map = |at: usize| { + let mut pos = at as isize; + for (r, s) in &changes { + if r.end <= at { pos += s.chars().count() as isize - r.len() as isize } + else if r.start < at { pos += (s.chars().count() as isize - r.len() as isize).max(r.start as isize - at as isize) } + } + pos.max(0) as usize + }; + let next: Vec = self.sels.iter().map(|s| Sel { anchor: map(s.anchor), head: map(s.head), want_col: None }).collect(); + self.apply(changes, EditKind::Other, |_, _, _| Sel::cursor(0)); + self.set_sels(next); + } + + pub fn indent(&mut self, p: &Prefs) { + if self.sels.iter().all(|s| s.is_empty() || self.pos(s.anchor).0 == self.pos(s.head).0) { + let changes = self.sels.iter().map(|s| { + let t = if p.spaces { " ".repeat(p.tab_width - self.pos(s.range().start).1 % p.tab_width) } else { "\t".to_string() }; + (s.range(), t) + }).collect(); + return self.apply(changes, EditKind::Typing, |_, st, n| Sel::cursor(st + n)); + } + let unit = if p.spaces { " ".repeat(p.tab_width) } else { "\t".to_string() }; + self.edit_lines(|b, l| (b.line_len(l) > 0).then(|| (b.line_start(l)..b.line_start(l), unit.clone()))); + } + + pub fn unindent(&mut self, p: &Prefs) { + let w = p.tab_width; + self.edit_lines(|b, l| { + let t = b.line_text(l); + let n = if t.starts_with('\t') { 1 } else { t.chars().take(w).take_while(|c| *c == ' ').count() }; + (n > 0).then(|| (b.line_start(l)..b.line_start(l) + n, String::new())) + }); + } + + pub fn toggle_comment(&mut self, line: Option<&str>, block: Option<(&str, &str)>) { + let Some(tok) = line else { + let Some((a, b)) = block else { return }; + let changes = self.sels.iter().map(|s| { + let t = self.text(s.range()); + let inner = t.strip_prefix(a).and_then(|x| x.strip_suffix(b)); + (s.range(), inner.map(str::to_string).unwrap_or_else(|| format!("{a}{t}{b}"))) + }).collect(); + return self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st, head: st + n, want_col: None }); + }; + let lines = self.covered_lines(); + let all = lines.iter().all(|(a, b)| (*a..=*b).all(|l| { + let t = self.line_text(l); + t.trim().is_empty() || t.trim_start().starts_with(tok) + })); + let col = lines.iter().flat_map(|(a, b)| *a..=*b).filter(|l| !self.line_text(*l).trim().is_empty()).map(|l| self.first_text_col(l)).min().unwrap_or(0); + self.edit_lines(|b, l| { + let t = b.line_text(l); + if t.trim().is_empty() { + return None; + } + if all { + let c = b.first_text_col(l); + let n = tok.chars().count(); + let extra = t.chars().nth(c + n).is_some_and(|x| x == ' ') as usize; + let s = b.line_start(l) + c; + Some((s..s + n + extra, String::new())) + } else { + let s = b.line_start(l) + col; + Some((s..s, format!("{tok} "))) + } + }); + } + + pub fn duplicate_lines(&mut self) { + let mut changes = vec![]; + for (a, b) in self.covered_lines() { + let end = if b + 1 < self.lines() { self.line_start(b + 1) } else { self.len() }; + let mut t = self.text(self.line_start(a)..end); + if !t.ends_with('\n') { t.insert(0, '\n'); } + changes.push((end..end, t)); + } + let sels = self.sels.clone(); + self.apply(changes, EditKind::Other, |_, _, _| Sel::cursor(0)); + self.set_sels(sels); + } + + pub fn delete_lines(&mut self) { + let mut changes = vec![]; + for (a, b) in self.covered_lines() { + let start = self.line_start(a); + let r = if b + 1 < self.lines() { start..self.line_start(b + 1) } else { start.saturating_sub(1)..self.len() }; + changes.push((r, String::new())); + } + self.apply(changes, EditKind::Other, |_, st, _| Sel::cursor(st)); + } + + pub fn move_lines(&mut self, up: bool) { + let cov = self.covered_lines(); + let (first, last) = (cov[0].0, cov[cov.len() - 1].1); + if (up && first == 0) || (!up && last + 1 >= self.lines()) { + return; + } + let (a, b) = if up { (first - 1, last) } else { (first, last + 1) }; + let end = if b + 1 < self.lines() { self.line_start(b + 1) } else { self.len() }; + let start = self.line_start(a); + let mut ls: Vec = (a..=b).map(|l| self.line_text(l)).collect(); + let shift; + if up { + let l = ls.remove(0); + shift = -((l.chars().count() + 1) as isize); + ls.push(l); + } else { + let l = ls.pop().unwrap(); + shift = l.chars().count() as isize + 1; + ls.insert(0, l); + } + let mut t = ls.join("\n"); + if b + 1 < self.lines() { t.push('\n') } + let sels: Vec = self.sels.iter().map(|s| Sel { anchor: (s.anchor as isize + shift) as usize, head: (s.head as isize + shift) as usize, want_col: s.want_col }).collect(); + self.apply(vec![(start..end, t)], EditKind::Other, |_, _, _| Sel::cursor(0)); + self.set_sels(sels); + } + + pub fn join_lines(&mut self) { + let mut changes = vec![]; + for (a, b) in self.covered_lines() { + let b = if a == b { (a + 1).min(self.lines() - 1) } else { b }; + for l in a..b { + let e = self.at(l, usize::MAX); + let s = self.line_start(l + 1) + self.first_text_col(l + 1); + changes.push((e..s, " ".to_string())); + } + } + self.apply(changes, EditKind::Other, |_, st, _| Sel::cursor(st)); + } + + pub fn transform(&mut self, f: impl Fn(&str) -> String) { + let changes = self.sels.iter().map(|s| { + let r = if s.is_empty() { self.word_at(s.head) } else { s.range() }; + let t = f(&self.text(r.clone())); + (r, t) + }).collect(); + self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st, head: st + n, want_col: None }); + } + + pub fn sort_lines(&mut self) { + let mut changes = vec![]; + for (a, b) in self.covered_lines() { + if a == b { continue } + let mut ls: Vec = (a..=b).map(|l| self.line_text(l)).collect(); + ls.sort(); + changes.push((self.line_start(a)..self.at(b, usize::MAX), ls.join("\n"))); + } + self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st, head: st + n, want_col: None }); + } + + pub fn trim_trailing(&mut self) { + let mut changes = vec![]; + for l in 0..self.lines() { + let t = self.line_text(l); + let n = t.trim_end_matches([' ', '\t']).chars().count(); + let total = t.chars().count(); + if n < total { + let s = self.line_start(l); + changes.push((s + n..s + total, String::new())); + } + } + let map: Vec<(usize, usize)> = changes.iter().map(|c: &(std::ops::Range, String)| (c.0.start, c.0.len())).collect(); + let fix = |at: usize| at - map.iter().map(|(s, n)| if *s + *n <= at { *n } else if *s < at { at - *s } else { 0 }).sum::(); + let next: Vec = self.sels.iter().map(|s| Sel { anchor: fix(s.anchor), head: fix(s.head), want_col: None }).collect(); + self.apply(changes, EditKind::Other, |_, _, _| Sel::cursor(0)); + self.set_sels(next); + } + + /// Adds a cursor on the line above or below each edge cursor (Kate's Ctrl+Alt+Up/Down). + pub fn add_cursor_vertical(&mut self, down: bool) { + let edge = if down { self.sels.iter().max_by_key(|s| s.head) } else { self.sels.iter().min_by_key(|s| s.head) }; + let Some(s) = edge.copied() else { return }; + let (l, c) = self.pos(s.head); + let want = s.want_col.unwrap_or(c); + if (down && l + 1 >= self.lines()) || (!down && l == 0) { + return; + } + let t = if down { l + 1 } else { l - 1 }; + let at = self.at(t, want); + let mut v = self.sels.clone(); + v.push(Sel { anchor: at, head: at, want_col: Some(want) }); + self.set_sels(v); + } + + /// Selects the word under the cursor, then each next occurrence (Kate's Alt+J). + pub fn select_next(&mut self) { + let last = self.sels[self.primary]; + if last.is_empty() { + let r = self.word_at(last.head); + if r.is_empty() { return } + let mut v = self.sels.clone(); + v[self.primary] = Sel { anchor: r.start, head: r.end, want_col: None }; + return self.set_sels(v); + } + let needle = self.text(last.range()); + let hay = self.rope.to_string(); + let byte = self.rope.char_to_byte(last.range().end); + let hit = hay[byte..].find(&needle).map(|i| i + byte).or_else(|| hay.find(&needle)); + let Some(b) = hit else { return }; + let a = self.rope.byte_to_char(b); + if self.sels.iter().any(|s| s.range().start == a) { return } + let mut v = self.sels.clone(); + v.push(Sel { anchor: a, head: a + needle.chars().count(), want_col: None }); + self.set_sels(v); + } + + /// The bracket matching one next to a position. + pub fn matching_bracket(&self, at: usize) -> Option<(usize, usize)> { + let pairs = [('(', ')'), ('[', ']'), ('{', '}')]; + let probe = |i: usize| -> Option<(usize, usize)> { + let c = self.rope.get_char(i)?; + let (open, close, fwd) = pairs.iter().find_map(|(a, b)| if c == *a { Some((*a, *b, true)) } else if c == *b { Some((*a, *b, false)) } else { None })?; + let (mut depth, mut j, mut steps) = (0i32, i as isize, 0); + while j >= 0 && (j as usize) < self.len() && steps < 200_000 { + let x = self.rope.char(j as usize); + if x == open { depth += if fwd { 1 } else { -1 } } + if x == close { depth += if fwd { -1 } else { 1 } } + if depth == 0 { return Some((i, j as usize)) } + j += if fwd { 1 } else { -1 }; + steps += 1; + } + None + }; + probe(at).or_else(|| at.checked_sub(1).and_then(probe)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn b(t: &str) -> Buffer { Buffer::new(t) } + fn text(b: &Buffer) -> String { b.rope.to_string() } + fn p() -> Prefs { Prefs::default() } + + #[test] + fn typing_undoes_as_one_group() { + let mut x = b(""); + for c in "hello".chars() { x.type_text(&c.to_string(), &p()); } + assert_eq!(text(&x), "hello"); + assert!(x.is_modified()); + x.undo(); + assert_eq!(text(&x), ""); + assert!(!x.is_modified()); + x.redo(); + assert_eq!(text(&x), "hello"); + } + + #[test] + fn multi_cursor_types_everywhere_and_undoes() { + let mut x = b("a\nb\nc"); + x.add_cursor_vertical(true); + x.add_cursor_vertical(true); + assert_eq!(x.sels.len(), 3); + x.insert("> ", EditKind::Other); + assert_eq!(text(&x), "> a\n> b\n> c"); + x.undo(); + assert_eq!(text(&x), "a\nb\nc"); + assert_eq!(x.sels.len(), 3); + } + + #[test] + fn brackets_pair_wrap_and_type_over() { + let mut x = b(""); + x.type_text("(", &p()); + assert_eq!(text(&x), "()"); + x.type_text(")", &p()); + assert_eq!(text(&x), "()"); + assert_eq!(x.head(), 2); + let mut y = b("word"); + y.select_all(); + y.type_text("[", &p()); + assert_eq!(text(&y), "[word]"); + assert_eq!(y.selected_text(), "word"); + } + + #[test] + fn apostrophe_after_a_word_does_not_pair() { + let mut x = b("don"); + x.set_cursor(3); + x.type_text("'", &p()); + assert_eq!(text(&x), "don'"); + } + + #[test] + fn newline_indents_and_splits_braces() { + let mut x = b(" fn a() {}"); + x.set_cursor(10); + x.newline(&p()); + assert_eq!(text(&x), " fn a() {\n \n }"); + assert_eq!(x.pos(x.head()), (1, 6)); + } + + #[test] + fn multi_cursor_newline_keeps_each_cursor() { + let mut x = b("{}\n{}"); + x.set_sels(vec![Sel::cursor(1), Sel::cursor(4)]); + x.newline(&p()); + assert_eq!(text(&x), "{\n \n}\n{\n \n}"); + assert_eq!(x.sels.len(), 2); + assert_eq!(x.pos(x.sels[0].head), (1, 4)); + assert_eq!(x.pos(x.sels[1].head), (4, 4)); + } + + #[test] + fn backspace_clears_indent_stop_and_pairs() { + let mut x = b(" a"); + x.set_cursor(8); + x.backspace(&p()); + assert_eq!(text(&x), " a"); + let mut y = b("()"); + y.set_cursor(1); + y.backspace(&p()); + assert_eq!(text(&y), ""); + } + + #[test] + fn comment_toggles_on_and_off() { + let mut x = b(" a\n b"); + x.select_all(); + x.toggle_comment(Some("//"), None); + assert_eq!(text(&x), " // a\n // b"); + x.toggle_comment(Some("//"), None); + assert_eq!(text(&x), " a\n b"); + } + + #[test] + fn move_and_duplicate_lines() { + let mut x = b("one\ntwo\nthree"); + x.set_cursor(x.at(1, 1)); + x.move_lines(true); + assert_eq!(text(&x), "two\none\nthree"); + assert_eq!(x.pos(x.head()), (0, 1)); + x.move_lines(false); + x.move_lines(false); + assert_eq!(text(&x), "one\nthree\ntwo"); + assert_eq!(x.pos(x.head()), (2, 1)); + x.duplicate_lines(); + assert_eq!(text(&x), "one\nthree\ntwo\ntwo"); + } + + #[test] + fn selection_kept_through_indent() { + let mut x = b("a\nb"); + x.select_all(); + x.indent(&p()); + assert_eq!(text(&x), " a\n b"); + x.unindent(&p()); + assert_eq!(text(&x), "a\nb"); + } + + #[test] + fn next_occurrence_wraps() { + let mut x = b("foo bar foo"); + x.set_cursor(1); + x.select_next(); + assert_eq!(x.selected_text(), "foo"); + x.select_next(); + assert_eq!(x.sels.len(), 2); + } + + #[test] + fn saved_point_survives_undo_past_it() { + let mut x = b(""); + x.insert("a", EditKind::Other); + x.mark_saved(); + x.insert("b", EditKind::Other); + x.undo(); + assert!(!x.is_modified()); + x.undo(); + assert!(x.is_modified()); + x.insert("c", EditKind::Other); + assert!(x.is_modified()); + } + + #[test] + fn matching_brackets() { + let x = b("a(b[c]d)"); + assert_eq!(x.matching_bracket(1), Some((1, 7))); + assert_eq!(x.matching_bracket(8), Some((7, 1))); + } + + #[test] + fn vertical_move_keeps_column() { + let mut x = b("long line\nx\nlong line"); + x.set_cursor(6); + x.move_cursors(Move::Down, false); + assert_eq!(x.pos(x.head()), (1, 1)); + x.move_cursors(Move::Down, false); + assert_eq!(x.pos(x.head()), (2, 6)); + } +} diff --git a/src/text/doc.rs b/src/text/doc.rs new file mode 100644 index 0000000..a3b6c21 --- /dev/null +++ b/src/text/doc.rs @@ -0,0 +1,419 @@ +//! An open file: its buffer plus highlighting, folding, and file details. + +use super::buffer::{Buffer, LineChange}; +use crate::syntax::def::DefMeta; +use crate::syntax::engine::Highlighter; +use crate::syntax::{FoldEvent, Registry, Span, State}; +use std::collections::{BTreeSet, HashMap}; +use std::path::PathBuf; +use std::sync::Arc; +use std::time::SystemTime; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Eol { Lf, CrLf, Cr } + +impl Eol { + pub fn label(self) -> &'static str { + match self { Eol::Lf => "LF", Eol::CrLf => "CRLF", Eol::Cr => "CR" } + } + pub fn text(self) -> &'static str { + match self { Eol::Lf => "\n", Eol::CrLf => "\r\n", Eol::Cr => "\r" } + } +} + +#[derive(Clone, Default)] +pub struct LineHl { + pub spans: Arc>, + pub folds: Arc>, + pub end: Option>, +} + +pub struct Doc { + pub id: u64, + pub buf: Buffer, + pub path: Option, + pub language: String, + pub meta: DefMeta, + pub encoding: &'static encoding_rs::Encoding, + pub bom: bool, + pub eol: Eol, + pub mtime: Option, + pub hl: Vec, + start_state: Option>, + /// First line that may be out of date, and the line up to which it certainly is. + dirty: Option<(usize, usize)>, + pub folded: BTreeSet, + pub fold_ends: HashMap, + fold_version: u64, + pub bookmarks: BTreeSet, + /// Bumped whenever the colours of any line change; the preview redraws from this. + pub hl_version: u64, + /// App time of the last save, for the tick on the tab. + pub saved_at: f64, +} + +fn decode(bytes: &[u8]) -> (String, &'static encoding_rs::Encoding, bool) { + if let Some((enc, skip)) = encoding_rs::Encoding::for_bom(bytes) { + let (t, _) = enc.decode_without_bom_handling(&bytes[skip..]); + return (t.into_owned(), enc, true); + } + match std::str::from_utf8(bytes) { + Ok(s) => (s.to_string(), encoding_rs::UTF_8, false), + Err(_) => { + let (t, _) = encoding_rs::WINDOWS_1252.decode_without_bom_handling(bytes); + (t.into_owned(), encoding_rs::WINDOWS_1252, false) + } + } +} + +impl Doc { + pub fn new(id: u64, text: &str, path: Option, reg: &mut Registry) -> Doc { + let eol = if text.contains("\r\n") { Eol::CrLf } else if text.contains('\r') { Eol::Cr } else { Eol::Lf }; + let norm = if eol == Eol::Lf { text.to_string() } else { text.replace("\r\n", "\n").replace('\r', "\n") }; + let mut d = Doc { + id, buf: Buffer::new(&norm), path, language: String::new(), meta: DefMeta::default(), + encoding: encoding_rs::UTF_8, bom: false, eol, mtime: None, hl: vec![], start_state: None, + dirty: None, folded: BTreeSet::new(), fold_ends: HashMap::new(), fold_version: u64::MAX, + bookmarks: BTreeSet::new(), hl_version: 0, saved_at: f64::MIN, + }; + let name = d.file_name(); + let first = d.buf.line_text(0); + let lang = reg.detect(&name, &first).map(str::to_string).unwrap_or_else(|| "None".to_string()); + d.set_language(&lang, reg); + d + } + + pub fn open(id: u64, path: PathBuf, reg: &mut Registry) -> std::io::Result { + let bytes = std::fs::read(&path)?; + let (text, enc, bom) = decode(&bytes); + let mtime = std::fs::metadata(&path).and_then(|m| m.modified()).ok(); + let mut d = Doc::new(id, &text, Some(path), reg); + d.encoding = enc; + d.bom = bom; + d.mtime = mtime; + Ok(d) + } + + /// Replaces the text with what's on disk, as an edit, so it can be undone. + pub fn reload(&mut self) -> std::io::Result<()> { + let Some(path) = self.path.clone() else { return Ok(()) }; + let bytes = std::fs::read(&path)?; + let (text, enc, bom) = decode(&bytes); + let keep = self.buf.head(); + self.buf.select_all(); + self.buf.insert(&text.replace("\r\n", "\n").replace('\r', "\n"), super::EditKind::Other); + self.buf.set_cursor(keep); + self.encoding = enc; + self.bom = bom; + self.mtime = std::fs::metadata(&path).and_then(|m| m.modified()).ok(); + // it matches the disk now, whatever it held before + self.buf.mark_saved(); + Ok(()) + } + + pub fn file_name(&self) -> String { + self.path.as_ref().and_then(|p| p.file_name()).map(|n| n.to_string_lossy().into_owned()).unwrap_or_default() + } + + pub fn title(&self) -> String { + let n = self.file_name(); + if n.is_empty() { "Untitled".to_string() } else { n } + } + + pub fn set_language(&mut self, name: &str, reg: &mut Registry) { + self.language = name.to_string(); + self.meta = reg.meta(name); + self.start_state = reg.initial_state(name).map(Arc::new); + self.hl = vec![LineHl::default(); self.buf.lines()]; + self.dirty = Some((0, self.buf.lines())); + self.hl_version += 1; + self.fold_version = u64::MAX; + } + + pub fn save(&mut self) -> std::io::Result<()> { + let Some(path) = self.path.clone() else { + return Err(std::io::Error::other("no file name")); + }; + let mut text = self.buf.rope.to_string(); + if self.eol != Eol::Lf { + text = text.replace('\n', self.eol.text()); + } + let (enc, _, _) = self.encoding.encode(&text); + let mut bytes = Vec::with_capacity(enc.len() + 3); + if self.bom && self.encoding == encoding_rs::UTF_8 { + bytes.extend_from_slice(&[0xEF, 0xBB, 0xBF]); + } + bytes.extend_from_slice(&enc); + // write beside the file, then swap, so a crash mid-save can't leave half a file + // (a symlink stays a link: the swap happens at the file it points to) + let target = std::fs::canonicalize(&path).unwrap_or_else(|_| path.clone()); + let name = target.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); + let tmp = target.with_file_name(format!(".{name}.damson-tmp")); + std::fs::write(&tmp, &bytes)?; + if let Ok(m) = std::fs::metadata(&target) { + let _ = std::fs::set_permissions(&tmp, m.permissions()); + } + std::fs::rename(&tmp, &target)?; + self.mtime = std::fs::metadata(&path).and_then(|m| m.modified()).ok(); + self.buf.mark_saved(); + Ok(()) + } + + /// Brings the line tables in step with edits made to the buffer. + pub fn sync_edits(&mut self) { + let changes: Vec = std::mem::take(&mut self.buf.changes); + for c in changes { + let end = (c.first + c.old).min(self.hl.len()); + let first = c.first.min(self.hl.len()); + self.hl.splice(first..end, std::iter::repeat_n(LineHl::default(), c.new)); + let delta = c.new as isize - c.old as isize; + let shift = |s: &BTreeSet| -> BTreeSet { + s.iter().filter_map(|l| { + if *l < c.first { Some(*l) } + else if *l >= c.first + c.old { Some((*l as isize + delta) as usize) } + else if delta == 0 { Some(*l) } else { None } + }).collect() + }; + self.folded = shift(&self.folded); + self.bookmarks = shift(&self.bookmarks); + let (a, b) = self.dirty.unwrap_or((c.first, c.first)); + let b = if b >= c.first + c.old { (b as isize + delta) as usize } else { c.first + c.new }; + self.dirty = Some((a.min(c.first), b.max(c.first + c.new))); + } + self.hl.resize(self.buf.lines(), LineHl::default()); + } + + pub fn highlight_pending(&self) -> bool { + self.dirty.is_some() && self.start_state.is_some() + } + + /// Highlights onward from the first dirty line until `until`, or until `max_lines` are done, + /// stopping early when a line ends in the same state it had before. + pub fn highlight(&mut self, reg: &Registry, until: usize, max_lines: usize) { + self.sync_edits(); + let Some(start_state) = self.start_state.clone() else { + self.dirty = None; + return; + }; + let Some((mut line, must)) = self.dirty else { return }; + let total = self.buf.lines(); + let mut state: State = if line == 0 { + (*start_state).clone() + } else { + match self.hl.get(line - 1).and_then(|h| h.end.clone()) { + Some(s) => (*s).clone(), + None => (*start_state).clone(), + } + }; + let mut h = Highlighter::new(®.compiled); + let mut done = 0; + while line < total && ((line <= until && done < 3000) || done < max_lines) { + let text = self.buf.line_text(line); + let r = h.line(&text, &mut state); + let same = self.hl[line].end.as_deref() == Some(&state); + self.hl[line] = LineHl { spans: Arc::new(r.spans), folds: Arc::new(r.folds), end: Some(Arc::new(state.clone())) }; + line += 1; + done += 1; + if same && line >= must { + self.dirty = None; + self.hl_version += 1; + self.fold_version = u64::MAX; + return; + } + } + self.hl_version += 1; + self.fold_version = u64::MAX; + self.dirty = if line >= total { None } else { Some((line, must)) }; + } + + /// Works out which lines start a foldable range. + pub fn refresh_folds(&mut self, tab: usize) { + if self.fold_version == self.hl_version { + return; + } + self.fold_version = self.hl_version; + self.fold_ends.clear(); + if self.meta.indent_fold { + self.indent_folds(tab); + } else { + let mut stack: Vec<(u32, usize)> = vec![]; + for (l, h) in self.hl.iter().enumerate() { + for (_, ev) in h.folds.iter() { + match ev { + FoldEvent::Begin(r) => stack.push((*r, l)), + FoldEvent::End(r) => { + if let Some(p) = stack.iter().rposition(|s| s.0 == *r) { + let (_, start) = stack[p]; + stack.truncate(p); + if l > start { + let e = self.fold_ends.entry(start).or_insert(l); + *e = (*e).max(l); + } + } + } + } + } + } + } + let keep = self.fold_ends.clone(); + self.folded.retain(|l| keep.contains_key(l)); + } + + fn indent_folds(&mut self, tab: usize) { + let n = self.buf.lines().min(200_000); + let indent: Vec> = (0..n).map(|l| { + let t = self.buf.line_text(l); + if t.trim().is_empty() { return None } + Some(t.chars().take_while(|c| c.is_whitespace()).map(|c| if c == '\t' { tab } else { 1 }).sum()) + }).collect(); + let mut stack: Vec<(usize, usize)> = vec![]; + let mut last = 0; + for (l, i) in indent.iter().enumerate() { + let Some(i) = i else { continue }; + while let Some(&(si, start)) = stack.last() { + if *i <= si { + stack.pop(); + if last > start { self.fold_ends.insert(start, last); } + } else { break } + } + stack.push((*i, l)); + last = l; + } + for (_, start) in stack { + if last > start { self.fold_ends.insert(start, last); } + } + } + + pub fn toggle_fold(&mut self, line: usize) { + if !self.folded.remove(&line) && self.fold_ends.contains_key(&line) { + self.folded.insert(line); + } + } + + /// Is this line hidden inside a folded range? + pub fn hidden_lines(&self) -> Vec<(usize, usize)> { + let mut v: Vec<(usize, usize)> = vec![]; + for l in &self.folded { + let Some(e) = self.fold_ends.get(l) else { continue }; + if v.last().is_some_and(|p| *l < p.1) { continue } + v.push((*l + 1, *e)); + } + v + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::syntax::DefStyle; + + fn style(d: &Doc, reg: &Registry, line: usize, col: u32) -> DefStyle { + let s = d.hl[line].spans.iter().find(|s| s.start <= col && col < s.end).unwrap(); + reg.compiled.styles[s.style as usize].base + } + + #[test] + fn opening_a_block_comment_recolours_later_lines_and_undo_restores() { + let mut reg = Registry::scan(); + let mut d = Doc::new(1, "let a = 1;\nlet b = 2;\nlet c = 3;\n", Some("x.rs".into()), &mut reg); + d.highlight(®, 10, 1000); + assert_eq!(d.language, "Rust"); + assert_eq!(style(&d, ®, 2, 0), DefStyle::Keyword); + d.buf.set_cursor(0); + d.buf.insert("/*", crate::text::EditKind::Other); + d.highlight(®, 10, 1000); + assert_eq!(style(&d, ®, 2, 0), DefStyle::Comment); + d.buf.undo(); + d.highlight(®, 10, 1000); + assert_eq!(style(&d, ®, 2, 0), DefStyle::Keyword); + } + + #[test] + fn line_tables_track_insert_and_delete() { + let mut reg = Registry::scan(); + let mut d = Doc::new(1, "a\nb\nc\n", Some("x.rs".into()), &mut reg); + d.highlight(®, 10, 1000); + d.buf.set_cursor(2); + d.buf.insert("x\ny\n", crate::text::EditKind::Other); + d.sync_edits(); + assert_eq!(d.hl.len(), d.buf.lines()); + d.buf.select_all(); + d.buf.insert("", crate::text::EditKind::Other); + d.sync_edits(); + assert_eq!(d.hl.len(), 1); + } + + #[test] + fn folds_come_from_syntax_and_indentation() { + let mut reg = Registry::scan(); + let mut d = Doc::new(1, "fn a() {\n b();\n}\n", Some("x.rs".into()), &mut reg); + d.highlight(®, 10, 1000); + d.refresh_folds(4); + assert_eq!(d.fold_ends.get(&0), Some(&2)); + let mut p = Doc::new(2, "def a():\n b()\n c()\nd()\n", Some("x.py".into()), &mut reg); + p.highlight(®, 10, 1000); + p.refresh_folds(4); + assert_eq!(p.fold_ends.get(&0), Some(&2)); + } + + #[test] + fn saving_keeps_a_symlink_a_symlink() { + let dir = std::env::temp_dir().join(format!("damson-link-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let (real, link) = (dir.join("real.txt"), dir.join("link.txt")); + std::fs::write(&real, "old").unwrap(); + std::os::unix::fs::symlink(&real, &link).unwrap(); + let mut reg = Registry::scan(); + let mut d = Doc::new(1, "new", Some(link.clone()), &mut reg); + d.save().unwrap(); + assert!(std::fs::symlink_metadata(&link).unwrap().file_type().is_symlink()); + assert_eq!(std::fs::read_to_string(&real).unwrap(), "new"); + std::fs::remove_dir_all(dir).unwrap(); + } + + #[test] + fn reload_can_be_undone_and_reads_latin1() { + let dir = std::env::temp_dir().join(format!("damson-reload-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let p = dir.join("a.txt"); + std::fs::write(&p, "one").unwrap(); + let mut reg = Registry::scan(); + let mut d = Doc::open(1, p.clone(), &mut reg).unwrap(); + d.buf.insert("unsaved ", crate::text::EditKind::Other); + std::fs::write(&p, [b'c', b'a', b'f', 0xE9]).unwrap(); + d.reload().unwrap(); + assert_eq!(d.buf.rope.to_string(), "caf\u{e9}"); + assert!(!d.buf.is_modified()); + d.buf.undo(); + assert_eq!(d.buf.rope.to_string(), "unsaved one"); + std::fs::remove_dir_all(dir).unwrap(); + } + + #[test] + fn jumping_deep_into_a_huge_file_stays_bounded() { + let mut reg = Registry::scan(); + let text = "let x = 1;\n".repeat(200_000); + let mut d = Doc::new(1, &text, Some("x.rs".into()), &mut reg); + let t = std::time::Instant::now(); + d.highlight(®, 190_000, 0); + assert!(d.highlight_pending(), "should stop early and finish in the background"); + assert!(t.elapsed().as_millis() < 500, "took {:?}", t.elapsed()); + } + + #[test] + fn save_round_trips_crlf() { + let dir = std::env::temp_dir().join(format!("damson-doc-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let p = dir.join("a.txt"); + std::fs::write(&p, "one\r\ntwo\r\n").unwrap(); + let mut reg = Registry::scan(); + let mut d = Doc::open(1, p.clone(), &mut reg).unwrap(); + assert_eq!(d.eol, Eol::CrLf); + d.buf.set_cursor(0); + d.buf.insert("z", crate::text::EditKind::Other); + d.save().unwrap(); + assert_eq!(std::fs::read_to_string(&p).unwrap(), "zone\r\ntwo\r\n"); + assert!(!d.buf.is_modified()); + std::fs::remove_dir_all(dir).unwrap(); + } +} diff --git a/src/text/mod.rs b/src/text/mod.rs new file mode 100644 index 0000000..7f5a8c4 --- /dev/null +++ b/src/text/mod.rs @@ -0,0 +1,6 @@ +pub mod buffer; +pub mod commands; +pub mod doc; + +pub use buffer::{Buffer, EditKind, Sel}; +pub use doc::Doc; diff --git a/src/theme.rs b/src/theme.rs new file mode 100644 index 0000000..b0a1cbc --- /dev/null +++ b/src/theme.rs @@ -0,0 +1,268 @@ +//! Material You colours: taken from Caelestia's scheme, or built from a seed in OKLCH space +//! (tone == CIE L*). Also picks the colours code is drawn in. + +use crate::config::Settings; +use crate::syntax::DefStyle; +use eframe::egui::Color32; +use std::path::PathBuf; + +fn srgb_to_lin(c: f64) -> f64 { + if c <= 0.04045 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) } +} + +fn lin_to_srgb(c: f64) -> f64 { + if c <= 0.0031308 { 12.92 * c } else { 1.055 * c.powf(1.0 / 2.4) - 0.055 } +} + +pub fn rgb_to_oklch(c: Color32) -> (f64, f64, f64) { + let (r, g, b) = (srgb_to_lin(c.r() as f64 / 255.0), srgb_to_lin(c.g() as f64 / 255.0), srgb_to_lin(c.b() as f64 / 255.0)); + let l = (0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b).cbrt(); + let m = (0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b).cbrt(); + let s = (0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b).cbrt(); + let ll = 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s; + let a = 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s; + let bb = 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s; + (ll, a.hypot(bb), bb.atan2(a).to_degrees().rem_euclid(360.0)) +} + +fn oklch_to_lin(l: f64, c: f64, h: f64) -> (f64, f64, f64) { + let (a, b) = (c * h.to_radians().cos(), c * h.to_radians().sin()); + let l_ = (l + 0.3963377774 * a + 0.2158037573 * b).powi(3); + let m_ = (l - 0.1055613458 * a - 0.0638541728 * b).powi(3); + let s_ = (l - 0.0894841775 * a - 1.2914855480 * b).powi(3); + ( + 4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_, + -1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_, + -0.0041960863 * l_ - 0.7034186147 * m_ + 1.7076147010 * s_, + ) +} + +fn in_gamut(x: (f64, f64, f64)) -> bool { + [x.0, x.1, x.2].iter().all(|v| (-1e-4..=1.0001).contains(v)) +} + +pub fn oklch(l: f64, c: f64, h: f64) -> Color32 { + let mut rgb = oklch_to_lin(l, c, h); + if !in_gamut(rgb) { + let (mut lo, mut hi) = (0.0, c); + for _ in 0..18 { + let mid = (lo + hi) / 2.0; + if in_gamut(oklch_to_lin(l, mid, h)) { lo = mid } else { hi = mid } + } + rgb = oklch_to_lin(l, lo, h); + } + let q = |x: f64| (lin_to_srgb(x.clamp(0.0, 1.0)) * 255.0).round() as u8; + Color32::from_rgb(q(rgb.0), q(rgb.1), q(rgb.2)) +} + +fn tone_l(t: f64) -> f64 { + if t <= 8.0 { (t / 903.2963).cbrt() } else { (t + 16.0) / 116.0 } +} + +#[derive(Clone, Copy)] +struct Tonal { h: f64, c: f64 } + +impl Tonal { + fn at(&self, t: f64) -> Color32 { + oklch(tone_l(t), self.c, self.h) + } +} + +pub fn mix(a: Color32, b: Color32, t: f32) -> Color32 { + let t = t.clamp(0.0, 1.0); + let l = |x: u8, y: u8| (x as f32 + (y as f32 - x as f32) * t).round() as u8; + Color32::from_rgba_unmultiplied(l(a.r(), b.r()), l(a.g(), b.g()), l(a.b(), b.b()), l(a.a(), b.a())) +} + +pub fn alpha(c: Color32, a: f32) -> Color32 { + let [r, g, b, _] = c.to_srgba_unmultiplied(); + Color32::from_rgba_unmultiplied(r, g, b, (a.clamp(0.0, 1.0) * 255.0).round() as u8) +} + +pub fn hex(s: &str) -> Option { + let s = s.trim().trim_start_matches('#'); + if s.len() != 6 { + return None; + } + let v = u32::from_str_radix(s, 16).ok()?; + Some(Color32::from_rgb((v >> 16) as u8, (v >> 8) as u8, v as u8)) +} + +#[derive(Clone)] +pub struct Theme { + pub dark: bool, + pub primary: Color32, pub on_primary: Color32, + pub primary_container: Color32, pub on_primary_container: Color32, + pub secondary: Color32, + pub secondary_container: Color32, pub on_secondary_container: Color32, + pub tertiary: Color32, + pub tertiary_container: Color32, pub on_tertiary_container: Color32, + pub error: Color32, pub on_error: Color32, + pub surface: Color32, + pub lowest: Color32, pub low: Color32, pub container: Color32, pub high: Color32, pub highest: Color32, + pub on_surface: Color32, pub on_variant: Color32, + pub outline: Color32, pub outline_variant: Color32, + pub syntax: [Color32; 31], + pub ansi: [Color32; 16], + /// Hues used for added/changed/removed marks. + pub added: Color32, pub changed: Color32, pub removed: Color32, +} + +fn caelestia_path() -> PathBuf { + dirs::state_dir().unwrap_or_else(|| PathBuf::from(".")).join("caelestia/scheme.json") +} + +fn kde_accent() -> (Option, Option) { + let Some(p) = dirs::config_dir().map(|d| d.join("kdeglobals")) else { return (None, None) }; + let Ok(txt) = std::fs::read_to_string(p) else { return (None, None) }; + let parse = |s: &str| -> Option { + let v: Vec = s.split(',').take(3).filter_map(|x| x.trim().parse().ok()).collect(); + (v.len() == 3).then(|| Color32::from_rgb(v[0], v[1], v[2])) + }; + let (mut sec, mut accent, mut sel, mut win) = (String::new(), None, None, None); + for line in txt.lines() { + if let Some(s) = line.trim().strip_prefix('[').and_then(|l| l.strip_suffix(']')) { + sec = s.to_string(); + } else if let Some((k, v)) = line.split_once('=') { + match (sec.as_str(), k.trim()) { + ("General", "AccentColor") => accent = parse(v), + ("Colors:Selection", "BackgroundNormal") => sel = parse(v), + ("Colors:Window", "BackgroundNormal") => win = parse(v), + _ => {} + } + } + } + (accent.or(sel), win.map(|w| rgb_to_oklch(w).0 < 0.6)) +} + +/// Seed colour and dark flag from Caelestia's current scheme. +fn caelestia_seed() -> Option<(Color32, bool)> { + let v: serde_json::Value = serde_json::from_slice(&std::fs::read(caelestia_path()).ok()?).ok()?; + let seed = hex(v["colours"]["primary"].as_str()?)?; + Some((seed, v["mode"].as_str() != Some("light"))) +} + +/// Something that changes when the desktop's colours do. +pub fn source_stamp() -> Option { + let a = std::fs::metadata(caelestia_path()).ok().and_then(|m| m.modified().ok()); + let b = dirs::config_dir().and_then(|d| std::fs::metadata(d.join("kdeglobals")).ok()).and_then(|m| m.modified().ok()); + a.max(b) +} + +impl Theme { + pub fn build(s: &Settings) -> Theme { + let (kde_seed, kde_dark) = kde_accent(); + let cael = caelestia_seed(); + let fallback = Color32::from_rgb(0x7f, 0x5f, 0xc4); + let custom = hex(&s.custom_color); + let (seed, sys_dark) = match s.color_source.as_str() { + "custom" => (custom.unwrap_or(fallback), cael.map(|c| c.1).or(kde_dark)), + "kde" => (kde_seed.unwrap_or(fallback), kde_dark), + "caelestia" => (cael.map(|c| c.0).or(kde_seed).unwrap_or(fallback), cael.map(|c| c.1)), + _ => (cael.map(|c| c.0).or(kde_seed).unwrap_or(fallback), cael.map(|c| c.1).or(kde_dark)), + }; + let dark = match s.mode.as_str() { "dark" => true, "light" => false, _ => sys_dark.unwrap_or(true) }; + Self::from_seed(seed, dark, &s.scheme) + } + + pub fn from_seed(seed: Color32, dark: bool, scheme: &str) -> Theme { + let (_, sc, sh) = rgb_to_oklch(seed); + let (pc, sec_c, ter_c, ter_shift, neutral_c) = match scheme { + "vibrant" => (sc.clamp(0.13, 0.19), 0.08, 0.11, 45.0, 0.022), + "expressive" => (sc.clamp(0.10, 0.16), 0.07, 0.12, 130.0, 0.026), + "mono" => (0.012, 0.008, 0.012, 0.0, 0.004), + _ => (sc.clamp(0.085, 0.15), 0.04, 0.075, 60.0, 0.014), + }; + let p = Tonal { h: sh, c: pc }; + let sec = Tonal { h: sh, c: sec_c }; + let ter = Tonal { h: (sh + ter_shift) % 360.0, c: ter_c }; + let err = Tonal { h: 25.0, c: 0.17 }; + let n = Tonal { h: sh, c: neutral_c }; + let nv = Tonal { h: sh, c: (neutral_c * 1.8).max(0.016) }; + let d = |dk: f64, lt: f64| if dark { dk } else { lt }; + + // code colours: fixed hue families pulled a little towards the seed so they sit in the scheme + let tone = d(82.0, 38.0); + let chroma = if scheme == "mono" { 0.02 } else if scheme == "vibrant" { 0.135 } else { 0.105 }; + let pull = |h: f64| { + let delta = (sh - h + 540.0).rem_euclid(360.0) - 180.0; + h + delta * 0.14 + }; + let hue = |h: f64, t: f64, c: f64| oklch(tone_l(t), chroma * c, pull(h)); + let main = n.at(d(90.0, 14.0)); + let dim = nv.at(d(62.0, 48.0)); + let key = p.at(d(80.0, 40.0)); + let ctl = Tonal { h: (sh + 300.0) % 360.0, c: pc.max(0.1) }.at(d(80.0, 40.0)); + let func = hue(235.0, tone + d(3.0, 0.0), 1.0); + let typ = ter.at(d(82.0, 38.0)); + let string = hue(145.0, tone, 1.0); + let special = hue(175.0, tone, 1.0); + let number = hue(60.0, tone, 1.1); + let constant = hue(30.0, tone, 1.1); + let prep = hue(95.0, tone, 1.0); + let warn = hue(85.0, tone, 1.3); + let attr = hue(350.0, tone, 0.9); + let mut syntax = [main; 31]; + for st in DefStyle::ALL { + use DefStyle::*; + syntax[st as usize] = match st { + Normal | Variable | Others => main, + Keyword => key, ControlFlow => ctl, Function => func, Operator => nv.at(d(78.0, 36.0)), + BuiltIn | Extension => func, Preprocessor | Import => prep, Attribute | Annotation => attr, + Char | SpecialChar | SpecialString => special, String | VerbatimString => string, + DataType => typ, DecVal | BaseN | Float => number, Constant => constant, + Comment | Documentation | CommentVar | RegionMarker => dim, + Information => func, Warning => warn, Alert => constant, Error => err.at(d(80.0, 40.0)), + }; + } + let a = |h: f64, t: f64| oklch(tone_l(t), 0.12, pull(h)); + let (lo, hi) = (d(72.0, 42.0), d(84.0, 54.0)); + let ansi = [ + n.at(d(24.0, 22.0)), a(25.0, lo), a(145.0, lo), a(85.0, lo), a(250.0, lo), a(320.0, lo), a(195.0, lo), n.at(d(82.0, 70.0)), + n.at(d(46.0, 44.0)), a(25.0, hi), a(145.0, hi), a(85.0, hi), a(250.0, hi), a(320.0, hi), a(195.0, hi), n.at(d(96.0, 92.0)), + ]; + Theme { + dark, + primary: p.at(d(80.0, 40.0)), on_primary: p.at(d(20.0, 100.0)), + primary_container: p.at(d(30.0, 90.0)), on_primary_container: p.at(d(90.0, 10.0)), + secondary: sec.at(d(80.0, 40.0)), + secondary_container: sec.at(d(30.0, 90.0)), on_secondary_container: sec.at(d(90.0, 10.0)), + tertiary: ter.at(d(80.0, 40.0)), + tertiary_container: ter.at(d(30.0, 90.0)), on_tertiary_container: ter.at(d(90.0, 10.0)), + error: err.at(d(80.0, 40.0)), on_error: err.at(d(20.0, 100.0)), + surface: n.at(d(6.0, 98.0)), + lowest: n.at(d(4.0, 100.0)), low: n.at(d(10.0, 96.0)), container: n.at(d(12.0, 94.0)), + high: n.at(d(17.0, 92.0)), highest: n.at(d(22.0, 90.0)), + on_surface: n.at(d(90.0, 10.0)), on_variant: nv.at(d(80.0, 30.0)), + outline: nv.at(d(60.0, 50.0)), outline_variant: nv.at(d(30.0, 80.0)), + syntax, ansi, + added: hue(145.0, d(74.0, 48.0), 1.3), changed: hue(235.0, d(74.0, 48.0), 1.3), removed: err.at(d(70.0, 50.0)), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn contrast(a: Color32, b: Color32) -> f64 { + let lum = |c: Color32| 0.2126 * srgb_to_lin(c.r() as f64 / 255.0) + 0.7152 * srgb_to_lin(c.g() as f64 / 255.0) + 0.0722 * srgb_to_lin(c.b() as f64 / 255.0); + let (x, y) = (lum(a), lum(b)); + (x.max(y) + 0.05) / (x.min(y) + 0.05) + } + + #[test] + fn code_stays_readable_on_every_scheme() { + for seed in ["#7f5fc4", "#d0485e", "#3f9c6b", "#c8a020", "#2b7fd4"] { + for dark in [true, false] { + for sc in ["tonal", "vibrant", "expressive", "mono"] { + let t = Theme::from_seed(hex(seed).unwrap(), dark, sc); + for st in DefStyle::ALL { + let c = contrast(t.syntax[st as usize], t.low); + assert!(c >= 3.0, "{seed} dark={dark} {sc} {st:?} contrast {c:.2}"); + } + } + } + } + } +} diff --git a/src/ui/commands.rs b/src/ui/commands.rs new file mode 100644 index 0000000..3ce9834 --- /dev/null +++ b/src/ui/commands.rs @@ -0,0 +1,75 @@ +//! Everything the app can be told to do, for shortcuts, menus and the command palette. + +#[derive(Clone, Debug, PartialEq)] +pub enum Cmd { + New, Open, OpenFolder, Save, SaveAs, SaveAll, CloseTab, ReopenClosed, Reload, Quit, + Undo, Redo, Cut, Copy, Paste, SelectAll, + Comment, DuplicateLines, DeleteLines, MoveLinesUp, MoveLinesDown, JoinLines, Indent, Unindent, + Upper, Lower, Capitalize, SortLines, TrimTrailing, CursorAbove, CursorBelow, SelectNext, + Find, Replace, FindInFiles, GotoLine, Palette, QuickOpen, Languages, Symbols, + ToggleTerminal, NewTerminal, RunFile, TerminalHere, + ToggleSidebar, Side(usize), SplitRight, SplitDown, CloseSplit, FocusNextPane, + Zen, ToggleWrap, ToggleWhitespace, ToggleNumbers, TogglePreview, ToggleLens, ZoomIn, ZoomOut, ZoomReset, + FoldHere, FoldAll, UnfoldAll, ToggleBookmark, NextBookmark, PrevBookmark, + GotoDefinition, Hover, Complete, NextProblem, + ToggleDark, Settings, About, + NextTab, PrevTab, TabAt(usize), + GitRefresh, +} + +pub struct Entry { + pub cmd: Cmd, + pub label: &'static str, + pub ic: &'static str, + pub keys: &'static str, +} + +macro_rules! e { + ($c:expr, $l:literal, $i:literal, $k:literal) => { Entry { cmd: $c, label: $l, ic: $i, keys: $k } }; +} + +pub fn all() -> Vec { + use Cmd::*; + vec![ + e!(New, "New file", "add", "Ctrl+N"), e!(Open, "Open file…", "folder_open", "Ctrl+O"), + e!(OpenFolder, "Open folder…", "folder", "Ctrl+Shift+O"), e!(Save, "Save", "save", "Ctrl+S"), + e!(SaveAs, "Save as…", "save_as", "Ctrl+Shift+S"), e!(SaveAll, "Save all", "save", "Ctrl+L"), + e!(CloseTab, "Close tab", "close", "Ctrl+W"), e!(ReopenClosed, "Reopen closed tab", "history", "Ctrl+Shift+T"), + e!(Reload, "Reload from disk", "refresh", "F5"), e!(Quit, "Quit", "close", "Ctrl+Q"), + e!(Undo, "Undo", "undo", "Ctrl+Z"), e!(Redo, "Redo", "redo", "Ctrl+Y"), + e!(Cut, "Cut", "content_cut", "Ctrl+X"), e!(Copy, "Copy", "content_copy", "Ctrl+C"), + e!(Paste, "Paste", "content_paste", "Ctrl+V"), e!(SelectAll, "Select all", "select_all", "Ctrl+A"), + e!(Comment, "Toggle comment", "code", "Ctrl+/"), e!(DuplicateLines, "Duplicate lines", "content_copy", "Ctrl+Alt+Shift+Down"), + e!(DeleteLines, "Delete lines", "delete", "Ctrl+K"), e!(MoveLinesUp, "Move lines up", "arrow_upward", "Ctrl+Shift+Up"), + e!(MoveLinesDown, "Move lines down", "arrow_downward", "Ctrl+Shift+Down"), e!(JoinLines, "Join lines", "merge", "Ctrl+J"), + e!(Indent, "Indent", "format_indent_increase", "Tab"), e!(Unindent, "Unindent", "format_align_left", "Shift+Tab"), + e!(Upper, "Uppercase", "text_fields", "Ctrl+U"), e!(Lower, "Lowercase", "text_fields", "Ctrl+Shift+U"), + e!(Capitalize, "Capitalize", "text_fields", "Ctrl+Alt+U"), e!(SortLines, "Sort lines", "swap_vert", ""), + e!(TrimTrailing, "Trim trailing spaces", "format_align_left", ""), + e!(CursorAbove, "Add cursor above", "keyboard_arrow_up", "Ctrl+Alt+Up"), e!(CursorBelow, "Add cursor below", "keyboard_arrow_down", "Ctrl+Alt+Down"), + e!(SelectNext, "Select next occurrence", "select_all", "Alt+J"), + e!(Find, "Find", "search", "Ctrl+F"), e!(Replace, "Find and replace", "find_replace", "Ctrl+R"), + e!(FindInFiles, "Find in files", "manage_search", "Ctrl+Shift+F"), e!(GotoLine, "Go to line", "tag", "Ctrl+G"), + e!(Palette, "Command palette", "keyboard_command_key", "Ctrl+Shift+P"), e!(QuickOpen, "Quick open file", "description", "Ctrl+P"), + e!(Languages, "Change language", "language", ""), e!(Symbols, "Go to symbol", "data_object", "Ctrl+Shift+R"), + e!(ToggleTerminal, "Show or hide terminal", "terminal", "F4"), e!(NewTerminal, "New terminal", "add", "Ctrl+Shift+`"), + e!(RunFile, "Run this file in the terminal", "play_arrow", "Ctrl+F5"), e!(TerminalHere, "Terminal at this file", "terminal", ""), + e!(ToggleSidebar, "Show or hide side panel", "view_sidebar", "Ctrl+B"), + e!(Side(0), "Files", "folder", "Alt+1"), e!(Side(1), "Search", "search", "Alt+2"), e!(Side(2), "Outline", "account_tree", "Alt+3"), + e!(Side(3), "Git", "commit", "Alt+4"), e!(Side(4), "Problems", "error", "Alt+5"), + e!(SplitRight, "Split right", "vertical_split", "Ctrl+Shift+L"), e!(SplitDown, "Split down", "splitscreen", ""), + e!(CloseSplit, "Close split", "close_fullscreen", ""), e!(FocusNextPane, "Next split", "tab", "Alt+Tab"), + e!(Zen, "Zen mode", "fullscreen", "F11"), e!(ToggleWrap, "Word wrap", "wrap_text", "F10"), + e!(ToggleWhitespace, "Show whitespace", "visibility", ""), e!(ToggleNumbers, "Line numbers", "looks_one", "F11+Shift"), + e!(TogglePreview, "Scrolling preview", "map", ""), e!(ToggleLens, "Preview lens", "manage_search", ""), + e!(ZoomIn, "Larger text", "add", "Ctrl+="), e!(ZoomOut, "Smaller text", "remove", "Ctrl+-"), e!(ZoomReset, "Default text size", "text_fields", "Ctrl+0"), + e!(FoldHere, "Fold or unfold here", "unfold_less", "Ctrl+Shift+-"), e!(FoldAll, "Fold everything", "unfold_less", "Ctrl+Shift+["), + e!(UnfoldAll, "Unfold everything", "unfold_more", "Ctrl+Shift+]"), + e!(ToggleBookmark, "Toggle bookmark", "bookmark_add", "Ctrl+Shift+B"), e!(NextBookmark, "Next bookmark", "bookmark", "Alt+PageDown"), e!(PrevBookmark, "Previous bookmark", "bookmark", "Alt+PageUp"), + e!(GotoDefinition, "Go to definition", "arrow_forward", "F12"), e!(Hover, "Show symbol info", "info", "Ctrl+I"), + e!(Complete, "Show completions", "code", "Ctrl+Space"), e!(NextProblem, "Next problem", "warning", "F8"), + e!(ToggleDark, "Switch light or dark", "contrast", ""), e!(Settings, "Settings", "settings", "Ctrl+,"), e!(About, "About Damson", "info", ""), + e!(NextTab, "Next tab", "chevron_right", "Ctrl+Tab"), e!(PrevTab, "Previous tab", "chevron_left", "Ctrl+Shift+Tab"), + e!(GitRefresh, "Refresh git status", "sync", ""), + ] +} diff --git a/src/ui/editor.rs b/src/ui/editor.rs new file mode 100644 index 0000000..b6ac042 --- /dev/null +++ b/src/ui/editor.rs @@ -0,0 +1,639 @@ +//! The text surface: gutter, code, selections and carets, all drawn by hand. Scroll position, the +//! current-line bubble and the caret are springs, so nothing here ever jumps. + +use super::morph::{self, Morph}; +use super::{fonts, widgets::*}; +use crate::app::{App, Pane}; +use crate::motion::{self, spring, Preset, Spring}; +use crate::syntax::Registry; +use crate::text::commands::{Move, Prefs}; +use crate::text::{Doc, EditKind, Sel}; +use crate::theme::{alpha, Theme}; +use eframe::egui::{self, pos2, text::LayoutJob, vec2, Color32, Event, FontId, Key, Modifiers, PointerButton, Pos2, Rect, Sense, TextFormat, Ui}; +use std::sync::Arc; +use unicode_width::UnicodeWidthChar; + +const CARET: Preset = Preset { stiffness: 1700.0, damping: 0.78 }; +const SCROLL: Preset = Preset { stiffness: 520.0, damping: 1.0 }; + +/// Visual rows, when wrapping or folding make them differ from lines. +#[derive(Default)] +pub struct Rows { + key: (u64, u64, usize, usize), + /// (line, first char column) of each row; `None` means rows and lines are the same. + map: Option>>, +} + +#[derive(Clone, Copy, PartialEq, Debug)] +pub struct Metrics { + pub cw: f32, + pub lh: f32, + pub font: f32, +} + +pub struct Tab { + pub doc: u64, + pub scroll: Spring, + pub scroll_x: f32, + pub caret: [Spring; 2], + pub rows: Rows, + pub beacon: Option<(usize, f64)>, + pub block_anchor: Option, + pub click: (f64, usize, u8), + pub drag_word: Option>, + pub born: f64, +} + +impl Tab { + pub fn new(doc: u64, now: f64) -> Tab { + Tab { doc, scroll: Spring::new(0.0), scroll_x: 0.0, caret: [Spring::new(0.0), Spring::new(0.0)], rows: Rows::default(), beacon: None, block_anchor: None, click: (0.0, 0, 0), drag_word: None, born: now } + } +} + +pub fn cell_width(c: char, x: usize, tab: usize) -> usize { + if c == '\t' { tab - x % tab } else { c.width().unwrap_or(0).max(if c.is_control() { 0 } else { 1 }) } +} + +/// Screen cells before char column `col` of `line`. +pub fn vis_col(line: &str, col: usize, tab: usize) -> usize { + let mut x = 0; + for c in line.chars().take(col) { + x += cell_width(c, x, tab); + } + x +} + +/// The char column nearest to `cells` screen cells into `line`. +pub fn col_at(line: &str, cells: f32, tab: usize) -> usize { + let mut x = 0; + for (i, c) in line.chars().enumerate() { + let w = cell_width(c, x, tab); + if (x as f32 + w as f32 / 2.0) > cells { + return i; + } + x += w; + } + line.chars().count() +} + +/// Builds the coloured text of part of a line, with tabs opened out into spaces. +pub fn line_job(doc: &Doc, reg: &Registry, t: &Theme, line: usize, cols: (usize, usize), font: &FontId, tab: usize, ws: bool) -> LayoutJob { + let text = doc.buf.line_text(line); + let spans: &[crate::syntax::Span] = doc.hl.get(line).map(|h| h.spans.as_slice()).unwrap_or(&[]); + let mut job = LayoutJob::default(); + job.wrap.max_width = f32::INFINITY; + let normal = t.syntax[0]; + let (mut si, mut x, mut byte) = (0, 0usize, 0u32); + let mut run = String::new(); + let mut cur: Option<(Color32, bool, bool)> = None; + let flush = |job: &mut LayoutJob, run: &mut String, st: Option<(Color32, bool, bool)>| { + if run.is_empty() { return } + let (color, italics, underline) = st.unwrap_or((normal, false, false)); + let fmt = TextFormat { font_id: font.clone(), color, italics, underline: if underline { egui::Stroke::new(1.0, color) } else { egui::Stroke::NONE }, ..Default::default() }; + job.append(run, 0.0, fmt); + run.clear(); + }; + for (i, c) in text.chars().enumerate() { + let w = cell_width(c, x, tab); + if i >= cols.0 && i < cols.1 { + while si < spans.len() && spans[si].end <= byte { si += 1 } + let style = spans.get(si).filter(|s| s.start <= byte).and_then(|s| reg.compiled.styles.get(s.style as usize)); + let st = match style { + Some(s) => (t.syntax[s.base as usize], s.italic.unwrap_or(matches!(s.base, crate::syntax::DefStyle::Comment | crate::syntax::DefStyle::Documentation)), s.underline), + None => (normal, false, false), + }; + if cur != Some(st) { + flush(&mut job, &mut run, cur); + cur = Some(st); + } + if c == '\t' { + run.extend(std::iter::repeat_n(' ', w)); + } else if ws && c == ' ' { + run.push('·'); + } else { + run.push(c); + } + } + x += w; + byte += c.len_utf8() as u32; + } + flush(&mut job, &mut run, cur); + job +} + +impl Rows { + fn refresh(&mut self, doc: &Doc, wrap: usize, tab: usize) { + let folds = doc.folded.iter().fold(doc.folded.len() as u64, |h, l| h.wrapping_mul(31).wrapping_add(*l as u64)); + let key = (doc.buf.version, folds, wrap, tab); + if self.key == key { + return; + } + self.key = key; + if wrap == 0 && doc.folded.is_empty() { + self.map = None; + return; + } + let hidden = doc.hidden_lines(); + let mut v = Vec::with_capacity(doc.buf.lines()); + let (mut h, mut l, total) = (0, 0, doc.buf.lines()); + while l < total { + if h < hidden.len() && l >= hidden[h].0 { + l = hidden[h].1 + 1; + h += 1; + continue; + } + v.push((l as u32, 0)); + if wrap > 0 && doc.buf.rope.line(l).len_chars() > wrap / 2 { + // long-line break at a word gap where one is close enough + let text = doc.buf.line_text(l); + let (mut x, mut last_gap, mut start) = (0, 0, 0); + for (i, c) in text.chars().enumerate() { + let w = cell_width(c, x, tab); + if x + w > wrap { + let cut = if last_gap > start + wrap / 3 { last_gap } else { i }; + v.push((l as u32, cut as u32)); + start = cut; + x = text.chars().skip(cut).take(i - cut).fold(0, |a, ch| a + cell_width(ch, a, tab)); + } + if c == ' ' { last_gap = i + 1 } + x += w; + } + } + l += 1; + } + self.map = Some(Arc::new(v)); + } + + pub fn count(&self, doc: &Doc) -> usize { + self.map.as_ref().map_or(doc.buf.lines(), |m| m.len()) + } + + /// (line, first column) of a row. + pub fn row(&self, r: usize) -> (usize, usize) { + match &self.map { + Some(m) => m.get(r).map_or((usize::MAX, 0), |x| (x.0 as usize, x.1 as usize)), + None => (r, 0), + } + } + + /// The last column shown in a row (exclusive). + fn row_end(&self, r: usize, doc: &Doc) -> usize { + let (l, _) = self.row(r); + match self.map.as_ref().and_then(|m| m.get(r + 1)) { + Some(n) if n.0 as usize == l => n.1 as usize, + _ => doc.buf.line_len(l), + } + } + + pub fn row_of(&self, line: usize, col: usize) -> usize { + match &self.map { + None => line, + Some(m) => m.partition_point(|x| (x.0 as usize, x.1 as usize) <= (line, col)).saturating_sub(1), + } + } +} + +fn prefs(a: &App) -> Prefs { + Prefs { tab_width: a.s.tab_width, spaces: a.s.spaces, auto_close: a.s.auto_close } +} + +impl App { + pub fn metrics(&self, ui: &Ui) -> Metrics { + let font = self.s.font_size; + let id = fonts::mono(font); + let cw = ui.fonts_mut(|f| f.glyph_width(&id, 'M')); + Metrics { cw, lh: (font * 1.55).round(), font } + } + + /// Draws one open tab of a pane in `rect`. + pub fn editor(&mut self, ui: &mut Ui, pane: usize, rect: Rect) { + let m = self.metrics(ui); + let t = self.t.clone(); + let id = self.pane_focus_id(pane); + let Some(doc_id) = self.panes[pane].tabs.get(self.panes[pane].active).map(|x| x.doc) else { return }; + let digits = self.docs.get(&doc_id).map_or(3, |d| d.buf.lines().to_string().len().max(3)); + let gutter = if self.s.line_numbers { digits as f32 * m.cw * 0.92 + 42.0 } else { 34.0 }; + let code = Rect::from_min_max(pos2(rect.left() + gutter, rect.top()), rect.max); + let wrap = if self.s.word_wrap { ((code.width() - 24.0) / m.cw).max(20.0) as usize } else { 0 }; + let tab_w = self.s.tab_width; + + let (rect_h, resp) = (rect.height(), ui.interact(rect, id, Sense::click_and_drag())); + if resp.hovered() { + ui.ctx().set_cursor_icon(if ui.input(|i| i.pointer.hover_pos()).is_some_and(|p| p.x >= code.left()) { egui::CursorIcon::Text } else { egui::CursorIcon::Default }); + } + if resp.clicked() || resp.drag_started() { + resp.request_focus(); + self.focus_pane = pane; + } + let focused = resp.has_focus(); + if focused { + ui.ctx().memory_mut(|mem| mem.set_focus_lock_filter(id, egui::EventFilter { tab: true, horizontal_arrows: true, vertical_arrows: true, escape: false })); + self.keyboard(ui, pane, m, rect_h); + } + + { + let doc = self.docs.get_mut(&doc_id).unwrap(); + doc.sync_edits(); + doc.refresh_folds(tab_w); + let p = &mut self.panes[pane]; + let tb = &mut p.tabs[p.active]; + tb.rows.refresh(doc, wrap, tab_w); + } + self.pointer(ui, pane, doc_id, &resp, code, m); + + // scrolling, with a small rubber band past either end + let (count, head_row) = { + let doc = &self.docs[&doc_id]; + let tb = &self.panes[pane].tabs[self.panes[pane].active]; + let (l, c) = doc.buf.pos(doc.buf.head()); + (tb.rows.count(doc), tb.rows.row_of(l, c)) + }; + let max = (count as f32 * m.lh - rect.height() * 0.5).max(0.0); + let wheel = if resp.hovered() || ui.rect_contains_pointer(rect) { (crate::ui::widgets::wheel(ui), ui.input(|i| i.modifiers)) } else { (egui::Vec2::ZERO, Modifiers::NONE) }; + let pending_reveal = focused && std::mem::take(&mut self.reveal); + { + let tb = { let p = &mut self.panes[pane]; let a = p.active; &mut p.tabs[a] }; + if wheel.1.command { + if wheel.0.y != 0.0 { + self.s.font_size = (self.s.font_size + wheel.0.y.signum()).clamp(8.0, 40.0); + } + } else { + tb.scroll.target -= wheel.0.y * 1.6; + tb.scroll_x = (tb.scroll_x - wheel.0.x).max(0.0); + } + if tb.scroll.target < 0.0 { + tb.scroll.target = if tb.scroll.target < -60.0 { -60.0 } else { tb.scroll.target * 0.8 }; + } else if tb.scroll.target > max { + tb.scroll.target = max + (tb.scroll.target - max).min(60.0) * 0.8; + } + if tb.scroll.target.abs() < 0.5 { tb.scroll.target = 0.0 } + if pending_reveal && focused { + let y = head_row as f32 * m.lh; + let (top, bot) = (tb.scroll.target + m.lh * 2.0, tb.scroll.target + rect.height() - m.lh * 3.0); + if y < top { tb.scroll.target = (y - m.lh * 2.0).max(0.0) } + else if y > bot { tb.scroll.target = y - rect.height() + m.lh * 3.0 } + } + tb.scroll.step(SCROLL); + } + let (scroll, scroll_x) = { let tb = &self.panes[pane].tabs[self.panes[pane].active]; (tb.scroll.x, tb.scroll_x) }; + + // make sure what's on screen, and a bit beyond, has colours + let first = (scroll / m.lh).floor().max(0.0) as usize; + let shown = (rect.height() / m.lh).ceil() as usize + 1; + let last_line = { + let tb = &self.panes[pane].tabs[self.panes[pane].active]; + let d = &self.docs[&doc_id]; + let r = tb.rows.row((first + shown).min(tb.rows.count(d).saturating_sub(1))).0; + r.min(d.buf.lines()) + }; + let doc = self.docs.get_mut(&doc_id).unwrap(); + doc.highlight(&self.reg, last_line + 40, 0); + + let doc = &self.docs[&doc_id]; + let tb = &self.panes[pane].tabs[self.panes[pane].active]; + let clip = rect.shrink2(vec2(0.0, 4.0)); + let painter = ui.painter_at(clip); + let code_clip = Rect::from_min_max(pos2(code.left(), clip.top()), clip.max); + let code_p = ui.painter_at(code_clip); + let font = fonts::mono(m.font); + let y_of = |row: usize| rect.top() + 6.0 + row as f32 * m.lh - scroll; + let x0 = code.left() + 6.0 - scroll_x; + + // indent guides, selections and search hits sit behind the text + let rows: Vec<(usize, (usize, usize), usize)> = (first..(first + shown).min(count)).map(|r| (r, tb.rows.row(r), tb.rows.row_end(r, doc))).collect(); + let cur_line = doc.buf.pos(doc.buf.head()).0; + + // the current line is a bubble that slides between lines + let bubble_y = spring(format!("cur/{pane}"), rect.top() + 6.0 + head_row as f32 * m.lh, Preset { stiffness: 1100.0, damping: 0.72 }) - scroll; + if doc.buf.sels.len() == 1 && doc.buf.sels[0].is_empty() { + let r = Rect::from_min_size(pos2(rect.left() + 6.0, bubble_y), vec2(rect.width() - 12.0, m.lh)); + painter.rect_filled(r, cr(10.0), alpha(t.primary, if focused { 0.08 } else { 0.04 })); + } + for (_, (line, _), _) in &rows { + if *line >= doc.buf.lines() { continue } + } + let line_cols = |line: usize| doc.buf.line_text(line); + for s in doc.buf.sels.iter().filter(|s| !s.is_empty()) { + let r = s.range(); + let (a, b) = (doc.buf.pos(r.start), doc.buf.pos(r.end)); + for (row, (line, c0), c1) in &rows { + if *line < a.0 || *line > b.0 || *line >= doc.buf.lines() { continue } + let text = line_cols(*line); + let from = if *line == a.0 { a.1.max(*c0) } else { *c0 }; + let to = if *line == b.0 { b.1.min(*c1) } else { *c1 }; + if from > to || (*line == a.0 && a.1 > *c1) { continue } + let base = vis_col(&text, *c0, tab_w); + let xa = (vis_col(&text, from, tab_w) - base) as f32 * m.cw; + let eol = if *line < b.0 && to == *c1 { m.cw * 0.6 } else { 0.0 }; + let xb = (vis_col(&text, to, tab_w) - base) as f32 * m.cw + eol; + let sr = Rect::from_min_max(pos2(x0 + xa, y_of(*row)), pos2(x0 + xb, y_of(*row) + m.lh)); + code_p.rect_filled(sr, cr(5.0), alpha(t.primary, 0.3)); + } + } + for (a, b, is_current) in self.find_hits_in(doc_id, doc, &rows) { + let (line, c0) = doc.buf.pos(a); + let text = doc.buf.line_text(line); + let Some(row) = rows.iter().find(|r| r.1.0 == line && r.1.1 <= c0 && c0 <= r.2) else { continue }; + let base = vis_col(&text, row.1.1, tab_w); + let xa = (vis_col(&text, c0, tab_w) - base) as f32 * m.cw; + let xb = (vis_col(&text, c0 + (b - a), tab_w) - base) as f32 * m.cw; + let sr = Rect::from_min_max(pos2(x0 + xa - 1.0, y_of(row.0) + 1.0), pos2(x0 + xb + 1.0, y_of(row.0) + m.lh - 1.0)); + code_p.rect_filled(sr, cr(5.0), if is_current { alpha(t.tertiary, 0.6) } else { alpha(t.tertiary, 0.24) }); + } + if let Some((a, b)) = doc.buf.matching_bracket(doc.buf.head()) { + for at in [a, b] { + let (line, col) = doc.buf.pos(at); + let Some(row) = rows.iter().find(|r| r.1.0 == line && r.1.1 <= col && col < r.2) else { continue }; + let text = doc.buf.line_text(line); + let x = (vis_col(&text, col, tab_w) - vis_col(&text, row.1.1, tab_w)) as f32 * m.cw; + let r = Rect::from_min_size(pos2(x0 + x - 1.0, y_of(row.0) + 1.0), vec2(m.cw + 2.0, m.lh - 2.0)); + let pop = spring(format!("br/{pane}/{}", (at == a) as u8), 1.0, motion::FAST); + code_p.rect_filled(scale_rect(r, pop), cr(5.0), alpha(t.primary, 0.26)); + } + } + + let g_font = fonts::mono((m.font * 0.86).round()); + for (row, (line, c0), c1) in &rows { + if *line >= doc.buf.lines() { continue } + let y = y_of(*row); + if *c0 == 0 { + if self.s.line_numbers { + let col = if *line == cur_line { t.primary } else { alpha(t.on_variant, 0.55) }; + painter.text(pos2(rect.left() + gutter - 22.0, y + m.lh / 2.0), egui::Align2::RIGHT_CENTER, (line + 1).to_string(), g_font.clone(), col); + } + if doc.bookmarks.contains(line) { + painter.circle_filled(pos2(rect.left() + 11.0, y + m.lh / 2.0), 4.0, t.tertiary); + } + self.gutter_marks(&painter, doc, *line, pos2(rect.left() + gutter - 2.0, y), m.lh); + if doc.fold_ends.contains_key(line) { + let folded = doc.folded.contains(line); + let hover = ui.input(|i| i.pointer.hover_pos()).is_some_and(|p| rect.contains(p) && p.x < code.left() + 4.0); + let vis = if folded { 1.0 } else { spring(format!("foldv/{pane}"), hover as u8 as f32, motion::EFFECT) }; + if vis > 0.01 { + let turn = spring(format!("fold/{doc_id}/{line}"), !folded as u8 as f32, motion::DEFAULT); + morph::paint(&painter, pos2(rect.left() + gutter - 12.0, y + m.lh / 2.0), 15.0, Morph::Fold, turn, alpha(t.on_variant, vis * 0.9), t.low); + } + } + } + if self.s.indent_guides && *c0 == 0 { + let text = doc.buf.line_text(*line); + let lead = vis_col(&text, text.chars().take_while(|c| *c == ' ' || *c == '\t').count(), tab_w); + let mut g = tab_w; + while g < lead { + let x = x0 + g as f32 * m.cw; + code_p.line_segment([pos2(x, y), pos2(x, y + m.lh)], egui::Stroke::new(1.0, alpha(t.outline_variant, 0.5))); + g += tab_w; + } + } + let job = line_job(doc, &self.reg, &t, *line, (*c0, *c1), &font, tab_w, self.s.show_whitespace); + let galley = ui.painter().layout_job(job); + let gy = y + (m.lh - galley.size().y) / 2.0; + code_p.galley(pos2(x0, gy), galley, t.syntax[0]); + if doc.folded.contains(line) { + let px = (doc.buf.line_len(*line) + 2) as f32 * m.cw; + let tag = Rect::from_min_size(pos2(x0 + px, y + 3.0), vec2(m.cw * 5.0, m.lh - 6.0)); + code_p.rect_filled(tag, cr(tag.height() / 2.0), t.secondary_container); + let n = doc.fold_ends.get(line).map_or(0, |e| e - line); + code_p.text(tag.center(), egui::Align2::CENTER_CENTER, n.to_string(), fonts::mono(m.font * 0.75), t.on_secondary_container); + } + } + if let Some((line, born)) = tb.beacon { + let age = (ui.input(|i| i.time) - born) as f32; + if age < 0.9 { + let row = tb.rows.row_of(line, 0); + let k = 1.0 - (age / 0.9); + let r = Rect::from_min_size(pos2(rect.left() + 6.0, y_of(row)), vec2(rect.width() - 12.0, m.lh)); + let grow = motion::stagger(age, 0.0, 0.35); + painter.rect_filled(r.expand2(vec2(0.0, 5.0 * (1.0 - grow))), cr(10.0), alpha(t.primary, 0.34 * k * k)); + motion::keep_alive(); + } + } + + // carets: the primary glides, the rest are placed directly + let now = ui.input(|i| i.time); + let idle = (now - self.last_input) as f32; + let blink = if focused { if idle < 0.7 { 1.0 } else { (0.5 + 0.5 * ((idle - 0.7) * 3.6).cos()).clamp(0.0, 1.0) } } else { 0.0 }; + let primary = doc.buf.primary; + let caret_at = |at: usize| -> Option { + let (line, col) = doc.buf.pos(at); + let row = tb.rows.row_of(line, col); + let text = doc.buf.line_text(line); + let (_, c0) = tb.rows.row(row); + let x = (vis_col(&text, col, tab_w) - vis_col(&text, c0, tab_w)) as f32 * m.cw; + Some(pos2(x, row as f32 * m.lh)) + }; + let positions: Vec> = doc.buf.sels.iter().map(|s| caret_at(s.head)).collect(); + for (i, p) in positions.iter().enumerate() { + let Some(p) = p else { continue }; + if i != primary { + let pos = pos2(x0 + p.x, rect.top() + 6.0 + p.y - scroll); + code_p.rect_filled(Rect::from_min_size(pos, vec2(2.0, m.lh)), cr(1.0), alpha(t.primary, blink)); + } + } + let target = positions.get(primary).copied().flatten(); + let tb_mut = { let p = &mut self.panes[pane]; let a = p.active; &mut p.tabs[a] }; + if let Some(p) = target { + tb_mut.caret[0].target = p.x; + tb_mut.caret[1].target = p.y; + let (x, y) = (tb_mut.caret[0].step(CARET), tb_mut.caret[1].step(CARET)); + let speed = tb_mut.caret[0].v.abs() + tb_mut.caret[1].v.abs(); + let stretch = (speed / 900.0).min(1.0); + let squash = spring(format!("caret-kick/{pane}"), 0.0, motion::FAST); + let w = 2.2 + stretch * 5.0 + squash.abs() * 3.0; + let h = m.lh * (1.0 - 0.2 * squash.abs()); + let r = Rect::from_min_size(pos2(x0 + x - w / 2.0 + 1.0, rect.top() + 6.0 + y - scroll + (m.lh - h) / 2.0), vec2(w, h)); + code_p.rect_filled(r, cr(w / 2.0), alpha(t.primary, blink.max(stretch))); + } + if focused && idle < 30.0 { + ui.ctx().request_repaint_after(std::time::Duration::from_millis(40)); + } + } + + fn keyboard(&mut self, ui: &mut Ui, pane: usize, m: Metrics, height: f32) { + let Some(doc_id) = self.panes[pane].tabs.get(self.panes[pane].active).map(|x| x.doc) else { return }; + let events = ui.input(|i| i.events.clone()); + let p = prefs(self); + let page = (height / m.lh) as usize; + let mut acted = false; + let mut typed = false; + for ev in events { + let doc = self.docs.get_mut(&doc_id).unwrap(); + match ev { + Event::Text(s) => { + if s.chars().all(|c| !c.is_control()) { + doc.buf.type_text(&s, &p); + acted = true; + typed = true; + } + } + Event::Ime(egui::ImeEvent::Commit(s)) => { + doc.buf.insert(&s, EditKind::Typing); + acted = true; + } + Event::Paste(s) => { + doc.buf.insert(&s.replace("\r\n", "\n"), EditKind::Other); + acted = true; + } + Event::Copy => { + let t = doc.buf.selected_text(); + if !t.is_empty() { ui.ctx().copy_text(t) } + } + Event::Cut => { + let t = doc.buf.selected_text(); + if !t.is_empty() { + ui.ctx().copy_text(t); + doc.buf.insert("", EditKind::Other); + acted = true; + } + } + Event::Key { key, pressed: true, modifiers: md, .. } => { + let (cmd, sh, alt) = (md.command, md.shift, md.alt); + acted = true; + let mv = |doc: &mut Doc, k: Move| doc.buf.move_cursors(k, sh); + match key { + Key::ArrowLeft if !alt => mv(doc, if cmd { Move::WordLeft } else { Move::Left }), + Key::ArrowRight if !alt => mv(doc, if cmd { Move::WordRight } else { Move::Right }), + Key::ArrowUp if !cmd && !alt => mv(doc, Move::Up), + Key::ArrowDown if !cmd && !alt => mv(doc, Move::Down), + Key::Home => mv(doc, if cmd { Move::DocStart } else { Move::Home }), + Key::End => mv(doc, if cmd { Move::DocEnd } else { Move::End }), + Key::PageUp if !alt => mv(doc, Move::PageUp(page)), + Key::PageDown if !alt => mv(doc, Move::PageDown(page)), + Key::Enter if !cmd => doc.buf.newline(&p), + Key::Backspace => if cmd { doc.buf.delete_word(false) } else { doc.buf.backspace(&p) }, + Key::Delete => if cmd { doc.buf.delete_word(true) } else { doc.buf.delete_forward() }, + Key::Tab if !cmd => if sh { doc.buf.unindent(&p) } else { doc.buf.indent(&p) }, + Key::Escape => { + let keep = doc.buf.sels[doc.buf.primary]; + doc.buf.set_sels(vec![Sel::cursor(keep.head)]); + } + _ => acted = false, + } + } + _ => {} + } + } + if acted { + self.reveal = true; + self.last_input = ui.input(|i| i.time); + if typed { + motion::spring(format!("caret-kick/{pane}"), 0.0, motion::FAST); + motion::kick(format!("caret-kick/{pane}"), 4.0); + } + ui.ctx().request_repaint(); + } + } + + fn pointer(&mut self, ui: &mut Ui, pane: usize, doc_id: u64, resp: &egui::Response, code: Rect, m: Metrics) { + let hover = ui.input(|i| i.pointer.interact_pos()); + let Some(pos) = hover else { return }; + let mods = ui.input(|i| i.modifiers); + let now = ui.input(|i| i.time); + let tab_w = self.s.tab_width; + let doc = self.docs.get_mut(&doc_id).unwrap(); + let p = &mut self.panes[pane]; + let a = p.active; + let tb = &mut p.tabs[a]; + let locate = |tb: &Tab, doc: &Doc, pos: Pos2| -> usize { + let row = ((pos.y - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize; + let (line, c0) = tb.rows.row(row.min(tb.rows.count(doc).saturating_sub(1))); + if line >= doc.buf.lines() { return doc.buf.len() } + let text = doc.buf.line_text(line); + let base = vis_col(&text, c0, tab_w); + let cells = (pos.x - code.left() - 6.0 + tb.scroll_x) / m.cw + base as f32; + doc.buf.at(line, col_at(&text, cells, tab_w)) + }; + if resp.contains_pointer() && ui.input(|i| i.pointer.button_pressed(PointerButton::Primary)) { + if pos.x < code.left() { + let row = ((pos.y - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize; + let (line, _) = tb.rows.row(row); + if line < doc.buf.lines() { + if doc.fold_ends.contains_key(&line) { doc.toggle_fold(line) } + else { + let at = doc.buf.at(line, 0); + doc.buf.set_cursor(at); + } + } + return; + } + let at = locate(tb, doc, pos); + let multi = if now - tb.click.0 < 0.35 && tb.click.1 == at { (tb.click.2 % 3) + 1 } else { 1 }; + tb.click = (now, at, multi); + self.last_input = now; + let (line, _) = doc.buf.pos(at); + if mods.alt { + tb.block_anchor = Some(pos); + } else if mods.command { + let mut v = doc.buf.sels.clone(); + v.push(Sel::cursor(at)); + doc.buf.set_sels(v); + } else if mods.shift { + let s = doc.buf.sels[doc.buf.primary]; + doc.buf.set_sels(vec![Sel { anchor: s.anchor, head: at, want_col: None }]); + } else { + match multi { + 2 => { + let r = doc.buf.word_at(at); + tb.drag_word = Some(r.clone()); + doc.buf.set_sels(vec![Sel { anchor: r.start, head: r.end, want_col: None }]); + } + 3 => { + let end = if line + 1 < doc.buf.lines() { doc.buf.at(line + 1, 0) } else { doc.buf.len() }; + let s = doc.buf.at(line, 0); + tb.drag_word = Some(s..end); + doc.buf.set_sels(vec![Sel { anchor: s, head: end, want_col: None }]); + } + _ => { + tb.drag_word = None; + doc.buf.set_cursor(at); + } + } + } + } + if resp.dragged_by(PointerButton::Primary) && pos.x >= code.left() - 40.0 { + if let Some(anchor) = tb.block_anchor { + // Alt-drag: one cursor per line, a block selection + let (r0, r1) = (anchor.y.min(pos.y), anchor.y.max(pos.y)); + let (c0, c1) = (anchor.x, pos.x); + let top = ((r0 - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize; + let bot = ((r1 - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize; + let cell = |x: f32| (x - code.left() - 6.0 + tb.scroll_x) / m.cw; + let mut v = vec![]; + for row in top..=bot.min(tb.rows.count(doc).saturating_sub(1)) { + let (line, _) = tb.rows.row(row); + let text = doc.buf.line_text(line); + let (a, b) = (doc.buf.at(line, col_at(&text, cell(c0), tab_w)), doc.buf.at(line, col_at(&text, cell(c1), tab_w))); + v.push(Sel { anchor: a, head: b, want_col: None }); + } + doc.buf.set_sels(v); + } else { + let at = locate(tb, doc, pos); + if let Some(w) = tb.drag_word.clone() { + let (anchor, head) = if at < w.start { (w.end, at) } else { (w.start, at.max(w.end)) }; + doc.buf.set_sels(vec![Sel { anchor, head, want_col: None }]); + } else if doc.buf.sels.len() == 1 { + let s = doc.buf.sels[0]; + doc.buf.set_sels(vec![Sel { anchor: s.anchor, head: at, want_col: None }]); + } + } + // keep selecting past the edges + if pos.y < code.top() + 10.0 { tb.scroll.target -= 18.0; motion::keep_alive() } + if pos.y > code.bottom() - 10.0 { tb.scroll.target += 18.0; motion::keep_alive() } + } + if resp.drag_stopped() { + tb.block_anchor = None; + tb.drag_word = None; + } + if resp.secondary_clicked() { + let at = locate(tb, doc, pos); + if !doc.buf.sels.iter().any(|s| s.range().contains(&at)) { + doc.buf.set_cursor(at); + } + self.editor_menu(pos); + } + } + + pub fn editor_scroll_of(pane: &Pane) -> f32 { + pane.tabs.get(pane.active).map_or(0.0, |t| t.scroll.x) + } +} diff --git a/src/ui/find.rs b/src/ui/find.rs new file mode 100644 index 0000000..6fb71c6 --- /dev/null +++ b/src/ui/find.rs @@ -0,0 +1,189 @@ +//! The find bubble: floats over the top of the editor and unfolds a replace row when asked. + +use super::morph::{self, Morph}; +use super::{fonts, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring}; +use crate::text::{Doc, EditKind, Sel}; +use eframe::egui::{self, pos2, vec2, Align2, Id, Key, Rect, Ui}; + +#[derive(Default)] +pub struct Find { + pub open: bool, + pub replace: bool, + pub query: String, + pub with: String, + pub case: bool, + pub word: bool, + pub regex: bool, + pub focus: bool, + /// Char ranges of every match, for the doc in `key.0`. + pub hits: Vec<(usize, usize)>, + pub cur: usize, + key: (u64, u64, String, u8), + pub error: bool, +} + +const MAX_HITS: usize = 50_000; + +impl Find { + pub fn refresh(&mut self, doc: &Doc) { + let flags = self.case as u8 | (self.word as u8) << 1 | (self.regex as u8) << 2; + let key = (doc.id, doc.buf.version, self.query.clone(), flags); + if key == self.key { + return; + } + self.key = key; + self.hits.clear(); + self.error = false; + if self.query.is_empty() { + return; + } + let pat = if self.regex { self.query.clone() } else { regex::escape(&self.query) }; + let pat = if self.word { format!(r"\b(?:{pat})\b") } else { pat }; + let re = regex::RegexBuilder::new(&pat).case_insensitive(!self.case).multi_line(true).build(); + let Ok(re) = re else { self.error = true; return }; + let text = doc.buf.rope.to_string(); + for m in re.find_iter(&text).take(MAX_HITS) { + if m.is_empty() { continue } + self.hits.push((doc.buf.rope.byte_to_char(m.start()), doc.buf.rope.byte_to_char(m.end()))); + } + let head = doc.buf.head(); + self.cur = self.hits.iter().position(|h| h.0 >= head).unwrap_or(0); + } +} + +impl App { + pub fn find_hits_in(&self, doc_id: u64, doc: &Doc, rows: &[(usize, (usize, usize), usize)]) -> Vec<(usize, usize, bool)> { + if !self.find.open || self.find.key.0 != doc_id || rows.is_empty() { + return vec![]; + } + let lines = doc.buf.lines(); + let first = doc.buf.rope.line_to_char(rows[0].1.0.min(lines - 1)); + let last_line = rows[rows.len() - 1].1.0.min(lines - 1); + let end = doc.buf.at(last_line, usize::MAX); + let a = self.find.hits.partition_point(|h| h.1 < first); + self.find.hits[a..].iter().enumerate().take_while(|(_, h)| h.0 <= end).map(|(i, h)| (h.0, h.1, a + i == self.find.cur)).collect() + } + + fn find_refresh(&mut self) { + if let Some(d) = self.cur_doc_id().and_then(|i| self.docs.get(&i)) { + self.find.refresh(d); + } + } + + pub fn find_step(&mut self, ctx: &egui::Context, back: bool) { + let n = self.find.hits.len(); + if n == 0 { + return; + } + self.find.cur = if back { (self.find.cur + n - 1) % n } else { (self.find.cur + 1) % n }; + self.find_show(ctx); + } + + fn find_show(&mut self, ctx: &egui::Context) { + let Some(&(a, b)) = self.find.hits.get(self.find.cur) else { return }; + if let Some(d) = self.cur_doc_mut() { + d.buf.set_sels(vec![Sel { anchor: a, head: b, want_col: None }]); + let line = d.buf.pos(a).0; + self.jump_to_line(ctx, line); + } + } + + fn replace_one(&mut self, ctx: &egui::Context) { + let Some(&(a, b)) = self.find.hits.get(self.find.cur) else { return }; + let with = self.find.with.clone(); + if let Some(d) = self.cur_doc_mut() { + d.buf.apply(vec![(a..b, with)], EditKind::Other, |_, st, n| Sel::cursor(st + n)); + } + self.find_refresh(); + self.find_show(ctx); + } + + fn replace_all(&mut self) { + let hits = self.find.hits.clone(); + let with = self.find.with.clone(); + let n = hits.len(); + if let Some(d) = self.cur_doc_mut() { + let ch = hits.into_iter().map(|(a, b)| (a..b, with.clone())).collect(); + d.buf.apply(ch, EditKind::Other, |_, st, n| Sel::cursor(st + n)); + } + self.toast("find_replace", format!("Replaced {n} matches")); + } + + pub fn find_bar(&mut self, ui: &mut Ui, card: Rect) { + let t = self.t.clone(); + let k = spring("find/open", self.find.open as u8 as f32, motion::DEFAULT); + if k < 0.01 && !self.find.open { + return; + } + let rep = spring("find/rep", self.find.replace as u8 as f32, motion::DEFAULT).clamp(0.0, 1.2); + self.find_refresh(); + let w = (card.width() - 150.0).clamp(300.0, 500.0); + let h = 52.0 + 46.0 * rep; + let target = Rect::from_min_size(pos2(card.right() - 108.0 - w, card.top() + 10.0), vec2(w, h)); + let origin = Rect::from_center_size(pos2(target.right() - 26.0, target.top() + 26.0), vec2(44.0, 44.0)); + let rect = lerp_rect(origin, target, k); + egui::Area::new(Id::unique("findbar")).order(egui::Order::Foreground).fixed_pos(rect.min).interactable(true).show(ui.ctx(), |ui| { + ui.set_clip_rect(rect.expand(30.0)); + let p = ui.painter().clone(); + shadow(&p, rect, 24.0, k.clamp(0.0, 1.0), t.dark); + p.rect_filled(rect, cr(24.0), t.high); + if k < 0.6 { + return; + } + let row = Rect::from_min_size(rect.min, vec2(rect.width(), 52.0)); + if morph::button(ui, &t, Rect::from_center_size(pos2(rect.left() + 26.0, row.center().y), vec2(34.0, 34.0)), "find/more", Morph::Fold, self.find.replace, "Replace", t.high).clicked() { + self.find.replace = !self.find.replace; + } + let tools = 4.0 * 32.0 + 124.0; + let field = Rect::from_min_max(pos2(rect.left() + 48.0, row.top() + 9.0), pos2(rect.right() - tools, row.bottom() - 9.0)); + let te = ui.put(field, egui::TextEdit::singleline(&mut self.find.query).frame(egui::Frame::NONE).hint_text("Find").font(fonts::ui(14.0)).align(Align2::LEFT_CENTER).text_color(if self.find.error { t.error } else { t.on_surface })); + if self.find.focus { + self.find.focus = false; + te.request_focus(); + let mut st = egui::text_edit::TextEditState::load(ui.ctx(), te.id).unwrap_or_default(); + let all = egui::text::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(self.find.query.chars().count())); + st.cursor.set_char_range(Some(all)); + st.store(ui.ctx(), te.id); + } + if te.has_focus() || te.lost_focus() { + let (enter, shift) = ui.input(|i| (i.key_pressed(Key::Enter), i.modifiers.shift)); + if enter { + self.find_step(ui.ctx(), shift); + te.request_focus(); + } + } + let count = if self.find.query.is_empty() { String::new() } else if self.find.hits.is_empty() { "None".to_string() } else { format!("{}/{}", self.find.cur + 1, self.find.hits.len()) }; + p.text(pos2(rect.right() - tools + 52.0, row.center().y), Align2::CENTER_CENTER, count, fonts::ui(12.0), t.on_variant); + let mut x = rect.right() - 142.0; + for (key, tip, label, on) in [("find/case", "Match case", "Aa", self.find.case), ("find/word", "Whole word", "ab", self.find.word), ("find/re", "Regular expression", ".*", self.find.regex)] { + let r = Rect::from_center_size(pos2(x, row.center().y), vec2(30.0, 30.0)); + let resp = icon_btn(ui, &t, r, key, "", tip, on); + p.text(r.center(), Align2::CENTER_CENTER, label, fonts::med(12.0), if on { t.on_secondary_container } else { t.on_variant }); + if resp.clicked() { + match key { "find/case" => self.find.case ^= true, "find/word" => self.find.word ^= true, _ => self.find.regex ^= true } + } + x += 30.0; + } + if icon_btn(ui, &t, Rect::from_center_size(pos2(x + 2.0, row.center().y), vec2(30.0, 30.0)), "find/next", "keyboard_arrow_down", "Next (Enter)", false).clicked() { self.find_step(ui.ctx(), false) } + if morph::button(ui, &t, Rect::from_center_size(pos2(x + 32.0, row.center().y), vec2(30.0, 30.0)), "find/close", Morph::SearchClose, self.find.open, "Close (Esc)", t.high).clicked() { self.find_close(ui.ctx()) } + if rep > 0.5 { + let y = row.bottom() - 2.0; + let f2 = Rect::from_min_max(pos2(rect.left() + 48.0, y + 8.0), pos2(rect.right() - 170.0, y + 34.0)); + ui.put(f2, egui::TextEdit::singleline(&mut self.find.with).frame(egui::Frame::NONE).hint_text("Replace with").font(fonts::ui(14.0)).align(Align2::LEFT_CENTER).text_color(t.on_surface)); + if pill(ui, &t, Rect::from_min_size(pos2(rect.right() - 164.0, y + 6.0), vec2(74.0, 30.0)), "find/r1", "", "Replace", Tone::Tonal).clicked() { self.replace_one(ui.ctx()) } + if pill(ui, &t, Rect::from_min_size(pos2(rect.right() - 86.0, y + 6.0), vec2(74.0, 30.0)), "find/ra", "", "All", Tone::Tonal).clicked() { self.replace_all() } + } + }); + if self.find.open && ui.input(|i| i.key_pressed(Key::Escape)) { + self.find_close(ui.ctx()); + } + } + + pub fn find_close(&mut self, ctx: &egui::Context) { + self.find.open = false; + self.find.hits.clear(); + self.focus_editor(ctx); + } +} diff --git a/src/ui/fonts.rs b/src/ui/fonts.rs new file mode 100644 index 0000000..e66fff3 --- /dev/null +++ b/src/ui/fonts.rs @@ -0,0 +1,63 @@ +//! Fonts: Rubik for the interface (variable, in several weights), a coding face for text. + +use eframe::egui::{self, FontData, FontDefinitions, FontFamily, FontId}; +use eframe::epaint::text::{FontTweak, VariationCoords}; +use std::sync::Arc; + +pub const MED: &str = "rubik-500"; +pub const SEMI: &str = "rubik-600"; + +fn fc_match(pattern: &str) -> Option<(String, String)> { + let out = std::process::Command::new("fc-match").args(["-f", "%{file}\n%{family}", pattern]).output().ok()?; + let txt = String::from_utf8_lossy(&out.stdout).to_string(); + let (file, family) = txt.split_once('\n')?; + (!file.is_empty()).then(|| (file.to_string(), family.to_string())) +} + +const CODING: [&str; 6] = ["JetBrains Mono", "JetBrainsMono Nerd Font Mono", "Fira Code", "Cascadia Code", "Source Code Pro", "Hack"]; + +pub fn install(ctx: &egui::Context, mono: &str) { + let mut defs = FontDefinitions::default(); + let rubik: &'static [u8] = include_bytes!("../../assets/Rubik.ttf"); + let mut add = |key: &str, w: f32| { + let mut tw = FontTweak::default(); + tw.coords = VariationCoords::new([(b"wght", w)]); + defs.font_data.insert(key.to_string(), Arc::new(FontData::from_static(rubik).tweak(tw))); + }; + add("rubik", 400.0); + add(MED, 500.0); + add(SEMI, 600.0); + let fallback: Vec = defs.families.get(&FontFamily::Proportional).cloned().unwrap_or_default(); + let fam = |k: &str| { let mut v = vec![k.to_string()]; v.extend(fallback.iter().cloned()); v }; + defs.families.insert(FontFamily::Proportional, fam("rubik")); + defs.families.insert(FontFamily::Name(Arc::from(MED)), fam(MED)); + defs.families.insert(FontFamily::Name(Arc::from(SEMI)), fam(SEMI)); + + let picked = if !mono.is_empty() { fc_match(mono) } else { None }.or_else(|| { + CODING.iter().find_map(|n| { + let (f, fam) = fc_match(n)?; + fam.to_lowercase().contains(&n.to_lowercase()).then_some((f, fam)) + }) + }); + if let Some(bytes) = picked.and_then(|(f, _)| std::fs::read(f).ok()) { + defs.font_data.insert("code".into(), Arc::new(FontData::from_owned(bytes))); + defs.families.get_mut(&FontFamily::Monospace).unwrap().insert(0, "code".into()); + } + ctx.set_fonts(defs); +} + +pub fn ui(size: f32) -> FontId { + FontId::new(size, FontFamily::Proportional) +} + +pub fn med(size: f32) -> FontId { + FontId::new(size, FontFamily::Name(Arc::from(MED))) +} + +pub fn semi(size: f32) -> FontId { + FontId::new(size, FontFamily::Name(Arc::from(SEMI))) +} + +pub fn mono(size: f32) -> FontId { + FontId::monospace(size) +} diff --git a/src/ui/icons.rs b/src/ui/icons.rs new file mode 100644 index 0000000..8be038b --- /dev/null +++ b/src/ui/icons.rs @@ -0,0 +1,57 @@ +//! Material Symbols drawn from SVG path data, tinted with theme colours. + +use crate::icondata::ICONS; +use eframe::egui::{self, Color32, Context, Painter, Pos2, Rect, TextureHandle, TextureOptions}; +use std::cell::RefCell; +use std::collections::HashMap; + +thread_local! { + static CACHE: RefCell> = RefCell::new(HashMap::new()); +} + +fn texture(ctx: &Context, name: &str, px: u32) -> Option { + CACHE.with(|c| { + let mut c = c.borrow_mut(); + if let Some(h) = c.get(&(name.to_string(), px)) { + return Some(h.id()); + } + let (_, d) = ICONS.iter().find(|(n, _)| *n == name)?; + let svg = format!(r##""##); + let mut pm = resvg::tiny_skia::Pixmap::new(px, px)?; + let tree = resvg::usvg::Tree::from_str(&svg, &resvg::usvg::Options::default()).ok()?; + resvg::render(&tree, resvg::tiny_skia::Transform::identity(), &mut pm.as_mut()); + let img = egui::ColorImage::from_rgba_premultiplied([px as usize; 2], pm.data()); + let h = ctx.load_texture(format!("icon-{name}-{px}"), img, TextureOptions::LINEAR); + let id = h.id(); + c.insert((name.to_string(), px), h); + Some(id) + }) +} + +pub fn paint(ctx: &Context, p: &Painter, center: Pos2, size: f32, name: &str, color: Color32) { + if color.a() == 0 || size < 1.0 { + return; + } + let px = (((size * ctx.pixels_per_point()).ceil() as u32).div_ceil(8) * 8).clamp(16, 256); + if let Some(id) = texture(ctx, name, px) { + let r = Rect::from_center_size(center, egui::vec2(size, size)); + p.image(id, r, Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), color); + } +} + +#[cfg(test)] +mod tests { + #[test] + fn every_icon_the_app_names_exists() { + let src = ["app.rs", "ui/commands.rs", "ui/widgets.rs", "ui/tabs.rs", "ui/rail.rs", "ui/sidebar.rs", "ui/status.rs", "ui/terminal.rs", "ui/settings.rs", "ui/find.rs", "ui/palette.rs", "ui/welcome.rs", "ui/editor.rs", "ui/preview.rs", "ui/menu.rs"]; + let re = regex::Regex::new(r#"\b(?:icon_btn|paint|ic)\b\(?[^"\n]{0,60}"([a-z_0-9]+)""#).unwrap(); + for f in src { + let Ok(t) = std::fs::read_to_string(format!("{}/src/{f}", env!("CARGO_MANIFEST_DIR"))) else { continue }; + for c in re.captures_iter(&t) { + // `ic = match kind { "type" …` names a symbol kind, not an icon + if c[0].contains("match") { continue } + assert!(crate::icondata::ICONS.iter().any(|(n, _)| *n == &c[1]), "{f}: no icon {}", &c[1]); + } + } + } +} diff --git a/src/ui/menu.rs b/src/ui/menu.rs new file mode 100644 index 0000000..e5b3489 --- /dev/null +++ b/src/ui/menu.rs @@ -0,0 +1,257 @@ +//! Pop-out menus and dialogs. They live inside the window, so they can scale out from where they +//! were opened instead of appearing as separate windows. + +use super::commands::{self, Cmd}; +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring_from, Preset}; +use crate::theme::alpha; +use eframe::egui::{self, emath::TSTransform, pos2, vec2, Align2, Area, Id, Key, Order, Pos2, Rect, Sense, Ui}; +use std::path::PathBuf; + +#[derive(Clone, Debug)] +pub enum Act { + Cmd(Cmd), + CloseOthers(usize, usize), + CloseTabAt(usize, usize), + NewFile(PathBuf), + NewFolder(PathBuf), + Rename(PathBuf), + Trash(PathBuf), + CopyPath(PathBuf), + TerminalAt(PathBuf), + SetRoot(PathBuf), + OpenRecent(PathBuf), +} + +pub struct MenuItem { + pub ic: &'static str, + pub label: String, + pub keys: String, + pub act: Option, +} + +pub struct Menu { + pub pos: Pos2, + pub items: Vec, + pub seq: u64, +} + +pub enum Dialog { + Prompt { title: String, value: String, act: Act }, + Confirm { title: String, body: String, pane: usize, tab: usize }, + ConfirmTrash(PathBuf), + ConfirmQuit, +} + +fn item(cmd: Cmd) -> MenuItem { + let e = commands::all().into_iter().find(|e| e.cmd == cmd); + match e { + Some(e) => MenuItem { ic: e.ic, label: e.label.to_string(), keys: e.keys.to_string(), act: Some(Act::Cmd(cmd)) }, + None => MenuItem { ic: "more_horiz", label: format!("{cmd:?}"), keys: String::new(), act: Some(Act::Cmd(cmd)) }, + } +} + +fn sep() -> MenuItem { + MenuItem { ic: "", label: String::new(), keys: String::new(), act: None } +} + +fn act(ic: &'static str, label: &str, a: Act) -> MenuItem { + MenuItem { ic, label: label.to_string(), keys: String::new(), act: Some(a) } +} + +impl App { + pub fn open_menu(&mut self, pos: Pos2, items: Vec) { + self.menu_seq += 1; + self.menu = Some(Menu { pos, items, seq: self.menu_seq }); + } + + pub fn editor_menu(&mut self, pos: Pos2) { + use Cmd::*; + self.open_menu(pos, vec![item(Cut), item(Copy), item(Paste), sep(), item(GotoDefinition), item(Hover), sep(), item(Comment), item(DuplicateLines), item(SelectNext), sep(), item(SelectAll), item(ToggleBookmark)]); + } + + pub fn tab_menu(&mut self, pane: usize, tab: usize, pos: Pos2) { + let mut v = vec![act("close", "Close", Act::CloseTabAt(pane, tab)), act("close_fullscreen", "Close others", Act::CloseOthers(pane, tab)), sep()]; + let path = self.panes[pane].tabs.get(tab).and_then(|t| self.docs.get(&t.doc)).and_then(|d| d.path.clone()); + if let Some(p) = path { + v.push(act("content_copy", "Copy path", Act::CopyPath(p.clone()))); + if let Some(dir) = p.parent() { v.push(act("terminal", "Terminal here", Act::TerminalAt(dir.to_path_buf()))) } + v.push(sep()); + } + v.push(item(Cmd::SplitRight)); + v.push(item(Cmd::SplitDown)); + self.open_menu(pos, v); + } + + pub fn app_menu(&mut self, pos: Pos2) { + use Cmd::*; + let mut v = vec![item(New), item(Open), item(OpenFolder), item(Save), item(SaveAs), sep(), item(Palette), item(QuickOpen), item(Find), item(FindInFiles), sep(), item(ToggleTerminal), item(SplitRight), item(Zen)]; + let recent: Vec = self.s.recent.iter().take(4).cloned().collect(); + if !recent.is_empty() { + v.push(sep()); + for r in recent { + let name = std::path::Path::new(&r).file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or(r.clone()); + v.push(act("history", &name, Act::OpenRecent(PathBuf::from(r)))); + } + } + v.push(sep()); + v.push(item(Settings)); + v.push(item(About)); + v.push(item(Quit)); + self.open_menu(pos, v); + } + + pub fn file_menu(&mut self, path: PathBuf, is_dir: bool, pos: Pos2) { + let dir = if is_dir { path.clone() } else { path.parent().map(PathBuf::from).unwrap_or_default() }; + let mut v = vec![act("add", "New file", Act::NewFile(dir.clone())), act("folder", "New folder", Act::NewFolder(dir.clone())), sep(), act("edit", "Rename", Act::Rename(path.clone())), act("delete", "Move to trash", Act::Trash(path.clone())), sep(), act("content_copy", "Copy path", Act::CopyPath(path.clone())), act("terminal", "Terminal here", Act::TerminalAt(dir))]; + if is_dir { v.push(act("home", "Make this the project folder", Act::SetRoot(path))) } + self.open_menu(pos, v); + } + + pub fn menu_ui(&mut self, ctx: &egui::Context) { + let Some(menu) = &self.menu else { return }; + let t = self.t.clone(); + let key = format!("menu/{}", menu.seq); + let k = spring_from(&key, 0.0, 1.0, Preset { stiffness: 800.0, damping: 0.66 }); + let row = 36.0; + let height: f32 = menu.items.iter().map(|i| if i.act.is_none() { 11.0 } else { row }).sum::() + 14.0; + let width = 268.0; + let screen = ctx.content_rect(); + let x = menu.pos.x.min(screen.right() - width - 10.0); + let y = menu.pos.y.min(screen.bottom() - height - 10.0).max(8.0); + let rect = Rect::from_min_size(pos2(x, y), vec2(width, height)); + let anchor = menu.pos; + + let mut chosen: Option = None; + let mut dismiss = false; + let scrim = Area::new(Id::unique("menu-scrim")).order(Order::Foreground).fixed_pos(screen.min).show(ctx, |ui| { + ui.allocate_rect(screen, Sense::click()) + }).inner; + if scrim.clicked() || scrim.secondary_clicked() || ctx.input(|i| i.key_pressed(Key::Escape)) { + dismiss = true; + } + let area = Area::new(Id::unique("menu-body")).order(Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| { + ui.set_min_size(rect.size()); + let p = ui.painter(); + shadow(p, rect, 22.0, 1.0, t.dark); + p.rect_filled(rect, cr(22.0), t.high); + let mut yy = rect.top() + 7.0; + for (i, it) in menu.items.iter().enumerate() { + let Some(a) = &it.act else { + let ly = yy + 5.5; + p.line_segment([pos2(rect.left() + 16.0, ly), pos2(rect.right() - 16.0, ly)], egui::Stroke::new(1.0, t.outline_variant)); + yy += 11.0; + continue; + }; + let r = Rect::from_min_size(pos2(rect.left() + 7.0, yy), vec2(width - 14.0, row)); + let ikey = format!("{key}/{i}"); + let resp = ui.interact(r, Id::unique(&ikey), Sense::click()); + let (hov, press) = states(&ikey, &resp); + let k2 = motion::stagger(motion::spring_from(format!("{ikey}/t"), 0.0, 1.0, motion::SLOW), i as f32 * 0.035, 0.6); + let dx = (1.0 - k2) * -10.0; + let col = alpha(t.on_surface, k2.clamp(0.0, 1.0)); + if hov > 0.01 { p.rect_filled(scale_rect(r, 1.0 - 0.02 * press), cr(14.0), alpha(t.primary, 0.13 * hov)); } + if !it.ic.is_empty() { icons::paint(ui.ctx(), p, pos2(r.left() + 20.0 + dx, r.center().y), 18.0, it.ic, alpha(t.on_variant, k2.clamp(0.0, 1.0))) } + p.text(pos2(r.left() + 42.0 + dx, r.center().y), Align2::LEFT_CENTER, &it.label, fonts::ui(13.5), col); + if !it.keys.is_empty() { p.text(pos2(r.right() - 12.0, r.center().y), Align2::RIGHT_CENTER, &it.keys, fonts::ui(11.5), alpha(t.outline, k2.clamp(0.0, 1.0))); } + if resp.clicked() { chosen = Some(a.clone()) } + yy += row; + } + }); + let s = k.max(0.02); + let scale = 0.72 + 0.28 * s; + let tf = TSTransform::from_translation(anchor.to_vec2()) * TSTransform::from_scaling(scale) * TSTransform::from_translation(-anchor.to_vec2()); + ctx.set_transform_layer(area.response.layer_id, tf); + if let Some(a) = chosen { + self.menu = None; + self.act(ctx, a); + } else if dismiss { + self.menu = None; + } + } + + pub fn dialog_ui(&mut self, ctx: &egui::Context) { + let Some(mut dlg) = self.dialog.take() else { return }; + let t = self.t.clone(); + let screen = ctx.content_rect(); + let k = spring_from("dialog", 0.0, 1.0, motion::DEFAULT); + Area::new(Id::unique("dlg-scrim")).order(Order::Foreground).fixed_pos(screen.min).show(ctx, |ui| { + ui.allocate_rect(screen, Sense::click()); + ui.painter().rect_filled(screen, cr(0.0), alpha(egui::Color32::BLACK, 0.4 * k.clamp(0.0, 1.0))); + }); + let rect = Rect::from_center_size(screen.center(), vec2(420.0, 190.0)); + let mut close = ctx.input(|i| i.key_pressed(Key::Escape)); + let mut after: Option> = None; + let area = Area::new(Id::unique("dlg")).order(Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui: &mut Ui| { + ui.set_min_size(rect.size()); + shadow(ui.painter(), rect, 28.0, 1.0, t.dark); + ui.painter().rect_filled(rect, cr(28.0), t.high); + let title = match &dlg { + Dialog::Prompt { title, .. } | Dialog::Confirm { title, .. } => title.clone(), + Dialog::ConfirmTrash(p) => format!("Move {} to the trash?", p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default()), + Dialog::ConfirmQuit => "Quit with unsaved changes?".to_string(), + }; + ui.painter().text(rect.left_top() + vec2(26.0, 34.0), Align2::LEFT_CENTER, title, fonts::med(18.0), t.on_surface); + let btn_y = rect.bottom() - 48.0; + let primary = Rect::from_min_size(pos2(rect.right() - 126.0, btn_y), vec2(104.0, 36.0)); + let cancel = Rect::from_min_size(pos2(rect.right() - 226.0, btn_y), vec2(92.0, 36.0)); + if pill(ui, &t, cancel, "dlg/cancel", "", "Cancel", Tone::Text).clicked() { close = true } + match &mut dlg { + Dialog::Prompt { value, act, .. } => { + let field = Rect::from_min_size(rect.left_top() + vec2(24.0, 66.0), vec2(rect.width() - 48.0, 42.0)); + ui.painter().rect_filled(field, cr(16.0), t.highest); + let te = ui.put(field.shrink2(vec2(14.0, 10.0)), egui::TextEdit::singleline(value).frame(egui::Frame::NONE).font(fonts::ui(14.0)).text_color(t.on_surface)); + te.request_focus(); + let enter = ctx.input(|i| i.key_pressed(Key::Enter)); + if pill(ui, &t, primary, "dlg/ok", "", "OK", Tone::Filled).clicked() || enter { + let (v, a) = (value.clone(), act.clone()); + after = Some(Box::new(move |app, ctx| app.prompt_done(ctx, a, v))); + close = true; + } + } + Dialog::Confirm { body, pane, tab, .. } => { + ui.painter().text(rect.left_top() + vec2(26.0, 72.0), Align2::LEFT_CENTER, body.as_str(), fonts::ui(14.0), t.on_variant); + let (pane, tab) = (*pane, *tab); + let discard = Rect::from_min_size(pos2(rect.left() + 18.0, btn_y), vec2(100.0, 36.0)); + if pill(ui, &t, discard, "dlg/discard", "", "Don't save", Tone::Text).clicked() { + after = Some(Box::new(move |app, _| app.force_close(pane, tab))); + close = true; + } + if pill(ui, &t, primary, "dlg/ok", "", "Save", Tone::Filled).clicked() { + after = Some(Box::new(move |app, ctx| { + app.focus_pane = pane; + app.panes[pane].active = tab; + app.run(ctx, Cmd::Save); + if !app.cur_doc().is_some_and(|d| d.buf.is_modified()) { app.force_close(pane, tab) } + })); + close = true; + } + } + Dialog::ConfirmTrash(p) => { + let p = p.clone(); + if pill(ui, &t, primary, "dlg/ok", "", "Move", Tone::Filled).clicked() { + after = Some(Box::new(move |app, _| app.trash(&p))); + close = true; + } + } + Dialog::ConfirmQuit => { + ui.painter().text(rect.left_top() + vec2(26.0, 72.0), Align2::LEFT_CENTER, "They stay saved as recovery copies for next time.", fonts::ui(14.0), t.on_variant); + if pill(ui, &t, primary, "dlg/ok", "", "Quit", Tone::Filled).clicked() { + after = Some(Box::new(|app, ctx| { app.quit_now = true; ctx.send_viewport_cmd(egui::ViewportCommand::Close) })); + close = true; + } + } + } + }); + let a = screen.center(); + let s = 0.8 + 0.2 * k; + ctx.set_transform_layer(area.response.layer_id, TSTransform::from_translation(a.to_vec2()) * TSTransform::from_scaling(s) * TSTransform::from_translation(-a.to_vec2())); + if close { + motion::forget("dialog"); + } else { + self.dialog = Some(dlg); + } + if let Some(f) = after { f(self, ctx) } + } +} diff --git a/src/ui/mod.rs b/src/ui/mod.rs new file mode 100644 index 0000000..2b2b5d8 --- /dev/null +++ b/src/ui/mod.rs @@ -0,0 +1,17 @@ +pub mod commands; +pub mod editor; +pub mod find; +pub mod fonts; +pub mod icons; +pub mod menu; +pub mod morph; +pub mod palette; +pub mod preview; +pub mod rail; +pub mod settings; +pub mod sidebar; +pub mod status; +pub mod tabs; +pub mod terminal; +pub mod welcome; +pub mod widgets; diff --git a/src/ui/morph.rs b/src/ui/morph.rs new file mode 100644 index 0000000..648028c --- /dev/null +++ b/src/ui/morph.rs @@ -0,0 +1,218 @@ +//! Icons that change shape instead of swapping. Each is drawn from strokes with a morph value `t`, +//! 0 at the first state and 1 at the second; both ends are the plain icon for that action. Values +//! past 1 are fine, so a bouncy spring overshoots the shape as well as the position. + +use crate::motion::{self, spring}; +use crate::theme::{mix, Theme}; +use eframe::egui::{self, epaint::PathShape, pos2, vec2, Color32, Painter, Pos2, Rect, Response, Sense, Stroke, Ui, Vec2}; +use std::f32::consts::{FRAC_PI_2, FRAC_PI_4, TAU}; + +#[derive(Clone, Copy, PartialEq, Debug)] +pub enum Morph { + /// `+` that turns a quarter when `t` goes 0 to 1 and is still a `+`. + AddSpin, + /// `+` to `−`. + AddRemove, + /// Chevron turning from pointing right to pointing down. + Fold, + /// Terminal prompt to a chevron saying "hide". + TerminalHide, + /// Sun to moon. Needs the background colour for the moon's bite. + SunMoon, + /// Magnifier to `×`. + SearchClose, + /// Play triangle to stop square. + PlayStop, + /// Corners pointing out (maximize) to pointing in (restore). + MaxRestore, + /// Straight arrow to a wrapped one. + Wrap, + /// Two sheets (copy) to a tick. + CopyCheck, +} + +fn line(p: &Painter, pts: &[Pos2], w: f32, c: Color32) { + if pts.len() < 2 { + return; + } + p.add(PathShape::line(pts.to_vec(), Stroke::new(w, c))); + // egui strokes end square; these make the caps round + p.circle_filled(pts[0], w / 2.0, c); + p.circle_filled(pts[pts.len() - 1], w / 2.0, c); + for q in &pts[1..pts.len() - 1] { + p.circle_filled(*q, w / 2.0, c); + } +} + +fn lerp_p(a: Pos2, b: Pos2, t: f32) -> Pos2 { + a + (b - a) * t +} + +fn rot(v: Vec2, a: f32) -> Vec2 { + let (s, c) = a.sin_cos(); + vec2(v.x * c - v.y * s, v.x * s + v.y * c) +} + +/// Draws `kind` at `t`. `bg` is what's behind the icon. +pub fn paint(p: &Painter, c: Pos2, size: f32, kind: Morph, t: f32, col: Color32, bg: Color32) { + let u = size / 24.0; + let w = 2.0 * u; + let k = t.clamp(0.0, 1.0); + match kind { + Morph::AddSpin => { + let a = t * FRAC_PI_2; + let r = 7.0 * u; + line(p, &[c + rot(vec2(-r, 0.0), a), c + rot(vec2(r, 0.0), a)], w, col); + line(p, &[c + rot(vec2(0.0, -r), a), c + rot(vec2(0.0, r), a)], w, col); + } + Morph::AddRemove => { + let r = 7.0 * u; + line(p, &[c - vec2(r, 0.0), c + vec2(r, 0.0)], w, col); + let v = r * (1.0 - t).max(0.0); + if v > 0.3 { + line(p, &[c - vec2(0.0, v), c + vec2(0.0, v)], w, col); + } + } + Morph::Fold => { + let a = t * FRAC_PI_2; + let (x, y) = (3.5 * u, 6.0 * u); + let pts = [vec2(-x, -y), vec2(x, 0.0), vec2(-x, y)].map(|v| c + rot(v, a)); + line(p, &pts, w, col); + } + Morph::TerminalHide => { + let (x, y) = (3.5 * u, 6.0 * u); + let center = lerp_p(c + vec2(-5.0 * u, 0.0), c, k); + let a = t * FRAC_PI_2; + line(p, &[vec2(-x, -y), vec2(x, 0.0), vec2(-x, y)].map(|v| center + rot(v, a)), w, col); + let bar = 1.0 - k; + if bar > 0.05 { + let s = c + vec2(1.5 * u, 6.0 * u); + line(p, &[s, s + vec2(7.5 * u * bar, 0.0)], w, col); + } + } + Morph::SunMoon => { + let r = (4.8 + 3.2 * k) * u; + p.circle_filled(c, r, col); + if k > 0.001 { + let bite = lerp_p(c + vec2(11.0 * u, -11.0 * u), c + vec2(3.6 * u, -3.6 * u), k); + p.with_clip_rect(Rect::from_center_size(c, Vec2::splat(r * 2.4))).circle_filled(bite, r * 0.92, bg); + } + let ray = 1.0 - k; + if ray > 0.03 { + for i in 0..8 { + let a = i as f32 / 8.0 * TAU + t * FRAC_PI_4; + let d = Vec2::angled(a); + line(p, &[c + d * 7.6 * u, c + d * (7.6 + 2.6 * ray) * u], 1.8 * u, col); + } + } + } + Morph::SearchClose => { + // the handle grows into one bar of the X while the lens closes into the other + let lens = c + vec2(-2.5 * u, -2.5 * u) * (1.0 - k); + let r = 5.5 * u * (1.0 - k); + let d = Vec2::angled(FRAC_PI_4); + if r > 0.4 { + p.circle_stroke(lens, r, Stroke::new(w, col)); + } + let far = c + d * lerp_f(9.0, 8.0, k) * u; + let near = lerp_p(lens + d * r, c - d * 8.0 * u, k); + line(p, &[near, far], w, col); + if k > 0.02 { + let e = rot(d, FRAC_PI_2) * 8.0 * u * k; + line(p, &[c - e, c + e], w, col); + } + } + Morph::PlayStop => { + let tri = [vec2(-5.0, -7.0), vec2(7.0, 0.0), vec2(7.0, 0.0), vec2(-5.0, 7.0)]; + let sq = [vec2(-6.0, -6.0), vec2(6.0, -6.0), vec2(6.0, 6.0), vec2(-6.0, 6.0)]; + let pts: Vec = (0..4).map(|i| c + (tri[i] + (sq[i] - tri[i]) * t) * u).collect(); + p.add(PathShape::convex_polygon(pts, col, Stroke::new(1.4 * u, col))); + } + Morph::MaxRestore => { + // each corner bracket slides across the middle and turns to face inward + for (sx, sy) in [(-1.0, -1.0), (1.0, -1.0), (1.0, 1.0), (-1.0, 1.0)] { + let at = lerp_f(7.0, 2.5, k); + let arm = 3.8 * lerp_f(1.0, -1.0, k); + let o = c + vec2(sx * at, sy * at) * u; + line(p, &[o - vec2(sx * -arm * -1.0, 0.0) * u, o, o - vec2(0.0, sy * arm) * u], w, col); + } + } + Morph::Wrap => { + let (a, b) = (-8.0, 8.0); + let tail = lerp_p(pos2(b, 0.0), pos2(4.0, 5.0), k); + let bend = lerp_p(pos2(b - 1.0, 0.0), pos2(8.0, 2.5), k); + let head = lerp_p(pos2(b, 0.0), pos2(-1.0, 5.0), k); + let pts = [c + vec2(a, lerp_f(0.0, -4.0, k)) * u, c + vec2(4.0, lerp_f(0.0, -4.0, k)) * u, c + bend.to_vec2() * u, c + tail.to_vec2() * u, c + head.to_vec2() * u]; + line(p, &pts, w, col); + let dir = if k > 0.5 { -1.0 } else { 1.0 }; + let h = c + head.to_vec2() * u; + let s = (2.0 * (k - 0.5).abs()).clamp(0.2, 1.0) * 3.4 * u; + line(p, &[h + vec2(-dir * s, -s), h, h + vec2(-dir * s, s)], w, col); + } + Morph::CopyCheck => { + let f = 1.0 - k; + if f > 0.02 { + let a = Rect::from_center_size(c + vec2(1.5, 1.5) * u, Vec2::splat(11.0 * u)); + let col_a = crate::theme::alpha(col, f * col.a() as f32 / 255.0); + p.rect_stroke(a, 2.5 * u, Stroke::new(w, col_a), egui::StrokeKind::Middle); + line(p, &[c + vec2(-7.0, 3.0) * u, c + vec2(-7.0, -7.0) * u, c + vec2(3.0, -7.0) * u], w, col_a); + } + if k > 0.02 { + check(p, c, size, k, col); + } + } + } +} + +fn lerp_f(a: f32, b: f32, t: f32) -> f32 { + a + (b - a) * t +} + +/// A tick drawing itself on, `t` from 0 to 1. +pub fn check(p: &Painter, c: Pos2, size: f32, t: f32, col: Color32) { + let u = size / 24.0; + let (a, b, e) = (c + vec2(-7.0, 0.5) * u, c + vec2(-2.0, 5.5) * u, c + vec2(7.5, -5.5) * u); + let k = t.clamp(0.0, 1.0); + if k < 0.36 { + line(p, &[a, lerp_p(a, b, k / 0.36)], 2.2 * u, col); + } else { + line(p, &[a, b, lerp_p(b, e, (k - 0.36) / 0.64)], 2.2 * u, col); + } +} + +/// A round button whose icon morphs to `on`. The hover state can also drive the morph, for AddSpin. +pub fn button(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, kind: Morph, on: bool, tip: &str, bg: Color32) -> Response { + let mut r = ui.interact(rect, ui.scope_id().with(key), Sense::click()); + if !tip.is_empty() { + r = r.on_hover_text(tip); + } + let (hov, press) = super::widgets::states(key, &r); + let on = on || (kind == Morph::AddSpin && r.hovered()); + let m = spring(format!("{key}/m"), on as u8 as f32, motion::DEFAULT); + let c = super::widgets::scale_rect(rect, 1.0 - 0.1 * press); + let radius = super::widgets::lerp(rect.height() / 2.0, rect.height() * 0.3, press.clamp(0.0, 1.0)); + if hov > 0.01 { + ui.painter().rect_filled(c, super::widgets::cr(radius), crate::theme::alpha(t.on_surface, 0.09 * hov)); + } + let col = mix(t.on_variant, t.on_surface, hov); + paint(ui.painter(), rect.center(), rect.height() * 0.6 * (1.0 - 0.08 * press), kind, m, col, mix(bg, t.on_surface, 0.09 * hov)); + r +} + +#[cfg(test)] +mod tests { + use super::*; + + /// Every morph has to draw at both ends and past them, since springs overshoot. + #[test] + fn all_kinds_draw_across_the_range() { + let ctx = egui::Context::default(); + let p = Painter::new(ctx, egui::LayerId::background(), Rect::EVERYTHING); + use Morph::*; + for kind in [AddSpin, AddRemove, Fold, TerminalHide, SunMoon, SearchClose, PlayStop, MaxRestore, Wrap, CopyCheck] { + for t in [-0.2, 0.0, 0.33, 0.5, 0.9, 1.0, 1.25] { + paint(&p, pos2(10.0, 10.0), 24.0, kind, t, Color32::WHITE, Color32::BLACK); + } + } + } +} diff --git a/src/ui/palette.rs b/src/ui/palette.rs new file mode 100644 index 0000000..5c85cd9 --- /dev/null +++ b/src/ui/palette.rs @@ -0,0 +1,270 @@ +//! The command palette. One box does everything: type to find a file, `>` for commands, `:` for a +//! line, `@` for a symbol, `!` to run something in the terminal. Rows fall into place one by one. + +use super::commands::{self, Cmd}; +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring, Preset}; +use crate::theme::alpha; +use eframe::egui::{self, emath::TSTransform, pos2, vec2, Align2, Area, Id, Key, Order, Rect, Sense}; +use std::path::PathBuf; + +#[derive(Clone)] +pub enum Pick { + Cmd(Cmd), + File(PathBuf), + Line(usize), + Lang(String), + Run(String), +} + +#[derive(Clone)] +pub struct Row { + pub ic: &'static str, + pub label: String, + pub detail: String, + pub keys: String, + pub pick: Pick, + score: i32, +} + +#[derive(Default)] +pub struct Palette { + pub open: bool, + pub query: String, + last: Option, + pub rows: Vec, + pub sel: usize, + pub born: f64, + pub langs: bool, + pub files: Vec, + pub files_root: Option, + pub focus: bool, +} + +/// Subsequence match, favouring word starts and runs. `None` if not all of `q` is in `s`. +pub fn fuzzy(q: &str, s: &str) -> Option { + if q.is_empty() { + return Some(0); + } + let s_l: Vec = s.to_lowercase().chars().collect(); + let orig: Vec = s.chars().collect(); + let (mut score, mut i, mut run) = (0i32, 0usize, 0i32); + for qc in q.to_lowercase().chars() { + let mut found = false; + while i < s_l.len() { + if s_l[i] == qc { + let start = i == 0 || !orig.get(i - 1).is_some_and(|c| c.is_alphanumeric()); + let camel = orig.get(i).is_some_and(|c| c.is_uppercase()) && i > 0; + run += 1; + score += 2 + run * 2 + if start { 10 } else { 0 } + if camel { 5 } else { 0 }; + i += 1; + found = true; + break; + } + run = 0; + score -= 1; + i += 1; + } + if !found { + return None; + } + } + Some(score - s_l.len() as i32 / 8) +} + +impl App { + pub fn open_palette(&mut self, ctx: &egui::Context, prefix: &str, langs: bool) { + let p = &mut self.palette; + p.open = true; + p.langs = langs; + p.query = prefix.to_string(); + p.last = None; + p.sel = 0; + p.born = ctx.input(|i| i.time); + p.focus = true; + motion::forget("pal/in"); + if p.files_root != self.root { + p.files_root = self.root.clone(); + p.files = self.root.as_deref().map(project_files).unwrap_or_default(); + } + } + + fn palette_rows(&mut self) -> Vec { + let q = self.palette.query.clone(); + let mut out: Vec = vec![]; + if self.palette.langs { + let mut names: Vec<(String, String)> = self.reg.languages.iter().filter(|l| !l.hidden).map(|l| (l.name.clone(), l.section.clone())).collect(); + names.sort(); + for (n, sec) in names { + if let Some(score) = fuzzy(&q, &n) { + out.push(Row { ic: "language", detail: sec, keys: String::new(), pick: Pick::Lang(n.clone()), label: n, score }); + } + } + } else if let Some(c) = q.strip_prefix('>') { + for e in commands::all() { + if let Some(score) = fuzzy(c.trim(), e.label) { + out.push(Row { ic: e.ic, label: e.label.to_string(), detail: String::new(), keys: e.keys.to_string(), pick: Pick::Cmd(e.cmd), score }); + } + } + } else if let Some(l) = q.strip_prefix(':') { + if let Ok(n) = l.trim().parse::() { + out.push(Row { ic: "tag", label: format!("Go to line {n}"), detail: String::new(), keys: String::new(), pick: Pick::Line(n.saturating_sub(1)), score: 0 }); + } + } else if let Some(s) = q.strip_prefix('@') { + for (line, name, kind) in self.outline() { + if let Some(score) = fuzzy(s.trim(), &name) { + out.push(Row { ic: "data_object", label: name, detail: kind.to_string(), keys: format!("{}", line + 1), pick: Pick::Line(line), score }); + } + } + } else if let Some(c) = q.strip_prefix('!') { + out.push(Row { ic: "terminal", label: format!("Run {}", c.trim()), detail: "in the terminal".into(), keys: String::new(), pick: Pick::Run(c.trim().to_string()), score: 0 }); + } else { + let root = self.root.clone(); + let open: Vec = self.docs.values().filter_map(|d| d.path.clone()).collect(); + for f in open.iter().chain(self.palette.files.iter().filter(|f| !open.contains(f))) { + let rel = root.as_ref().and_then(|r| f.strip_prefix(r).ok()).unwrap_or(f).to_string_lossy().into_owned(); + let name = f.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); + let by_name = fuzzy(&q, &name).map(|s| s + 40); + if let Some(score) = by_name.or_else(|| fuzzy(&q, &rel)) { + out.push(Row { ic: "description", label: name, detail: rel, keys: String::new(), pick: Pick::File(f.clone()), score }); + } + } + if q.is_empty() { + for r in self.s.recent.clone() { + let p = PathBuf::from(&r); + if out.iter().any(|o| matches!(&o.pick, Pick::File(f) if *f == p)) { continue } + out.push(Row { ic: "history", label: p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(), detail: r, keys: String::new(), pick: Pick::File(p), score: -1 }); + } + } + } + out.sort_by_key(|r| -r.score); + out.truncate(60); + out + } + + pub fn palette_ui(&mut self, ctx: &egui::Context) { + let k = spring("pal/k", self.palette.open as u8 as f32, Preset { stiffness: 760.0, damping: 0.66 }); + if !self.palette.open && k < 0.02 { + return; + } + let t = self.t.clone(); + if self.palette.last.as_deref() != Some(&self.palette.query) { + self.palette.last = Some(self.palette.query.clone()); + self.palette.rows = self.palette_rows(); + self.palette.sel = 0; + self.palette.born = ctx.input(|i| i.time); + } + let screen = ctx.content_rect(); + let width = (screen.width() * 0.56).clamp(420.0, 680.0); + let row_h = 46.0; + let shown = self.palette.rows.len().min(9); + let list_h = spring("pal/h", shown as f32 * row_h + if shown > 0 { 12.0 } else { 0.0 }, motion::DEFAULT); + let rect = Rect::from_min_size(pos2(screen.center().x - width / 2.0, screen.top() + 66.0), vec2(width, 60.0 + list_h.max(0.0))); + + let scrim = Area::new(Id::unique("pal-scrim")).order(Order::Foreground).fixed_pos(screen.min).show(ctx, |ui| { + let r = ui.allocate_rect(screen, Sense::click()); + ui.painter().rect_filled(screen, cr(0.0), alpha(egui::Color32::BLACK, 0.36 * k.clamp(0.0, 1.0))); + r + }).inner; + if scrim.clicked() { self.close_palette(ctx) } + let (up, down, enter, esc) = ctx.input_mut(|i| (i.consume_key(egui::Modifiers::NONE, Key::ArrowUp), i.consume_key(egui::Modifiers::NONE, Key::ArrowDown), i.consume_key(egui::Modifiers::NONE, Key::Enter), i.consume_key(egui::Modifiers::NONE, Key::Escape))); + let n = self.palette.rows.len(); + if up && n > 0 { self.palette.sel = (self.palette.sel + n - 1) % n } + if down && n > 0 { self.palette.sel = (self.palette.sel + 1) % n } + if esc && self.palette.open { self.close_palette(ctx) } + let mut picked = enter.then(|| self.palette.rows.get(self.palette.sel).map(|r| r.pick.clone())).flatten(); + + let now = ctx.input(|i| i.time); + let age = (now - self.palette.born) as f32; + let sel = self.palette.sel; + let first = sel.saturating_sub(shown.saturating_sub(1)); + let area = Area::new(Id::unique("palette")).order(Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| { + ui.set_min_size(rect.size()); + let p = ui.painter().clone(); + shadow(&p, rect, 28.0, 1.0, t.dark); + p.rect_filled(rect, cr(28.0), t.high); + icons::paint(ctx, &p, pos2(rect.left() + 28.0, rect.top() + 30.0), 22.0, "search", t.primary); + let field = Rect::from_min_size(rect.min + vec2(50.0, 17.0), vec2(width - 66.0, 28.0)); + let hint = if self.palette.langs { "Pick a language" } else { "Files · > commands · : line · @ symbol · ! run" }; + let te = ui.put(field, egui::TextEdit::singleline(&mut self.palette.query).frame(egui::Frame::NONE).hint_text(hint).font(fonts::ui(16.0)).text_color(t.on_surface).lock_focus(true)); + if self.palette.focus { + self.palette.focus = false; + te.request_focus(); + } + if self.palette.open && !te.has_focus() { te.request_focus() } + let list = Rect::from_min_max(pos2(rect.left() + 8.0, rect.top() + 56.0), pos2(rect.right() - 8.0, rect.bottom() - 6.0)); + let lp = p.with_clip_rect(list); + let sel_y = spring("pal/sel", (sel - first.min(sel)) as f32 * row_h, Preset { stiffness: 1200.0, damping: 0.72 }); + if shown > 0 { + lp.rect_filled(Rect::from_min_size(list.min + vec2(0.0, sel_y), vec2(list.width(), row_h)), cr(18.0), t.secondary_container); + } + let rows: Vec = self.palette.rows.iter().skip(first).take(shown).cloned().collect(); + for (i, r) in rows.iter().enumerate() { + let rr = Rect::from_min_size(list.min + vec2(0.0, i as f32 * row_h), vec2(list.width(), row_h)); + let resp = ui.interact(rr, Id::unique(("pal-row", i)), Sense::click()); + let e = motion::stagger(age, i as f32 * 0.022, 0.26); + let dy = (1.0 - e) * 14.0; + let a = e.clamp(0.0, 1.0); + let is_sel = first + i == sel; + if resp.hovered() && !is_sel { lp.rect_filled(rr, cr(18.0), alpha(t.on_surface, 0.05)); } + let fg = if is_sel { t.on_secondary_container } else { t.on_surface }; + let c = rr.left_center() + vec2(22.0, dy); + icons::paint(ctx, &lp, c, 19.0, r.ic, alpha(if is_sel { fg } else { t.on_variant }, a)); + let mut x = rr.left() + 46.0; + let g = lp.layout_no_wrap(r.label.clone(), fonts::med(14.0), alpha(fg, a)); + let gw = g.size().x; + lp.galley(pos2(x, rr.center().y + dy - g.size().y / 2.0), g, fg); + x += gw + 12.0; + if !r.detail.is_empty() { + lp.text(pos2(x, rr.center().y + dy), Align2::LEFT_CENTER, &r.detail, fonts::ui(12.0), alpha(t.outline, a)); + } + if !r.keys.is_empty() { + lp.text(pos2(rr.right() - 14.0, rr.center().y + dy), Align2::RIGHT_CENTER, &r.keys, fonts::ui(12.0), alpha(if is_sel { fg } else { t.outline }, a * 0.9)); + } + if resp.clicked() { picked = Some(r.pick.clone()) } + } + }); + let a = rect.center_top(); + let s = 0.86 + 0.14 * k; + ctx.set_transform_layer(area.response.layer_id, TSTransform::from_translation(a.to_vec2()) * TSTransform::from_scaling(s) * TSTransform::from_translation(-a.to_vec2())); + if let Some(pick) = picked { + self.close_palette(ctx); + match pick { + Pick::Cmd(c) => self.run(ctx, c), + Pick::File(f) => self.open_path(ctx, f, None), + Pick::Line(l) => self.jump_to_line(ctx, l), + Pick::Lang(n) => { + let id = self.cur_doc_id(); + if let Some(d) = id.and_then(|id| self.docs.get_mut(&id)) { d.set_language(&n, &mut self.reg) } + } + Pick::Run(c) => self.run_in_terminal(ctx, &c), + } + } + } + + pub fn close_palette(&mut self, ctx: &egui::Context) { + self.palette.open = false; + self.focus_editor(ctx); + } +} + +/// Files under a folder, skipping build output and hidden directories. +pub fn project_files(root: &std::path::Path) -> Vec { + walkdir::WalkDir::new(root).max_depth(10).into_iter().filter_entry(|e| { + let n = e.file_name().to_string_lossy(); + e.depth() == 0 || !(e.file_type().is_dir() && (n.starts_with('.') || matches!(n.as_ref(), "target" | "node_modules" | "build" | "dist" | "__pycache__"))) + }).flatten().filter(|e| e.file_type().is_file()).take(50_000).map(|e| e.into_path()).collect() +} + +#[cfg(test)] +mod tests { + use super::fuzzy; + + #[test] + fn fuzzy_prefers_word_starts_and_rejects_missing() { + assert!(fuzzy("mn", "main.rs").is_some()); + assert!(fuzzy("zz", "main.rs").is_none()); + assert!(fuzzy("gd", "go definition").unwrap() > fuzzy("gd", "highlander").unwrap()); + } +} diff --git a/src/ui/preview.rs b/src/ui/preview.rs new file mode 100644 index 0000000..e65efd4 --- /dev/null +++ b/src/ui/preview.rs @@ -0,0 +1,332 @@ +//! The scrolling preview. A texture of the whole file sits on a rail beside the code. +//! +//! Pressing the rail pops it out: it widens over the code, the lines near the pointer swell like a +//! lens (the texture is drawn on a bent mesh), and a card of real, readable code bursts out beside +//! it and follows the pointer on a spring. Dragging scrolls the file; holding Shift only peeks, +//! and the view stays put. + +use super::{fonts, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring, Preset}; +use crate::text::Doc; +use crate::theme::{alpha, mix, Theme}; +use eframe::egui::{self, emath::TSTransform, pos2, vec2, Color32, ColorImage, Id, LayerId, Mesh, Order, Rect, Sense, TextureHandle, TextureOptions, Ui}; + +const ROW_PX: usize = 3; +const CHAR_PX: usize = 2; +const COLS: usize = 120; +const MAX_ROWS: usize = 4096; +const STRIPS: usize = 72; + +#[derive(Default)] +pub struct Mini { + tex: Option, + key: (u64, u64, u32), + built: f64, + /// Doc lines per texture row. + step: f32, + rows: usize, +} + +fn build(doc: &Doc, reg: &crate::syntax::Registry, t: &Theme, tab: usize) -> (ColorImage, usize, f32) { + let lines = doc.buf.lines(); + let rows = lines.min(MAX_ROWS).max(1); + let step = lines as f32 / rows as f32; + let (w, h) = (COLS * CHAR_PX, rows * ROW_PX); + let mut px = vec![Color32::TRANSPARENT; w * h]; + for r in 0..rows { + let line = (r as f32 * step) as usize; + let text = doc.buf.line_text(line); + let spans = doc.hl.get(line).map(|h| h.spans.clone()); + let (mut x, mut byte, mut si) = (0usize, 0u32, 0usize); + for c in text.chars() { + let cells = super::editor::cell_width(c, x, tab); + if x >= COLS { break } + if !c.is_whitespace() { + let mut col = t.syntax[0]; + if let Some(sp) = &spans { + while si < sp.len() && sp[si].end <= byte { si += 1 } + if let Some(s) = sp.get(si).filter(|s| s.start <= byte) { + if let Some(st) = reg.compiled.styles.get(s.style as usize) { col = t.syntax[st.base as usize] } + } + } + let col = alpha(col, 0.86); + for yy in 0..ROW_PX - 1 { + for xx in 0..CHAR_PX * cells { + let px_x = x * CHAR_PX + xx; + if px_x < w { px[(r * ROW_PX + yy) * w + px_x] = col } + } + } + } + x += cells; + byte += c.len_utf8() as u32; + } + } + (ColorImage::new([w, h], px), rows, step) +} + +/// Line ↔ rail position, including the lens bend around the pointer. +#[derive(Clone, Copy)] +struct Map { + top: f32, + height: f32, + lh: f32, + offset: f32, + bend: f32, + center: f32, +} + +impl Map { + fn base(&self, y: f32) -> f32 { + (y + self.offset) / self.lh + } + + /// The doc line (fractional) shown at height `y` inside the rail. + fn line_at(&self, y: f32) -> f32 { + const R: f32 = 64.0; + let d = y - self.center; + self.base(self.center) + (d - self.bend * R * (d / R).atan()) / self.lh + } + + /// The inverse of `line_at`. + fn y_of(&self, line: f32) -> f32 { + let (mut lo, mut hi) = (-self.height, self.height * 2.0); + for _ in 0..24 { + let mid = (lo + hi) / 2.0; + if self.line_at(mid) < line { lo = mid } else { hi = mid } + } + self.top + hi + } +} + +impl App { + pub fn preview(&mut self, ui: &mut Ui, pane: usize, rail: Rect) { + let t = self.t.clone(); + let Some((doc_id, scroll, count)) = self.panes[pane].tabs.get(self.panes[pane].active).map(|x| (x.doc, x.scroll.x, self.docs[&x.doc].buf.lines())) else { return }; + let m = self.metrics(ui); + let now = ui.input(|i| i.time); + + // texture: rebuilt when colours or text change, but not more than a few times a second + { + let doc = &self.docs[&doc_id]; + let mini = &mut self.panes[pane].mini; + let key = (doc_id, doc.hl_version, self.theme_stamp); + if mini.key != key && (now - mini.built > 0.14 || mini.key.0 != doc_id || mini.tex.is_none()) { + let (img, rows, step) = build(doc, &self.reg, &t, self.s.tab_width); + match &mut mini.tex { + Some(h) if h.size() == img.size => h.set(img, TextureOptions::LINEAR), + _ => mini.tex = Some(ui.ctx().load_texture(format!("mini-{pane}"), img, TextureOptions::LINEAR)), + } + mini.key = key; + mini.built = now; + mini.rows = rows; + mini.step = step; + } + if mini.key != key { motion::keep_alive() } + } + + let key = format!("mini/{pane}"); + let id = ui.scope_id().with(&key); + let active = self.panes[pane].dragging_mini; + let pop = spring(format!("{key}/pop"), active as u8 as f32, Preset { stiffness: 620.0, damping: 0.62 }); + let hover_rail = ui.rect_contains_pointer(rail); + let hov = spring(format!("{key}/hov"), hover_rail as u8 as f32, motion::EFFECT); + + let visual = lerp(1.0, 2.4, pop.max(0.0)); + let popped = pop.abs() > 0.004; + let frame = Rect::from_min_max(pos2(rail.right() - rail.width() * visual - 2.0 * hov, rail.top()), rail.max); + let lh = lerp(2.0, 3.0, pop.clamp(0.0, 1.2)); + let visible = m.lh * count as f32; + let total_h = lh * count as f32; + let max_scroll = (visible - rail.height()).max(1.0); + let frac = (scroll / max_scroll).clamp(0.0, 1.0); + let offset = if total_h > frame.height() { frac * (total_h - frame.height()) } else { 0.0 }; + + let ptr = ui.input(|i| i.pointer.interact_pos()); + let center = spring(format!("{key}/cy"), ptr.map_or(0.0, |p| (p.y - frame.top()).clamp(0.0, frame.height())), Preset { stiffness: 900.0, damping: 0.8 }); + let map = Map { top: frame.top(), height: frame.height(), lh, offset, bend: 0.74 * pop.clamp(0.0, 1.0), center }; + + let painter = if popped { + let layer = LayerId::new(Order::Foreground, Id::unique(&key)); + egui::Painter::new(ui.ctx().clone(), layer, ui.ctx().content_rect()) + } else { + ui.painter().clone() + }; + if popped { + shadow(&painter, frame, 18.0, pop.clamp(0.0, 1.0), t.dark); + } + painter.rect_filled(frame, cr(18.0), mix(t.container, t.high, pop.clamp(0.0, 1.0))); + let inner = frame.shrink2(vec2(7.0, 6.0)); + + // the bent texture + let mini = &self.panes[pane].mini; + if let Some(tex) = &mini.tex { + let mut mesh = Mesh::with_texture(tex.id()); + let tint = alpha(Color32::WHITE, lerp(0.8, 1.0, pop.clamp(0.0, 1.0))); + let u_max = (inner.width() / (COLS as f32 * lerp(1.0, 1.7, pop.clamp(0.0, 1.0)))).min(1.0); + for i in 0..=STRIPS { + let y = inner.height() * i as f32 / STRIPS as f32; + let line = map.line_at(y).clamp(0.0, count as f32); + let v = (line / mini.step.max(0.001) / mini.rows.max(1) as f32).clamp(0.0, 1.0); + // nothing is drawn below the last line + let fade = if line >= count as f32 { 0.0 } else { 1.0 }; + let c = alpha(tint, fade * tint.a() as f32 / 255.0); + mesh.vertices.push(egui::epaint::Vertex { pos: pos2(inner.left(), inner.top() + y), uv: pos2(0.0, v), color: c }); + mesh.vertices.push(egui::epaint::Vertex { pos: pos2(inner.right(), inner.top() + y), uv: pos2(u_max, v), color: c }); + if i < STRIPS { + let b = (i * 2) as u32; + mesh.indices.extend([b, b + 1, b + 2, b + 1, b + 3, b + 2]); + } + } + painter.with_clip_rect(frame.shrink(2.0)).add(mesh); + } + + // viewport bubble: squashes and stretches with speed + let first_line = { + let tb = &self.panes[pane].tabs[self.panes[pane].active]; + tb.rows.row((scroll / m.lh).max(0.0) as usize).0.min(count) as f32 + }; + let view_lines = (rail.height() / m.lh).min(count as f32); + let y_a = map.y_of(first_line); + let y_b = map.y_of(first_line + view_lines); + let top = spring(format!("{key}/ta"), y_a, Preset { stiffness: 1500.0, damping: 0.74 }); + let bot = spring(format!("{key}/tb"), y_b.max(y_a + 14.0), Preset { stiffness: 620.0, damping: 0.66 }); + let thumb = Rect::from_min_max(pos2(frame.left() + 3.0, top), pos2(frame.right() - 3.0, bot.max(top + 12.0))); + let thumb_alpha = 0.16 + 0.1 * hov + 0.06 * pop.clamp(0.0, 1.0); + painter.rect_filled(thumb, cr(12.0), alpha(t.primary, thumb_alpha)); + painter.rect_stroke(thumb, cr(12.0), egui::Stroke::new(1.0 + hov, alpha(t.primary, 0.3 + 0.4 * hov)), egui::StrokeKind::Inside); + + // marks along the edge: problems, changes, search hits, bookmarks, the cursor + let lane = frame.right() - 5.0; + for (line, col) in self.preview_marks(doc_id) { + let y = map.y_of(line as f32); + if y >= frame.top() && y <= frame.bottom() { + painter.rect_filled(Rect::from_min_size(pos2(lane - 3.0, y - 1.0), vec2(5.0, 3.0)), cr(1.5), col); + } + } + let cur = self.docs[&doc_id].buf.pos(self.docs[&doc_id].buf.head()).0; + let cy = map.y_of(cur as f32); + if cy >= frame.top() && cy <= frame.bottom() { + painter.rect_filled(Rect::from_min_size(pos2(frame.left() + 3.0, cy - 1.0), vec2(frame.width() - 6.0, 2.0)), cr(1.0), alpha(t.primary, 0.9)); + } + + // interaction + let resp = ui.interact(rail.union(if active { frame } else { rail }), id, Sense::click_and_drag()); + let pressed = resp.is_pointer_button_down_on(); + if pressed && !self.panes[pane].dragging_mini { + self.panes[pane].dragging_mini = true; + self.panes[pane].peek_from = ui.input(|i| i.modifiers.shift).then_some(scroll); + motion::forget(format!("{key}/lens")); + } + if resp.hovered() || active { ui.ctx().set_cursor_icon(if active { egui::CursorIcon::Grabbing } else { egui::CursorIcon::Grab }) } + let wheel = if hover_rail { crate::ui::widgets::wheel(ui).y } else { 0.0 }; + let (pane_ref, top_line); + { + pane_ref = &mut self.panes[pane]; + top_line = pane_ref.lens_line; + } + if wheel != 0.0 { + let a = pane_ref.active; + pane_ref.tabs[a].scroll.target -= wheel * 4.0; + } + if pane_ref.dragging_mini { + if let Some(p) = ptr { + let y = (p.y - frame.top()).clamp(0.0, frame.height()); + // the file maps onto the rail, whatever the scroll, so a drag can't feed back on itself + let line = if total_h > frame.height() { (y / frame.height()) * count as f32 } else { (y / lh).min(count as f32) }; + pane_ref.lens_line = line; + pane_ref.lens_y = p.y; + if pane_ref.peek_from.is_none() { + let a = pane_ref.active; + let target = line * m.lh - rail.height() / 2.0; + pane_ref.tabs[a].scroll.target = target.clamp(0.0, (count as f32 * m.lh - rail.height() * 0.5).max(0.0)); + } + } + if !ui.input(|i| i.pointer.primary_down()) { + pane_ref.dragging_mini = false; + let a = pane_ref.active; + if let Some(from) = pane_ref.peek_from.take() { + pane_ref.tabs[a].scroll.target = from; + } else { + pane_ref.tabs[a].beacon = Some((top_line as usize, now)); + } + } + } + let lens = spring(format!("{key}/lens"), active as u8 as f32, Preset { stiffness: 520.0, damping: 0.6 }); + if self.s.lens && lens > 0.01 { + self.lens(ui, pane, doc_id, frame, lens); + } + } + + /// The card of real code beside the popped-out rail. + fn lens(&mut self, ui: &mut Ui, pane: usize, doc_id: u64, frame: Rect, k: f32) { + let t = self.t.clone(); + let doc = &self.docs[&doc_id]; + let (line, y) = (self.panes[pane].lens_line, self.panes[pane].lens_y); + let screen = ui.ctx().content_rect(); + let lh = 19.0; + let rows = 15usize; + let width = (frame.left() - screen.left() - 110.0).clamp(240.0, 620.0); + let height = rows as f32 * lh + 44.0; + let key = format!("mini/{pane}"); + let cy = spring(format!("{key}/lensy"), y, Preset { stiffness: 340.0, damping: 0.66 }).clamp(screen.top() + height / 2.0 + 8.0, screen.bottom() - height / 2.0 - 8.0); + let card = Rect::from_center_size(pos2(frame.left() - 16.0 - width / 2.0, cy), vec2(width, height)); + let anchor = pos2(frame.left(), y); + + let layer = LayerId::new(Order::Tooltip, Id::unique(format!("{key}/lens-layer"))); + let s = k.max(0.02); + let tf = TSTransform::from_translation(anchor.to_vec2()) * TSTransform::from_scaling(s) * TSTransform::from_translation(-anchor.to_vec2()); + ui.ctx().set_transform_layer(layer, tf); + let p = egui::Painter::new(ui.ctx().clone(), layer, screen); + let fade = k.clamp(0.0, 1.0); + shadow(&p, card, 26.0, fade, t.dark); + p.rect_filled(card, cr(26.0), t.high); + + // header: where you are + let total = doc.buf.lines(); + let center = (line as usize).min(total.saturating_sub(1)); + let peek = self.panes[pane].peek_from.is_some(); + let label = format!("{} · line {}", doc.title(), center + 1); + p.text(pos2(card.left() + 20.0, card.top() + 22.0), egui::Align2::LEFT_CENTER, label, fonts::med(12.5), t.on_variant); + if peek { + let tag = Rect::from_min_size(pos2(card.right() - 66.0, card.top() + 11.0), vec2(52.0, 22.0)); + p.rect_filled(tag, cr(11.0), t.tertiary_container); + p.text(tag.center(), egui::Align2::CENTER_CENTER, "Peek", fonts::med(11.5), t.on_tertiary_container); + } + + // code: the lines slide by at a sub-line offset so dragging reads as motion, not steps + let area = Rect::from_min_max(pos2(card.left() + 8.0, card.top() + 40.0), pos2(card.right() - 8.0, card.bottom() - 8.0)); + let code = p.with_clip_rect(area); + let band = Rect::from_center_size(pos2(area.center().x, area.center().y), vec2(area.width(), lh)); + code.rect_filled(band, cr(9.0), alpha(t.primary, 0.14)); + let font = fonts::mono(12.5); + let cw = ui.fonts_mut(|f| f.glyph_width(&font, 'M')); + let frac = line.fract(); + let gut = 44.0; + let half = rows as isize / 2 + 1; + for i in -half..=half { + let l = center as isize + i; + if l < 0 || l as usize >= total { continue } + let l = l as usize; + let y = area.center().y + (i as f32 - frac + 0.5) * lh - lh / 2.0; + let d = ((y - area.center().y).abs() / (area.height() / 2.0)).min(1.0); + let dim = 1.0 - d * d * 0.75; + let col = if l == center { t.primary } else { alpha(t.on_variant, 0.55 * dim) }; + code.text(pos2(area.left() + gut - 12.0, y), egui::Align2::RIGHT_CENTER, (l + 1).to_string(), fonts::mono(11.0), col); + let max_cols = ((area.width() - gut - 8.0) / cw) as usize + 8; + let job = super::editor::line_job(doc, &self.reg, &t, l, (0, max_cols), &font, self.s.tab_width, false); + let g = ui.painter().layout_job(job); + let pos = pos2(area.left() + gut, y - g.size().y / 2.0); + code.galley(pos, g, t.syntax[0]); + } + // pointer tail tying the card to the rail + let tip = pos2(card.right(), cy.clamp(card.top() + 30.0, card.bottom() - 30.0)); + let mut mesh = Mesh::default(); + let c = t.high; + mesh.colored_vertex(tip + vec2(-2.0, -12.0), c); + mesh.colored_vertex(tip + vec2(-2.0, 12.0), c); + mesh.colored_vertex(pos2(card.right() + 15.0, y.clamp(card.top() + 8.0, card.bottom() - 8.0)), c); + mesh.add_triangle(0, 1, 2); + p.add(mesh); + } +} diff --git a/src/ui/rail.rs b/src/ui/rail.rs new file mode 100644 index 0000000..5ed8e74 --- /dev/null +++ b/src/ui/rail.rs @@ -0,0 +1,93 @@ +//! The navigation rail: the logo, the side panels, and the light/dark and settings buttons. + +use super::commands::Cmd; +use super::morph::{self, Morph}; +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring}; +use crate::theme::{alpha, mix}; +use eframe::egui::{pos2, vec2, Align2, Rect, Sense, Ui}; + +pub const SIDES: [(&str, &str, &str); 5] = [("Files", "folder", "folder_fill"), ("Search", "search", "search"), ("Outline", "account_tree", "account_tree_fill"), ("Git", "commit", "commit"), ("Problems", "error", "error_fill")]; + +impl App { + pub fn rail(&mut self, ui: &mut Ui, rect: Rect) { + let t = self.t.clone(); + let logo = pos2(rect.center().x, rect.top() + 28.0); + let lr = Rect::from_center_size(logo, vec2(46.0, 46.0)); + let resp = ui.interact(lr, ui.scope_id().with("logo"), Sense::click()).on_hover_text("Menu"); + let (hov, press) = states("logo", &resp); + // the logo breathes between shapes and spins up under the pointer + if resp.hovered() { + self.logo_clock += motion::dt(); + motion::keep_alive(); + } + let spin = self.logo_clock * 0.5 + spring("logo/spin", self.logo_spin, motion::SLOW); + let amount = 0.075 + 0.035 * (self.logo_clock * 1.6).sin() + 0.03 * hov; + blob(ui.painter(), logo, 20.0 * (1.0 - 0.1 * press), 7.0, amount, spin, t.primary_container); + icons::paint(ui.ctx(), ui.painter(), logo, 22.0, "code", t.on_primary_container); + if resp.clicked() { + self.logo_spin += 1.2; + self.app_menu(lr.right_top() + vec2(8.0, 0.0)); + } + + let open = self.side_open.then_some(self.side); + let h = 62.0; + let top = rect.top() + 72.0; + let pill_y = spring("rail/y", top + self.side as f32 * h, crate::motion::Preset { stiffness: 900.0, damping: 0.68 }); + let on = spring("rail/on", open.is_some() as u8 as f32, motion::FAST); + let problems = self.problem_count(); + let git_changes = self.git.files.len(); + for (i, (name, ic, filled)) in SIDES.iter().enumerate() { + let r = Rect::from_min_size(pos2(rect.left(), top + i as f32 * h), vec2(rect.width(), h)); + let key = format!("rail/{i}"); + let resp = ui.interact(r, ui.scope_id().with(&key), Sense::click()); + let (hov, press) = states(&key, &resp); + let sel = open == Some(i); + let c = pos2(r.center().x, r.top() + 22.0); + let ind = Rect::from_center_size(c, vec2(56.0, 32.0)); + if hov > 0.01 && !sel { + ui.painter().rect_filled(scale_rect(ind, 1.0 - 0.06 * press), cr(16.0), alpha(t.on_surface, 0.08 * hov)); + } + if i == 0 { + // one indicator, shared by all items, that slides + let ic_y = pill_y + 22.0; + let w = 56.0 * on.clamp(0.0, 1.2); + let vel = (pill_y - (top + self.side as f32 * h)).abs().min(60.0) / 60.0; + let ind = Rect::from_center_size(pos2(c.x, ic_y), vec2(w * (1.0 - 0.18 * vel), 32.0 + 14.0 * vel)); + ui.painter().rect_filled(ind, cr(16.0), alpha(t.secondary_container, on.clamp(0.0, 1.0))); + } + let k = spring(format!("{key}/s"), sel as u8 as f32, motion::EFFECT); + let col = mix(t.on_variant, t.on_secondary_container, k); + icons::paint(ui.ctx(), ui.painter(), c, 22.0 * (1.0 - 0.08 * press), if sel { filled } else { ic }, col); + ui.painter().text(pos2(r.center().x, r.top() + 47.0), Align2::CENTER_CENTER, *name, fonts::med(11.0), col); + let n = if i == 3 { git_changes } else if i == 4 { problems } else { 0 }; + if n > 0 { + let pop = spring(format!("{key}/badge"), 1.0, motion::FAST); + let b = pos2(c.x + 13.0, c.y - 10.0); + let txt = if n > 99 { "99+".to_string() } else { n.to_string() }; + let w = if n > 9 { 22.0 } else { 16.0 }; + let col = if i == 4 { t.error } else { t.primary }; + let on = if i == 4 { t.on_error } else { t.on_primary }; + ui.painter().rect_filled(Rect::from_center_size(b, vec2(w, 16.0) * pop), cr(8.0), col); + ui.painter().text(b, Align2::CENTER_CENTER, txt, fonts::med(10.0), on); + } + if resp.clicked() { + self.run(ui.ctx(), Cmd::Side(i)); + } + } + + let b = rect.bottom() - 26.0; + let sr = Rect::from_center_size(pos2(rect.center().x, b), vec2(44.0, 44.0)); + if icon_btn(ui, &t, sr, "rail/settings", "settings", "Settings", self.settings_open).clicked() { + self.run(ui.ctx(), Cmd::Settings); + } + let dr = Rect::from_center_size(pos2(rect.center().x, b - 50.0), vec2(44.0, 44.0)); + // shows what the button will switch to: a sun in the dark, a moon in the light + let resp = morph::button(ui, &t, dr, "rail/dark", Morph::SunMoon, !t.dark, "Switch light or dark", t.surface); + if resp.clicked() { + self.theme_wave = Some((dr.center(), ui.input(|i| i.time))); + self.run(ui.ctx(), Cmd::ToggleDark); + } + } +} diff --git a/src/ui/settings.rs b/src/ui/settings.rs new file mode 100644 index 0000000..6f1891b --- /dev/null +++ b/src/ui/settings.rs @@ -0,0 +1,195 @@ +//! Settings: a sheet that rises over the window, in the same card-and-rows look as Nacre's. + +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring, spring_from}; +use crate::theme::{alpha, hex}; +use eframe::egui::{self, pos2, vec2, Align2, Area, Color32, Id, Key, Order, Rect, Sense, Ui}; + +const SECTIONS: [(&str, &str); 4] = [("Appearance", "palette"), ("Editor", "edit"), ("Motion", "motion_mode"), ("Terminal", "terminal")]; +const SEEDS: [&str; 8] = ["#7f5fc4", "#d0485e", "#d9782b", "#c8a020", "#3f9c6b", "#1f9aa8", "#2b7fd4", "#c656a8"]; + +impl App { + pub fn settings_ui(&mut self, ctx: &egui::Context) { + let k = spring("set/k", self.settings_open as u8 as f32, motion::Preset { stiffness: 520.0, damping: 0.74 }); + if !self.settings_open && k < 0.01 { + return; + } + let t = self.t.clone(); + let screen = ctx.content_rect(); + Area::new(Id::unique("set-scrim")).order(Order::Foreground).fixed_pos(screen.min).show(ctx, |ui| { + let r = ui.allocate_rect(screen, Sense::click()); + ui.painter().rect_filled(screen, cr(0.0), alpha(Color32::BLACK, 0.42 * k.clamp(0.0, 1.0))); + if r.clicked() { self.settings_open = false } + }); + let w = (screen.width() - 80.0).min(860.0); + let h = (screen.height() - 60.0).min(680.0); + let full = Rect::from_center_size(screen.center(), vec2(w, h)); + let rect = full.translate(vec2(0.0, (1.0 - k) * (screen.height() - full.top()))); + let before = self.s.clone(); + Area::new(Id::unique("settings")).order(Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| { + ui.set_min_size(rect.size()); + let p = ui.painter().clone(); + shadow(&p, rect, 32.0, 1.0, t.dark); + p.rect_filled(rect, cr(32.0), t.container); + let nav = Rect::from_min_size(rect.min + vec2(14.0, 22.0), vec2(120.0, rect.height() - 44.0)); + let y = spring("set/nav", self.settings_tab as f32 * 74.0, motion::FAST); + let pill_r = Rect::from_center_size(pos2(nav.center().x, nav.top() + 22.0 + y), vec2(58.0, 32.0)); + p.rect_filled(pill_r, cr(16.0), t.secondary_container); + for (i, (name, ic)) in SECTIONS.iter().enumerate() { + let r = Rect::from_min_size(nav.min + vec2(0.0, i as f32 * 74.0), vec2(nav.width(), 70.0)); + let resp = ui.interact(r, Id::unique(("set-nav", i)), Sense::click()); + let col = if self.settings_tab == i { t.on_secondary_container } else { t.on_variant }; + icons::paint(ctx, &p, pos2(r.center().x, r.top() + 22.0), 21.0, ic, col); + p.text(pos2(r.center().x, r.top() + 50.0), Align2::CENTER_CENTER, *name, fonts::med(12.0), t.on_variant); + if resp.clicked() { self.settings_tab = i } + } + let close = Rect::from_center_size(rect.right_top() + vec2(-34.0, 34.0), vec2(38.0, 38.0)); + if icon_btn(ui, &t, close, "set/close", "close", "Close", false).clicked() { self.settings_open = false } + let body = Rect::from_min_max(pos2(nav.right() + 22.0, rect.top() + 22.0), pos2(rect.right() - 26.0, rect.bottom() - 16.0)); + p.text(body.min + vec2(0.0, 12.0), Align2::LEFT_CENTER, SECTIONS[self.settings_tab].0, fonts::med(26.0), t.on_surface); + let list = Rect::from_min_max(body.min + vec2(0.0, 48.0), body.max); + let mut sub = ui.new_child(egui::UiBuilder::new().max_rect(list)); + sub.set_clip_rect(list); + let mut y = list.top(); + let tab = self.settings_tab; + let entered = spring_from(format!("set/tab{tab}"), 0.0, 1.0, motion::DEFAULT); + let off = (1.0 - entered) * 24.0; + y += off; + match tab { + 0 => self.appearance(&mut sub, list, &mut y), + 1 => self.editor_settings(&mut sub, list, &mut y), + 2 => self.motion_settings(&mut sub, list, &mut y), + _ => self.terminal_settings(&mut sub, list, &mut y), + } + }); + if ctx.input(|i| i.key_pressed(Key::Escape)) { self.settings_open = false } + if self.s != before { + self.settings_changed(ctx, &before); + } + } + + fn card(&self, ui: &Ui, r: Rect) { + ui.painter().rect_filled(r, cr(18.0), self.t.high); + } + + fn label(&self, ui: &Ui, r: Rect, title: &str, sub: &str) { + let t = &self.t; + let p = ui.painter(); + if sub.is_empty() { + p.text(pos2(r.left() + 18.0, r.center().y), Align2::LEFT_CENTER, title, fonts::med(14.0), t.on_surface); + } else { + p.text(pos2(r.left() + 18.0, r.center().y - 10.0), Align2::LEFT_CENTER, title, fonts::med(14.0), t.on_surface); + p.text(pos2(r.left() + 18.0, r.center().y + 10.0), Align2::LEFT_CENTER, sub, fonts::ui(12.0), t.on_variant); + } + } + + fn toggle(&mut self, ui: &mut Ui, list: Rect, y: &mut f32, key: &str, title: &str, sub: &str, get: fn(&mut crate::config::Settings) -> &mut bool) { + let r = Rect::from_min_size(pos2(list.left(), *y), vec2(list.width(), 62.0)); + self.card(ui, r); + self.label(ui, r, title, sub); + let t = self.t.clone(); + let on = *get(&mut self.s); + let sw = Rect::from_center_size(pos2(r.right() - 44.0, r.center().y), vec2(60.0, 38.0)); + if switch(ui, &t, sw, key, on).clicked() { *get(&mut self.s) = !on } + *y += 66.0; + } + + fn choice(&mut self, ui: &mut Ui, list: Rect, y: &mut f32, key: &str, title: &str, sub: &str, opts: &[(&str, &str)], cur: &str) -> Option { + let r = Rect::from_min_size(pos2(list.left(), *y), vec2(list.width(), 62.0)); + self.card(ui, r); + self.label(ui, r, title, sub); + let t = self.t.clone(); + let w = (opts.len() as f32 * 88.0).min(list.width() * 0.62); + let seg = Rect::from_min_size(pos2(r.right() - w - 14.0, r.center().y - 19.0), vec2(w, 38.0)); + *y += 66.0; + segmented(ui, &t, seg, key, opts, cur) + } + + fn stepper(&mut self, ui: &mut Ui, list: Rect, y: &mut f32, key: &str, title: &str, value: String) -> i32 { + let r = Rect::from_min_size(pos2(list.left(), *y), vec2(list.width(), 62.0)); + self.card(ui, r); + self.label(ui, r, title, ""); + let t = self.t.clone(); + let c = pos2(r.right() - 70.0, r.center().y); + ui.painter().text(c, Align2::CENTER_CENTER, value, fonts::med(14.0), t.on_surface); + let mut d = 0; + if icon_btn(ui, &t, Rect::from_center_size(c - vec2(44.0, 0.0), vec2(34.0, 34.0)), &format!("{key}-"), "remove", "", false).clicked() { d = -1 } + if icon_btn(ui, &t, Rect::from_center_size(c + vec2(44.0, 0.0), vec2(34.0, 34.0)), &format!("{key}+"), "add", "", false).clicked() { d = 1 } + *y += 66.0; + d + } + + fn appearance(&mut self, ui: &mut Ui, list: Rect, y: &mut f32) { + let mode = self.s.mode.clone(); + if let Some(v) = self.choice(ui, list, y, "set/mode", "Theme", "Follows your desktop on Auto", &[("auto", "Auto"), ("light", "Light"), ("dark", "Dark")], &mode) { self.s.mode = v } + let src = self.s.color_source.clone(); + if let Some(v) = self.choice(ui, list, y, "set/src", "Colours from", "Your desktop, or a colour you pick", &[("auto", "Desktop"), ("caelestia", "Caelestia"), ("kde", "KDE"), ("custom", "Custom")], &src) { self.s.color_source = v } + let sch = self.s.scheme.clone(); + if let Some(v) = self.choice(ui, list, y, "set/sch", "Style", "How much colour the scheme uses", &[("tonal", "Tonal"), ("vibrant", "Vibrant"), ("expressive", "Expressive"), ("mono", "Mono")], &sch) { self.s.scheme = v } + let r = Rect::from_min_size(pos2(list.left(), *y), vec2(list.width(), 74.0)); + self.card(ui, r); + self.label(ui, r, "Custom colour", ""); + let mut x = r.right() - 32.0 - (SEEDS.len() - 1) as f32 * 42.0; + for (i, s) in SEEDS.iter().enumerate() { + let c = hex(s).unwrap(); + let rr = Rect::from_center_size(pos2(x, r.center().y), vec2(36.0, 36.0)); + let resp = ui.interact(rr, ui.scope_id().with(("seed", i)), Sense::click()); + let on = self.s.color_source == "custom" && self.s.custom_color == *s; + let v = spring(format!("seed/{i}"), on as u8 as f32, motion::FAST); + let hov = spring(format!("seedh/{i}"), resp.hovered() as u8 as f32, motion::FAST); + blob(ui.painter(), rr.center(), 15.0 + 2.0 * hov, 8.0, 0.09 * v.clamp(0.0, 1.0), 0.0, c); + if on { icons::paint(ui.ctx(), ui.painter(), rr.center(), 18.0, "check", Color32::WHITE) } + if resp.clicked() { + self.s.custom_color = s.to_string(); + self.s.color_source = "custom".into(); + self.theme_wave = ui.input(|i| i.pointer.interact_pos()).map(|p| (p, i_time(ui))); + } + x += 42.0; + } + *y += 78.0; + } + + fn editor_settings(&mut self, ui: &mut Ui, list: Rect, y: &mut f32) { + let fs = self.s.font_size; + let d = self.stepper(ui, list, y, "set/font", "Text size", format!("{fs:.0}")); + self.s.font_size = (fs + d as f32).clamp(8.0, 40.0); + let tw = self.s.tab_width; + let d = self.stepper(ui, list, y, "set/tab", "Tab width", tw.to_string()); + self.s.tab_width = (tw as i32 + d).clamp(1, 12) as usize; + self.toggle(ui, list, y, "set/spaces", "Indent with spaces", "", |s| &mut s.spaces); + self.toggle(ui, list, y, "set/pairs", "Close brackets and quotes", "", |s| &mut s.auto_close); + self.toggle(ui, list, y, "set/wrap", "Word wrap", "", |s| &mut s.word_wrap); + self.toggle(ui, list, y, "set/nums", "Line numbers", "", |s| &mut s.line_numbers); + self.toggle(ui, list, y, "set/guides", "Indent guides", "", |s| &mut s.indent_guides); + self.toggle(ui, list, y, "set/trim", "Trim trailing spaces on save", "", |s| &mut s.trim_on_save); + self.toggle(ui, list, y, "set/lsp", "Language servers", "clangd, rust-analyzer and others, when installed", |s| &mut s.lsp); + } + + fn motion_settings(&mut self, ui: &mut Ui, list: Rect, y: &mut f32) { + let cur = self.s.motion.to_string(); + if let Some(v) = self.choice(ui, list, y, "set/motion", "Animation", "Calm never overshoots; Jelly wobbles", &[("0", "Off"), ("1", "Calm"), ("2", "Bouncy"), ("3", "Jelly")], &cur) { + self.s.motion = v.parse().unwrap_or(2); + } + self.toggle(ui, list, y, "set/prev", "Scrolling preview", "The rail of code beside the editor", |s| &mut s.preview); + self.toggle(ui, list, y, "set/lens", "Preview lens", "A card of real code pops out while you drag the preview. Hold Shift to peek.", |s| &mut s.lens); + } + + fn terminal_settings(&mut self, ui: &mut Ui, list: Rect, y: &mut f32) { + let f = self.s.terminal_font; + let d = self.stepper(ui, list, y, "set/tfont", "Text size", format!("{f:.0}")); + self.s.terminal_font = (f + d as f32).clamp(8.0, 30.0); + let r = Rect::from_min_size(pos2(list.left(), *y), vec2(list.width(), 62.0)); + self.card(ui, r); + self.label(ui, r, "Shell", "Empty uses your login shell"); + let t = self.t.clone(); + let field = Rect::from_min_size(pos2(r.right() - 234.0, r.center().y - 18.0), vec2(220.0, 36.0)); + ui.painter().rect_filled(field, cr(14.0), t.highest); + ui.put(field.shrink2(vec2(12.0, 9.0)), egui::TextEdit::singleline(&mut self.s.shell).frame(egui::Frame::NONE).font(fonts::ui(13.0)).text_color(t.on_surface)); + *y += 66.0; + } +} + +fn i_time(ui: &Ui) -> f64 { + ui.input(|i| i.time) +} diff --git a/src/ui/sidebar.rs b/src/ui/sidebar.rs new file mode 100644 index 0000000..d08c24c --- /dev/null +++ b/src/ui/sidebar.rs @@ -0,0 +1,376 @@ +//! The side panel: files, search in files, outline, git and problems. + +use super::commands::Cmd; +use super::morph::{self, Morph}; +use super::{fonts, icons, rail::SIDES, widgets::*}; +use crate::app::{App, Msg}; +use crate::motion::{self, spring}; +use crate::theme::alpha; +use eframe::egui::{self, pos2, vec2, Align2, Key, Rect, Sense, Ui}; +use std::collections::{HashMap, HashSet}; +use std::path::{Path, PathBuf}; + +#[derive(Default)] +pub struct Side { + pub expanded: HashSet, + pub dirs: HashMap>, + pub scroll: [f32; 5], + pub search: String, + pub searching: bool, + pub results: Vec<(PathBuf, usize, String)>, + pub search_focus: bool, + pub commit: String, + outline: (u64, u64, Vec<(usize, String, &'static str)>), +} + +fn list_dir(p: &Path) -> Vec<(String, bool)> { + let mut v: Vec<(String, bool)> = std::fs::read_dir(p).map(|rd| rd.flatten().map(|e| { + let d = e.file_type().map(|t| t.is_dir()).unwrap_or(false) || e.path().is_dir(); + (e.file_name().to_string_lossy().into_owned(), d) + }).collect()).unwrap_or_default(); + v.sort_by_key(|(n, d)| (!*d, n.starts_with('.'), n.to_lowercase())); + v +} + +const SYMBOLS: &[(&str, &str)] = &[ + (r"^\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+|unsafe\s+|const\s+)*fn\s+(\w+)", "fn"), + (r"^\s*(?:pub(?:\([^)]*\))?\s+)?(struct|enum|trait|impl|mod|type)\s+([\w:<>, ]+)", "type"), + (r"^\s*(?:async\s+)?def\s+(\w+)", "def"), + (r"^\s*class\s+(\w+)", "class"), + (r"^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*(\w+)", "function"), + (r"^\s*(?:export\s+)?(?:interface|type)\s+(\w+)", "type"), + (r"^(?:[\w:*&<>]+\s+)+[*&]?(\w+)\s*\([^;]*$", "function"), + (r"^func\s+(?:\([^)]*\)\s*)?(\w+)", "func"), + (r"^(#{1,6}\s+.+)$", "heading"), +]; + +impl App { + /// (line, name, kind) of each symbol in the current file. + pub fn outline(&mut self) -> Vec<(usize, String, &'static str)> { + let Some(id) = self.cur_doc_id() else { return vec![] }; + let d = &self.docs[&id]; + if self.side_state.outline.0 == id && self.side_state.outline.1 == d.buf.version { + return self.side_state.outline.2.clone(); + } + let res: Vec<(regex::Regex, &'static str)> = SYMBOLS.iter().filter_map(|(p, k)| regex::Regex::new(p).ok().map(|r| (r, *k))).collect(); + let mut v = vec![]; + for l in 0..d.buf.lines().min(100_000) { + let text = d.buf.line_text(l); + if text.len() > 400 { continue } + for (re, kind) in &res { + if let Some(c) = re.captures(&text) { + let name = c.iter().skip(1).flatten().map(|m| m.as_str().trim()).collect::>().join(" "); + v.push((l, name, *kind)); + break; + } + } + } + self.side_state.outline = (id, d.buf.version, v.clone()); + v + } + + pub fn start_search(&mut self) { + let q = self.side_state.search.clone(); + let Some(root) = self.root.clone() else { return self.toast("folder", "Open a folder to search in it".to_string()) }; + if q.is_empty() { return } + self.side_state.searching = true; + self.side_state.results.clear(); + let tx = self.tx.clone(); + std::thread::spawn(move || { + let needle = regex::RegexBuilder::new(®ex::escape(&q)).case_insensitive(true).build(); + let Ok(re) = needle else { return }; + let mut out = vec![]; + 'files: for f in super::palette::project_files(&root) { + let Ok(bytes) = std::fs::read(&f) else { continue }; + if bytes.len() > 4_000_000 || bytes.contains(&0) { continue } + let text = String::from_utf8_lossy(&bytes); + for (i, l) in text.lines().enumerate() { + if re.is_match(l) { + out.push((f.clone(), i, l.trim().chars().take(160).collect::())); + if out.len() >= 2000 { break 'files } + } + } + } + let _ = tx.send(Msg::Search(out)); + }); + } + + pub fn side_panel(&mut self, ui: &mut Ui, rect: Rect) { + let t = self.t.clone(); + let p = ui.painter().clone(); + p.rect_filled(rect, cr(24.0), t.low); + let inner = rect.shrink(10.0); + let (title, _, _) = SIDES[self.side]; + let clipped = p.with_clip_rect(rect); + clipped.text(pos2(inner.left() + 8.0, inner.top() + 18.0), Align2::LEFT_CENTER, title, fonts::semi(16.0), t.on_surface); + let head_btn = Rect::from_center_size(pos2(inner.right() - 16.0, inner.top() + 18.0), vec2(32.0, 32.0)); + match self.side { + 0 => { + if icon_btn(ui, &t, head_btn, "side/open", "folder_open", "Open folder", false).clicked() { self.run(ui.ctx(), Cmd::OpenFolder) } + if self.root.is_some() && icon_btn(ui, &t, head_btn.translate(vec2(-34.0, 0.0)), "side/refresh", "refresh", "Refresh", false).clicked() { + self.side_state.dirs.clear(); + } + } + 3 => if icon_btn(ui, &t, head_btn, "side/gitr", "sync", "Refresh", false).clicked() { self.run(ui.ctx(), Cmd::GitRefresh) }, + _ => {} + } + let body = Rect::from_min_max(pos2(inner.left(), inner.top() + 40.0), inner.max); + let mut sub = ui.new_child(egui::UiBuilder::new().max_rect(body)); + sub.set_clip_rect(body.intersect(ui.clip_rect())); + match self.side { + 0 => self.files_panel(&mut sub, body), + 1 => self.search_panel(&mut sub, body), + 2 => self.outline_panel(&mut sub, body), + 3 => self.git_panel(&mut sub, body), + _ => self.problems_panel(&mut sub, body), + } + } + + /// Shared row: an icon, a label, a faint detail. + #[allow(clippy::too_many_arguments)] + fn row(&self, ui: &mut Ui, r: Rect, key: &str, ic: &str, col: egui::Color32, label: &str, detail: &str, sel: bool) -> egui::Response { + let t = &self.t; + let resp = ui.interact(r, ui.scope_id().with(key), Sense::click()); + let (hov, press) = states(key, &resp); + let c = scale_rect(r, 1.0 - 0.015 * press); + let p = ui.painter(); + if sel { p.rect_filled(c, cr(14.0), t.secondary_container); } + else if hov > 0.01 { p.rect_filled(c, cr(14.0), alpha(t.on_surface, 0.07 * hov)); } + if !ic.is_empty() { icons::paint(ui.ctx(), p, pos2(r.left() + 16.0, r.center().y), 17.0, ic, col) } + let fg = if sel { t.on_secondary_container } else { t.on_surface }; + let tx = r.left() + if ic.is_empty() { 12.0 } else { 34.0 }; + let g = p.layout_no_wrap(label.to_string(), fonts::ui(13.0), fg); + let w = g.size().x; + p.with_clip_rect(r.intersect(ui.clip_rect())).galley(pos2(tx, r.center().y - g.size().y / 2.0), g, fg); + if !detail.is_empty() { + p.with_clip_rect(r.intersect(ui.clip_rect())).text(pos2(tx + w + 8.0, r.center().y), Align2::LEFT_CENTER, detail, fonts::ui(11.5), t.outline); + } + resp + } + + fn scrolled(&mut self, ui: &Ui, area: Rect, idx: usize, content: f32) -> f32 { + let max = (content - area.height()).max(0.0); + if ui.rect_contains_pointer(area) { + self.side_state.scroll[idx] -= crate::ui::widgets::wheel(ui).y * 1.4; + } + self.side_state.scroll[idx] = self.side_state.scroll[idx].clamp(0.0, max); + let s = spring(format!("side/scroll/{idx}"), self.side_state.scroll[idx], motion::Preset { stiffness: 520.0, damping: 1.0 }); + scroll_pill(ui.painter(), &self.t, area, s, content); + s + } + + fn files_panel(&mut self, ui: &mut Ui, area: Rect) { + let t = self.t.clone(); + let Some(root) = self.root.clone() else { + let c = area.center_top() + vec2(0.0, 90.0); + ui.painter().text(c, Align2::CENTER_CENTER, "No folder open", fonts::ui(13.5), t.on_variant); + let r = Rect::from_center_size(c + vec2(0.0, 40.0), vec2(150.0, 40.0)); + if pill(ui, &t, r, "side/openf", "folder_open", "Open folder", Tone::Tonal).clicked() { self.run(ui.ctx(), Cmd::OpenFolder) } + return; + }; + let mut rows: Vec<(PathBuf, String, bool, usize)> = vec![]; + let mut stack: Vec<(PathBuf, usize)> = vec![(root.clone(), 0)]; + while let Some((dir, depth)) = stack.pop() { + if !self.side_state.dirs.contains_key(&dir) { + self.side_state.dirs.insert(dir.clone(), list_dir(&dir)); + } + let list = self.side_state.dirs[&dir].clone(); + let at = rows.len(); + let mut block = vec![]; + for (n, d) in list { + block.push((dir.join(&n), n, d, depth)); + } + let nested: Vec<(PathBuf, usize)> = block.iter().filter(|b| b.2 && self.side_state.expanded.contains(&b.0)).map(|b| (b.0.clone(), depth + 1)).collect(); + rows.splice(at..at, block); + // children go straight after their parent, so walk them now + for (d, dp) in nested.into_iter().rev() { + let pos = rows.iter().position(|r| r.0 == d).unwrap() + 1; + let sub = self.tree_rows(&d, dp); + rows.splice(pos..pos, sub); + } + } + let row_h = 30.0; + let scroll = self.scrolled(ui, area, 0, rows.len() as f32 * row_h); + let cur = self.cur_doc().and_then(|d| d.path.clone()); + let first = (scroll / row_h) as usize; + let git_root = self.git.root.clone(); + let changed: HashMap = self.git.files.iter().filter_map(|f| git_root.as_ref().map(|r| (r.join(&f.2), if f.1 != ' ' { f.1 } else { f.0 }))).collect(); + for (i, (path, name, is_dir, depth)) in rows.iter().enumerate().skip(first).take((area.height() / row_h) as usize + 2) { + let y = area.top() + i as f32 * row_h - scroll; + let r = Rect::from_min_size(pos2(area.left() + *depth as f32 * 14.0, y), vec2(area.width() - *depth as f32 * 14.0 - 6.0, row_h - 2.0)); + let key = format!("f/{}", path.display()); + let open = self.side_state.expanded.contains(path); + let (ic, col) = if *is_dir { (if open { "folder_open" } else { "folder" }, t.primary) } else { ("description", t.on_variant) }; + let git = changed.get(path).copied(); + let resp = self.row(ui, r, &key, ic, col, name, "", cur.as_ref() == Some(path)); + if let Some(g) = git { + let c = match g { '?' | 'A' => t.added, 'D' => t.removed, _ => t.changed }; + ui.painter().circle_filled(pos2(r.right() - 12.0, r.center().y), 3.5, c); + } + if resp.clicked() { + if *is_dir { + if !self.side_state.expanded.remove(path) { + self.side_state.expanded.insert(path.clone()); + } + } else { + self.open_path(ui.ctx(), path.clone(), None); + } + } + if resp.secondary_clicked() { + if let Some(p) = ui.input(|i| i.pointer.interact_pos()) { self.file_menu(path.clone(), *is_dir, p) } + } + } + } + + fn tree_rows(&mut self, dir: &Path, depth: usize) -> Vec<(PathBuf, String, bool, usize)> { + if !self.side_state.dirs.contains_key(dir) { + self.side_state.dirs.insert(dir.to_path_buf(), list_dir(dir)); + } + let mut out = vec![]; + for (n, d) in self.side_state.dirs[dir].clone() { + let p = dir.join(&n); + let open = d && self.side_state.expanded.contains(&p); + out.push((p.clone(), n, d, depth)); + if open { out.extend(self.tree_rows(&p, depth + 1)) } + } + out + } + + fn search_panel(&mut self, ui: &mut Ui, area: Rect) { + let t = self.t.clone(); + let field = Rect::from_min_size(area.min + vec2(2.0, 2.0), vec2(area.width() - 4.0, 40.0)); + ui.painter().rect_filled(field, cr(20.0), t.high); + icons::paint(ui.ctx(), ui.painter(), pos2(field.left() + 20.0, field.center().y), 18.0, "search", t.on_variant); + let te = ui.put(Rect::from_min_max(pos2(field.left() + 38.0, field.top() + 10.0), pos2(field.right() - 12.0, field.bottom() - 8.0)), egui::TextEdit::singleline(&mut self.side_state.search).frame(egui::Frame::NONE).hint_text("Search in project").font(fonts::ui(13.5)).text_color(t.on_surface)); + if self.side_state.search_focus { self.side_state.search_focus = false; te.request_focus() } + if te.lost_focus() && ui.input(|i| i.key_pressed(Key::Enter)) { self.start_search() } + let list = Rect::from_min_max(pos2(area.left(), area.top() + 52.0), area.max); + if self.side_state.searching { + let c = list.center_top() + vec2(0.0, 30.0); + let now = ui.input(|i| i.time) as f32; + blob(ui.painter(), c, 14.0, 5.0, 0.16, now * 2.0, t.primary_container); + motion::keep_alive(); + return; + } + let results = std::mem::take(&mut self.side_state.results); + let row_h = 44.0; + let scroll = self.scrolled(ui, list, 1, results.len() as f32 * row_h); + let first = (scroll / row_h) as usize; + let root = self.root.clone().unwrap_or_default(); + let mut open = None; + for (i, (path, line, text)) in results.iter().enumerate().skip(first).take((list.height() / row_h) as usize + 2) { + let y = list.top() + i as f32 * row_h - scroll; + let r = Rect::from_min_size(pos2(list.left(), y), vec2(list.width() - 6.0, row_h - 2.0)); + let resp = ui.interact(r, ui.scope_id().with(("res", i)), Sense::click()); + let (hov, _) = states(&format!("res/{i}"), &resp); + let p = ui.painter().with_clip_rect(r.intersect(ui.clip_rect())); + if hov > 0.01 { p.rect_filled(r, cr(14.0), alpha(t.on_surface, 0.07 * hov)); } + p.text(pos2(r.left() + 10.0, r.top() + 13.0), Align2::LEFT_CENTER, text, fonts::mono(12.0), t.on_surface); + let rel = path.strip_prefix(&root).unwrap_or(path).display(); + p.text(pos2(r.left() + 10.0, r.top() + 31.0), Align2::LEFT_CENTER, format!("{rel}:{}", line + 1), fonts::ui(11.0), t.outline); + if resp.clicked() { open = Some((path.clone(), *line)) } + } + self.side_state.results = results; + if let Some((p, l)) = open { self.open_path(ui.ctx(), p, Some(l)) } + } + + fn outline_panel(&mut self, ui: &mut Ui, area: Rect) { + let t = self.t.clone(); + let items = self.outline(); + if items.is_empty() { + ui.painter().text(area.center_top() + vec2(0.0, 80.0), Align2::CENTER_CENTER, "No symbols found", fonts::ui(13.5), t.on_variant); + return; + } + let row_h = 30.0; + let scroll = self.scrolled(ui, area, 2, items.len() as f32 * row_h); + let cur = self.cur_doc().map_or(0, |d| d.buf.pos(d.buf.head()).0); + let here = items.iter().rposition(|i| i.0 <= cur); + let first = (scroll / row_h) as usize; + let mut go = None; + for (i, (line, name, kind)) in items.iter().enumerate().skip(first).take((area.height() / row_h) as usize + 2) { + let y = area.top() + i as f32 * row_h - scroll; + let r = Rect::from_min_size(pos2(area.left(), y), vec2(area.width() - 6.0, row_h - 2.0)); + let ic = match *kind { "type" | "class" => "data_object", "heading" => "tag", _ => "code" }; + if self.row(ui, r, &format!("o/{i}"), ic, t.primary, name, "", here == Some(i)).clicked() { go = Some(*line) } + } + if let Some(l) = go { self.jump_to_line(ui.ctx(), l) } + } + + fn git_panel(&mut self, ui: &mut Ui, area: Rect) { + let t = self.t.clone(); + if self.git.root.is_none() { + ui.painter().text(area.center_top() + vec2(0.0, 80.0), Align2::CENTER_CENTER, "Not a git repository", fonts::ui(13.5), t.on_variant); + return; + } + let root = self.git.root.clone().unwrap(); + let branch = Rect::from_min_size(area.min + vec2(2.0, 2.0), vec2(area.width() - 4.0, 38.0)); + ui.painter().rect_filled(branch, cr(19.0), t.secondary_container); + icons::paint(ui.ctx(), ui.painter(), pos2(branch.left() + 20.0, branch.center().y), 18.0, "call_split", t.on_secondary_container); + ui.painter().text(pos2(branch.left() + 38.0, branch.center().y), Align2::LEFT_CENTER, format!("{} {}", self.git.branch, self.git.ahead), fonts::med(13.0), t.on_secondary_container); + let field = Rect::from_min_size(area.min + vec2(2.0, 50.0), vec2(area.width() - 4.0, 40.0)); + ui.painter().rect_filled(field, cr(16.0), t.high); + ui.put(field.shrink2(vec2(14.0, 11.0)), egui::TextEdit::singleline(&mut self.side_state.commit).frame(egui::Frame::NONE).hint_text("Commit message").font(fonts::ui(13.5)).text_color(t.on_surface)); + let w = (area.width() - 10.0) / 3.0; + let row = |i: usize| Rect::from_min_size(pos2(area.left() + 2.0 + i as f32 * (w + 3.0), area.top() + 98.0), vec2(w, 34.0)); + if pill(ui, &t, row(0), "git/commit", "check", "Commit", Tone::Filled).clicked() { self.git_commit() } + if pill(ui, &t, row(1), "git/pull", "download", "Pull", Tone::Tonal).clicked() { self.git_remote("pull") } + if pill(ui, &t, row(2), "git/push", "upload", "Push", Tone::Tonal).clicked() { self.git_remote("push") } + let list = Rect::from_min_max(pos2(area.left(), area.top() + 142.0), area.max); + let files = self.git.files.clone(); + let row_h = 32.0; + let scroll = self.scrolled(ui, list, 3, files.len() as f32 * row_h); + let mut cl = ui.new_child(egui::UiBuilder::new().max_rect(list)); + cl.set_clip_rect(list.intersect(ui.clip_rect())); + for (i, (x, y, path)) in files.iter().enumerate() { + let yy = list.top() + i as f32 * row_h - scroll; + if yy + row_h < list.top() || yy > list.bottom() { continue } + let r = Rect::from_min_size(pos2(list.left(), yy), vec2(list.width() - 6.0, row_h - 2.0)); + let staged = *x != ' ' && *x != '?'; + let name = Path::new(path).file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); + let dir = Path::new(path).parent().map(|d| d.to_string_lossy().into_owned()).unwrap_or_default(); + let resp = self.row(&mut cl, Rect::from_min_max(r.min, pos2(r.right() - 32.0, r.bottom())), &format!("g/{path}"), "description", t.on_variant, &name, &dir, false); + let letter = if *y != ' ' { *y } else { *x }; + let col = match letter { '?' | 'A' => t.added, 'D' => t.removed, _ => t.changed }; + cl.painter().text(pos2(r.right() - 42.0, r.center().y), Align2::CENTER_CENTER, letter.to_string(), fonts::med(12.0), col); + let b = Rect::from_center_size(pos2(r.right() - 16.0, r.center().y), vec2(26.0, 26.0)); + if morph::button(&mut cl, &t, b, &format!("gs/{path}"), Morph::AddRemove, staged, if staged { "Unstage" } else { "Stage" }, t.low).clicked() { + self.git_stage(path, staged); + } + if resp.clicked() { + self.open_diff(ui.ctx(), &root, path); + } + } + } + + fn problems_panel(&mut self, ui: &mut Ui, area: Rect) { + let t = self.t.clone(); + let mut all: Vec<(PathBuf, crate::lsp::Diag)> = self.diags.iter().flat_map(|(p, v)| v.iter().map(move |d| (p.clone(), d.clone()))).collect(); + all.sort_by_key(|x| (x.1.severity, x.0.clone(), x.1.line)); + if all.is_empty() { + let c = area.center_top() + vec2(0.0, 80.0); + icons::paint(ui.ctx(), ui.painter(), c, 34.0, "check_circle", t.primary); + ui.painter().text(c + vec2(0.0, 32.0), Align2::CENTER_CENTER, "No problems", fonts::ui(13.5), t.on_variant); + return; + } + let row_h = 54.0; + let scroll = self.scrolled(ui, area, 4, all.len() as f32 * row_h); + let first = (scroll / row_h) as usize; + let mut open = None; + for (i, (path, d)) in all.iter().enumerate().skip(first).take((area.height() / row_h) as usize + 2) { + let y = area.top() + i as f32 * row_h - scroll; + let r = Rect::from_min_size(pos2(area.left(), y), vec2(area.width() - 6.0, row_h - 2.0)); + let resp = ui.interact(r, ui.scope_id().with(("prob", i)), Sense::click()); + let (hov, _) = states(&format!("prob/{i}"), &resp); + let p = ui.painter().with_clip_rect(r.intersect(ui.clip_rect())); + if hov > 0.01 { p.rect_filled(r, cr(14.0), alpha(t.on_surface, 0.07 * hov)); } + let (ic, col) = if d.severity == 1 { ("error", t.error) } else if d.severity == 2 { ("warning", t.syntax[crate::syntax::DefStyle::Warning as usize]) } else { ("info", t.primary) }; + icons::paint(ui.ctx(), &p, pos2(r.left() + 15.0, r.top() + 16.0), 17.0, ic, col); + let msg: String = d.msg.lines().next().unwrap_or("").chars().take(70).collect(); + p.text(pos2(r.left() + 32.0, r.top() + 16.0), Align2::LEFT_CENTER, msg, fonts::ui(12.5), t.on_surface); + let name = path.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); + p.text(pos2(r.left() + 32.0, r.top() + 36.0), Align2::LEFT_CENTER, format!("{name}:{}", d.line + 1), fonts::ui(11.0), t.outline); + if resp.clicked() { open = Some((path.clone(), d.line)) } + } + if let Some((p, l)) = open { self.open_path(ui.ctx(), p, Some(l)) } + } +} diff --git a/src/ui/status.rs b/src/ui/status.rs new file mode 100644 index 0000000..e926e14 --- /dev/null +++ b/src/ui/status.rs @@ -0,0 +1,92 @@ +//! The bottom strip: little pills for where you are in the file, and the terminal button. The +//! button is a bubbly blob that the terminal card grows out of. + +use super::commands::Cmd; +use super::morph::{self, Morph}; +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring}; +use crate::theme::{alpha, mix}; +use eframe::egui::{pos2, vec2, Align2, Rect, Sense, Ui}; + +pub const FAB_W: f32 = 132.0; + +impl App { + pub fn status(&mut self, ui: &mut Ui, rect: Rect) { + let t = self.t.clone(); + let mut x = rect.left(); + let mut items: Vec<(String, &str, Option)> = vec![]; + if !self.git.branch.is_empty() { + items.push((self.git.branch.clone(), "call_split", Some(Cmd::Side(3)))); + } + if let Some(d) = self.cur_doc() { + let (l, c) = d.buf.pos(d.buf.head()); + let mut pos = format!("{}:{}", l + 1, c + 1); + let sel: usize = d.buf.sels.iter().map(|s| s.range().len()).sum(); + if d.buf.sels.len() > 1 { pos.push_str(&format!(" · {} cursors", d.buf.sels.len())) } + if sel > 0 { pos.push_str(&format!(" · {sel} selected")) } + items.push((pos, "", Some(Cmd::GotoLine))); + let lang = if d.language == "None" { "Plain text".to_string() } else { d.language.clone() }; + items.push((lang, "", Some(Cmd::Languages))); + items.push((format!("{} {}", if self.s.spaces { "Spaces" } else { "Tabs" }, self.s.tab_width), "", Some(Cmd::Settings))); + items.push((d.encoding.name().to_string(), "", None)); + items.push((d.eol.label().to_string(), "", None)); + } + let (e, w) = self.problem_totals(); + if e + w > 0 { + items.push((format!("{e} errors, {w} warnings"), if e > 0 { "error" } else { "warning" }, Some(Cmd::Side(4)))); + } + for (i, (text, ic, cmd)) in items.iter().enumerate() { + let g = ui.painter().layout_no_wrap(text.clone(), fonts::ui(12.5), t.on_variant); + let w = g.size().x + 22.0 + if ic.is_empty() { 0.0 } else { 20.0 }; + if x + w > rect.right() - FAB_W - 52.0 { break } + let r = Rect::from_min_size(pos2(x, rect.center().y - 14.0), vec2(w, 28.0)); + let key = format!("st/{i}"); + let resp = ui.interact(r, ui.scope_id().with(&key), if cmd.is_some() { Sense::click() } else { Sense::hover() }); + let (hov, press) = states(&key, &resp); + ui.painter().rect_filled(scale_rect(r, 1.0 - 0.06 * press), cr(14.0), alpha(t.on_surface, 0.07 * hov)); + let mut tx = r.left() + 11.0; + if !ic.is_empty() { + icons::paint(ui.ctx(), ui.painter(), pos2(tx + 7.0, r.center().y), 15.0, ic, t.on_variant); + tx += 20.0; + } + ui.painter().galley(pos2(tx, r.center().y - g.size().y / 2.0), g, t.on_variant); + if resp.clicked() { + if let Some(c) = cmd { self.run(ui.ctx(), c.clone()) } + } + x += w + 2.0; + } + + if self.cur_doc().is_some() { + let r = Rect::from_center_size(pos2(rect.right() - FAB_W - 26.0, rect.center().y), vec2(32.0, 32.0)); + let (wrap, tip) = (self.s.word_wrap, "Word wrap (F10)"); + if morph::button(ui, &t, r, "st/wrap", Morph::Wrap, wrap, tip, t.surface).clicked() { + self.run(ui.ctx(), Cmd::ToggleWrap); + } + } + + // the terminal button + let open = self.term_open; + let fab = Rect::from_min_size(pos2(rect.right() - FAB_W, rect.center().y - 22.0), vec2(FAB_W, 44.0)); + self.fab_rect = fab; + let resp = ui.interact(fab, ui.scope_id().with("fab"), Sense::click()).on_hover_text("Terminal (F4)"); + let (hov, press) = states("fab", &resp); + let on = spring("fab/on", open as u8 as f32, motion::DEFAULT); + let c = scale_rect(fab, (1.0 - 0.05 * press) * (1.0 + 0.02 * hov)); + let radius = lerp(c.height() * 0.5, c.height() * 0.3, press.clamp(0.0, 1.0).max(on.clamp(0.0, 1.0) * 0.5)); + let bg = mix(t.primary_container, t.primary, on.clamp(0.0, 1.0)); + let fg = mix(t.on_primary_container, t.on_primary, on.clamp(0.0, 1.0)); + ui.painter().rect_filled(c, cr(radius), bg); + ui.painter().rect_filled(c, cr(radius), alpha(fg, 0.08 * hov)); + let ic = pos2(c.left() + 28.0, c.center().y); + blob(ui.painter(), ic, 15.0, 6.0, 0.09 + 0.05 * on, on * 2.0 + hov * 0.4, alpha(fg, 0.16)); + morph::paint(ui.painter(), ic, 21.0, Morph::TerminalHide, on, fg, bg); + ui.painter().text(pos2(c.left() + 50.0, c.center().y), Align2::LEFT_CENTER, "Terminal", fonts::med(13.5), fg); + if self.term_busy { + ui.painter().circle_filled(pos2(c.right() - 14.0, c.center().y), 3.5, fg); + } + if resp.clicked() { + self.run(ui.ctx(), Cmd::ToggleTerminal); + } + } +} diff --git a/src/ui/tabs.rs b/src/ui/tabs.rs new file mode 100644 index 0000000..4a08cb8 --- /dev/null +++ b/src/ui/tabs.rs @@ -0,0 +1,183 @@ +//! Bubble tabs. A jelly indicator stretches between tabs (its two edges are separate springs), new +//! tabs pop in, and dragging a tab slides its neighbours out of the way. + +use super::morph::{self, Morph}; +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring, spring_from, Preset}; +use crate::theme::{alpha, mix}; +use eframe::egui::{self, pos2, vec2, Color32, Rect, Sense, Ui}; + +const H: f32 = 36.0; +const LEAD: Preset = Preset { stiffness: 1300.0, damping: 0.72 }; +const TRAIL: Preset = Preset { stiffness: 480.0, damping: 0.72 }; + +/// The little coloured dot for a language. +pub fn lang_color(t: &crate::theme::Theme, lang: &str) -> Color32 { + let h = lang.bytes().fold(7u32, |a, b| a.wrapping_mul(31).wrapping_add(b as u32)); + t.ansi[9 + (h % 6) as usize] +} + +impl App { + pub fn tabstrip(&mut self, ui: &mut Ui, pane: usize, rect: Rect) { + let t = self.t.clone(); + let tabs: Vec<(u64, String, bool, String)> = self.panes[pane].tabs.iter().map(|x| { + let d = &self.docs[&x.doc]; + (x.doc, d.title(), d.buf.is_modified(), d.language.clone()) + }).collect(); + let active = self.panes[pane].active; + let font = fonts::med(13.0); + let widths: Vec = tabs.iter().map(|x| { + let g = ui.painter().layout_no_wrap(x.1.clone(), font.clone(), Color32::WHITE); + (g.size().x + 66.0).clamp(92.0, 230.0) + }).collect(); + let area = Rect::from_min_max(rect.min, pos2(rect.right() - 42.0, rect.bottom())); + let total: f32 = widths.iter().sum::() + 6.0 * tabs.len() as f32; + let scroll_max = (total - area.width()).max(0.0); + let scroll_key = format!("tabs/{pane}/scroll"); + if ui.rect_contains_pointer(area) { + let d = crate::ui::widgets::wheel(ui); + self.panes[pane].tab_scroll -= d.x + d.y; + } + // keep the active tab in view + let a_x: f32 = widths.iter().take(active).sum::() + 6.0 * active as f32; + if self.panes[pane].reveal_tab { + self.panes[pane].reveal_tab = false; + let w = widths.get(active).copied().unwrap_or(0.0); + let s = &mut self.panes[pane].tab_scroll; + if a_x < *s { *s = a_x } else if a_x + w > *s + area.width() { *s = a_x + w - area.width() } + } + let tab_scroll = { let s = &mut self.panes[pane].tab_scroll; *s = s.clamp(0.0, scroll_max); *s }; + let offset = spring(scroll_key, tab_scroll, Preset { stiffness: 600.0, damping: 1.0 }); + + let painter = ui.painter_at(area); + let y = rect.center().y - H / 2.0; + + // target slots; a dragged tab hands its slot to whichever neighbour it passes + let mut order: Vec = (0..tabs.len()).collect(); + let drag = self.panes[pane].tab_drag; + if let Some((idx, grab)) = drag { + if let Some(p) = ui.input(|i| i.pointer.interact_pos()) { + let x = p.x - grab - area.left() + offset + widths[idx] / 2.0; + let mut acc = 0.0; + let mut dest = tabs.len() - 1; + for (i, w) in widths.iter().enumerate() { + acc += w + 6.0; + if x < acc { dest = i; break } + } + let v = order.remove(idx); + order.insert(dest, v); + } + } + let mut slot_x = vec![0.0; tabs.len()]; + let mut acc = 0.0; + for i in &order { + slot_x[*i] = acc; + acc += widths[*i] + 6.0; + } + + // jelly indicator + if !tabs.is_empty() { + let (l, r) = (slot_x[active], slot_x[active] + widths[active]); + let going_right = l > spring(format!("tabs/{pane}/last"), l, motion::EFFECT); + let (pl, pr) = if going_right { (TRAIL, LEAD) } else { (LEAD, TRAIL) }; + let il = spring(format!("tabs/{pane}/il"), l, pl); + let ir = spring(format!("tabs/{pane}/ir"), r, pr); + let bump = spring(format!("tabs/{pane}/save"), 0.0, motion::FAST); + let rr = Rect::from_min_max(pos2(area.left() + il - offset, y - bump * 2.0), pos2(area.left() + ir - offset, y + H + bump * 2.0)); + painter.rect_filled(rr, cr(H / 2.0), t.secondary_container); + } + + let now = ui.input(|i| i.time); + let mut close = None; + let mut activate = None; + for (i, (doc, title, modified, lang)) in tabs.iter().enumerate() { + let key = format!("tab/{pane}/{doc}"); + let dragging = drag.is_some_and(|d| d.0 == i); + let sx = spring_from(format!("{key}/x"), slot_x[i], slot_x[i], Preset { stiffness: 900.0, damping: 0.72 }); + let birth = spring_from(format!("{key}/in"), 0.0, 1.0, motion::DEFAULT); + let mut x = area.left() + sx - offset; + if dragging { + if let (Some(p), Some((_, grab))) = (ui.input(|n| n.pointer.interact_pos()), drag) { + x = p.x - grab; + } + } + let r = Rect::from_min_size(pos2(x, y), vec2(widths[i], H)); + let resp = ui.interact(r.intersect(area), ui.scope_id().with(&key), Sense::click_and_drag()); + let (hov, press) = states(&key, &resp); + let sel = spring(format!("{key}/sel"), (i == active) as u8 as f32, motion::EFFECT); + let c = scale_rect(r, (0.6 + 0.4 * birth) * (1.0 - 0.04 * press) * if dragging { 1.05 } else { 1.0 }); + let p = if dragging { ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Foreground, ui.scope_id().with("tabdrag"))) } else { painter.clone() }; + if dragging { + shadow(&p, c, H / 2.0, 0.8, t.dark); + p.rect_filled(c, cr(H / 2.0), t.secondary_container); + } + if hov > 0.01 && i != active { + p.rect_filled(c, cr(H / 2.0), alpha(t.on_surface, 0.07 * hov)); + } + let fg = mix(t.on_variant, t.on_secondary_container, sel); + let dot = pos2(c.left() + 16.0, c.center().y); + p.circle_filled(dot, 4.0 + 1.0 * sel, lang_color(&t, lang)); + let g = p.layout_no_wrap(title.clone(), font.clone(), fg); + let text_clip = p.with_clip_rect(Rect::from_min_max(c.min, pos2(c.right() - 30.0, c.max.y)).intersect(area)); + text_clip.galley(pos2(c.left() + 28.0, c.center().y - g.size().y / 2.0), g, fg); + + // close button, which is a dot while the file has changes + let xr = Rect::from_center_size(pos2(c.right() - 17.0, c.center().y), vec2(22.0, 22.0)); + let xresp = ui.interact(xr.intersect(area), ui.scope_id().with(&key).with("x"), Sense::click()); + let xh = spring(format!("{key}/xh"), xresp.hovered() as u8 as f32, motion::FAST); + if xh > 0.01 { p.circle_filled(xr.center(), 11.0 * xh.clamp(0.0, 1.0), alpha(t.on_surface, 0.12)); } + let saved = spring(format!("{key}/mod"), *modified as u8 as f32, motion::FAST); + let show_x = (hov.max(sel) * (1.0 - saved.clamp(0.0, 1.0))).max(xh.clamp(0.0, 1.0)); + if show_x > 0.02 { icons::paint(ui.ctx(), &p, xr.center(), 15.0 * show_x.clamp(0.5, 1.0), "close", alpha(fg, show_x.clamp(0.0, 1.0))) } + if saved > 0.02 && xh < 0.5 { p.circle_filled(xr.center(), 4.5 * saved.max(0.0), t.primary); } + // a tick draws itself on where the dot was, then fades + let since = now - self.docs[doc].saved_at; + if since < 1.2 && *modified == false && xh < 0.5 { + morph::check(&p, xr.center(), 17.0, (since as f32 / 0.3).min(1.0), alpha(t.primary, ((1.2 - since as f32) / 0.3).min(1.0))); + motion::keep_alive(); + } + + if xresp.clicked() { + close = Some(i); + } else if resp.clicked() { + activate = Some(i); + } else if resp.middle_clicked() { + close = Some(i); + } + if resp.drag_started() { + if let Some(pp) = ui.input(|n| n.pointer.interact_pos()) { + self.panes[pane].tab_drag = Some((i, pp.x - x)); + } + activate = Some(i); + } + if resp.secondary_clicked() { + self.tab_menu(pane, i, resp.rect.center_bottom()); + } + } + if let Some((idx, _)) = drag { + if !ui.input(|i| i.pointer.primary_down()) { + self.panes[pane].tab_drag = None; + let dest = order.iter().position(|i| *i == idx).unwrap_or(idx); + if dest != idx { + let p = &mut self.panes[pane]; + let tb = p.tabs.remove(idx); + p.tabs.insert(dest, tb); + p.active = dest; + } + } + } + if let Some(i) = activate { + if drag.is_none() { self.activate_tab(pane, i, now) } + } + if let Some(i) = close { + self.close_tab(pane, i); + } + let add = Rect::from_center_size(pos2(rect.right() - 20.0, rect.center().y), vec2(34.0, 34.0)); + if morph::button(ui, &t, add, &format!("tabs/{pane}/add"), Morph::AddSpin, false, "New file", t.surface).clicked() { + self.focus_pane = pane; + self.run(ui.ctx(), super::commands::Cmd::New); + } + } +} + diff --git a/src/ui/terminal.rs b/src/ui/terminal.rs new file mode 100644 index 0000000..b78ef4d --- /dev/null +++ b/src/ui/terminal.rs @@ -0,0 +1,523 @@ +//! The baked-in terminal: alacritty's emulator behind a card that grows out of the terminal button. + +use super::morph::{self, Morph}; +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self, spring, Preset, Spring}; +use crate::theme::{alpha, mix, Theme}; +use alacritty_terminal::event::{Event as TermEvent, EventListener, WindowSize}; +use alacritty_terminal::event_loop::{EventLoop, Msg, Notifier}; +use alacritty_terminal::grid::{Dimensions, Scroll}; +use alacritty_terminal::index::{Column, Line, Point, Side}; +use alacritty_terminal::selection::{Selection, SelectionType}; +use alacritty_terminal::sync::FairMutex; +use alacritty_terminal::term::cell::Flags; +use alacritty_terminal::term::{Config, Term, TermMode}; +use alacritty_terminal::tty; +use alacritty_terminal::vte::ansi::{Color, NamedColor, Rgb}; +use eframe::egui::{self, pos2, text::LayoutJob, vec2, Color32, Event, Key, Modifiers, Pos2, Rect, Sense, TextFormat, Ui}; +use std::path::PathBuf; +use std::sync::mpsc::{channel, Receiver, Sender}; +use std::sync::Arc; + +/// Title a tracked command sets when it ends. +pub const RUN_DONE: &str = "damson-run-done"; + +#[derive(Clone)] +struct Proxy { + tx: Sender, + ctx: egui::Context, +} + +impl EventListener for Proxy { + fn send_event(&self, e: TermEvent) { + let _ = self.tx.send(e); + self.ctx.request_repaint(); + } +} + +#[derive(Clone, Copy)] +struct Size { + cols: usize, + lines: usize, +} + +impl Dimensions for Size { + fn total_lines(&self) -> usize { self.lines } + fn screen_lines(&self) -> usize { self.lines } + fn columns(&self) -> usize { self.cols } +} + +pub struct Session { + term: Arc>>, + notifier: Notifier, + rx: Receiver, + size: Size, + cell: (f32, f32), + pub title: String, + pub exited: bool, + /// A command started from Run is still going. + pub running: bool, + caret: [Spring; 2], + id: u64, +} + +impl Session { + pub fn spawn(ctx: &egui::Context, id: u64, cwd: Option, shell: &str) -> std::io::Result { + let size = Size { cols: 100, lines: 24 }; + let (tx, rx) = channel(); + let proxy = Proxy { tx, ctx: ctx.clone() }; + let mut env = std::collections::HashMap::new(); + env.insert("TERM".to_string(), "xterm-256color".to_string()); + env.insert("COLORTERM".to_string(), "truecolor".to_string()); + env.insert("TERM_PROGRAM".to_string(), "damson".to_string()); + let shell = (!shell.is_empty()).then(|| tty::Shell::new(shell.to_string(), vec![])); + let opts = tty::Options { shell, working_directory: cwd, drain_on_exit: false, env, ..Default::default() }; + let ws = WindowSize { num_lines: 24, num_cols: 100, cell_width: 8, cell_height: 18 }; + tty::setup_env(); + let pty = tty::new(&opts, ws, id)?; + let term = Arc::new(FairMutex::new(Term::new(Config::default(), &size, proxy.clone()))); + let lp = EventLoop::new(term.clone(), proxy, pty, false, false).map_err(std::io::Error::other)?; + let notifier = Notifier(lp.channel()); + lp.spawn(); + Ok(Session { term, notifier, rx, size, cell: (8.0, 18.0), title: "Shell".into(), exited: false, running: false, caret: [Spring::new(0.0), Spring::new(0.0)], id }) + } + + pub fn write(&self, s: impl Into>) { + let v: Vec = s.into(); + if !v.is_empty() { + let _ = self.notifier.0.send(Msg::Input(v.into())); + } + } + + fn pump(&mut self, ctx: &egui::Context) { + while let Ok(e) = self.rx.try_recv() { + match e { + TermEvent::Title(t) if t == RUN_DONE => { + self.running = false; + self.title = "Shell".into(); + } + TermEvent::Title(t) => self.title = t, + TermEvent::ResetTitle => self.title = "Shell".into(), + TermEvent::PtyWrite(s) => self.write(s), + TermEvent::ClipboardStore(_, s) => ctx.copy_text(s), + TermEvent::ColorRequest(_, f) => { + self.write(f(Rgb { r: 20, g: 18, b: 24 })); + } + TermEvent::TextAreaSizeRequest(f) => { + let ws = WindowSize { num_lines: self.size.lines as u16, num_cols: self.size.cols as u16, cell_width: self.cell.0 as u16, cell_height: self.cell.1 as u16 }; + self.write(f(ws)); + } + TermEvent::Exit | TermEvent::ChildExit(_) => self.exited = true, + _ => {} + } + } + } + + fn resize(&mut self, cols: usize, lines: usize, cell: (f32, f32)) { + if cols == self.size.cols && lines == self.size.lines { + return; + } + self.size = Size { cols, lines }; + self.cell = cell; + let _ = self.notifier.0.send(Msg::Resize(WindowSize { num_lines: lines as u16, num_cols: cols as u16, cell_width: cell.0 as u16, cell_height: cell.1 as u16 })); + self.term.lock().resize(self.size); + } +} + +impl Drop for Session { + fn drop(&mut self) { + let _ = self.notifier.0.send(Msg::Shutdown); + } +} + +fn indexed(i: u8, t: &Theme) -> Color32 { + match i { + 0..=15 => t.ansi[i as usize], + 16..=231 => { + let n = i - 16; + let f = |v: u8| if v == 0 { 0 } else { 55 + v * 40 }; + Color32::from_rgb(f(n / 36), f((n / 6) % 6), f(n % 6)) + } + _ => { let v = 8 + (i - 232) * 10; Color32::from_rgb(v, v, v) } + } +} + +fn resolve(c: Color, t: &Theme, bold: bool, fg: Color32, bg: Color32) -> Color32 { + match c { + Color::Spec(r) => Color32::from_rgb(r.r, r.g, r.b), + Color::Indexed(i) => indexed(if bold && i < 8 { i + 8 } else { i }, t), + Color::Named(n) => match n { + NamedColor::Foreground | NamedColor::BrightForeground | NamedColor::Cursor => fg, + NamedColor::DimForeground => alpha(fg, 0.7), + NamedColor::Background => bg, + _ => { + let v = n as usize; + if v < 16 { t.ansi[if bold && v < 8 { v + 8 } else { v }] } else { let dim = v.saturating_sub(16 + 243); t.ansi[dim.min(7)] } + } + }, + } +} + +fn key_bytes(key: Key, md: Modifiers, app_cursor: bool) -> Option> { + let mod_code = 1 + md.shift as u8 + 2 * md.alt as u8 + 4 * md.ctrl as u8; + let csi = |final_c: char| -> Vec { + if mod_code > 1 { format!("\x1b[1;{mod_code}{final_c}").into_bytes() } + else if app_cursor { format!("\x1bO{final_c}").into_bytes() } + else { format!("\x1b[{final_c}").into_bytes() } + }; + let tilde = |n: u8| -> Vec { + if mod_code > 1 { format!("\x1b[{n};{mod_code}~").into_bytes() } else { format!("\x1b[{n}~").into_bytes() } + }; + let fkey = |c: char| -> Vec { + if mod_code > 1 { format!("\x1b[1;{mod_code}{c}").into_bytes() } else { format!("\x1bO{c}").into_bytes() } + }; + Some(match key { + Key::Enter => if md.alt { b"\x1b\r".to_vec() } else { b"\r".to_vec() }, + Key::Tab => if md.shift { b"\x1b[Z".to_vec() } else { b"\t".to_vec() }, + Key::Backspace => if md.ctrl { vec![0x08] } else if md.alt { b"\x1b\x7f".to_vec() } else { vec![0x7f] }, + Key::Escape => vec![0x1b], + Key::ArrowUp => csi('A'), Key::ArrowDown => csi('B'), Key::ArrowRight => csi('C'), Key::ArrowLeft => csi('D'), + Key::Home => csi('H'), Key::End => csi('F'), + Key::Insert => tilde(2), Key::Delete => tilde(3), Key::PageUp => tilde(5), Key::PageDown => tilde(6), + Key::F1 => fkey('P'), Key::F2 => fkey('Q'), Key::F3 => fkey('R'), Key::F5 => tilde(15), + Key::F6 => tilde(17), Key::F7 => tilde(18), Key::F8 => tilde(19), Key::F9 => tilde(20), Key::F10 => tilde(21), Key::F12 => tilde(24), + _ => { + let name = key.name(); + let mut cs = name.chars(); + let c = cs.next()?; + if cs.next().is_some() { + return (key == Key::Space && md.ctrl).then(|| vec![0]); + } + if !md.ctrl && !md.alt { return None } + let l = c.to_ascii_lowercase(); + let code: Vec = if md.ctrl { + if l.is_ascii_lowercase() { vec![l as u8 & 0x1f] } + else { match c { '[' => vec![0x1b], '\\' => vec![0x1c], ']' => vec![0x1d], _ => return None } } + } else { vec![l as u8] }; + if md.alt { let mut v = vec![0x1b]; v.extend(code); v } else { code } + } + }) +} + +impl App { + pub fn term_focus_id(&self) -> egui::Id { + egui::Id::unique("terminal-surface") + } + + pub fn new_terminal(&mut self, ctx: &egui::Context, cwd: Option) { + let cwd = cwd.or_else(|| self.root.clone()).or_else(|| dirs::home_dir()); + self.next_term += 1; + match Session::spawn(ctx, self.next_term, cwd, &self.s.shell) { + Ok(s) => { + self.terms.push(s); + self.term_cur = self.terms.len() - 1; + } + Err(e) => self.toast("error", format!("Terminal failed to start: {e}")), + } + } + + pub fn pump_terminals(&mut self, ctx: &egui::Context) { + for s in &mut self.terms { + s.pump(ctx); + } + let before = self.terms.len(); + self.terms.retain(|s| !s.exited); + if self.terms.len() != before { + self.term_cur = self.term_cur.min(self.terms.len().saturating_sub(1)); + if self.terms.is_empty() { + self.term_open = false; + ctx.memory_mut(|m| m.surrender_focus(egui::Id::unique("terminal-surface"))); + } + } + self.term_busy = !self.terms.is_empty() && !self.term_open; + } + + /// Draws the card. `open` is the spring from 0 (the button) to 1 (the full card). + pub fn terminal_card(&mut self, ui: &mut Ui, target: Rect, open: f32) { + let t = self.t.clone(); + let k = open.clamp(0.0, 1.0); + let rect = lerp_rect(self.fab_rect, target, open.clamp(-0.02, 1.04)); + let radius = lerp(22.0, 24.0, k); + let p = ui.painter().clone(); + shadow(&p, rect, radius, (1.0 - (k - 0.5).abs() * 2.0).max(0.0) * 0.9, t.dark); + let fill = mix(t.primary_container, t.lowest, (k * 1.6).min(1.0)); + p.rect_filled(rect, cr(radius), fill); + if k < 0.35 { + return; + } + let vis = ((k - 0.35) / 0.65).clamp(0.0, 1.0); + let inner = rect.shrink(4.0); + let head = Rect::from_min_size(inner.min, vec2(inner.width(), 38.0)); + + // dragging the card's top edge sets its height + let edge = Rect::from_center_size(pos2(rect.center().x, rect.top() + 1.0), vec2(rect.width() - 48.0, 10.0)); + let eresp = ui.interact(edge, ui.scope_id().with("term-edge"), Sense::drag()); + if eresp.hovered() || eresp.dragged() { ui.ctx().set_cursor_icon(egui::CursorIcon::ResizeVertical) } + if eresp.dragged() { + self.term_height = (self.term_height - eresp.drag_delta().y).clamp(140.0, ui.ctx().content_rect().height() - 180.0); + } + let hh = spring("term/handle", (eresp.hovered() || eresp.dragged()) as u8 as f32, motion::FAST); + p.rect_filled(Rect::from_center_size(pos2(rect.center().x, rect.top() + 7.0), vec2(36.0 + 18.0 * hh, 4.0)), cr(2.0), alpha(t.outline, (0.5 + 0.4 * hh) * vis)); + + // session pills + let mut x = head.left() + 8.0; + let mut pick = None; + let mut kill = None; + let names: Vec<(String, u64)> = self.terms.iter().map(|s| (s.title.clone(), s.id)).collect(); + for (i, (name, id)) in names.iter().enumerate() { + let label: String = name.chars().take(26).collect(); + let g = p.layout_no_wrap(label, fonts::med(12.5), t.on_variant); + let w = g.size().x + 46.0; + let r = Rect::from_min_size(pos2(x, head.center().y - 14.0), vec2(w, 28.0)); + let key = format!("term/tab/{id}"); + let resp = ui.interact(r, ui.scope_id().with(&key), Sense::click()); + let (hov, _) = states(&key, &resp); + let sel = i == self.term_cur; + let pop = crate::motion::spring_from(format!("{key}/in"), 0.5, 1.0, motion::DEFAULT); + let c = scale_rect(r, pop); + if sel { p.rect_filled(c, cr(14.0), alpha(t.secondary_container, vis)); } + else if hov > 0.01 { p.rect_filled(c, cr(14.0), alpha(t.on_surface, 0.07 * hov * vis)); } + let fg = if sel { t.on_secondary_container } else { t.on_variant }; + p.galley(pos2(r.left() + 12.0, r.center().y - g.size().y / 2.0), g, alpha(fg, vis)); + let xr = Rect::from_center_size(pos2(r.right() - 14.0, r.center().y), vec2(20.0, 20.0)); + let xresp = ui.interact(xr, ui.scope_id().with(&key).with("x"), Sense::click()); + icons::paint(ui.ctx(), &p, xr.center(), 14.0, "close", alpha(fg, vis * if xresp.hovered() { 1.0 } else { 0.55 })); + if xresp.clicked() { kill = Some(i) } else if resp.clicked() { pick = Some(i) } + x += w + 4.0; + } + use super::commands::Cmd; + let running = self.terms.get(self.term_cur).is_some_and(|s| s.running); + let tool = |i: usize| Rect::from_center_size(pos2(head.right() - 22.0 - (2 - i) as f32 * 36.0, head.center().y), vec2(32.0, 32.0)); + if morph::button(ui, &t, tool(0), "term/add", Morph::AddSpin, false, "New terminal", fill).clicked() { + self.run(ui.ctx(), Cmd::NewTerminal); + } + let tip = if running { "Stop" } else { "Run this file" }; + if morph::button(ui, &t, tool(1), "term/run", Morph::PlayStop, running, tip, fill).clicked() { + if running { + if let Some(s) = self.terms.get_mut(self.term_cur) { + s.write(vec![3]); + s.running = false; + } + } else { + self.run(ui.ctx(), Cmd::RunFile); + } + } + if morph::button(ui, &t, tool(2), "term/hide", Morph::Fold, true, "Hide terminal", fill).clicked() { + self.run(ui.ctx(), Cmd::ToggleTerminal); + } + if let Some(i) = pick { + self.term_cur = i; + self.term_want_focus = true; + } + if let Some(i) = kill { + self.terms.remove(i); + self.term_cur = self.term_cur.min(self.terms.len().saturating_sub(1)); + if self.terms.is_empty() { self.term_open = false } + return; + } + let body = Rect::from_min_max(pos2(inner.left() + 10.0, head.bottom()), pos2(inner.right() - 8.0, inner.bottom() - 6.0)); + if !self.terms.is_empty() { + self.terminal_surface(ui, body, vis); + } + } + + fn terminal_surface(&mut self, ui: &mut Ui, body: Rect, vis: f32) { + let t = self.t.clone(); + let size = self.s.terminal_font; + let font = fonts::mono(size); + let cw = ui.fonts_mut(|f| f.glyph_width(&font, 'M')); + let lh = (size * 1.36).round(); + let cols = ((body.width() / cw) as usize).max(10); + let lines = ((body.height() / lh) as usize).max(3); + let id = self.term_focus_id(); + let resp = ui.interact(body, id, Sense::click_and_drag()); + if resp.hovered() { ui.ctx().set_cursor_icon(egui::CursorIcon::Text) } + // asked for here, not when opening: egui drops focus from a widget that doesn't exist yet, + // and this one only appears partway through the morph + if resp.clicked() || resp.drag_started() || std::mem::take(&mut self.term_want_focus) { resp.request_focus() } + let focused = resp.has_focus(); + if focused { + ui.ctx().memory_mut(|m| m.set_focus_lock_filter(id, egui::EventFilter { tab: true, horizontal_arrows: true, vertical_arrows: true, escape: true })); + } + let cur = self.term_cur; + let session = &mut self.terms[cur]; + session.resize(cols, lines, (cw, lh)); + + let cell_at = |p: Pos2, s: &Session| -> (Point, Side) { + let x = ((p.x - body.left()) / cw).max(0.0); + let col = (x as usize).min(s.size.cols - 1); + let row = (((p.y - body.top()) / lh).max(0.0) as usize).min(s.size.lines - 1); + let term = s.term.lock(); + let off = term.grid().display_offset() as i32; + (Point::new(Line(row as i32 - off), Column(col)), if x.fract() < 0.5 { Side::Left } else { Side::Right }) + }; + + let mouse_mode = session.term.lock().mode().intersects(TermMode::MOUSE_MODE); + if !mouse_mode { + if resp.drag_started() { + if let Some(p) = resp.interact_pointer_pos() { + let (pt, side) = cell_at(p, session); + session.term.lock().selection = Some(Selection::new(SelectionType::Simple, pt, side)); + } + } else if resp.dragged() { + if let Some(p) = resp.interact_pointer_pos() { + let (pt, side) = cell_at(p, session); + if let Some(s) = session.term.lock().selection.as_mut() { s.update(pt, side) } + } + } else if resp.double_clicked() { + if let Some(p) = resp.interact_pointer_pos() { + let (pt, side) = cell_at(p, session); + session.term.lock().selection = Some(Selection::new(SelectionType::Semantic, pt, side)); + } + } else if resp.clicked() { + session.term.lock().selection = None; + } + } + if ui.rect_contains_pointer(body) { + let dy = crate::ui::widgets::wheel(ui).y; + if dy != 0.0 { + let n = (dy / 16.0).round() as i32; + let n = if n == 0 { dy.signum() as i32 } else { n }; + let mode = *session.term.lock().mode(); + if mode.contains(TermMode::ALT_SCREEN) { + let seq = if n > 0 { "\x1b[A" } else { "\x1b[B" }; + session.write(seq.repeat(n.unsigned_abs() as usize)); + } else { + session.term.lock().scroll_display(Scroll::Delta(n)); + } + } + } + if focused { + let mode = *session.term.lock().mode(); + let app_cursor = mode.contains(TermMode::APP_CURSOR); + let events = ui.input(|i| i.events.clone()); + let mut any = false; + for e in events { + match e { + Event::Text(s) => { session.write(s.into_bytes()); any = true } + Event::Paste(s) => { + let s = s.replace("\r\n", "\r").replace('\n', "\r"); + if mode.contains(TermMode::BRACKETED_PASTE) { session.write(format!("\x1b[200~{s}\x1b[201~")) } else { session.write(s) } + any = true; + } + Event::Copy => { + let sel = session.term.lock().selection_to_string().filter(|s| !s.is_empty()); + match sel { + Some(s) => { ui.ctx().copy_text(s); session.term.lock().selection = None } + None => { session.write(vec![3]); any = true } + } + } + Event::Cut => { session.write(vec![0x18]); any = true } + Event::Key { key, pressed: true, modifiers, .. } => { + if modifiers.shift && !modifiers.ctrl { + let page = match key { Key::PageUp => Some(Scroll::PageUp), Key::PageDown => Some(Scroll::PageDown), _ => None }; + if let Some(s) = page { + session.term.lock().scroll_display(s); + continue; + } + } + if let Some(b) = key_bytes(key, modifiers, app_cursor) { session.write(b); any = true } + } + _ => {} + } + } + if any { session.term.lock().scroll_display(Scroll::Bottom) } + } + + // painting: backgrounds first, then one text run per line + let p = ui.painter_at(body.expand(2.0)); + let default_fg = mix(t.on_surface, t.on_variant, 0.15); + let default_bg = Color32::TRANSPARENT; + let term = session.term.lock(); + let content = term.renderable_content(); + let off = content.display_offset as i32; + let (cursor, cur_shape, hidden) = (content.cursor.point, content.cursor.shape, content.mode.contains(TermMode::SHOW_CURSOR)); + let sel = content.selection; + let mut rows: Vec> = vec![Vec::with_capacity(cols); lines]; + for c in content.display_iter { + let row = c.point.line.0 + off; + if row < 0 || row as usize >= lines { continue } + if c.flags.intersects(Flags::WIDE_CHAR_SPACER | Flags::LEADING_WIDE_CHAR_SPACER) { + rows[row as usize].push(('\0', default_fg, default_bg, c.flags, false)); + continue; + } + let bold = c.flags.contains(Flags::BOLD); + let (mut fg, mut bg) = (resolve(c.fg, &t, bold, default_fg, default_bg), resolve(c.bg, &t, false, default_fg, default_bg)); + if c.flags.contains(Flags::INVERSE) { + let keep = fg; + fg = if bg == default_bg { t.lowest } else { bg }; + bg = keep; + } + if c.flags.contains(Flags::DIM) { fg = alpha(fg, 0.65) } + let selected = sel.is_some_and(|s| s.contains(c.point)); + rows[row as usize].push((c.c, fg, bg, c.flags, selected)); + } + drop(term); + for (r, row) in rows.iter().enumerate() { + let y = body.top() + r as f32 * lh; + let (mut i, n) = (0, row.len()); + while i < n { + let (bg, sel) = (row[i].2, row[i].4); + let mut j = i + 1; + while j < n && row[j].2 == bg && row[j].4 == sel { j += 1 } + let rr = Rect::from_min_size(pos2(body.left() + i as f32 * cw, y), vec2((j - i) as f32 * cw + 0.5, lh)); + if sel { p.rect_filled(rr, cr(3.0), alpha(t.primary, 0.32 * vis)); } + else if bg.a() > 0 { p.rect_filled(rr, cr(0.0), alpha(bg, vis)); } + i = j; + } + let mut job = LayoutJob::default(); + job.wrap.max_width = f32::INFINITY; + let mut run = String::new(); + let mut style: Option<(Color32, bool, bool)> = None; + let flush = |job: &mut LayoutJob, run: &mut String, st: Option<(Color32, bool, bool)>| { + if let Some((color, italics, ul)) = st { + if !run.is_empty() { + let underline = if ul { egui::Stroke::new(1.0, color) } else { egui::Stroke::NONE }; + job.append(run, 0.0, TextFormat { font_id: font.clone(), color, italics, underline, ..Default::default() }); + run.clear(); + } + } + }; + let last = row.iter().rposition(|c| c.0 != ' ' && c.0 != '\0').map_or(0, |x| x + 1); + for c in &row[..last.min(n)] { + if c.0 == '\0' { continue } + let st = (alpha(c.1, vis * c.1.a() as f32 / 255.0), c.3.contains(Flags::ITALIC), c.3.intersects(Flags::UNDERLINE | Flags::DOUBLE_UNDERLINE | Flags::UNDERCURL)); + if style != Some(st) { + flush(&mut job, &mut run, style); + style = Some(st); + } + run.push(c.0); + } + flush(&mut job, &mut run, style); + if !job.sections.is_empty() { + let g = ui.painter().layout_job(job); + p.galley(pos2(body.left(), y + (lh - g.size().y) / 2.0), g, default_fg); + } + } + + // the cursor glides between cells + let session = &mut self.terms[cur]; + if hidden && off == 0 { + let (tx, ty) = (cursor.column.0 as f32 * cw, cursor.line.0 as f32 * lh); + session.caret[0].target = tx; + session.caret[1].target = ty; + let pr = Preset { stiffness: 1500.0, damping: 0.8 }; + let (x, y) = (session.caret[0].step(pr), session.caret[1].step(pr)); + let r = Rect::from_min_size(pos2(body.left() + x, body.top() + y), vec2(cw, lh)).shrink2(vec2(0.0, 1.0)); + use alacritty_terminal::vte::ansi::CursorShape as S; + let col = alpha(t.primary, vis); + if !focused { + p.rect_stroke(r, cr(3.0), egui::Stroke::new(1.0, col), egui::StrokeKind::Inside); + } else { + match cur_shape { + S::Beam => { p.rect_filled(Rect::from_min_size(r.min, vec2(2.0, r.height())), cr(1.0), col); } + S::Underline => { p.rect_filled(Rect::from_min_size(pos2(r.left(), r.bottom() - 2.0), vec2(r.width(), 2.0)), cr(1.0), col); } + _ => { + p.rect_filled(r, cr(3.0), alpha(t.primary, 0.75 * vis)); + } + } + } + } + } +} diff --git a/src/ui/welcome.rs b/src/ui/welcome.rs new file mode 100644 index 0000000..3ec05b3 --- /dev/null +++ b/src/ui/welcome.rs @@ -0,0 +1,55 @@ +//! The empty state, shown when a pane has no files open. + +use super::commands::Cmd; +use super::{fonts, icons, widgets::*}; +use crate::app::App; +use crate::motion::{self}; +use crate::theme::alpha; +use eframe::egui::{pos2, vec2, Align2, Rect, Sense, Ui}; +use std::path::PathBuf; + +impl App { + pub fn welcome(&mut self, ui: &mut Ui, rect: Rect) { + let t = self.t.clone(); + let now = ui.input(|i| i.time) as f32; + let c = pos2(rect.center().x, rect.top() + rect.height() * 0.3); + let k = motion::stagger(now.min(4.0), 0.0, 0.6).clamp(0.0, 1.2); + let petals = 9.0; + let breathe = 0.08 + 0.03 * (now * 0.8).sin(); + blob(ui.painter(), c, 58.0 * k, petals, breathe, now * 0.1, t.primary_container); + blob(ui.painter(), c, 42.0 * k, 6.0, 0.07, -now * 0.16, alpha(t.primary, 0.32)); + icons::paint(ui.ctx(), ui.painter(), c, 42.0 * k, "code", t.on_primary_container); + if ui.input(|i| i.focused) { motion::keep_alive() } + ui.painter().text(c + vec2(0.0, 92.0), Align2::CENTER_CENTER, "Damson", fonts::med(30.0), t.on_surface); + ui.painter().text(c + vec2(0.0, 124.0), Align2::CENTER_CENTER, "Open something to get started", fonts::ui(14.0), t.on_variant); + let y = c.y + 156.0; + let bw = 136.0; + let cx = rect.center().x; + let mut go = None; + for (i, (ic, label, cmd, tone)) in [("add", "New file", Cmd::New, Tone::Filled), ("description", "Open file", Cmd::Open, Tone::Tonal), ("folder_open", "Open folder", Cmd::OpenFolder, Tone::Tonal)].into_iter().enumerate() { + let r = Rect::from_min_size(pos2(cx - bw * 1.5 - 8.0 + i as f32 * (bw + 8.0), y), vec2(bw, 42.0)); + if pill(ui, &t, r, &format!("w/{i}"), ic, label, tone).clicked() { go = Some(cmd) } + } + if let Some(c) = go { + self.run(ui.ctx(), c); + } + let mut open: Option = None; + let w = 420.0_f32.min(rect.width() - 40.0); + let mut ry = y + 66.0; + for (i, r) in self.s.recent.clone().iter().take(6).enumerate() { + if ry + 40.0 > rect.bottom() { break } + let rr = Rect::from_min_size(pos2(cx - w / 2.0, ry), vec2(w, 38.0)); + let key = format!("w/r{i}"); + let resp = ui.interact(rr, ui.scope_id().with(&key), Sense::click()); + let (hov, press) = states(&key, &resp); + ui.painter().rect_filled(scale_rect(rr, 1.0 - 0.02 * press), cr(16.0), alpha(t.on_surface, 0.06 * hov)); + let p = std::path::Path::new(r); + icons::paint(ui.ctx(), ui.painter(), pos2(rr.left() + 20.0, rr.center().y), 17.0, "history", t.on_variant); + ui.painter().text(pos2(rr.left() + 42.0, rr.center().y), Align2::LEFT_CENTER, p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(), fonts::med(13.0), t.on_surface); + ui.painter().with_clip_rect(rr).text(pos2(rr.right() - 12.0, rr.center().y), Align2::RIGHT_CENTER, p.parent().map(|d| d.to_string_lossy().replace(&dirs::home_dir().unwrap_or_default().to_string_lossy().into_owned(), "~")).unwrap_or_default(), fonts::ui(11.5), t.outline); + if resp.clicked() { open = Some(p.to_path_buf()) } + ry += 40.0; + } + if let Some(p) = open { self.open_path(ui.ctx(), p, None) } + } +} diff --git a/src/ui/widgets.rs b/src/ui/widgets.rs new file mode 100644 index 0000000..7123dcf --- /dev/null +++ b/src/ui/widgets.rs @@ -0,0 +1,182 @@ +//! Small shared controls. Each one takes a rect: the layout of this app is computed by hand so that +//! everything in it can sit on a spring. + +use super::{fonts, icons}; +use crate::motion::{self, spring, spring_from, FAST}; +use crate::theme::{alpha, mix, Theme}; +use eframe::egui::{self, pos2, vec2, Align2, Color32, CornerRadius, Pos2, Rect, Response, Sense, Shadow, Stroke, StrokeKind, Ui, Vec2}; + +pub fn cr(r: f32) -> CornerRadius { + CornerRadius::same(r.clamp(0.0, 255.0).round() as u8) +} + +pub fn scale_rect(r: Rect, s: f32) -> Rect { + Rect::from_center_size(r.center(), r.size() * s) +} + +pub fn lerp(a: f32, b: f32, t: f32) -> f32 { + a + (b - a) * t +} + +pub fn lerp_rect(a: Rect, b: Rect, t: f32) -> Rect { + Rect::from_min_max(pos2(lerp(a.min.x, b.min.x, t), lerp(a.min.y, b.min.y, t)), pos2(lerp(a.max.x, b.max.x, t), lerp(a.max.y, b.max.y, t))) +} + +/// A soft elevation shadow under a card. +pub fn shadow(p: &egui::Painter, r: Rect, radius: f32, strength: f32, dark: bool) { + if strength <= 0.01 { + return; + } + let a = (if dark { 0.5 } else { 0.22 }) * strength.min(1.0); + let sh = Shadow { offset: [0, (10.0 * strength) as i8], blur: (34.0 * strength) as u8, spread: 0, color: Color32::from_black_alpha((a * 255.0) as u8) }; + p.add(sh.as_shape(r, cr(radius))); +} + +/// Press and hover values for a control: (hover 0..1, press 0..1 with bounce). +pub fn states(key: &str, r: &Response) -> (f32, f32) { + let hov = spring(format!("{key}/h"), r.hovered() as u8 as f32, motion::EFFECT); + let press = spring(format!("{key}/p"), r.is_pointer_button_down_on() as u8 as f32, FAST); + (hov, press) +} + +/// Round icon button. Pressing squashes it from a circle towards a squircle, as M3 Expressive does. +pub fn icon_btn(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, ic: &str, tip: &str, on: bool) -> Response { + let mut r = ui.interact(rect, ui.scope_id().with(key), Sense::click()); + if !tip.is_empty() { + r = r.on_hover_text(tip); + } + let (hov, press) = states(key, &r); + let sel = spring(format!("{key}/on"), on as u8 as f32, FAST); + let c = scale_rect(rect, 1.0 - 0.1 * press); + let radius = lerp(rect.height() / 2.0, rect.height() * 0.3, press.clamp(0.0, 1.0).max(sel.clamp(0.0, 1.0) * 0.6)); + let p = ui.painter(); + if sel > 0.01 { + p.rect_filled(scale_rect(c, sel.clamp(0.0, 1.2)), cr(radius), alpha(t.secondary_container, sel.clamp(0.0, 1.0))); + } + if hov > 0.01 { + p.rect_filled(c, cr(radius), alpha(t.on_surface, 0.09 * hov)); + } + let col = mix(t.on_variant, t.on_secondary_container, sel); + icons::paint(ui.ctx(), p, rect.center(), rect.height() * 0.56 * (1.0 - 0.08 * press), ic, col); + r +} + +#[derive(Clone, Copy, PartialEq)] +pub enum Tone { + Text, + Tonal, + Filled, +} + +pub fn pill(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, ic: &str, text: &str, tone: Tone) -> Response { + let r = ui.interact(rect, ui.scope_id().with(key), Sense::click()); + let (hov, press) = states(key, &r); + let (bg, fg) = match tone { + Tone::Text => (Color32::TRANSPARENT, t.primary), + Tone::Tonal => (t.secondary_container, t.on_secondary_container), + Tone::Filled => (t.primary, t.on_primary), + }; + let c = scale_rect(rect, 1.0 - 0.05 * press); + let radius = lerp(rect.height() / 2.0, rect.height() * 0.28, press.clamp(0.0, 1.0)); + let p = ui.painter(); + p.rect_filled(c, cr(radius), bg); + p.rect_filled(c, cr(radius), alpha(if tone == Tone::Filled { t.on_primary } else { t.on_surface }, 0.08 * hov)); + let font = fonts::med(13.5); + let g = p.layout_no_wrap(text.to_string(), font, fg); + let total = g.size().x + if ic.is_empty() { 0.0 } else { 26.0 }; + let mut x = rect.center().x - total / 2.0; + if !ic.is_empty() { + icons::paint(ui.ctx(), p, pos2(x + 9.0, rect.center().y), 18.0, ic, fg); + x += 26.0; + } + p.galley(pos2(x, rect.center().y - g.size().y / 2.0), g, fg); + r +} + +/// M3 switch; the thumb swells while pressed and grows when on. +pub fn switch(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, on: bool) -> Response { + let r = ui.interact(rect, ui.scope_id().with(key), Sense::click()); + let (_, press) = states(key, &r); + let v = spring(format!("{key}/v"), on as u8 as f32, FAST); + let track = Rect::from_center_size(rect.center(), vec2(50.0, 30.0)); + let p = ui.painter(); + let c = v.clamp(0.0, 1.0); + p.rect_filled(track, cr(15.0), mix(t.highest, t.primary, c)); + if c < 0.99 { + p.rect_stroke(track, cr(15.0), Stroke::new(2.0, alpha(t.outline, 1.0 - c)), StrokeKind::Inside); + } + let x = lerp(track.left() + 15.0, track.right() - 15.0, v); + let d = lerp(16.0, 24.0, c) + 4.0 * press; + p.circle_filled(pos2(x, track.center().y), d / 2.0, mix(t.outline, t.on_primary, c)); + r +} + +/// Connected button group; the selected segment's fill slides between choices. +pub fn segmented(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, opts: &[(&str, &str)], cur: &str) -> Option { + let w = rect.width() / opts.len() as f32; + let p = ui.painter().clone(); + p.rect_filled(rect, cr(rect.height() / 2.0), t.highest); + let idx = opts.iter().position(|o| o.0 == cur).unwrap_or(0); + let x = spring(format!("{key}/x"), idx as f32, FAST); + let sel = Rect::from_min_size(pos2(rect.left() + x * w, rect.top()), vec2(w, rect.height())).shrink(3.0); + p.rect_filled(sel, cr(sel.height() / 2.0), t.primary_container); + let mut out = None; + for (i, (v, label)) in opts.iter().enumerate() { + let r = Rect::from_min_size(pos2(rect.left() + i as f32 * w, rect.top()), vec2(w, rect.height())); + let resp = ui.interact(r, ui.scope_id().with(key).with(i), Sense::click()); + if resp.clicked() { + out = Some(v.to_string()); + } + let col = mix(t.on_variant, t.on_primary_container, 1.0 - (x - i as f32).abs().min(1.0)); + p.text(r.center(), Align2::CENTER_CENTER, *label, fonts::med(13.0), col); + } + out +} + +/// A thin scroll position pill for lists. +pub fn scroll_pill(p: &egui::Painter, t: &Theme, area: Rect, offset: f32, content: f32) { + if content <= area.height() { + return; + } + let h = (area.height() * area.height() / content).max(28.0); + let y = area.top() + (area.height() - h) * (offset / (content - area.height())).clamp(0.0, 1.0); + p.rect_filled(Rect::from_min_size(pos2(area.right() - 5.0, y), vec2(4.0, h)), cr(2.0), alpha(t.outline, 0.5)); +} + +/// Draws an expressive blob: `petals` lobes around a circle, for the logo and the terminal button. +pub fn blob(p: &egui::Painter, center: Pos2, radius: f32, petals: f32, amount: f32, spin: f32, fill: Color32) { + let n = 72; + let pts: Vec = (0..n).map(|i| { + let a = i as f32 / n as f32 * std::f32::consts::TAU; + let r = radius * (1.0 + amount * (petals * (a + spin)).cos()); + center + Vec2::angled(a) * r + }).collect(); + let mut mesh = egui::Mesh::default(); + mesh.colored_vertex(center, fill); + for q in &pts { mesh.colored_vertex(*q, fill) } + for i in 0..n as u32 { + mesh.add_triangle(0, 1 + i, 1 + (i + 1) % n as u32); + } + p.add(mesh); +} + +/// Mouse wheel movement this frame, in points. +pub fn wheel(ui: &Ui) -> Vec2 { + ui.input(|i| { + let mut d = Vec2::ZERO; + for e in &i.events { + if let egui::Event::MouseWheel { unit, delta, .. } = e { + d += match unit { + egui::MouseWheelUnit::Point => *delta, + egui::MouseWheelUnit::Line => *delta * 34.0, + egui::MouseWheelUnit::Page => *delta * 400.0, + }; + } + } + d + }) +} + +pub fn pop(key: &str) -> f32 { + spring_from(key, 0.0, 1.0, motion::DEFAULT) +} diff --git a/tests/shots.rs b/tests/shots.rs new file mode 100644 index 0000000..0e6681b --- /dev/null +++ b/tests/shots.rs @@ -0,0 +1,200 @@ +//! Drives the real app with no window and saves screenshots: +//! `DAMSON_SHOTS=/some/dir cargo test --test shots -- --nocapture --test-threads=1` + +use damson::app::App; +use damson::ui::commands::Cmd; +use eframe::egui::{self, pos2, vec2, Event, Modifiers, PointerButton, Pos2}; +use egui_kittest::Harness; + +type H<'a> = Harness<'a, App>; + +fn settle(h: &mut H, n: usize) { + for _ in 0..n { + h.step(); + std::thread::sleep(std::time::Duration::from_millis(16)); + } +} + +fn shot(h: &mut H, out: &str, name: &str) { + h.render().expect("render").save(format!("{out}/{name}.png")).unwrap(); +} + +fn cmd(h: &mut H, c: Cmd) { + let ctx = h.ctx.clone(); + h.state_mut().run(&ctx, c); + settle(h, 34); +} + +fn mv(h: &mut H, p: Pos2) { + h.input_mut().events.push(Event::PointerMoved(p)); + h.step(); +} + +fn press(h: &mut H, p: Pos2, down: bool) { + h.input_mut().events.push(Event::PointerButton { pos: p, button: PointerButton::Primary, pressed: down, modifiers: Modifiers::NONE }); + h.step(); +} + +#[test] +fn tour() { + let out = std::env::var("DAMSON_SHOTS").expect("set DAMSON_SHOTS"); + std::fs::create_dir_all(&out).unwrap(); + let sc = std::path::PathBuf::from(&out).join("home"); + std::fs::create_dir_all(&sc).unwrap(); + std::env::set_var("XDG_CONFIG_HOME", sc.join("config")); + std::env::set_var("XDG_DATA_HOME", sc.join("data")); + let root = env!("CARGO_MANIFEST_DIR"); + let file = format!("{root}/src/text/commands.rs"); + let mut h: H = Harness::builder().with_size(vec2(1400.0, 900.0)).wgpu().build_eframe(move |cc| App::new(cc, vec![file.clone()])); + h.ctx.set_missing_glyph_policy(eframe::epaint::text::MissingGlyphPolicy::Tofu); + settle(&mut h, 40); + assert_eq!(h.state().docs.len(), 1, "file opened"); + assert_eq!(h.state().cur_doc().unwrap().language, "Rust"); + shot(&mut h, &out, "01-editor"); + + // typing goes through the real input path + let before = h.state().cur_doc().unwrap().buf.len(); + h.input_mut().events.push(Event::Text("x".into())); + settle(&mut h, 3); + assert_eq!(h.state().cur_doc().unwrap().buf.len(), before + 1, "typing reaches the buffer"); + h.state_mut().cur_doc_mut().unwrap().buf.undo(); + settle(&mut h, 3); + + // grab the preview, drag, and catch it while popped out + let rail = pos2(1340.0, 300.0); + mv(&mut h, rail); + press(&mut h, rail, true); + settle(&mut h, 6); + shot(&mut h, &out, "02-preview-popping"); + for i in 0..24 { + mv(&mut h, pos2(1340.0, 300.0 + i as f32 * 12.0)); + std::thread::sleep(std::time::Duration::from_millis(16)); + } + settle(&mut h, 24); + assert!(h.state().panes[0].dragging_mini, "rail is being dragged"); + assert!(h.state().panes[0].tabs[0].scroll.x > 100.0, "dragging scrolled the file"); + shot(&mut h, &out, "03-preview-lens"); + press(&mut h, pos2(1340.0, 588.0), false); + settle(&mut h, 40); + assert!(!h.state().panes[0].dragging_mini); + shot(&mut h, &out, "04-preview-released"); + + cmd(&mut h, Cmd::Side(2)); + shot(&mut h, &out, "05-outline"); + + cmd(&mut h, Cmd::Find); + h.state_mut().find.query = "fn ".into(); + settle(&mut h, 20); + assert!(h.state().find.hits.len() > 10, "find works"); + shot(&mut h, &out, "06-find"); + let ctx = h.ctx.clone(); + h.state_mut().find_close(&ctx); + settle(&mut h, 20); + + cmd(&mut h, Cmd::Palette); + shot(&mut h, &out, "07-palette"); + let ctx = h.ctx.clone(); + h.state_mut().close_palette(&ctx); + settle(&mut h, 20); + + // terminal: mid-morph, then open and running a real command + let ctx = h.ctx.clone(); + h.state_mut().run(&ctx, Cmd::ToggleTerminal); + settle(&mut h, 7); + shot(&mut h, &out, "08-terminal-morph"); + settle(&mut h, 40); + h.state().terms[0].write("printf '\\033[1;35mdamson\\033[0m terminal: '; echo $((6*7)); ls src | head -4\r"); + for _ in 0..60 { settle(&mut h, 1); std::thread::sleep(std::time::Duration::from_millis(16)) } + shot(&mut h, &out, "09-terminal"); + cmd(&mut h, Cmd::ToggleTerminal); + settle(&mut h, 30); + + cmd(&mut h, Cmd::SplitRight); + shot(&mut h, &out, "10-split"); + cmd(&mut h, Cmd::CloseSplit); + + cmd(&mut h, Cmd::Settings); + settle(&mut h, 20); + shot(&mut h, &out, "11-settings"); + cmd(&mut h, Cmd::Settings); + + cmd(&mut h, Cmd::ToggleDark); + settle(&mut h, 30); + shot(&mut h, &out, "12-other-mode"); + + cmd(&mut h, Cmd::Zen); + settle(&mut h, 20); + shot(&mut h, &out, "13-zen"); + cmd(&mut h, Cmd::Zen); + + h.state_mut().force_close(0, 0); + settle(&mut h, 30); + shot(&mut h, &out, "14-welcome"); + let _ = egui::Key::A; +} + +fn key(h: &mut H, k: egui::Key, m: Modifiers) { + h.input_mut().events.push(Event::Key { key: k, physical_key: Some(k), pressed: true, repeat: false, modifiers: m }); + h.step(); + h.input_mut().events.push(Event::Key { key: k, physical_key: Some(k), pressed: false, repeat: false, modifiers: m }); + h.step(); +} + +/// Real key events, through the shortcut table and into the buffer and the terminal. +#[test] +fn keyboard_paths() { + let dir = std::env::temp_dir().join(format!("damson-keys-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + std::env::set_var("XDG_CONFIG_HOME", dir.join("config")); + let file = dir.join("t.py"); + std::fs::write(&file, "def a():\n pass\n").unwrap(); + let f = file.to_string_lossy().into_owned(); + let mut h: H = Harness::builder().with_size(vec2(1200.0, 800.0)).wgpu().build_eframe(move |cc| App::new(cc, vec![f.clone()])); + settle(&mut h, 8); + use egui::Key::{ArrowDown, End, Enter, Escape, Home, Slash, F4, S, Y, Z}; + let text = |h: &H| h.state().cur_doc().unwrap().buf.rope.to_string(); + key(&mut h, ArrowDown, Modifiers::NONE); + key(&mut h, End, Modifiers::NONE); + key(&mut h, Enter, Modifiers::NONE); + h.input_mut().events.push(Event::Text("return 1".into())); + settle(&mut h, 2); + assert_eq!(text(&h), "def a():\n pass\n return 1\n", "arrows, end, auto-indent and text"); + key(&mut h, Z, Modifiers::COMMAND); + settle(&mut h, 2); + assert!(!text(&h).contains("return"), "ctrl+z undoes: {}", text(&h)); + key(&mut h, Y, Modifiers::COMMAND); + settle(&mut h, 2); + assert!(text(&h).contains("return 1"), "ctrl+y redoes"); + key(&mut h, Slash, Modifiers::COMMAND); + settle(&mut h, 2); + assert!(text(&h).contains("# return 1"), "comment uses the Python token from Kate's definition: {}", text(&h)); + key(&mut h, S, Modifiers::COMMAND); + settle(&mut h, 2); + assert_eq!(std::fs::read_to_string(&file).unwrap(), text(&h), "ctrl+s writes the file"); + assert!(!h.state().cur_doc().unwrap().buf.is_modified()); + + // Ctrl+Alt+Down adds a cursor; typing lands at both + key(&mut h, Home, Modifiers::COMMAND); + key(&mut h, ArrowDown, Modifiers { alt: true, ctrl: true, command: true, ..Default::default() }); + settle(&mut h, 2); + assert_eq!(h.state().cur_doc().unwrap().buf.sels.len(), 2, "second cursor"); + key(&mut h, Escape, Modifiers::NONE); + + // the terminal gets keys, and Ctrl+S goes to the shell rather than saving + key(&mut h, F4, Modifiers::NONE); + settle(&mut h, 40); + assert!(h.state().term_open); + let marker = dir.join("from-terminal"); + h.input_mut().events.push(Event::Text(format!("touch '{}'", marker.display()))); + settle(&mut h, 3); + key(&mut h, Enter, Modifiers::NONE); + for _ in 0..80 { + settle(&mut h, 2); + if marker.exists() { break } + } + assert!(marker.exists(), "a command typed in the terminal ran"); + key(&mut h, F4, Modifiers::NONE); + settle(&mut h, 30); + assert!(!h.state().term_open, "F4 hides it even with the terminal focused"); + std::fs::remove_dir_all(dir).ok(); +} diff --git a/tests/syntax_all.rs b/tests/syntax_all.rs new file mode 100644 index 0000000..8a4c60f --- /dev/null +++ b/tests/syntax_all.rs @@ -0,0 +1,42 @@ +//! Loads every Kate syntax definition on this machine and highlights real files. +use damson::syntax::{engine::Highlighter, DefStyle, Registry}; + +#[test] +fn every_definition_compiles_and_runs() { + let mut reg = Registry::scan(); + let names: Vec = reg.languages.iter().map(|l| l.name.clone()).collect(); + assert!(names.len() >= 400, "only found {} definitions", names.len()); + let mut failed = vec![]; + for n in &names { + if reg.load(n).is_none() { + failed.push(n.clone()); + } + } + println!("{} definitions, {} contexts, {} failed to load: {failed:?}", names.len(), reg.compiled.contexts.len(), failed.len()); + println!("{} regexes the engine could not compile", reg.compiled.bad_regexes.len()); + let mut kinds = std::collections::BTreeMap::new(); + for (src, e) in ®.compiled.bad_regexes { + *kinds.entry(e.chars().take(70).collect::()).or_insert(0) += 1; + if std::env::var("SHOW_BAD").is_ok() { println!(" {src}\n {e}"); } + } + println!("{kinds:#?}"); + assert!(failed.is_empty()); +} + +#[test] +fn rust_highlights_like_kate() { + let mut reg = Registry::scan(); + let mut st = reg.initial_state("Rust").unwrap(); + let mut h = Highlighter::new(®.compiled); + let line = r#"pub fn main() { let s = "hi"; // note"#; + let r = h.line(line, &mut st); + let style = |frag: &str| { + let at = line.find(frag).unwrap() as u32; + let s = r.spans.iter().find(|s| s.start <= at && at < s.end).unwrap(); + reg.compiled.styles[s.style as usize].base + }; + assert_eq!(style("pub"), DefStyle::Keyword); + assert_eq!(style("\"hi\""), DefStyle::String); + assert_eq!(style("// note"), DefStyle::Comment); + assert!(r.folds.len() == 1); +} diff --git a/tools/gen_icons.py b/tools/gen_icons.py new file mode 100644 index 0000000..c2b8dc1 --- /dev/null +++ b/tools/gen_icons.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +"""Regenerate src/icondata.rs from the Material Symbols Rounded variable font (Apache 2.0). + + python tools/gen_icons.py path/to/MaterialSymbolsRounded.ttf +""" +import sys +from fontTools.ttLib import TTFont +from fontTools.varLib import instancer +from fontTools.pens.svgPathPen import SVGPathPen +from fontTools.pens.transformPen import TransformPen + +NAMES = """add arrow_back arrow_downward arrow_forward arrow_upward account_tree article bolt bookmark +bookmark_add build call_split check check_circle chevron_left chevron_right close close_fullscreen code +commit content_copy content_cut content_paste contrast dark_mode data_object delete description difference +do_not_disturb_on draft edit error expand_less expand_more find_replace folder folder_open folder_zip +format_align_left format_indent_increase format_list_bulleted fullscreen history home info insert_drive_file +keyboard_arrow_down keyboard_arrow_right keyboard_arrow_up keyboard_command_key language light_mode line_end +list looks_one manage_search map match_case memory merge minimize more_horiz more_vert motion_mode +move_up new_window open_in_full open_in_new palette play_arrow pin_drop push_pin redo refresh regular_expression +remove replace restart_alt rocket_launch save save_as search segment select_all settings +splitscreen splitscreen_right stop swap_vert sync tab tag terminal text_fields tune undo unfold_less unfold_more +upload download vertical_split view_sidebar visibility warning wrap_text""".split() + +font = TTFont(sys.argv[1]) +font = instancer.instantiateVariableFont(font, {"FILL": 0, "wght": 400, "GRAD": 0, "opsz": 24}) +filled = TTFont(sys.argv[1]) +filled = instancer.instantiateVariableFont(filled, {"FILL": 1, "wght": 400, "GRAD": 0, "opsz": 24}) + +def path(f, name): + gs = f.getGlyphSet() + if name not in gs: + return None + upem = f["head"].unitsPerEm + s = 960 / upem + pen = SVGPathPen(gs, ntos=lambda v: ("%.1f" % v).rstrip("0").rstrip(".")) + gs[name].draw(TransformPen(pen, (s, 0, 0, -s, 0, 0))) + return pen.getCommands() + +out = {} +missing = [] +for n in NAMES: + p = path(font, n) + if p is None: + missing.append(n) + continue + out[n] = p + q = path(filled, n) + if q and q != p: + out[n + "_fill"] = q +with open("src/icondata.rs", "w") as f: + f.write("//! Material Symbols Rounded (Apache 2.0) path data, viewBox 0 -960 960 960. Generated by tools/gen_icons.py.\n\n") + f.write("pub const ICONS: &[(&str, &str)] = &[\n") + for k in sorted(out): + f.write(f' ("{k}", "{out[k]}"),\n') + f.write("];\n") +print(len(out), "icons; missing:", missing)