Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

mobile: add the thinkterm-mobile crate, one pane over ssh on a native surface

RoversXc62bf6de7f17
diff --git a/Cargo.lock b/Cargo.lock
index f11b5829..20f4d9c4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -29,6 +29,43 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
+[[package]]
+name = "aead"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99"
+dependencies = [
+ "crypto-common 0.2.2",
+ "inout",
+]
+
+[[package]]
+name = "aes"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32"
+dependencies = [
+ "cipher",
+ "cpubits",
+ "cpufeatures 0.3.1",
+ "zeroize",
+]
+
+[[package]]
+name = "aes-gcm"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f2b8006a0c83f52b62ba44a97b58bf76fe2f70a329e588f67f89691d93d498f"
+dependencies = [
+ "aead",
+ "aes",
+ "cipher",
+ "ctr",
+ "ctutils",
+ "ghash",
+ "zeroize",
+]
+
[[package]]
name = "ahash"
version = "0.8.12"
@@ -154,6 +191,18 @@ dependencies = [
"syn 2.0.110",
]
+[[package]]
+name = "argon2"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "134c52ddac6d63c576bef8168db10c83c49c26444ecbc68060fef078925a901c"
+dependencies = [
+ "base64ct",
+ "blake2",
+ "cpufeatures 0.3.1",
+ "password-hash",
+]
+
[[package]]
name = "arrayref"
version = "0.3.9"
@@ -181,6 +230,59 @@ dependencies = [
"libloading",
]
+[[package]]
+name = "askama"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6024d73179f43f15ccd2b881bfea6fee7f3a46ec53f33b52210dea749ebebaa4"
+dependencies = [
+ "askama_macros",
+ "itoa",
+ "percent-encoding",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "askama_derive"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071ee5ebf2138e3ad180e0aacf6940c2cab5e6d8333741d9925c7bee2b153f39"
+dependencies = [
+ "askama_parser",
+ "basic-toml",
+ "glob",
+ "memchr",
+ "proc-macro2",
+ "quote",
+ "rustc-hash 2.1.1",
+ "serde",
+ "serde_derive",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "askama_macros"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "643e1c7cbb6aec1d920332fe51a7c0d8219e273dcb8602db03f5263e4d16487b"
+dependencies = [
+ "askama_derive",
+]
+
+[[package]]
+name = "askama_parser"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c5ae75772275d268b03ab8bdccdd12117b6169ee23256942b34e46c9f476583"
+dependencies = [
+ "rustc-hash 2.1.1",
+ "serde",
+ "serde_derive",
+ "unicode-ident",
+ "winnow 1.0.4",
+]
+
[[package]]
name = "assert_fs"
version = "1.1.3"
@@ -422,6 +524,12 @@ dependencies = [
"windows-link 0.2.1",
]
+[[package]]
+name = "base16ct"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6"
+
[[package]]
name = "base64"
version = "0.13.1"
@@ -440,10 +548,25 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+[[package]]
+name = "base64ct"
+version = "1.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
+
[[package]]
name = "base91"
version = "0.1.0"
+[[package]]
+name = "basic-toml"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "battery"
version = "0.1.0"
@@ -455,6 +578,17 @@ dependencies = [
"wezterm-dynamic 0.2.1",
]
+[[package]]
+name = "bcrypt-pbkdf"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "144e573728da132683b9488acd528274c790e07fc06ff81ee29f9d8f8b1041e0"
+dependencies = [
+ "blowfish",
+ "pbkdf2",
+ "sha2 0.11.0",
+]
+
[[package]]
name = "benchmarking"
version = "0.4.13"
@@ -522,6 +656,15 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
+[[package]]
+name = "blake2"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b5d4d889834ee8ecfc0f8426ad30faf7cdcb10f741a8e6d7224d95325479f6f"
+dependencies = [
+ "digest 0.11.3",
+]
+
[[package]]
name = "block"
version = "0.1.6"
@@ -534,7 +677,26 @@ version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
- "generic-array",
+ "generic-array 0.14.9",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
+dependencies = [
+ "hybrid-array",
+ "zeroize",
+]
+
+[[package]]
+name = "block-padding"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b"
+dependencies = [
+ "hybrid-array",
]
[[package]]
@@ -559,6 +721,16 @@ dependencies = [
"piper",
]
+[[package]]
+name = "blowfish"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62ce3946557b35e71d1bbe07ec385073ce9eda05043f95de134eb578fcf1a298"
+dependencies = [
+ "byteorder",
+ "cipher",
+]
+
[[package]]
name = "bstr"
version = "1.12.1"
@@ -616,9 +788,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
-version = "1.10.1"
+version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
+checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]]
name = "cairo-rs"
@@ -646,6 +818,33 @@ name = "camino"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "cargo-platform"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd0061da739915fae12ea00e16397555ed4371a6bb285431aab930f61b0aa4ba"
+dependencies = [
+ "serde",
+ "serde_core",
+]
+
+[[package]]
+name = "cargo_metadata"
+version = "0.23.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9"
+dependencies = [
+ "camino",
+ "cargo-platform",
+ "semver",
+ "serde",
+ "serde_json",
+ "thiserror 2.0.20",
+]
[[package]]
name = "cassowary"
@@ -668,6 +867,15 @@ dependencies = [
"rustversion",
]
+[[package]]
+name = "cbc"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "cc"
version = "1.2.67"
@@ -711,6 +919,19 @@ dependencies = [
"libc",
]
+[[package]]
+name = "chacha20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures 0.3.1",
+ "rand_core 0.10.1",
+ "zeroize",
+]
+
[[package]]
name = "chrono"
version = "0.4.42"
@@ -718,9 +939,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
dependencies = [
"iana-time-zone",
+ "js-sys",
"num-traits",
"pure-rust-locales",
"serde",
+ "wasm-bindgen",
"windows-link 0.2.1",
]
@@ -751,6 +974,18 @@ dependencies = [
"half",
]
+[[package]]
+name = "cipher"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
+dependencies = [
+ "block-buffer 0.12.1",
+ "crypto-common 0.2.2",
+ "inout",
+ "zeroize",
+]
+
[[package]]
name = "clap"
version = "4.5.51"
@@ -819,6 +1054,12 @@ dependencies = [
"error-code",
]
+[[package]]
+name = "cmov"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
+
[[package]]
name = "cocoa"
version = "0.25.0"
@@ -977,7 +1218,7 @@ dependencies = [
"log",
"luahelper",
"mlua",
- "nix",
+ "nix 0.29.0",
"notify",
"ordered-float 4.6.0",
"portable-pty",
@@ -1011,6 +1252,12 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "const-oid"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
+
[[package]]
name = "convert_case"
version = "0.10.0"
@@ -1124,6 +1371,12 @@ dependencies = [
"libm",
]
+[[package]]
+name = "cpubits"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
+
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -1133,6 +1386,15 @@ dependencies = [
"libc",
]
+[[package]]
+name = "cpufeatures"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "crc32fast"
version = "1.5.0"
@@ -1267,16 +1529,44 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
+[[package]]
+name = "crypto-bigint"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271"
+dependencies = [
+ "cpubits",
+ "ctutils",
+ "getrandom 0.4.3",
+ "hybrid-array",
+ "num-traits",
+ "rand_core 0.10.1",
+ "serdect",
+ "subtle",
+ "zeroize",
+]
+
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
- "generic-array",
+ "generic-array 0.14.9",
"typenum",
]
+[[package]]
+name = "crypto-common"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
+dependencies = [
+ "getrandom 0.4.3",
+ "hybrid-array",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "csscolorparser"
version = "0.6.2"
@@ -1287,12 +1577,59 @@ dependencies = [
"phf",
]
+[[package]]
+name = "ctr"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baaca1c4b237092596f64d571e9db6ce4109c4ef9742e27590f1709594461f21"
+dependencies = [
+ "cipher",
+]
+
+[[package]]
+name = "ctutils"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
+dependencies = [
+ "cmov",
+ "subtle",
+]
+
[[package]]
name = "cursor-icon"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"
+[[package]]
+name = "curve25519-dalek"
+version = "5.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "curve25519-dalek-derive",
+ "digest 0.11.3",
+ "fiat-crypto",
+ "rand_core 0.10.1",
+ "rustc_version",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "curve25519-dalek-derive"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.110",
+]
+
[[package]]
name = "darling"
version = "0.20.11"
@@ -1380,12 +1717,34 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
+[[package]]
+name = "delegate"
+version = "0.13.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "780eb241654bf097afb00fc5f054a09b687dad862e485fdcf8399bb056565370"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.110",
+]
+
[[package]]
name = "deltae"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4"
+[[package]]
+name = "der"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a"
+dependencies = [
+ "const-oid",
+ "pem-rfc7468",
+ "zeroize",
+]
+
[[package]]
name = "deranged"
version = "0.5.8"
@@ -1418,6 +1777,15 @@ dependencies = [
"syn 2.0.110",
]
+[[package]]
+name = "des"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "916a94e407b54f9034d71dd748234cd1e516ced6284009906ae246f177eafe5a"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "dhat"
version = "0.3.3"
@@ -1452,8 +1820,20 @@ version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
- "block-buffer",
- "crypto-common",
+ "block-buffer 0.10.4",
+ "crypto-common 0.1.6",
+]
+
+[[package]]
+name = "digest"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
+dependencies = [
+ "block-buffer 0.12.1",
+ "const-oid",
+ "crypto-common 0.2.2",
+ "ctutils",
]
[[package]]
@@ -1554,12 +1934,75 @@ dependencies = [
"wio",
]
+[[package]]
+name = "ecdsa"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0681a4fc24c767085329728d8dfba959af91228aa4610cca4f8ce317ba46ae0"
+dependencies = [
+ "der",
+ "digest 0.11.3",
+ "elliptic-curve",
+ "rfc6979",
+ "signature",
+ "spki",
+ "zeroize",
+]
+
+[[package]]
+name = "ed25519"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a"
+dependencies = [
+ "pkcs8",
+ "signature",
+]
+
+[[package]]
+name = "ed25519-dalek"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de"
+dependencies = [
+ "curve25519-dalek",
+ "ed25519",
+ "rand_core 0.10.1",
+ "serde",
+ "sha2 0.11.0",
+ "signature",
+ "subtle",
+ "zeroize",
+]
+
[[package]]
name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
+[[package]]
+name = "elliptic-curve"
+version = "0.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d65aa39b3a5c1c9c1b745c9a019234bb7a21b77abcb4f4d266d706e2d577d65"
+dependencies = [
+ "base16ct",
+ "crypto-bigint",
+ "crypto-common 0.2.2",
+ "digest 0.11.3",
+ "ff",
+ "group",
+ "hkdf",
+ "hybrid-array",
+ "pem-rfc7468",
+ "pkcs8",
+ "rand_core 0.10.1",
+ "sec1",
+ "subtle",
+ "zeroize",
+]
+
[[package]]
name = "embed-resource"
version = "1.8.0"
@@ -1608,6 +2051,18 @@ dependencies = [
"syn 1.0.109",
]
+[[package]]
+name = "enum_dispatch"
+version = "0.3.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd"
+dependencies = [
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.110",
+]
+
[[package]]
name = "enumflags2"
version = "0.7.12"
@@ -1870,6 +2325,22 @@ dependencies = [
"simd-adler32",
]
+[[package]]
+name = "ff"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f"
+dependencies = [
+ "rand_core 0.10.1",
+ "subtle",
+]
+
+[[package]]
+name = "fiat-crypto"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24"
+
[[package]]
name = "filedescriptor"
version = "0.8.3"
@@ -2017,7 +2488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198"
dependencies = [
"memchr",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
]
[[package]]
@@ -2136,6 +2607,15 @@ dependencies = [
"fixed",
]
+[[package]]
+name = "fs-err"
+version = "3.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b91aa448ca50d7e79433bdf3ee8d99215430d2ec02ade5aefab2a073a1822e8a"
+dependencies = [
+ "autocfg",
+]
+
[[package]]
name = "fsevent-sys"
version = "4.1.0"
@@ -2270,6 +2750,17 @@ dependencies = [
"version_check",
]
+[[package]]
+name = "generic-array"
+version = "1.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "337d46834ee672ab3e48caca2cb0c78cc174fb12b3a68d0d88f99a0519a5e36e"
+dependencies = [
+ "generic-array 0.14.9",
+ "rustversion",
+ "typenum",
+]
+
[[package]]
name = "gethostname"
version = "0.5.0"
@@ -2302,11 +2793,35 @@ dependencies = [
"cfg-if",
"js-sys",
"libc",
- "r-efi",
+ "r-efi 5.3.0",
"wasip2",
"wasm-bindgen",
]
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "libc",
+ "r-efi 6.0.0",
+ "rand_core 0.10.1",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "ghash"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5"
+dependencies = [
+ "polyval",
+ "zeroize",
+]
+
[[package]]
name = "gif"
version = "0.13.3"
@@ -2413,6 +2928,17 @@ dependencies = [
"gl_generator",
]
+[[package]]
+name = "goblin"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47"
+dependencies = [
+ "log",
+ "plain",
+ "scroll",
+]
+
[[package]]
name = "governor"
version = "0.5.1"
@@ -2479,6 +3005,17 @@ dependencies = [
"bitflags 2.13.1",
]
+[[package]]
+name = "group"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4"
+dependencies = [
+ "ff",
+ "rand_core 0.10.1",
+ "subtle",
+]
+
[[package]]
name = "guillotiere"
version = "0.6.2"
@@ -2629,12 +3166,36 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+[[package]]
+name = "hex-literal"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e712f64ec3850b98572bffac52e2c6f282b29fe6c5fa6d42334b30be438d95c1"
+
[[package]]
name = "hexf-parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
+[[package]]
+name = "hkdf"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018"
+dependencies = [
+ "hmac",
+]
+
+[[package]]
+name = "hmac"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
+dependencies = [
+ "digest 0.11.3",
+]
+
[[package]]
name = "hostname"
version = "0.4.1"
@@ -2711,6 +3272,18 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
+[[package]]
+name = "hybrid-array"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
+dependencies = [
+ "ctutils",
+ "subtle",
+ "typenum",
+ "zeroize",
+]
+
[[package]]
name = "hyper"
version = "1.7.0"
@@ -3014,6 +3587,8 @@ checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f"
dependencies = [
"equivalent",
"hashbrown 0.16.0",
+ "serde",
+ "serde_core",
]
[[package]]
@@ -3045,6 +3620,16 @@ dependencies = [
"libc",
]
+[[package]]
+name = "inout"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
+dependencies = [
+ "block-padding",
+ "hybrid-array",
+]
+
[[package]]
name = "instability"
version = "0.3.12"
@@ -3242,14 +3827,34 @@ dependencies = [
]
[[package]]
-name = "kasuari"
-version = "0.4.11"
+name = "kasuari"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fe90c1150662e858c7d5f945089b7517b0a80d8bf7ba4b1b5ffc984e7230a5b"
+dependencies = [
+ "hashbrown 0.16.0",
+ "portable-atomic",
+ "thiserror 2.0.20",
+]
+
+[[package]]
+name = "keccak"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8f198d1db720e4940b5a493201d199d9f24f568f8f746bd13706243a2f71598"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+]
+
+[[package]]
+name = "kem"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8fe90c1150662e858c7d5f945089b7517b0a80d8bf7ba4b1b5ffc984e7230a5b"
+checksum = "01737161ba802849cfd486b5bd209d38ba4943494c249a8126005170c7621edd"
dependencies = [
- "hashbrown 0.16.0",
- "portable-atomic",
- "thiserror 2.0.17",
+ "crypto-common 0.2.2",
+ "rand_core 0.10.1",
]
[[package]]
@@ -3344,9 +3949,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.177"
+version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
+checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
[[package]]
name = "libflate"
@@ -3610,7 +4215,7 @@ version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303"
dependencies = [
- "nix",
+ "nix 0.29.0",
"winapi",
]
@@ -3648,6 +4253,12 @@ dependencies = [
"rayon",
]
+[[package]]
+name = "md5"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ebb8d8732c6a6df3d8f032a82911cfc747e00efb95cc46e8d0acd5b5b88570c"
+
[[package]]
name = "memchr"
version = "2.7.6"
@@ -3773,6 +4384,20 @@ dependencies = [
"windows-sys 0.61.2",
]
+[[package]]
+name = "ml-kem"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e15f3e5b957493873e396a66914e83e616b6afe335cdef7efe5c6e1216aba66"
+dependencies = [
+ "hybrid-array",
+ "kem",
+ "module-lattice",
+ "pkcs8",
+ "rand_core 0.10.1",
+ "sha3 0.11.0",
+]
+
[[package]]
name = "mlua"
version = "0.9.9"
@@ -3803,6 +4428,17 @@ dependencies = [
"pkg-config",
]
+[[package]]
+name = "module-lattice"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c61b87c9683ab7cb1c6871d261ad5479b6b10ceb52c4352aaca3b5d35a8febe"
+dependencies = [
+ "ctutils",
+ "hybrid-array",
+ "num-traits",
+]
+
[[package]]
name = "moxcms"
version = "0.7.9"
@@ -3838,7 +4474,7 @@ dependencies = [
"metrics",
"mlua",
"names",
- "nix",
+ "nix 0.29.0",
"ntapi",
"parking_lot",
"percent-encoding",
@@ -3907,7 +4543,7 @@ dependencies = [
"rustc-hash 1.1.0",
"spirv",
"strum 0.26.3",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
"unicode-ident",
]
@@ -3974,6 +4610,18 @@ dependencies = [
"memoffset",
]
+[[package]]
+name = "nix"
+version = "0.31.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
+dependencies = [
+ "bitflags 2.13.1",
+ "cfg-if",
+ "cfg_aliases",
+ "libc",
+]
+
[[package]]
name = "no-std-compat"
version = "0.4.1"
@@ -4060,7 +4708,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
- "num-bigint",
+ "num-bigint 0.4.6",
"num-complex",
"num-integer",
"num-iter",
@@ -4078,6 +4726,18 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "num-bigint"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93e7820bc0a80a0238e650327316f929ba18d5be054b647490a3a6a339f3e7c0"
+dependencies = [
+ "num-integer",
+ "num-traits",
+ "rand 0.10.2",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "num-complex"
version = "0.4.6"
@@ -4130,7 +4790,7 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
- "num-bigint",
+ "num-bigint 0.4.6",
"num-integer",
"num-traits",
]
@@ -4374,6 +5034,67 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "p256"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2c9239b2dbc807adbbe147e8cf72ea7450c3a0aabe62cb8e75ff4ec22e1f72a"
+dependencies = [
+ "ecdsa",
+ "elliptic-curve",
+ "primefield",
+ "primeorder",
+ "sha2 0.11.0",
+]
+
+[[package]]
+name = "p384"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d17b851e6b3e378ab4ecb07fa2ed23f4d15f075735f8fec9fa1e7bdce5f8301f"
+dependencies = [
+ "ecdsa",
+ "elliptic-curve",
+ "fiat-crypto",
+ "primefield",
+ "primeorder",
+ "sha2 0.11.0",
+]
+
+[[package]]
+name = "p521"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ad64cc32c2dc466317c12ee5853e61f159f9eab1fe7efade0395dc2e7b43449"
+dependencies = [
+ "base16ct",
+ "ecdsa",
+ "elliptic-curve",
+ "primefield",
+ "primeorder",
+ "sha2 0.11.0",
+]
+
+[[package]]
+name = "pageant"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d8eab09a361a4afe0b1668be978cd97e4f052e927a92b0b608cf902965d49ce"
+dependencies = [
+ "base16ct",
+ "byteorder",
+ "bytes",
+ "delegate",
+ "futures",
+ "log",
+ "rand 0.10.2",
+ "sha2 0.11.0",
+ "thiserror 2.0.20",
+ "tokio",
+ "windows 0.62.2",
+ "windows-strings 0.5.1",
+]
+
[[package]]
name = "parking"
version = "2.2.1"
@@ -4412,12 +5133,31 @@ dependencies = [
"libc",
]
+[[package]]
+name = "password-hash"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aab41826031698d6ffcd9cff78ef56ef998e39dc7e5067cdfebe373842d4723b"
+dependencies = [
+ "phc",
+]
+
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+[[package]]
+name = "pbkdf2"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629"
+dependencies = [
+ "digest 0.11.3",
+ "hmac",
+]
+
[[package]]
name = "pem"
version = "3.0.6"
@@ -4428,6 +5168,15 @@ dependencies = [
"serde_core",
]
+[[package]]
+name = "pem-rfc7468"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9"
+dependencies = [
+ "base64ct",
+]
+
[[package]]
name = "percent-encoding"
version = "2.3.2"
@@ -4474,7 +5223,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a"
dependencies = [
"pest",
- "sha2",
+ "sha2 0.10.9",
+]
+
+[[package]]
+name = "phc"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44dc769b75f93afdddd8c7fa12d685292ddeff1e66f7f0f3a234cf1818afe892"
+dependencies = [
+ "base64ct",
+ "ctutils",
]
[[package]]
@@ -4587,12 +5346,47 @@ dependencies = [
"futures-io",
]
+[[package]]
+name = "pkcs5"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63d440a804ec8d6fafbb6b84471e013286658d373248927692ab3366686220ca"
+dependencies = [
+ "aes",
+ "aes-gcm",
+ "cbc",
+ "der",
+ "pbkdf2",
+ "rand_core 0.10.1",
+ "scrypt",
+ "sha2 0.11.0",
+ "spki",
+]
+
+[[package]]
+name = "pkcs8"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7"
+dependencies = [
+ "der",
+ "pkcs5",
+ "rand_core 0.10.1",
+ "spki",
+]
+
[[package]]
name = "pkg-config"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+[[package]]
+name = "plain"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
+
[[package]]
name = "plist"
version = "1.7.4"
@@ -4687,6 +5481,29 @@ dependencies = [
"windows-sys 0.61.2",
]
+[[package]]
+name = "poly1305"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c"
+dependencies = [
+ "cpufeatures 0.3.1",
+ "universal-hash",
+ "zeroize",
+]
+
+[[package]]
+name = "polyval"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0fa31d631f2b2cb2a544d0aa321ce847a94764d701ca2becc411138b93d49cd"
+dependencies = [
+ "cpubits",
+ "cpufeatures 0.3.1",
+ "universal-hash",
+ "zeroize",
+]
+
[[package]]
name = "portable-atomic"
version = "1.11.1"
@@ -4714,7 +5531,7 @@ dependencies = [
"lazy_static",
"libc",
"log",
- "nix",
+ "nix 0.29.0",
"serde",
"serial2",
"shared_library",
@@ -4794,6 +5611,33 @@ dependencies = [
"yansi",
]
+[[package]]
+name = "primefield"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c555a6e4eb7d4e158fcb028c835c3b8642206ddc279b5c6b202ef9a8bdb592f4"
+dependencies = [
+ "crypto-bigint",
+ "crypto-common 0.2.2",
+ "ff",
+ "rand_core 0.10.1",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "primeorder"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c9f42978c78a00e3d68f69fc03e57a234debae69da4020a4fb588fcdcd07b06"
+dependencies = [
+ "elliptic-curve",
+ "once_cell",
+ "primefield",
+ "serdect",
+ "wnaf",
+]
+
[[package]]
name = "proc-macro-crate"
version = "3.4.0"
@@ -4957,6 +5801,12 @@ 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 = "rand"
version = "0.8.5"
@@ -4979,6 +5829,17 @@ dependencies = [
"rand_core 0.9.3",
]
+[[package]]
+name = "rand"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"
+dependencies = [
+ "chacha20",
+ "getrandom 0.4.3",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "rand_chacha"
version = "0.3.1"
@@ -5018,6 +5879,12 @@ dependencies = [
"getrandom 0.3.4",
]
+[[package]]
+name = "rand_core"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
+
[[package]]
name = "range-alloc"
version = "0.1.4"
@@ -5059,7 +5926,7 @@ dependencies = [
"kasuari",
"lru",
"strum 0.27.2",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
"unicode-segmentation",
"unicode-truncate",
"unicode-width",
@@ -5338,6 +6205,16 @@ dependencies = [
"usvg",
]
+[[package]]
+name = "rfc6979"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b"
+dependencies = [
+ "crypto-bigint",
+ "hmac",
+]
+
[[package]]
name = "rgb"
version = "0.8.52"
@@ -5417,6 +6294,98 @@ dependencies = [
"smallvec",
]
+[[package]]
+name = "russh"
+version = "0.63.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "036204edbd199552a5b3832f63c60dcdf395dc44c7f06b4af1c0e8139cc11bce"
+dependencies = [
+ "aes",
+ "bitflags 2.13.1",
+ "block-padding",
+ "byteorder",
+ "bytes",
+ "cbc",
+ "cipher",
+ "crypto-bigint",
+ "ctr",
+ "curve25519-dalek",
+ "data-encoding",
+ "delegate",
+ "der",
+ "digest 0.11.3",
+ "ecdsa",
+ "ed25519-dalek",
+ "elliptic-curve",
+ "enum_dispatch",
+ "futures",
+ "generic-array 1.4.5",
+ "getrandom 0.4.3",
+ "ghash",
+ "hex-literal",
+ "hmac",
+ "inout",
+ "keccak",
+ "log",
+ "md5",
+ "ml-kem",
+ "module-lattice",
+ "num-bigint 0.5.1",
+ "p256",
+ "p384",
+ "p521",
+ "pageant",
+ "pbkdf2",
+ "pkcs5",
+ "pkcs8",
+ "polyval",
+ "rand 0.10.2",
+ "rand_core 0.10.1",
+ "ring",
+ "russh-cryptovec",
+ "russh-util",
+ "salsa20",
+ "scrypt",
+ "sec1",
+ "sha1 0.11.0",
+ "sha2 0.11.0",
+ "sha3 0.12.0",
+ "signature",
+ "spki",
+ "ssh-encoding",
+ "ssh-key",
+ "subtle",
+ "thiserror 2.0.20",
+ "tokio",
+ "typenum",
+ "universal-hash",
+ "zeroize",
+]
+
+[[package]]
+name = "russh-cryptovec"
+version = "0.62.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3aec6cb630dbe85d72ffd7bcd95f07e1bd69f9f270ee8adfa1afe443a6331438"
+dependencies = [
+ "log",
+ "nix 0.31.3",
+ "ssh-encoding",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "russh-util"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "668424a5dde0bcb45b55ba7de8476b93831b4aa2fa6947e145f3b053e22c60b6"
+dependencies = [
+ "chrono",
+ "tokio",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+]
+
[[package]]
name = "rustc-demangle"
version = "0.1.26"
@@ -5556,6 +6525,16 @@ version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
+[[package]]
+name = "salsa20"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f874456e72520ff1375a06c588eaf074b0f01f9e9e1aada45bd9b7954a6e42c"
+dependencies = [
+ "cfg-if",
+ "cipher",
+]
+
[[package]]
name = "same-file"
version = "1.0.6"
@@ -5586,6 +6565,52 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+[[package]]
+name = "scroll"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6"
+dependencies = [
+ "scroll_derive",
+]
+
+[[package]]
+name = "scroll_derive"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.110",
+]
+
+[[package]]
+name = "scrypt"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d87af57419b594aa23fa95f09f0e06d80d84ba01c26148c43844cad6ff4485f0"
+dependencies = [
+ "cfg-if",
+ "pbkdf2",
+ "salsa20",
+ "sha2 0.11.0",
+]
+
+[[package]]
+name = "sec1"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d56d437c2f19203ce5f7122e507831de96f3d2d4d3be5af44a0b0a09d8a80e4d"
+dependencies = [
+ "base16ct",
+ "ctutils",
+ "der",
+ "hybrid-array",
+ "subtle",
+ "zeroize",
+]
+
[[package]]
name = "security-framework"
version = "2.11.1"
@@ -5620,6 +6645,10 @@ name = "semver"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
+dependencies = [
+ "serde",
+ "serde_core",
+]
[[package]]
name = "serde"
@@ -5718,6 +6747,15 @@ dependencies = [
"serde",
]
+[[package]]
+name = "serde_spanned"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
+dependencies = [
+ "serde_core",
+]
+
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -5771,6 +6809,16 @@ dependencies = [
"unsafe-libyaml",
]
+[[package]]
+name = "serdect"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e"
+dependencies = [
+ "base16ct",
+ "serde",
+]
+
[[package]]
name = "serial2"
version = "0.2.33"
@@ -5789,8 +6837,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [
"cfg-if",
- "cpufeatures",
- "digest",
+ "cpufeatures 0.2.17",
+ "digest 0.10.7",
+]
+
+[[package]]
+name = "sha1"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "digest 0.11.3",
]
[[package]]
@@ -5800,11 +6859,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
- "cpufeatures",
- "digest",
+ "cpufeatures 0.2.17",
+ "digest 0.10.7",
"sha2-asm",
]
+[[package]]
+name = "sha2"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "digest 0.11.3",
+]
+
[[package]]
name = "sha2-asm"
version = "0.6.4"
@@ -5814,6 +6884,27 @@ dependencies = [
"cc",
]
+[[package]]
+name = "sha3"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be176f1a57ce4e3d31c1a166222d9768de5954f811601fb7ca06fc8203905ce1"
+dependencies = [
+ "digest 0.11.3",
+ "keccak",
+]
+
+[[package]]
+name = "sha3"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc9bad02c26382724b2d2692c6f179285e4b54eeecd7968f52a50059c3c11759"
+dependencies = [
+ "digest 0.11.3",
+ "keccak",
+ "sponge-cursor",
+]
+
[[package]]
name = "share-data"
version = "0.1.0"
@@ -5884,6 +6975,16 @@ dependencies = [
"libc",
]
+[[package]]
+name = "signature"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5"
+dependencies = [
+ "digest 0.11.3",
+ "rand_core 0.10.1",
+]
+
[[package]]
name = "simd-adler32"
version = "0.3.7"
@@ -6029,7 +7130,7 @@ dependencies = [
"httparse",
"log",
"rand 0.8.5",
- "sha1",
+ "sha1 0.10.6",
]
[[package]]
@@ -6074,6 +7175,22 @@ dependencies = [
"bitflags 2.13.1",
]
+[[package]]
+name = "spki"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d9efca8738c78ee9484207732f728b1ef517bbb1833d6fc0879ca898a522f6f"
+dependencies = [
+ "base64ct",
+ "der",
+]
+
+[[package]]
+name = "sponge-cursor"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a0219bd7d979d58245a4f41f695e1ac9f8befdffadd7f61f1bae9e39abc6620"
+
[[package]]
name = "sqlite-cache"
version = "0.1.4"
@@ -6086,6 +7203,38 @@ dependencies = [
"tracing",
]
+[[package]]
+name = "ssh-cipher"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d801accda99469cde6d73da741422610fdf6508a72d9a69d1b55cb241c720597"
+dependencies = [
+ "aead",
+ "aes",
+ "aes-gcm",
+ "chacha20",
+ "cipher",
+ "ctutils",
+ "des",
+ "poly1305",
+ "ssh-encoding",
+ "zeroize",
+]
+
+[[package]]
+name = "ssh-encoding"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b54d0ed0498daf3f78d82e00e28c8eec9d75a067c4cfbcc7a0f7d0f4077749e"
+dependencies = [
+ "base64ct",
+ "bytes",
+ "ctutils",
+ "digest 0.11.3",
+ "pem-rfc7468",
+ "zeroize",
+]
+
[[package]]
name = "ssh-funcs"
version = "0.1.0"
@@ -6096,6 +7245,31 @@ dependencies = [
"wezterm-ssh",
]
+[[package]]
+name = "ssh-key"
+version = "0.7.0-rc.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9a32fae177b74a22aa9c5b01bf7e68b33545be32d9e381e248058d2adc15ce3"
+dependencies = [
+ "argon2",
+ "bcrypt-pbkdf",
+ "ctutils",
+ "ed25519-dalek",
+ "hex",
+ "hmac",
+ "p256",
+ "p384",
+ "p521",
+ "rand_core 0.10.1",
+ "sec1",
+ "sha1 0.11.0",
+ "sha2 0.11.0",
+ "signature",
+ "ssh-cipher",
+ "ssh-encoding",
+ "zeroize",
+]
+
[[package]]
name = "ssh2"
version = "0.9.5"
@@ -6125,7 +7299,7 @@ dependencies = [
"lazycell",
"libc",
"mach2",
- "nix",
+ "nix 0.29.0",
"num-traits",
"plist",
"uom",
@@ -6265,6 +7439,17 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "syn"
+version = "3.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
[[package]]
name = "sync-color-schemes"
version = "0.1.0"
@@ -6454,14 +7639,14 @@ dependencies = [
"libc",
"log",
"memmem",
- "nix",
+ "nix 0.29.0",
"num-derive",
"num-traits",
"ordered-float 4.6.0",
"pest",
"pest_derive",
"phf",
- "sha2",
+ "sha2 0.10.9",
"signal-hook",
"siphasher 1.0.1",
"terminfo",
@@ -6497,7 +7682,7 @@ dependencies = [
"libc",
"log",
"memmem",
- "nix",
+ "nix 0.29.0",
"num-derive",
"num-traits",
"ordered-float 4.6.0",
@@ -6505,7 +7690,7 @@ dependencies = [
"pest_derive",
"phf",
"serde",
- "sha2",
+ "sha2 0.10.9",
"signal-hook",
"siphasher 1.0.1",
"terminfo",
@@ -6600,6 +7785,29 @@ dependencies = [
"unic-langid",
]
+[[package]]
+name = "thinkterm-mobile"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "bytemuck",
+ "codec",
+ "futures",
+ "log",
+ "russh",
+ "termwiz 0.24.0",
+ "thinkterm-font-web",
+ "thinkterm-proto",
+ "thinkterm-render",
+ "thinkterm-session",
+ "thinkterm-web",
+ "tokio",
+ "uniffi",
+ "wezterm-color-types 0.3.0",
+ "wezterm-term",
+ "wgpu",
+]
+
[[package]]
name = "thinkterm-proto"
version = "0.1.0"
@@ -6726,7 +7934,7 @@ dependencies = [
"semver",
"serde",
"serde_json",
- "sha2",
+ "sha2 0.10.9",
"tempfile",
]
@@ -6771,11 +7979,11 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "2.0.17"
+version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
+checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
dependencies = [
- "thiserror-impl 2.0.17",
+ "thiserror-impl 2.0.20",
]
[[package]]
@@ -6791,13 +7999,13 @@ dependencies = [
[[package]]
name = "thiserror-impl"
-version = "2.0.17"
+version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
+checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.110",
+ "syn 3.0.6",
]
[[package]]
@@ -7005,11 +8213,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
dependencies = [
"serde",
- "serde_spanned",
+ "serde_spanned 0.6.9",
"toml_datetime 0.6.11",
"toml_edit 0.22.27",
]
+[[package]]
+name = "toml"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8"
+dependencies = [
+ "indexmap 2.12.0",
+ "serde_core",
+ "serde_spanned 1.1.1",
+ "toml_datetime 0.7.3",
+ "toml_parser",
+ "toml_writer",
+ "winnow 0.7.13",
+]
+
[[package]]
name = "toml_datetime"
version = "0.6.11"
@@ -7036,10 +8259,10 @@ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
"indexmap 2.12.0",
"serde",
- "serde_spanned",
+ "serde_spanned 0.6.9",
"toml_datetime 0.6.11",
"toml_write",
- "winnow",
+ "winnow 0.7.13",
]
[[package]]
@@ -7051,7 +8274,7 @@ dependencies = [
"indexmap 2.12.0",
"toml_datetime 0.7.3",
"toml_parser",
- "winnow",
+ "winnow 0.7.13",
]
[[package]]
@@ -7060,7 +8283,7 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e"
dependencies = [
- "winnow",
+ "winnow 0.7.13",
]
[[package]]
@@ -7069,6 +8292,12 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
+[[package]]
+name = "toml_writer"
+version = "1.1.2+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
+
[[package]]
name = "tower"
version = "0.5.2"
@@ -7245,7 +8474,7 @@ checksum = "cd7a0c48d503cf4e0a57a2453424eaef2fce4b4269f13e3579e52f0d0c9e5cc8"
dependencies = [
"regex",
"streaming-iterator",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
"tree-sitter",
]
@@ -7413,9 +8642,9 @@ checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"
[[package]]
name = "typenum"
-version = "1.19.0"
+version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "ucd-trie"
@@ -7534,6 +8763,137 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
+[[package]]
+name = "uniffi"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "edf78ecfb9bb8d7c4f8da11e8eb2ab6304e8ec0adb3ab32d8fc77c21a5bb0b86"
+dependencies = [
+ "anyhow",
+ "camino",
+ "cargo_metadata",
+ "clap",
+ "uniffi_bindgen",
+ "uniffi_core",
+ "uniffi_macros",
+ "uniffi_pipeline",
+]
+
+[[package]]
+name = "uniffi_bindgen"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdea7c4574723928bef87dfc04b203d96321d0bf34ab295a56379e633be579f3"
+dependencies = [
+ "anyhow",
+ "askama",
+ "camino",
+ "cargo_metadata",
+ "fs-err",
+ "glob",
+ "goblin",
+ "heck",
+ "indexmap 2.12.0",
+ "once_cell",
+ "serde",
+ "tempfile",
+ "textwrap",
+ "toml 0.9.8",
+ "uniffi_internal_macros",
+ "uniffi_meta",
+ "uniffi_pipeline",
+ "uniffi_udl",
+]
+
+[[package]]
+name = "uniffi_core"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8b1c62ee415b805f063c82e8ef6bbcaa1b87f8eed360cf217537b7724e05601"
+dependencies = [
+ "anyhow",
+ "bytes",
+ "once_cell",
+ "static_assertions",
+]
+
+[[package]]
+name = "uniffi_internal_macros"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c79d4a3129d6c2c15e367d3954886a0533dd3e85d445ce4d93379f62c6949d7b"
+dependencies = [
+ "anyhow",
+ "indexmap 2.12.0",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.110",
+]
+
+[[package]]
+name = "uniffi_macros"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f6a9826a83f1140b2ec67c7944f562e1ef616e6eaf40e76247adccbd5b8a091"
+dependencies = [
+ "camino",
+ "fs-err",
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "syn 2.0.110",
+ "toml 0.9.8",
+ "uniffi_meta",
+]
+
+[[package]]
+name = "uniffi_meta"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf233eb014b595e8997c98df4ac6863b486a4ac6d54bd00230c7700753d7ef13"
+dependencies = [
+ "anyhow",
+ "siphasher 1.0.1",
+ "uniffi_internal_macros",
+ "uniffi_pipeline",
+]
+
+[[package]]
+name = "uniffi_pipeline"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55179706fbb6e7a23e729780d2c6165e6afe1ce725fa63754bcf217b440afc04"
+dependencies = [
+ "anyhow",
+ "heck",
+ "indexmap 2.12.0",
+ "tempfile",
+ "uniffi_internal_macros",
+]
+
+[[package]]
+name = "uniffi_udl"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "421a9add7a19c5a264a2aba760514125ef3840a8b246ec88237fc91e3f2f79b1"
+dependencies = [
+ "anyhow",
+ "textwrap",
+ "uniffi_meta",
+ "weedle2",
+]
+
+[[package]]
+name = "universal-hash"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96"
+dependencies = [
+ "crypto-common 0.2.2",
+ "ctutils",
+]
+
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
@@ -7949,6 +9309,15 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "weedle2"
+version = "5.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e"
+dependencies = [
+ "nom 7.1.3",
+]
+
[[package]]
name = "weezl"
version = "0.1.11"
@@ -8025,7 +9394,7 @@ version = "0.1.1"
dependencies = [
"getrandom 0.3.4",
"serde",
- "sha2",
+ "sha2 0.10.9",
"tempfile",
"thiserror 1.0.69",
"uuid",
@@ -8039,7 +9408,7 @@ checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7"
dependencies = [
"getrandom 0.3.4",
"mac_address",
- "sha2",
+ "sha2 0.10.9",
"thiserror 1.0.69",
"uuid",
]
@@ -8054,7 +9423,7 @@ dependencies = [
"ordered-float 4.6.0",
"serde",
"serde_bytes",
- "sha2",
+ "sha2 0.10.9",
"thiserror 1.0.69",
"wezterm-blob-leases 0.1.1",
"wezterm-char-props",
@@ -8151,7 +9520,7 @@ dependencies = [
"maplit",
"ordered-float 4.6.0",
"strsim",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
"wezterm-dynamic-derive 0.1.1",
]
@@ -8200,15 +9569,15 @@ dependencies = [
"image",
"k9",
"log",
- "nix",
+ "nix 0.29.0",
"num-derive",
"num-traits",
"ordered-float 4.6.0",
"pest",
"pest_derive",
"serde",
- "sha2",
- "thiserror 2.0.17",
+ "sha2 0.10.9",
+ "thiserror 2.0.20",
"vtparse 0.7.0",
"wezterm-blob-leases 0.1.1",
"wezterm-color-types 0.3.0",
@@ -8458,8 +9827,8 @@ dependencies = [
"rcgen",
"serde",
"serde_json",
- "sha1",
- "sha2",
+ "sha1 0.10.6",
+ "sha2 0.10.9",
"smol",
"soketto",
"tempfile",
@@ -8512,7 +9881,7 @@ dependencies = [
"predicates",
"regex",
"rstest",
- "sha2",
+ "sha2 0.10.9",
"shell-words",
"smol",
"socket2 0.5.10",
@@ -8665,7 +10034,7 @@ dependencies = [
"raw-window-handle",
"rustc-hash 1.1.0",
"smallvec",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
"wgpu-core-deps-apple",
"wgpu-core-deps-emscripten",
"wgpu-core-deps-windows-linux-android",
@@ -8739,7 +10108,7 @@ dependencies = [
"raw-window-handle",
"renderdoc-sys",
"smallvec",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
"wasm-bindgen",
"web-sys",
"wgpu-types",
@@ -8757,7 +10126,7 @@ dependencies = [
"bytemuck",
"js-sys",
"log",
- "thiserror 2.0.17",
+ "thiserror 2.0.20",
"web-sys",
]
@@ -8926,6 +10295,27 @@ dependencies = [
"windows-targets 0.52.6",
]
+[[package]]
+name = "windows"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"
+dependencies = [
+ "windows-collections",
+ "windows-core 0.62.2",
+ "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 0.62.2",
+]
+
[[package]]
name = "windows-core"
version = "0.56.0"
@@ -8964,6 +10354,17 @@ dependencies = [
"windows-strings 0.5.1",
]
+[[package]]
+name = "windows-future"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"
+dependencies = [
+ "windows-core 0.62.2",
+ "windows-link 0.2.1",
+ "windows-threading",
+]
+
[[package]]
name = "windows-implement"
version = "0.56.0"
@@ -9042,6 +10443,16 @@ 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 0.62.2",
+ "windows-link 0.2.1",
+]
+
[[package]]
name = "windows-registry"
version = "0.5.3"
@@ -9234,6 +10645,15 @@ dependencies = [
"windows_x86_64_msvc 0.53.1",
]
+[[package]]
+name = "windows-threading"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"
+dependencies = [
+ "windows-link 0.2.1",
+]
+
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
@@ -9453,6 +10873,15 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "winnow"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "winreg"
version = "0.10.1"
@@ -9483,6 +10912,18 @@ version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
+[[package]]
+name = "wnaf"
+version = "0.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "795ca18b3fdb5e62bf982199278341ddcf7ebf7d32e25e212ad05d496e95f6fa"
+dependencies = [
+ "ff",
+ "group",
+ "hybrid-array",
+ "primefield",
+]
+
[[package]]
name = "writeable"
version = "0.6.2"
@@ -9646,12 +11087,12 @@ dependencies = [
"futures-sink",
"futures-util",
"hex",
- "nix",
+ "nix 0.29.0",
"ordered-stream",
"rand 0.8.5",
"serde",
"serde_repr",
- "sha1",
+ "sha1 0.10.6",
"static_assertions",
"tracing",
"uds_windows",
@@ -9735,9 +11176,9 @@ dependencies = [
[[package]]
name = "zeroize"
-version = "1.8.2"
+version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
+checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"
[[package]]
name = "zerotrie"
diff --git a/Cargo.toml b/Cargo.toml
index 85ed7a07..8f2288ea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,6 +12,7 @@ members = [
"thinkterm-i18n",
"thinkterm-proto",
"thinkterm-render",
+ "thinkterm-mobile",
"thinkterm-session",
"thinkterm-web",
"thinkterm-tui",
@@ -317,6 +318,7 @@ wezterm-toast-notification = { path = "wezterm-toast-notification" }
wezterm-uds = { path = "wezterm-uds" }
wezterm-version = { path = "wezterm-version" }
wgpu = "25.0.2"
+uniffi = "0.32"
# The browser client. wasm-bindgen is pinned exactly: the CLI that emits
# the JavaScript glue must match the crate the wasm was built with.
wasm-bindgen = "=0.2.105"
diff --git a/thinkterm-mobile/Cargo.toml b/thinkterm-mobile/Cargo.toml
new file mode 100644
index 00000000..11a64a88
--- /dev/null
+++ b/thinkterm-mobile/Cargo.toml
@@ -0,0 +1,38 @@
+[package]
+name = "thinkterm-mobile"
+version = "0.1.0"
+edition = "2021"
+publish = false
+
+# The native-shell side of the mobile client: a core thread that owns the
+# GPU state, the session and (later) the App; a Send handle the shells call
+# through UniFFI; and the platform seams -- a surface from a CAMetalLayer or
+# an ANativeWindow, ssh as the transport, the shell's fonts for the glyphs
+# the bundled faces lack. S0/S0.5 scope: the thread model, the surface
+# lifecycle, and one real pane over ssh.
+
+[lib]
+crate-type = ["staticlib", "cdylib", "rlib"]
+
+[[bin]]
+name = "uniffi-bindgen"
+path = "src/bin/uniffi-bindgen.rs"
+
+[dependencies]
+anyhow.workspace = true
+bytemuck.workspace = true
+codec.workspace = true
+futures.workspace = true
+log.workspace = true
+russh = { version = "0.63.3", default-features = false, features = ["ring"] }
+termwiz = { workspace = true, features = ["use_serde"] }
+thinkterm-font-web.workspace = true
+thinkterm-proto.workspace = true
+thinkterm-render = { workspace = true, features = ["wgpu"] }
+thinkterm-session.workspace = true
+thinkterm-web.workspace = true
+tokio = { workspace = true, features = ["rt", "macros", "sync", "time", "net", "io-util"] }
+uniffi = { workspace = true, features = ["cli"] }
+wezterm-color-types.workspace = true
+wezterm-term = { workspace = true, features = ["use_serde"] }
+wgpu.workspace = true
diff --git a/thinkterm-mobile/src/bin/uniffi-bindgen.rs b/thinkterm-mobile/src/bin/uniffi-bindgen.rs
new file mode 100644
index 00000000..f6cff6cf
--- /dev/null
+++ b/thinkterm-mobile/src/bin/uniffi-bindgen.rs
@@ -0,0 +1,3 @@
+fn main() {
+ uniffi::uniffi_bindgen_main()
+}
diff --git a/thinkterm-mobile/src/core.rs b/thinkterm-mobile/src/core.rs
new file mode 100644
index 00000000..c16337ad
--- /dev/null
+++ b/thinkterm-mobile/src/core.rs
@@ -0,0 +1,1278 @@
+//! The core thread: owns the wgpu device, the current surface, the link to
+//! the server and the one pane the S0.5 slice shows. The shape is the one
+//! the plan fixes: device and pipeline outlive any surface; the surface is
+//! optional and carries a generation; drawing is a request the shell
+//! fulfils from its display callback; content changes -- the server's
+//! output, or the demo's clock -- only *ask* for a frame.
+//!
+//! The thread drives a `LocalPool` for the session's futures (the request
+//! answers, the input drain, the render-delta drain) and runs it after
+//! every event it handles. Nothing here waits on the shell.
+
+use crate::host::{Config, Events, MobileClock, MobileHost, Spawn};
+use crate::link::SshLink;
+use crate::painter::{GlyphPainter, MobilePlatform};
+use crate::ssh::{self, Net, Out, SshParams};
+use crate::terminal::{self, Attached, Terminal};
+use crate::Notify;
+use anyhow::{anyhow, Context, Result};
+use futures::executor::{LocalPool, LocalSpawner};
+use futures::task::LocalSpawnExt;
+use std::rc::Rc;
+use std::sync::mpsc::{Receiver, RecvTimeoutError, Sender};
+use std::sync::Arc;
+use std::time::{Duration, Instant};
+use thinkterm_font_web::{Face, FontSet};
+use thinkterm_render::pipeline::{
+ centred_projection, quad_indices, srgb_format, view_as, AtlasBindGroups, GpuTexture, Pipeline,
+ ShaderUniform,
+};
+use thinkterm_render::vertex::{Vertex, IS_SOLID_COLOR};
+use thinkterm_web::fallback::FallbackBudget;
+use thinkterm_web::glyphs::GlyphCache;
+use tokio::sync::mpsc::UnboundedSender;
+
+pub struct ConnectParams {
+ pub ssh: SshParams,
+ pub font_paths: Vec<String>,
+ pub size_pt: f64,
+}
+
+pub enum Cmd {
+ Attach {
+ layer: usize,
+ width: u32,
+ height: u32,
+ scale: f64,
+ reply: Sender<u64>,
+ },
+ Resize {
+ generation: u64,
+ width: u32,
+ height: u32,
+ scale: f64,
+ },
+ Detach {
+ generation: u64,
+ reply: Sender<()>,
+ },
+ Render,
+ Animate(bool),
+ Stats {
+ reply: Sender<String>,
+ },
+ Shutdown,
+ Connect {
+ params: ConnectParams,
+ painter: Box<dyn GlyphPainter>,
+ },
+ Disconnect,
+ /// From the network thread.
+ Net(Net),
+ /// The attach handshake finished (posted by its own future).
+ Attached(Result<Attached, String>),
+ /// The reattach handshake finished; `Err(true)` is permanent.
+ Reattached(Result<(), (String, bool)>),
+ Key {
+ name: String,
+ ctrl: bool,
+ alt: bool,
+ shift: bool,
+ },
+ Text(String),
+ Paste(String),
+ Scroll(i32),
+ Composing(bool),
+}
+
+/// Device-level state: survives surfaces coming and going.
+struct Gpu {
+ adapter: wgpu::Adapter,
+ device: wgpu::Device,
+ queue: Arc<wgpu::Queue>,
+ pipeline: Option<(wgpu::TextureFormat, Pipeline)>,
+ uniform_buffer: wgpu::Buffer,
+ vertex_buffer: wgpu::Buffer,
+ vertex_capacity: usize,
+ index_buffer: wgpu::Buffer,
+ index_quads: usize,
+ /// One white texel for solid quads drawn without an atlas.
+ white: Rc<GpuTexture>,
+ atlas_groups: Vec<(usize, AtlasBindGroups)>,
+ uniform_bind_group: Option<wgpu::BindGroup>,
+ adapter_name: String,
+}
+
+/// The surface currently attached, if any.
+struct Target {
+ surface: wgpu::Surface<'static>,
+ config: wgpu::SurfaceConfiguration,
+ view_format: wgpu::TextureFormat,
+ generation: u64,
+ scale: f64,
+}
+
+#[derive(Default)]
+struct Stats {
+ attaches: u64,
+ detaches: u64,
+ resizes: u64,
+ frames: u64,
+ frames_requested: u64,
+ errors: u64,
+ last_error: String,
+ last_frame_us: u128,
+ generation: u64,
+ phase: u64,
+ width: u32,
+ height: u32,
+ scale: f64,
+ bytes_in: u64,
+ pushes: u64,
+}
+
+/// The connection, from the shell's point of view.
+#[derive(Debug, Clone, PartialEq, Eq)]
+enum Conn {
+ Idle,
+ Connecting,
+ Attaching,
+ Ready,
+ /// Lost after being ready: trying to come back.
+ Reconnecting,
+ Disconnected(String),
+}
+
+const RECONNECT_MIN: Duration = Duration::from_millis(500);
+const RECONNECT_MAX: Duration = Duration::from_secs(10);
+const RECONNECT_GIVE_UP: u32 = 30;
+
+struct State {
+ cmd_tx: Sender<Cmd>,
+ instance: wgpu::Instance,
+ gpu: Option<Gpu>,
+ target: Option<Target>,
+ next_generation: u64,
+ animating: bool,
+ stats: Stats,
+ notify: Arc<dyn Notify>,
+ pool: LocalPool,
+ spawner: LocalSpawner,
+ clock: MobileClock,
+ link: SshLink,
+ host: Option<Arc<MobileHost>>,
+ net_out: Option<UnboundedSender<Out>>,
+ fonts: Option<Rc<FontSet>>,
+ platform: Option<Rc<MobilePlatform>>,
+ size_pt: f64,
+ /// The glyph cache built for the handshake, handed to the terminal
+ /// once the pane is known.
+ pending_glyphs: Option<GlyphCache>,
+ terminal: Option<Terminal>,
+ conn: Conn,
+ status: String,
+ /// What to dial again when the transport drops.
+ ssh_params: Option<SshParams>,
+ reconnect_at: Option<Instant>,
+ reconnect_delay: Duration,
+ reconnect_attempts: u32,
+}
+
+pub fn run(cmd_tx: Sender<Cmd>, rx: Receiver<Cmd>, notify: Box<dyn Notify>) {
+ let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
+ #[cfg(target_vendor = "apple")]
+ backends: wgpu::Backends::METAL,
+ #[cfg(not(target_vendor = "apple"))]
+ backends: wgpu::Backends::PRIMARY,
+ ..Default::default()
+ });
+ let pool = LocalPool::new();
+ let spawner = pool.spawner();
+ let notify: Arc<dyn Notify> = Arc::from(notify);
+ let mut state = State {
+ cmd_tx,
+ instance,
+ gpu: None,
+ target: None,
+ next_generation: 1,
+ animating: false,
+ stats: Stats::default(),
+ notify,
+ pool,
+ spawner,
+ clock: MobileClock::new(),
+ link: SshLink::new(),
+ host: None,
+ net_out: None,
+ fonts: None,
+ platform: None,
+ size_pt: 11.0,
+ pending_glyphs: None,
+ terminal: None,
+ conn: Conn::Idle,
+ status: String::new(),
+ ssh_params: None,
+ reconnect_at: None,
+ reconnect_delay: RECONNECT_MIN,
+ reconnect_attempts: 0,
+ };
+ state.notify.on_log("core thread up".into());
+ state.set_status("idle");
+
+ loop {
+ // While animating with a surface and no pane, the demo changes its
+ // scene every 100 ms and asks for a frame. Otherwise sleep until
+ // told; the session's futures are all woken through commands.
+ let mut wait = if state.animating && state.target.is_some() && state.terminal.is_none() {
+ Duration::from_millis(100)
+ } else {
+ Duration::from_secs(3600)
+ };
+ if let Some(at) = state.reconnect_at {
+ wait = wait.min(at.saturating_duration_since(Instant::now()));
+ }
+ match rx.recv_timeout(wait) {
+ Ok(Cmd::Shutdown) | Err(RecvTimeoutError::Disconnected) => break,
+ Ok(cmd) => state.handle(cmd),
+ Err(RecvTimeoutError::Timeout) => {
+ if state.reconnect_at.is_some_and(|at| Instant::now() >= at) {
+ state.reconnect_at = None;
+ state.try_reconnect();
+ } else if state.terminal.is_none() {
+ state.stats.phase = state.stats.phase.wrapping_add(1);
+ state.request_frame();
+ }
+ }
+ }
+ state.pool.run_until_stalled();
+ state.after_run();
+ }
+ state.disconnect();
+ state.target = None;
+ state.notify.on_log("core thread down".into());
+}
+
+impl State {
+ fn handle(&mut self, cmd: Cmd) {
+ match cmd {
+ Cmd::Attach {
+ layer,
+ width,
+ height,
+ scale,
+ reply,
+ } => {
+ let generation = match self.attach(layer, width, height, scale) {
+ Ok(generation) => generation,
+ Err(err) => {
+ self.fail(format!("attach: {err:#}"));
+ 0
+ }
+ };
+ let _ = reply.send(generation);
+ self.fit_terminal();
+ self.try_attach_pane();
+ }
+ Cmd::Resize {
+ generation,
+ width,
+ height,
+ scale,
+ } => {
+ self.resize(generation, width, height, scale);
+ self.fit_terminal();
+ }
+ Cmd::Detach { generation, reply } => {
+ self.detach(generation);
+ let _ = reply.send(());
+ }
+ Cmd::Render => {
+ if let Err(err) = self.render() {
+ self.fail(format!("render: {err:#}"));
+ }
+ }
+ Cmd::Animate(on) => {
+ self.animating = on;
+ if on {
+ self.request_frame();
+ }
+ }
+ Cmd::Stats { reply } => {
+ let _ = reply.send(self.stats_json());
+ }
+ Cmd::Shutdown => {}
+ Cmd::Connect { params, painter } => {
+ if let Err(err) = self.connect(params, painter) {
+ self.fail(format!("connect: {err:#}"));
+ self.conn = Conn::Disconnected(format!("{err:#}"));
+ self.set_status(&format!("failed: {err:#}"));
+ }
+ }
+ Cmd::Disconnect => {
+ self.disconnect();
+ self.set_status("disconnected");
+ }
+ Cmd::Net(net) => self.on_net(net),
+ Cmd::Attached(outcome) => self.on_attached(outcome),
+ Cmd::Reattached(outcome) => self.on_reattached(outcome),
+ Cmd::Key {
+ name,
+ ctrl,
+ alt,
+ shift,
+ } => {
+ if let Some(terminal) = self.terminal.as_mut() {
+ if !terminal.key(&name, ctrl, alt, shift) {
+ self.notify.on_log(format!("key {name:?} has no mapping"));
+ }
+ self.request_frame();
+ }
+ }
+ Cmd::Text(text) => {
+ if let Some(terminal) = self.terminal.as_mut() {
+ terminal.text(&text);
+ self.request_frame();
+ }
+ }
+ Cmd::Composing(on) => {
+ if let Some(terminal) = self.terminal.as_mut() {
+ terminal.composing = on;
+ }
+ }
+ Cmd::Paste(text) => {
+ if let Some(terminal) = self.terminal.as_mut() {
+ terminal.paste(&text);
+ self.request_frame();
+ }
+ }
+ Cmd::Scroll(lines) => {
+ if let Some(terminal) = self.terminal.as_mut() {
+ terminal.scroll_lines(lines);
+ self.request_frame();
+ }
+ }
+ }
+ }
+
+ /// After the executor ran: pushes the link collected while futures
+ /// were answering, and dirty panes.
+ fn after_run(&mut self) {
+ let pushes = self.link.take_pushes();
+ if !pushes.is_empty() {
+ self.stats.pushes += pushes.len() as u64;
+ let mut repaint = false;
+ for pdu in pushes {
+ if let Some(terminal) = self.terminal.as_mut() {
+ repaint |= terminal.on_push(pdu);
+ }
+ }
+ // A push may have queued futures (render deltas): run them now
+ // so the frame that follows sees their lines.
+ self.pool.run_until_stalled();
+ if repaint {
+ self.request_frame();
+ }
+ }
+ if let Some(host) = &self.host {
+ if !host.events.take_dirty().is_empty() {
+ self.request_frame();
+ }
+ }
+ }
+
+ fn fail(&mut self, message: String) {
+ self.stats.errors += 1;
+ self.stats.last_error = message.clone();
+ self.notify.on_log(message);
+ }
+
+ fn set_status(&mut self, status: &str) {
+ if self.status != status {
+ self.status = status.to_string();
+ self.notify.on_status(self.status.clone());
+ }
+ }
+
+ fn request_frame(&mut self) {
+ self.stats.frames_requested += 1;
+ self.notify.on_frame_needed();
+ }
+
+ // ----- connection -----
+
+ fn connect(&mut self, params: ConnectParams, painter: Box<dyn GlyphPainter>) -> Result<()> {
+ self.disconnect();
+ let mut faces = Vec::new();
+ for path in &params.font_paths {
+ let bytes = std::fs::read(path).with_context(|| format!("reading the font {path}"))?;
+ let name = std::path::Path::new(path)
+ .file_stem()
+ .and_then(|s| s.to_str())
+ .unwrap_or("font")
+ .to_string();
+ faces.push(Face::new(&name, bytes, 0).with_context(|| name.clone())?);
+ }
+ anyhow::ensure!(!faces.is_empty(), "no fonts given");
+ self.fonts = Some(Rc::new(FontSet::new(faces)?));
+ self.size_pt = params.size_pt;
+ self.platform = Some(Rc::new(MobilePlatform::new(painter, self.clock)));
+
+ let host = Arc::new(MobileHost {
+ clock: self.clock,
+ spawner: Spawn(self.spawner.clone()),
+ events: Events::default(),
+ link: self.link.clone(),
+ config: Config::default(),
+ });
+ let notify = Arc::clone(&self.notify);
+ host.events
+ .set_wake(Rc::new(move || notify.on_frame_needed()));
+ self.host = Some(host);
+
+ let tx = self.cmd_tx.clone();
+ let deliver: Box<dyn Fn(Net) + Send> = Box::new(move |net| {
+ let _ = tx.send(Cmd::Net(net));
+ });
+ self.net_out = Some(ssh::spawn(params.ssh.clone(), deliver));
+ self.ssh_params = Some(params.ssh.clone());
+ self.reconnect_attempts = 0;
+ self.reconnect_delay = RECONNECT_MIN;
+ self.reconnect_at = None;
+ self.conn = Conn::Connecting;
+ self.set_status(&format!(
+ "connecting to {}@{}:{}",
+ params.ssh.user, params.ssh.host, params.ssh.port
+ ));
+ Ok(())
+ }
+
+ fn disconnect(&mut self) {
+ if let Some(out) = self.net_out.take() {
+ let _ = out.send(Out::Close);
+ }
+ self.link.closed();
+ self.terminal = None;
+ self.pending_glyphs = None;
+ self.ssh_params = None;
+ self.reconnect_at = None;
+ self.conn = Conn::Idle;
+ }
+
+ // ----- reconnecting -----
+
+ /// The transport dropped under a live pane: keep the pane, dial again.
+ fn lost(&mut self, reason: &str) {
+ if let Some(terminal) = &self.terminal {
+ terminal.session.set_dead(true);
+ }
+ self.conn = Conn::Reconnecting;
+ self.schedule_reconnect(Duration::ZERO);
+ self.set_status(&format!("connection lost ({reason}); reconnecting"));
+ self.request_frame();
+ }
+
+ fn schedule_reconnect(&mut self, delay: Duration) {
+ if self.reconnect_at.is_none() {
+ self.reconnect_at = Some(Instant::now() + delay);
+ }
+ }
+
+ fn try_reconnect(&mut self) {
+ if self.conn != Conn::Reconnecting {
+ return;
+ }
+ let Some(params) = self.ssh_params.clone() else {
+ return;
+ };
+ if self.reconnect_attempts >= RECONNECT_GIVE_UP {
+ self.conn = Conn::Disconnected("gave up reconnecting".into());
+ self.set_status(&format!(
+ "still disconnected after {} attempts; reconnect by hand",
+ self.reconnect_attempts
+ ));
+ return;
+ }
+ self.reconnect_attempts += 1;
+ self.notify
+ .on_log(format!("reconnect attempt {}", self.reconnect_attempts));
+ let tx = self.cmd_tx.clone();
+ let deliver: Box<dyn Fn(Net) + Send> = Box::new(move |net| {
+ let _ = tx.send(Cmd::Net(net));
+ });
+ self.net_out = Some(ssh::spawn(params, deliver));
+ }
+
+ fn reconnect_failed(&mut self, reason: &str, permanent: bool) {
+ if permanent {
+ self.conn = Conn::Disconnected(reason.to_string());
+ self.set_status(&format!("not reconnecting: {reason}"));
+ if let Some(out) = self.net_out.take() {
+ let _ = out.send(Out::Close);
+ }
+ return;
+ }
+ self.reconnect_delay = (self.reconnect_delay * 2).clamp(RECONNECT_MIN, RECONNECT_MAX);
+ let delay = self.reconnect_delay;
+ self.notify.on_log(format!(
+ "reconnect failed ({reason}); retrying in {delay:?}"
+ ));
+ self.conn = Conn::Reconnecting;
+ self.schedule_reconnect(delay);
+ }
+
+ /// The transport is up again: run the reattach handshake on it.
+ fn start_reattach(&mut self) {
+ let Some(terminal) = self.terminal.as_ref() else {
+ return;
+ };
+ let size = self.target.as_ref().map(|_| terminal.size());
+ let (tab_id, pane_id) = (terminal.tab_id, terminal.pane_id);
+ let link = self.link.clone();
+ let tx = self.cmd_tx.clone();
+ let spawned = self.spawner.spawn_local(async move {
+ let outcome = terminal::reattach(&link, tab_id, pane_id, size)
+ .await
+ .map(|_| ())
+ .map_err(|err| {
+ let permanent = err.downcast_ref::<terminal::NoPanes>().is_some()
+ || err.to_string().contains("update the server or the app");
+ (format!("{err:#}"), permanent)
+ });
+ let _ = tx.send(Cmd::Reattached(outcome));
+ });
+ if let Err(err) = spawned {
+ self.fail(format!("spawning the reattach: {err}"));
+ }
+ }
+
+ fn on_reattached(&mut self, outcome: Result<(), (String, bool)>) {
+ match outcome {
+ Ok(()) => {
+ self.reconnect_attempts = 0;
+ self.reconnect_delay = RECONNECT_MIN;
+ let pane = self.terminal.as_mut().map(|terminal| {
+ terminal.reconnected();
+ terminal.pane_id
+ });
+ if let Some(pane) = pane {
+ self.conn = Conn::Ready;
+ self.set_status(&format!("pane {pane} · reconnected"));
+ }
+ self.request_frame();
+ }
+ Err((reason, permanent)) => self.reconnect_failed(&reason, permanent),
+ }
+ }
+
+ fn on_net(&mut self, net: Net) {
+ match net {
+ Net::Connected => {
+ if let Some(out) = self.net_out.clone() {
+ self.link.opened(out);
+ }
+ if self.conn == Conn::Reconnecting && self.terminal.is_some() {
+ self.set_status("reconnected; reattaching");
+ self.start_reattach();
+ } else {
+ self.conn = Conn::Attaching;
+ self.set_status("connected; attaching");
+ self.try_attach_pane();
+ }
+ }
+ Net::Data(bytes) => {
+ self.stats.bytes_in += bytes.len() as u64;
+ if let Err(err) = self.link.feed(&bytes) {
+ self.fail(format!("link: {err:#}"));
+ self.conn = Conn::Disconnected(format!("{err:#}"));
+ self.set_status(&format!("disconnected: {err:#}"));
+ }
+ }
+ Net::Stderr(text) => self.notify.on_log(format!("remote: {}", text.trim_end())),
+ Net::Exit(code) => self
+ .notify
+ .on_log(format!("remote command exited with {code}")),
+ Net::Closed(reason) => {
+ self.link.closed();
+ self.net_out = None;
+ self.pending_glyphs = None;
+ match self.conn {
+ Conn::Ready => self.lost(&reason),
+ Conn::Reconnecting => self.reconnect_failed(&reason, false),
+ _ => {
+ self.conn = Conn::Disconnected(reason.clone());
+ self.set_status(&format!("disconnected: {reason}"));
+ self.request_frame();
+ }
+ }
+ }
+ }
+ }
+
+ /// Start the handshake once the link is open and the GPU and fonts
+ /// exist (the glyph metrics decide the grid to report).
+ fn try_attach_pane(&mut self) {
+ if self.conn != Conn::Attaching || self.pending_glyphs.is_some() || self.terminal.is_some()
+ {
+ return;
+ }
+ if !self.link.is_open() {
+ return;
+ }
+ let (Some(gpu), Some(fonts), Some(platform)) = (&self.gpu, &self.fonts, &self.platform)
+ else {
+ return;
+ };
+ let scale = self.target.as_ref().map(|t| t.scale).unwrap_or(1.0);
+ // `size_pt` is in the platform's points (1/72 in on iOS), so the
+ // dpi is 72 per unit of scale -- not the browser's 96, which would
+ // make 11 pt a 44 px face on a 3x screen.
+ let dpi = (72.0 * scale) as u32;
+ let side = 1024u32.min(gpu.device.limits().max_texture_dimension_2d);
+ let texture = match GpuTexture::new(&gpu.device, Arc::clone(&gpu.queue), side, side) {
+ Ok(t) => Rc::new(t),
+ Err(err) => {
+ self.fail(format!("atlas: {err:#}"));
+ return;
+ }
+ };
+ let glyphs = match GlyphCache::new(
+ Rc::clone(fonts),
+ self.size_pt,
+ dpi,
+ texture,
+ Rc::from(""),
+ Rc::clone(platform) as thinkterm_web::raster::Platform,
+ ) {
+ Ok(g) => g,
+ Err(err) => {
+ self.fail(format!("glyph cache: {err:#}"));
+ return;
+ }
+ };
+ let (cw, ch) = (
+ glyphs.metrics.cell_size.width as u32,
+ glyphs.metrics.cell_size.height as u32,
+ );
+ let size = self.target.as_ref().and_then(|t| {
+ terminal::grid_for(t.config.width, t.config.height, cw, ch).map(|(cols, rows)| {
+ wezterm_term::TerminalSize {
+ rows,
+ cols,
+ pixel_width: cols * cw as usize,
+ pixel_height: rows * ch as usize,
+ dpi,
+ }
+ })
+ });
+ self.pending_glyphs = Some(glyphs);
+ self.notify.on_log(format!(
+ "cell {cw}x{ch} px at {} pt, {dpi} dpi; reporting {:?}",
+ self.size_pt,
+ size.map(|s| (s.cols, s.rows))
+ ));
+ let link = self.link.clone();
+ let tx = self.cmd_tx.clone();
+ let wall = thinkterm_session::clock::Clock::wall_millis(&self.clock);
+ let spawned = self.spawner.spawn_local(async move {
+ let outcome = terminal::attach(&link, size, wall)
+ .await
+ .map_err(|e| format!("{e:#}"));
+ let _ = tx.send(Cmd::Attached(outcome));
+ });
+ if let Err(err) = spawned {
+ self.fail(format!("spawning the handshake: {err}"));
+ }
+ }
+
+ fn on_attached(&mut self, outcome: Result<Attached, String>) {
+ let Some(glyphs) = self.pending_glyphs.take() else {
+ return;
+ };
+ match outcome {
+ Ok(attached) => {
+ let Some(host) = self.host.clone() else {
+ return;
+ };
+ let (cw, ch) = (
+ glyphs.metrics.cell_size.width as u32,
+ glyphs.metrics.cell_size.height as u32,
+ );
+ let (cols, rows) = self
+ .target
+ .as_ref()
+ .and_then(|t| terminal::grid_for(t.config.width, t.config.height, cw, ch))
+ .unwrap_or((attached.dims.cols, attached.dims.viewport_rows));
+ let dpi = glyphs.dpi;
+ self.notify.on_log(format!(
+ "attached to pane {} in tab {} on {} ({cols}x{rows}), server {}",
+ attached.pane_id, attached.tab_id, attached.server_version, attached.server_id
+ ));
+ self.terminal = Some(Terminal::new(host, glyphs, &attached, cols, rows, dpi));
+ self.conn = Conn::Ready;
+ self.set_status(&format!("pane {} · {}", attached.pane_id, attached.title));
+ self.request_frame();
+ }
+ Err(err) => {
+ self.fail(format!("attach: {err}"));
+ self.conn = Conn::Disconnected(err.clone());
+ self.set_status(&format!("attach failed: {err}"));
+ if let Some(out) = self.net_out.take() {
+ let _ = out.send(Out::Close);
+ }
+ }
+ }
+ }
+
+ /// The grid follows the surface.
+ fn fit_terminal(&mut self) {
+ let Some(target) = self.target.as_ref() else {
+ return;
+ };
+ let (w, h) = (target.config.width, target.config.height);
+ let Some(terminal) = self.terminal.as_mut() else {
+ return;
+ };
+ let (cw, ch) = terminal.cell_size();
+ if let Some((cols, rows)) = terminal::grid_for(w, h, cw, ch) {
+ if terminal.resize(cols, rows) {
+ self.request_frame();
+ }
+ }
+ }
+
+ // ----- surface -----
+
+ fn attach(&mut self, layer: usize, width: u32, height: u32, scale: f64) -> Result<u64> {
+ if self.target.is_some() {
+ anyhow::bail!("a surface is already attached; detach it first");
+ }
+ let surface = self.surface_from_layer(layer)?;
+ if self.gpu.is_none() {
+ self.gpu = Some(Self::make_gpu(&self.instance, &surface)?);
+ let name = self.gpu.as_ref().unwrap().adapter_name.clone();
+ self.notify.on_log(format!("gpu ready: {name}"));
+ }
+ let gpu = self.gpu.as_mut().unwrap();
+ let caps = surface.get_capabilities(&gpu.adapter);
+ let format = caps
+ .formats
+ .iter()
+ .copied()
+ .find(|f| matches!(f, wgpu::TextureFormat::Bgra8Unorm))
+ .or_else(|| caps.formats.first().copied())
+ .ok_or_else(|| anyhow!("the surface offers no texture format"))?;
+ let view_format = srgb_format(format);
+ let config = wgpu::SurfaceConfiguration {
+ usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
+ format,
+ width: width.max(1),
+ height: height.max(1),
+ present_mode: wgpu::PresentMode::Fifo,
+ alpha_mode: wgpu::CompositeAlphaMode::Opaque,
+ view_formats: vec![view_format],
+ desired_maximum_frame_latency: 2,
+ };
+ surface.configure(&gpu.device, &config);
+ gpu.ensure_pipeline(view_format);
+
+ let generation = self.next_generation;
+ self.next_generation += 1;
+ self.target = Some(Target {
+ surface,
+ config,
+ view_format,
+ generation,
+ scale,
+ });
+ self.stats.attaches += 1;
+ self.stats.generation = generation;
+ self.stats.width = width;
+ self.stats.height = height;
+ self.stats.scale = scale;
+ self.notify.on_log(format!(
+ "attached generation {generation}: {width}x{height} @{scale} {format:?}"
+ ));
+ self.request_frame();
+ Ok(generation)
+ }
+
+ #[cfg(target_vendor = "apple")]
+ fn surface_from_layer(&self, layer: usize) -> Result<wgpu::Surface<'static>> {
+ if layer == 0 {
+ anyhow::bail!("null layer");
+ }
+ // SAFETY: the shell passes an unretained CAMetalLayer pointer and
+ // guarantees the layer outlives the surface: it calls
+ // `detach_surface` -- which drops this surface before returning --
+ // ahead of releasing the layer.
+ unsafe {
+ self.instance
+ .create_surface_unsafe(wgpu::SurfaceTargetUnsafe::CoreAnimationLayer(
+ layer as *mut std::ffi::c_void,
+ ))
+ }
+ .context("creating the Metal surface")
+ }
+
+ #[cfg(not(target_vendor = "apple"))]
+ fn surface_from_layer(&self, _layer: usize) -> Result<wgpu::Surface<'static>> {
+ anyhow::bail!("no surface source on this platform yet")
+ }
+
+ fn make_gpu(instance: &wgpu::Instance, surface: &wgpu::Surface<'static>) -> Result<Gpu> {
+ let adapter =
+ futures::executor::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
+ power_preference: wgpu::PowerPreference::HighPerformance,
+ compatible_surface: Some(surface),
+ force_fallback_adapter: false,
+ }))
+ .context("requesting a GPU adapter")?;
+ let (device, queue) =
+ futures::executor::block_on(adapter.request_device(&wgpu::DeviceDescriptor {
+ label: Some("thinkterm-mobile"),
+ required_features: wgpu::Features::empty(),
+ required_limits:
+ wgpu::Limits::downlevel_defaults().using_resolution(adapter.limits()),
+ memory_hints: wgpu::MemoryHints::Performance,
+ trace: wgpu::Trace::Off,
+ }))
+ .context("requesting the GPU device")?;
+ let queue = Arc::new(queue);
+ let uniform_buffer = device.create_buffer(&wgpu::BufferDescriptor {
+ label: Some("ShaderUniform"),
+ size: std::mem::size_of::<ShaderUniform>() as u64,
+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
+ mapped_at_creation: false,
+ });
+ let vertex_capacity = 4096;
+ let vertex_buffer = Self::make_vertex_buffer(&device, vertex_capacity);
+ let index_quads = 1024;
+ let index_buffer = Self::make_index_buffer(&device, &queue, index_quads);
+ let white = GpuTexture::new(&device, Arc::clone(&queue), 1, 1)?;
+ queue.write_texture(
+ wgpu::TexelCopyTextureInfo {
+ texture: white.texture(),
+ mip_level: 0,
+ origin: wgpu::Origin3d::ZERO,
+ aspect: wgpu::TextureAspect::All,
+ },
+ &[255, 255, 255, 255],
+ wgpu::TexelCopyBufferLayout {
+ offset: 0,
+ bytes_per_row: Some(4),
+ rows_per_image: Some(1),
+ },
+ wgpu::Extent3d {
+ width: 1,
+ height: 1,
+ depth_or_array_layers: 1,
+ },
+ );
+ let adapter_name = {
+ let info = adapter.get_info();
+ format!("{} ({:?})", info.name, info.backend)
+ };
+ Ok(Gpu {
+ adapter,
+ device,
+ queue,
+ pipeline: None,
+ uniform_buffer,
+ vertex_buffer,
+ vertex_capacity,
+ index_buffer,
+ index_quads,
+ white: Rc::new(white),
+ atlas_groups: Vec::new(),
+ uniform_bind_group: None,
+ adapter_name,
+ })
+ }
+
+ fn make_vertex_buffer(device: &wgpu::Device, capacity: usize) -> wgpu::Buffer {
+ device.create_buffer(&wgpu::BufferDescriptor {
+ label: Some("vertices"),
+ size: (capacity * std::mem::size_of::<Vertex>()) as u64,
+ usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::COPY_DST,
+ mapped_at_creation: false,
+ })
+ }
+
+ fn make_index_buffer(device: &wgpu::Device, queue: &wgpu::Queue, quads: usize) -> wgpu::Buffer {
+ let indices = quad_indices(quads);
+ let buffer = device.create_buffer(&wgpu::BufferDescriptor {
+ label: Some("indices"),
+ size: (indices.len() * std::mem::size_of::<u32>()) as u64,
+ usage: wgpu::BufferUsages::INDEX | wgpu::BufferUsages::COPY_DST,
+ mapped_at_creation: false,
+ });
+ queue.write_buffer(&buffer, 0, bytemuck::cast_slice(&indices));
+ buffer
+ }
+
+ fn resize(&mut self, generation: u64, width: u32, height: u32, scale: f64) {
+ let Some(target) = self.target.as_mut() else {
+ return;
+ };
+ if target.generation != generation {
+ self.notify.on_log(format!(
+ "resize for stale generation {generation} ignored (current {})",
+ target.generation
+ ));
+ return;
+ }
+ let (width, height) = (width.max(1), height.max(1));
+ target.scale = scale;
+ self.stats.scale = scale;
+ if (width, height) == (target.config.width, target.config.height) {
+ return;
+ }
+ target.config.width = width;
+ target.config.height = height;
+ let gpu = self.gpu.as_ref().expect("gpu exists while a target does");
+ target.surface.configure(&gpu.device, &target.config);
+ self.stats.resizes += 1;
+ self.stats.width = width;
+ self.stats.height = height;
+ self.request_frame();
+ }
+
+ fn detach(&mut self, generation: u64) {
+ match self.target.take() {
+ Some(target) if target.generation == generation => {
+ drop(target);
+ self.stats.detaches += 1;
+ self.notify
+ .on_log(format!("detached generation {generation}"));
+ }
+ Some(target) => {
+ let current = target.generation;
+ self.target = Some(target);
+ self.notify.on_log(format!(
+ "detach for stale generation {generation} ignored (current {current})"
+ ));
+ }
+ None => self
+ .notify
+ .on_log(format!("detach {generation}: nothing attached")),
+ }
+ }
+
+ // ----- frames -----
+
+ fn render(&mut self) -> Result<()> {
+ let Some(target) = self.target.as_mut() else {
+ // A frame requested before the surface came, or after it went:
+ // nothing to draw on, and nothing to do.
+ return Ok(());
+ };
+ let gpu = self.gpu.as_mut().expect("gpu exists while a target does");
+ let started = Instant::now();
+ let (w, h) = (target.config.width, target.config.height);
+
+ let (vertices, texture, background): (Vec<Vertex>, Rc<GpuTexture>, [f32; 4]) =
+ match (self.terminal.as_mut(), self.platform.as_ref()) {
+ (Some(terminal), Some(platform)) => {
+ let mut budget = FallbackBudget::new(
+ thinkterm_web::raster::GlyphPlatform::now_ms(&**platform),
+ );
+ let (vertices, bg) = {
+ let (vertices, _, bg) = terminal.paint((w, h), &mut budget)?;
+ (vertices.to_vec(), bg.tuple())
+ };
+ // Glyphs the budget put off are owed to the next frame.
+ let owed = budget.deferred() + terminal.glyphs.declined();
+ if owed > 0 {
+ self.stats.frames_requested += 1;
+ self.notify.on_frame_needed();
+ }
+ (
+ vertices,
+ terminal.glyphs.texture_rc(),
+ [bg.0, bg.1, bg.2, bg.3],
+ )
+ }
+ _ => (
+ demo_scene(w as f32, h as f32, target.scale as f32, self.stats.phase),
+ Rc::clone(&gpu.white),
+ [0.07, 0.07, 0.09, 1.0],
+ ),
+ };
+
+ let uniforms = ShaderUniform {
+ foreground_text_hsb: [1.0, 1.0, 1.0],
+ milliseconds: (started.elapsed().as_millis() % u32::MAX as u128) as u32,
+ viewport_and_corner: [w as f32, h as f32, 0.0, 0.0],
+ window_border: [0.0; 4],
+ projection: centred_projection(w as f32, h as f32),
+ };
+ gpu.queue
+ .write_buffer(&gpu.uniform_buffer, 0, bytemuck::bytes_of(&uniforms));
+ let quads = gpu.upload_vertices(&vertices);
+ let group = gpu.atlas_groups(&texture);
+
+ let frame = match target.surface.get_current_texture() {
+ Ok(frame) => frame,
+ Err(wgpu::SurfaceError::Lost) | Err(wgpu::SurfaceError::Outdated) => {
+ target.surface.configure(&gpu.device, &target.config);
+ target
+ .surface
+ .get_current_texture()
+ .context("acquiring the frame after reconfiguring")?
+ }
+ Err(wgpu::SurfaceError::Timeout) => {
+ self.notify.on_log("frame skipped: surface timeout".into());
+ return Ok(());
+ }
+ Err(err) => return Err(anyhow!("acquiring the frame: {err}")),
+ };
+ let view = view_as(&frame.texture, target.view_format);
+ let pipeline = &gpu.pipeline.as_ref().expect("pipeline built at attach").1;
+ let groups = &gpu.atlas_groups[group].1;
+ let uniform_group = gpu
+ .uniform_bind_group
+ .as_ref()
+ .expect("uniform group built at attach");
+ let mut encoder = gpu
+ .device
+ .create_command_encoder(&wgpu::CommandEncoderDescriptor {
+ label: Some("frame"),
+ });
+ {
+ let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
+ label: Some("pane"),
+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {
+ view: &view,
+ resolve_target: None,
+ ops: wgpu::Operations {
+ load: wgpu::LoadOp::Clear(wgpu::Color {
+ r: background[0] as f64,
+ g: background[1] as f64,
+ b: background[2] as f64,
+ a: 1.0,
+ }),
+ store: wgpu::StoreOp::Store,
+ },
+ })],
+ depth_stencil_attachment: None,
+ timestamp_writes: None,
+ occlusion_query_set: None,
+ });
+ if quads > 0 {
+ pass.set_pipeline(&pipeline.render_pipeline);
+ pass.set_bind_group(0, uniform_group, &[]);
+ pass.set_bind_group(1, &groups.linear, &[]);
+ pass.set_bind_group(2, &groups.nearest, &[]);
+ pass.set_vertex_buffer(0, gpu.vertex_buffer.slice(..));
+ pass.set_index_buffer(gpu.index_buffer.slice(..), wgpu::IndexFormat::Uint32);
+ pass.draw_indexed(0..(quads * 6) as u32, 0, 0..1);
+ }
+ }
+ gpu.queue.submit(Some(encoder.finish()));
+ frame.present();
+ self.stats.frames += 1;
+ self.stats.last_frame_us = started.elapsed().as_micros();
+ Ok(())
+ }
+
+ fn stats_json(&self) -> String {
+ let s = &self.stats;
+ let adapter = self
+ .gpu
+ .as_ref()
+ .map(|g| g.adapter_name.clone())
+ .unwrap_or_default();
+ let grid = self
+ .terminal
+ .as_ref()
+ .map(|t| format!("{}x{}", t.cols, t.rows))
+ .unwrap_or_default();
+ let (inputs, composing) = self
+ .terminal
+ .as_ref()
+ .map(|t| (t.inputs_sent, t.composing))
+ .unwrap_or((0, false));
+ format!(
+ "{{\"attached\":{},\"generation\":{},\"size\":\"{}x{}@{}\",\"attaches\":{},\"detaches\":{},\"resizes\":{},\"frames\":{},\"frames_requested\":{},\"last_frame_us\":{},\"phase\":{},\"animating\":{},\"errors\":{},\"last_error\":{:?},\"adapter\":{:?},\"conn\":{:?},\"grid\":{:?},\"bytes_in\":{},\"pushes\":{},\"inputs_sent\":{},\"composing\":{}}}",
+ self.target.is_some(),
+ s.generation,
+ s.width,
+ s.height,
+ s.scale,
+ s.attaches,
+ s.detaches,
+ s.resizes,
+ s.frames,
+ s.frames_requested,
+ s.last_frame_us,
+ s.phase,
+ self.animating,
+ s.errors,
+ s.last_error,
+ adapter,
+ format!("{:?}", self.conn),
+ grid,
+ s.bytes_in,
+ s.pushes,
+ inputs,
+ composing,
+ )
+ }
+}
+
+impl Gpu {
+ fn ensure_pipeline(&mut self, view_format: wgpu::TextureFormat) {
+ let stale = self
+ .pipeline
+ .as_ref()
+ .map(|(format, _)| *format != view_format)
+ .unwrap_or(true);
+ if stale {
+ let pipeline = Pipeline::new(&self.device, view_format);
+ self.uniform_bind_group =
+ Some(pipeline.uniform_bind_group(&self.device, &self.uniform_buffer));
+ self.pipeline = Some((view_format, pipeline));
+ self.atlas_groups.clear();
+ }
+ }
+
+ /// Bind groups for `atlas`, made on first sight and kept for a few.
+ fn atlas_groups(&mut self, atlas: &GpuTexture) -> usize {
+ let identity = atlas.id();
+ if let Some(i) = self.atlas_groups.iter().position(|(id, _)| *id == identity) {
+ return i;
+ }
+ if self.atlas_groups.len() >= 8 {
+ self.atlas_groups.remove(0);
+ }
+ let pipeline = &self.pipeline.as_ref().expect("pipeline built at attach").1;
+ let groups = pipeline.atlas_bind_groups(&self.device, &atlas.view());
+ self.atlas_groups.push((identity, groups));
+ self.atlas_groups.len() - 1
+ }
+
+ fn upload_vertices(&mut self, vertices: &[Vertex]) -> usize {
+ let quads = vertices.len() / 4;
+ if vertices.len() > self.vertex_capacity {
+ self.vertex_capacity = vertices.len().next_power_of_two();
+ self.vertex_buffer = State::make_vertex_buffer(&self.device, self.vertex_capacity);
+ }
+ if quads > self.index_quads {
+ self.index_quads = quads.next_power_of_two();
+ self.index_buffer =
+ State::make_index_buffer(&self.device, &self.queue, self.index_quads);
+ }
+ if !vertices.is_empty() {
+ self.queue
+ .write_buffer(&self.vertex_buffer, 0, bytemuck::cast_slice(vertices));
+ }
+ quads
+ }
+}
+
+/// A grid of coloured cells the size a terminal's would be, one of them
+/// walking across with the phase, and a bar along the bottom whose length
+/// follows the width. Enough to see, in a screenshot, that the projection,
+/// the scale and a resize all land where they should.
+fn demo_scene(width: f32, height: f32, scale: f32, phase: u64) -> Vec<Vertex> {
+ let mut out = Vec::new();
+ let cell_w = 9.0 * scale;
+ let cell_h = 20.0 * scale;
+ let cols = ((width - 2.0 * cell_w) / cell_w).floor().max(1.0) as u64;
+ let rows = ((height - 4.0 * cell_h) / cell_h).floor().max(1.0) as u64;
+ let x0 = cell_w;
+ let y0 = cell_h * 2.0;
+ for row in 0..rows {
+ for col in 0..cols {
+ let i = row * cols + col;
+ let lit = (i + phase) % 7 == 0;
+ let color = if lit {
+ let hue = ((i * 37 + phase * 5) % 360) as f32;
+ hsl(hue, 0.7, 0.55)
+ } else {
+ [0.16, 0.16, 0.20, 1.0]
+ };
+ push_rect(
+ &mut out,
+ width,
+ height,
+ x0 + col as f32 * cell_w,
+ y0 + row as f32 * cell_h,
+ cell_w - 1.0 * scale,
+ cell_h - 1.0 * scale,
+ color,
+ );
+ }
+ }
+ let walker = (phase % cols.max(1)) as f32;
+ push_rect(
+ &mut out,
+ width,
+ height,
+ x0 + walker * cell_w,
+ cell_h * 0.5,
+ cell_w,
+ cell_h,
+ [1.0, 0.85, 0.2, 1.0],
+ );
+ push_rect(
+ &mut out,
+ width,
+ height,
+ x0,
+ height - cell_h * 1.5,
+ width - 2.0 * x0,
+ cell_h * 0.5,
+ [0.3, 0.7, 1.0, 1.0],
+ );
+ out
+}
+
+#[allow(clippy::too_many_arguments)]
+fn push_rect(
+ out: &mut Vec<Vertex>,
+ width: f32,
+ height: f32,
+ x: f32,
+ y: f32,
+ w: f32,
+ h: f32,
+ color: [f32; 4],
+) {
+ // The projection is centred: pixel (0,0) is at (-width/2, -height/2).
+ let left = x - width / 2.0;
+ let top = y - height / 2.0;
+ let right = left + w;
+ let bottom = top + h;
+ let vertex = |px: f32, py: f32| Vertex {
+ position: [px, py],
+ tex: [0.0, 0.0],
+ fg_color: color,
+ alt_color: color,
+ hsv: [1.0, 1.0, 1.0],
+ has_color: IS_SOLID_COLOR,
+ mix_value: 0.0,
+ };
+ // Order matches thinkterm_render::vertex::{V_TOP_LEFT, V_TOP_RIGHT,
+ // V_BOT_LEFT, V_BOT_RIGHT}, which quad_indices assumes.
+ out.push(vertex(left, top));
+ out.push(vertex(right, top));
+ out.push(vertex(left, bottom));
+ out.push(vertex(right, bottom));
+}
+
+fn hsl(h: f32, s: f32, l: f32) -> [f32; 4] {
+ let c = (1.0 - (2.0 * l - 1.0).abs()) * s;
+ let hp = h / 60.0;
+ let x = c * (1.0 - ((hp % 2.0) - 1.0).abs());
+ let (r, g, b) = match hp as u32 {
+ 0 => (c, x, 0.0),
+ 1 => (x, c, 0.0),
+ 2 => (0.0, c, x),
+ 3 => (0.0, x, c),
+ 4 => (x, 0.0, c),
+ _ => (c, 0.0, x),
+ };
+ let m = l - c / 2.0;
+ [r + m, g + m, b + m, 1.0]
+}
diff --git a/thinkterm-mobile/src/host.rs b/thinkterm-mobile/src/host.rs
new file mode 100644
index 00000000..04220cbe
--- /dev/null
+++ b/thinkterm-mobile/src/host.rs
@@ -0,0 +1,156 @@
+//! The session layer's view of the core thread: a monotonic clock, a
+//! spawner onto the thread's own executor, the dirty-pane events that turn
+//! into frame requests, and the configuration the browser client uses.
+
+use crate::link::SshLink;
+use futures::executor::LocalSpawner;
+use futures::task::LocalSpawnExt;
+use std::cell::RefCell;
+use std::collections::HashSet;
+use std::rc::Rc;
+use std::sync::Arc;
+use std::time::Instant;
+use thinkterm_session::clock::{Clock, Timestamp};
+use thinkterm_session::host::{
+ DetachedFuture, HostConfig, HostPaneId, ImageDomainKey, SessionEvents, SessionHost, Spawner,
+};
+
+#[derive(Clone, Copy)]
+pub struct MobileClock {
+ start: Instant,
+}
+
+impl MobileClock {
+ pub fn new() -> Self {
+ Self {
+ start: Instant::now(),
+ }
+ }
+
+ pub fn now_ms(&self) -> f64 {
+ self.start.elapsed().as_secs_f64() * 1000.0
+ }
+}
+
+impl Clock for MobileClock {
+ fn now(&self) -> Timestamp {
+ Timestamp::from_micros(self.start.elapsed().as_micros() as u64)
+ }
+
+ fn wall_millis(&self) -> u64 {
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map(|d| d.as_millis() as u64)
+ .unwrap_or(0)
+ }
+}
+
+/// Futures the session detaches run on the core thread's `LocalPool`,
+/// which the core loop drives after every event it handles.
+pub struct Spawn(pub LocalSpawner);
+
+impl Spawner for Spawn {
+ fn spawn_detached(&self, fut: DetachedFuture) {
+ if let Err(err) = self.0.spawn_local(fut) {
+ log::error!("the core executor refused a task: {err}");
+ }
+ }
+}
+
+#[derive(Default)]
+pub struct Events {
+ dirty: RefCell<HashSet<HostPaneId>>,
+ wake: RefCell<Option<Rc<dyn Fn()>>>,
+}
+
+impl Events {
+ pub fn set_wake(&self, wake: Rc<dyn Fn()>) {
+ *self.wake.borrow_mut() = Some(wake);
+ }
+
+ pub fn take_dirty(&self) -> HashSet<HostPaneId> {
+ std::mem::take(&mut *self.dirty.borrow_mut())
+ }
+
+ fn mark(&self, pane: HostPaneId) {
+ self.dirty.borrow_mut().insert(pane);
+ if let Some(wake) = self.wake.borrow().clone() {
+ wake();
+ }
+ }
+}
+
+impl SessionEvents for Events {
+ fn pane_output(&self, pane: HostPaneId) {
+ self.mark(pane);
+ }
+ fn alert(&self, _pane: HostPaneId, _alert: wezterm_term::Alert) {}
+ fn agent_status_changed(&self, _pane: HostPaneId) {}
+ fn pane_removed(&self, pane: HostPaneId) {
+ self.mark(pane);
+ }
+ fn pane_focused(&self, _pane: HostPaneId) {}
+ fn input_recorded(&self) {}
+}
+
+pub struct Config {
+ rules: Arc<Vec<termwiz::hyperlink::Rule>>,
+}
+
+impl Default for Config {
+ fn default() -> Self {
+ Self {
+ rules: Arc::new(Vec::new()),
+ }
+ }
+}
+
+impl HostConfig for Config {
+ fn hyperlink_rules(&self) -> Arc<Vec<termwiz::hyperlink::Rule>> {
+ Arc::clone(&self.rules)
+ }
+ fn fetch_rate_per_second(&self) -> u32 {
+ 10
+ }
+ fn scrollback_lookahead_screens(&self) -> usize {
+ 1
+ }
+ fn warm_scrollback(&self) -> bool {
+ false
+ }
+}
+
+pub struct MobileHost {
+ pub clock: MobileClock,
+ pub spawner: Spawn,
+ pub events: Events,
+ pub link: SshLink,
+ pub config: Config,
+}
+
+impl SessionHost for MobileHost {
+ type Clock = MobileClock;
+ type Spawner = Spawn;
+ type Events = Events;
+ type Link = SshLink;
+ type Config = Config;
+
+ fn clock(&self) -> &MobileClock {
+ &self.clock
+ }
+ fn spawner(&self) -> &Spawn {
+ &self.spawner
+ }
+ fn events(&self) -> &Events {
+ &self.events
+ }
+ fn link(&self) -> &SshLink {
+ &self.link
+ }
+ fn config(&self) -> &Config {
+ &self.config
+ }
+ fn image_domain(&self) -> ImageDomainKey {
+ 1
+ }
+}
diff --git a/thinkterm-mobile/src/lib.rs b/thinkterm-mobile/src/lib.rs
new file mode 100644
index 00000000..edb95c48
--- /dev/null
+++ b/thinkterm-mobile/src/lib.rs
@@ -0,0 +1,238 @@
+//! The mobile client's FFI surface.
+//!
+//! Everything a shell can call lives on [`Core`], a `Send + Sync` handle
+//! that forwards to one core thread. UniFFI requires exported objects to be
+//! callable from any thread; the session and (later) the App are single
+//! threaded (`Rc`, non-`Send` futures), so the handle is a channel, not the
+//! state. Commands are asynchronous except where the plan makes them a
+//! handshake: `detach_surface` returns only once the core thread has
+//! stopped touching the surface, because an Android `surfaceDestroyed` (and
+//! a UIKit view going away) must not return before that.
+//!
+//! The core thread never waits on the shell's main thread. It talks back
+//! only through [`Notify`] and [`painter::GlyphPainter`], whose calls the
+//! shell must treat as coming from a background thread.
+
+mod core;
+mod host;
+mod link;
+pub mod painter;
+mod ssh;
+mod terminal;
+
+use std::sync::mpsc::{self, Sender};
+use std::sync::Mutex;
+use std::thread::JoinHandle;
+
+uniffi::setup_scaffolding!();
+
+/// What the core tells the shell. Called on the core thread.
+#[uniffi::export(callback_interface)]
+pub trait Notify: Send + Sync {
+ /// The core has something to draw; the shell should call `render` from
+ /// its display callback (CADisplayLink, Choreographer). Never draw from
+ /// inside this call.
+ fn on_frame_needed(&self);
+ /// The connection's state in a line: connecting, attached to a pane,
+ /// disconnected and why.
+ fn on_status(&self, status: String);
+ /// A line for the shell's log view.
+ fn on_log(&self, line: String);
+}
+
+/// Rust's `log` output goes to stdout, which the simulator's console shows;
+/// a device build will want os_log instead.
+struct StdoutLogger;
+
+impl log::Log for StdoutLogger {
+ fn enabled(&self, metadata: &log::Metadata) -> bool {
+ metadata.level() <= log::Level::Info
+ }
+ fn log(&self, record: &log::Record) {
+ if self.enabled(record.metadata()) {
+ println!(
+ "rust {} {}: {}",
+ record.level(),
+ record.target(),
+ record.args()
+ );
+ }
+ }
+ fn flush(&self) {}
+}
+
+fn install_logger() {
+ static ONCE: std::sync::Once = std::sync::Once::new();
+ ONCE.call_once(|| {
+ static LOGGER: StdoutLogger = StdoutLogger;
+ let _ = log::set_logger(&LOGGER);
+ log::set_max_level(log::LevelFilter::Info);
+ });
+}
+
+#[derive(uniffi::Object)]
+pub struct Core {
+ tx: Sender<core::Cmd>,
+ thread: Mutex<Option<JoinHandle<()>>>,
+}
+
+#[uniffi::export]
+impl Core {
+ #[uniffi::constructor]
+ pub fn new(notify: Box<dyn Notify>) -> std::sync::Arc<Self> {
+ install_logger();
+ let (tx, rx) = mpsc::channel();
+ let thread = std::thread::Builder::new()
+ .name("thinkterm-core".into())
+ .spawn({
+ let tx = tx.clone();
+ move || core::run(tx, rx, notify)
+ })
+ .expect("spawning the core thread");
+ std::sync::Arc::new(Self {
+ tx,
+ thread: Mutex::new(Some(thread)),
+ })
+ }
+
+ /// Give the core a CAMetalLayer (`layer` is the unretained pointer) to
+ /// draw on. Returns the surface generation the shell must quote back
+ /// in `resize` and `detach_surface`, or 0 if the GPU could not be set
+ /// up (the reason goes to `on_log`).
+ pub fn attach_surface(&self, layer: u64, width: u32, height: u32, scale: f64) -> u64 {
+ let (reply, ack) = mpsc::channel();
+ if self
+ .tx
+ .send(core::Cmd::Attach {
+ layer: layer as usize,
+ width,
+ height,
+ scale,
+ reply,
+ })
+ .is_err()
+ {
+ return 0;
+ }
+ ack.recv().unwrap_or(0)
+ }
+
+ /// The surface's drawable size changed (rotation, keyboard, split
+ /// view). Asynchronous; a stale generation is ignored.
+ pub fn resize(&self, generation: u64, width: u32, height: u32, scale: f64) {
+ let _ = self.tx.send(core::Cmd::Resize {
+ generation,
+ width,
+ height,
+ scale,
+ });
+ }
+
+ /// The handshake: returns once the core thread has dropped the surface
+ /// and will not touch the layer again. The only call a shell may block
+ /// its main thread on.
+ pub fn detach_surface(&self, generation: u64) {
+ let (reply, ack) = mpsc::channel();
+ if self
+ .tx
+ .send(core::Cmd::Detach { generation, reply })
+ .is_ok()
+ {
+ let _ = ack.recv();
+ }
+ }
+
+ /// Draw one frame if a surface is attached. Asynchronous: the shell
+ /// calls this from its display callback and returns immediately.
+ pub fn render(&self) {
+ let _ = self.tx.send(core::Cmd::Render);
+ }
+
+ /// Start or stop the demo animation drawn while no pane is attached.
+ pub fn set_animating(&self, on: bool) {
+ let _ = self.tx.send(core::Cmd::Animate(on));
+ }
+
+ /// Connect over ssh, exec the proxy on the host and attach to its
+ /// active pane. `font_paths` are the TTF files to shape with (base face
+ /// first); `painter` draws what they lack.
+ #[allow(clippy::too_many_arguments)]
+ pub fn connect(
+ &self,
+ host: String,
+ port: u16,
+ user: String,
+ key_path: String,
+ remote_command: String,
+ font_paths: Vec<String>,
+ size_pt: f64,
+ painter: Box<dyn painter::GlyphPainter>,
+ ) {
+ let _ = self.tx.send(core::Cmd::Connect {
+ params: core::ConnectParams {
+ ssh: ssh::SshParams {
+ host,
+ port,
+ user,
+ key_path,
+ remote_command,
+ },
+ font_paths,
+ size_pt,
+ },
+ painter,
+ });
+ }
+
+ pub fn disconnect(&self) {
+ let _ = self.tx.send(core::Cmd::Disconnect);
+ }
+
+ /// A key by its DOM name ("Enter", "Backspace", "ArrowUp", "c"...).
+ pub fn key(&self, name: String, ctrl: bool, alt: bool, shift: bool) {
+ let _ = self.tx.send(core::Cmd::Key {
+ name,
+ ctrl,
+ alt,
+ shift,
+ });
+ }
+
+ /// The IME is composing (a Pinyin buffer is open, say): keys are the
+ /// IME's until it ends, and nothing reaches the pane meanwhile.
+ pub fn set_composing(&self, on: bool) {
+ let _ = self.tx.send(core::Cmd::Composing(on));
+ }
+
+ /// Committed text from the soft keyboard or an IME.
+ pub fn text(&self, text: String) {
+ let _ = self.tx.send(core::Cmd::Text(text));
+ }
+
+ pub fn paste(&self, text: String) {
+ let _ = self.tx.send(core::Cmd::Paste(text));
+ }
+
+ /// Scroll the view by whole lines; positive is back into history.
+ pub fn scroll(&self, lines: i32) {
+ let _ = self.tx.send(core::Cmd::Scroll(lines));
+ }
+
+ /// Counters for the probe's screen: frames drawn, attach/detach
+ /// generations, last frame time, errors, connection state.
+ pub fn stats(&self) -> String {
+ let (reply, ack) = mpsc::channel();
+ if self.tx.send(core::Cmd::Stats { reply }).is_err() {
+ return "core thread gone".into();
+ }
+ ack.recv().unwrap_or_else(|_| "core thread gone".into())
+ }
+
+ /// Stop the core thread. Blocks until it has exited.
+ pub fn shutdown(&self) {
+ let _ = self.tx.send(core::Cmd::Shutdown);
+ if let Some(thread) = self.thread.lock().unwrap().take() {
+ let _ = thread.join();
+ }
+ }
+}
diff --git a/thinkterm-mobile/src/link.rs b/thinkterm-mobile/src/link.rs
new file mode 100644
index 00000000..b23d2225
--- /dev/null
+++ b/thinkterm-mobile/src/link.rs
@@ -0,0 +1,296 @@
+//! The core thread's end of the PDU stream, whatever carries it.
+//!
+//! The network thread hands in bytes and takes out bytes; this side does
+//! the framing, matches answers to requests by serial, hands pushes to the
+//! App and keeps the lease. It is the transport-neutral 450 lines of the
+//! browser's `link.rs`, minus the WebSocket.
+//!
+//! Sending is ordered by construction: `request` encodes and queues the
+//! bytes on the spot, in the order it was called, and the network thread
+//! writes the queue in that order. That is the `PduLink` contract ("on the
+//! wire now, behind everything sent before it"); the plan's saturation
+//! rules for a bounded queue come with the real Transport, not this probe.
+
+use crate::ssh::Out;
+use anyhow::{anyhow, Result};
+use codec::Pdu;
+use futures::channel::oneshot;
+use std::cell::{Cell, RefCell};
+use std::future::Future;
+use std::pin::Pin;
+use std::rc::Rc;
+use thinkterm_proto::TabId;
+use thinkterm_session::connection::{Answer, SerialTable};
+use thinkterm_session::host::{LinkError, PduLink};
+use thinkterm_session::input::PaneLink;
+use thinkterm_web::lease::Lease;
+use tokio::sync::mpsc::UnboundedSender;
+
+pub type LocalFuture<T> = Pin<Box<dyn Future<Output = T> + 'static>>;
+
+#[derive(Clone)]
+pub struct SshLink(Rc<Inner>);
+
+struct Inner {
+ out: RefCell<Option<UnboundedSender<Out>>>,
+ serials: RefCell<SerialTable<oneshot::Sender<Pdu>>>,
+ pushes: RefCell<Option<Box<dyn FnMut(Pdu)>>>,
+ pending_pushes: RefCell<Vec<Pdu>>,
+ lease: RefCell<Lease>,
+ inbound: RefCell<Vec<u8>>,
+ open: Cell<bool>,
+ generation: Cell<u64>,
+}
+
+impl SshLink {
+ pub fn new() -> Self {
+ Self(Rc::new(Inner {
+ out: RefCell::new(None),
+ serials: RefCell::new(SerialTable::new()),
+ pushes: RefCell::new(None),
+ pending_pushes: RefCell::new(Vec::new()),
+ lease: RefCell::new(Lease::default()),
+ inbound: RefCell::new(Vec::new()),
+ open: Cell::new(false),
+ generation: Cell::new(0),
+ }))
+ }
+
+ /// A transport came up: everything sent from now on goes to `out`.
+ pub fn opened(&self, out: UnboundedSender<Out>) {
+ self.0.inbound.borrow_mut().clear();
+ self.0.serials.borrow_mut().drain();
+ *self.0.out.borrow_mut() = Some(out);
+ self.0.open.set(true);
+ self.0.generation.set(self.0.generation.get() + 1);
+ }
+
+ /// The transport went away. Every request still waiting is answered
+ /// with an error by its sender being dropped.
+ pub fn closed(&self) {
+ self.0.open.set(false);
+ *self.0.out.borrow_mut() = None;
+ self.0.serials.borrow_mut().drain();
+ }
+
+ pub fn is_open(&self) -> bool {
+ self.0.open.get()
+ }
+
+ /// Bytes from the wire. Decodes every whole PDU in them, answers
+ /// requests and hands pushes on; a partial PDU waits for more.
+ pub fn feed(&self, bytes: &[u8]) -> Result<()> {
+ self.0.inbound.borrow_mut().extend_from_slice(bytes);
+ loop {
+ let decoded = {
+ let mut inbound = self.0.inbound.borrow_mut();
+ match Pdu::stream_decode(&mut inbound) {
+ Ok(Some(decoded)) => decoded,
+ Ok(None) => return Ok(()),
+ Err(err) => {
+ self.closed();
+ return Err(anyhow!("decoding the stream: {err:#}"));
+ }
+ }
+ };
+ let (serial, pdu) = (decoded.serial, decoded.pdu);
+ if serial == 0 {
+ match pdu {
+ Pdu::Ping(_) => {
+ let _ = self.send(&Pdu::Pong(codec::Pong {}), 0);
+ }
+ Pdu::FrontendAccessState(access) => {
+ self.0.lease.borrow_mut().apply_access(&access);
+ self.push(Pdu::FrontendAccessState(access));
+ }
+ Pdu::ClientViewportState(state) => {
+ self.0.lease.borrow_mut().apply_viewport(&state);
+ self.push(Pdu::ClientViewportState(state));
+ }
+ other => self.push(other),
+ }
+ continue;
+ }
+ let answer = self
+ .0
+ .serials
+ .borrow_mut()
+ .answer(serial, pdu, |tx, pdu| tx.send(pdu).is_ok());
+ if answer == Answer::Unmatched {
+ log::error!("the server answered serial {serial}, which nothing asked for");
+ }
+ }
+ }
+
+ pub fn lease(&self) -> std::cell::Ref<'_, Lease> {
+ self.0.lease.borrow()
+ }
+
+ pub fn lease_mut(&self) -> std::cell::RefMut<'_, Lease> {
+ self.0.lease.borrow_mut()
+ }
+
+ /// The pushes that arrived since the last call, in order. The core
+ /// loop drains these after every `feed` rather than installing a
+ /// handler, so nothing re-enters the App from inside the decoder.
+ pub fn take_pushes(&self) -> Vec<Pdu> {
+ std::mem::take(&mut *self.0.pending_pushes.borrow_mut())
+ }
+
+ #[allow(dead_code)]
+ pub fn set_push_handler(&self, handler: impl FnMut(Pdu) + 'static) {
+ *self.0.pushes.borrow_mut() = Some(Box::new(handler));
+ let pending = std::mem::take(&mut *self.0.pending_pushes.borrow_mut());
+ for pdu in pending {
+ self.push(pdu);
+ }
+ }
+
+ fn push(&self, pdu: Pdu) {
+ let handler = self.0.pushes.borrow_mut().take();
+ match handler {
+ Some(mut handler) => {
+ handler(pdu);
+ let mut slot = self.0.pushes.borrow_mut();
+ if slot.is_none() {
+ *slot = Some(handler);
+ }
+ drop(slot);
+ let pending = std::mem::take(&mut *self.0.pending_pushes.borrow_mut());
+ for pdu in pending {
+ self.push(pdu);
+ }
+ }
+ None => self.0.pending_pushes.borrow_mut().push(pdu),
+ }
+ }
+
+ fn send(&self, pdu: &Pdu, serial: u64) -> Result<(), LinkError> {
+ let mut bytes = Vec::new();
+ pdu.encode(&mut bytes, serial).map_err(|e| LinkError {
+ message: format!("encoding {}: {e:#}", pdu.pdu_name()),
+ retryable: false,
+ })?;
+ let out = self.0.out.borrow();
+ let Some(out) = out.as_ref().filter(|_| self.0.open.get()) else {
+ return Err(LinkError {
+ message: format!("sending {}: the connection is not open", pdu.pdu_name()),
+ retryable: true,
+ });
+ };
+ out.send(Out::Bytes(bytes)).map_err(|_| LinkError {
+ message: format!("sending {}: the network thread is gone", pdu.pdu_name()),
+ retryable: false,
+ })
+ }
+
+ pub async fn ensure_owner(&self, tab_id: TabId) -> Result<bool> {
+ {
+ let mut lease = self.0.lease.borrow_mut();
+ if lease.owns_viewport() {
+ return Ok(true);
+ }
+ if !lease.may_type() {
+ return Ok(false);
+ }
+ lease.fit = true;
+ }
+ self.claim(tab_id).await
+ }
+
+ pub async fn claim(&self, tab_id: TabId) -> Result<bool> {
+ let viewport = self
+ .0
+ .lease
+ .borrow()
+ .claim_viewport()
+ .ok_or_else(|| anyhow!("no viewport has been reported yet"))?;
+ let state = self.claim_with(tab_id, viewport.clone()).await?;
+ let mut lease = self.0.lease.borrow_mut();
+ lease.reported_viewport = Some(viewport);
+ lease.apply_viewport(&state);
+ Ok(lease.owns_viewport())
+ }
+
+ async fn claim_with(
+ &self,
+ tab_id: TabId,
+ viewport: codec::ClientViewport,
+ ) -> Result<codec::ClientViewportState> {
+ thinkterm_session::host::request(
+ self,
+ Pdu::ClaimClientViewport(codec::ClaimClientViewport { tab_id, viewport }),
+ |pdu| match pdu {
+ Pdu::ClientViewportState(state) => Ok(state),
+ other => Err(other),
+ },
+ )
+ .await
+ }
+
+ pub async fn report_viewport(&self, tab_id: TabId) -> Result<()> {
+ let viewport = {
+ let lease = self.0.lease.borrow();
+ match lease.claim_viewport() {
+ Some(v) if lease.reported_viewport.as_ref() != Some(&v) => v,
+ _ => return Ok(()),
+ }
+ };
+ let state = thinkterm_session::host::request(
+ self,
+ Pdu::SetClientViewport(codec::SetClientViewport {
+ tab_id,
+ viewport: viewport.clone(),
+ }),
+ |pdu| match pdu {
+ Pdu::ClientViewportState(state) => Ok(state),
+ other => Err(other),
+ },
+ )
+ .await?;
+ let mut lease = self.0.lease.borrow_mut();
+ lease.reported_viewport = Some(viewport);
+ lease.apply_viewport(&state);
+ Ok(())
+ }
+}
+
+impl PduLink for SshLink {
+ type Request = LocalFuture<Result<Pdu, LinkError>>;
+
+ fn request(&self, pdu: Pdu) -> Self::Request {
+ let (tx, rx) = oneshot::channel();
+ let serial = self.0.serials.borrow_mut().register(tx);
+ let sent = self.send(&pdu, serial);
+ if sent.is_err() {
+ self.0
+ .serials
+ .borrow_mut()
+ .answer(serial, Pdu::Invalid { ident: 0 }, |_, _| false);
+ }
+ Box::pin(async move {
+ sent?;
+ rx.await.map_err(|_| LinkError {
+ message: "the connection closed before the server answered".to_string(),
+ retryable: false,
+ })
+ })
+ }
+
+ fn is_reconnectable(&self) -> bool {
+ true
+ }
+
+ fn connection_generation(&self) -> u64 {
+ self.0.generation.get()
+ }
+}
+
+impl PaneLink for SshLink {
+ type Prepare = LocalFuture<Result<bool>>;
+
+ fn prepare(&self, remote_tab_id: TabId) -> Self::Prepare {
+ let link = self.clone();
+ Box::pin(async move { link.ensure_owner(remote_tab_id).await })
+ }
+}
diff --git a/thinkterm-mobile/src/painter.rs b/thinkterm-mobile/src/painter.rs
new file mode 100644
index 00000000..bdc6066b
--- /dev/null
+++ b/thinkterm-mobile/src/painter.rs
@@ -0,0 +1,84 @@
+//! Glyph fallback on a phone: the shell paints text the bundled faces lack
+//! (CJK, emoji) with the platform's own fonts -- CoreText on iOS -- and the
+//! shared procedure in `thinkterm_web::raster` does the rest.
+
+use crate::host::MobileClock;
+use anyhow::{ensure, Result};
+use std::sync::Arc;
+use thinkterm_web::raster::{GlyphPlatform, ScratchGeometry, TextPainter};
+
+/// Implemented by the shell. Called on the core thread, synchronously,
+/// while a frame is being built: keep it quick and never block on the
+/// main thread.
+#[uniffi::export(callback_interface)]
+pub trait GlyphPainter: Send + Sync {
+ /// Paint `text` at `px` pixels into a transparent `width` x `height`
+ /// RGBA bitmap, pen at (`pen_x`, `baseline`), in the solid colour
+ /// given, and return the bitmap's bytes (non-premultiplied, row-major,
+ /// `width * height * 4`). An empty vector means the platform could not
+ /// draw it.
+ #[allow(clippy::too_many_arguments)]
+ fn paint(
+ &self,
+ text: String,
+ px: f64,
+ width: u32,
+ height: u32,
+ pen_x: f64,
+ baseline: f64,
+ red: u8,
+ green: u8,
+ blue: u8,
+ ) -> Vec<u8>;
+}
+
+pub struct MobilePlatform {
+ painter: Arc<dyn GlyphPainter>,
+ clock: MobileClock,
+}
+
+impl MobilePlatform {
+ pub fn new(painter: Box<dyn GlyphPainter>, clock: MobileClock) -> Self {
+ Self {
+ painter: Arc::from(painter),
+ clock,
+ }
+ }
+}
+
+impl GlyphPlatform for MobilePlatform {
+ fn now_ms(&self) -> f64 {
+ self.clock.now_ms()
+ }
+
+ fn painter(&self, geometry: &ScratchGeometry, _families: &str) -> Result<Box<dyn TextPainter>> {
+ Ok(Box::new(ShellPainter {
+ painter: Arc::clone(&self.painter),
+ geometry: *geometry,
+ }))
+ }
+}
+
+struct ShellPainter {
+ painter: Arc<dyn GlyphPainter>,
+ geometry: ScratchGeometry,
+}
+
+impl TextPainter for ShellPainter {
+ fn paint(&self, text: &str, fill: [u8; 3]) -> Result<Vec<u8>> {
+ let g = &self.geometry;
+ let bytes = self.painter.paint(
+ text.to_string(),
+ g.px,
+ g.width as u32,
+ g.height as u32,
+ g.pen_x,
+ g.baseline,
+ fill[0],
+ fill[1],
+ fill[2],
+ );
+ ensure!(!bytes.is_empty(), "the shell could not paint {text:?}");
+ Ok(bytes)
+ }
+}
diff --git a/thinkterm-mobile/src/ssh.rs b/thinkterm-mobile/src/ssh.rs
new file mode 100644
index 00000000..f8a0227a
--- /dev/null
+++ b/thinkterm-mobile/src/ssh.rs
@@ -0,0 +1,157 @@
+//! The network thread: an ssh session to the host, an exec channel running
+//! `thinkterm cli --prefer-mux proxy`, and the PDU bytes flowing both ways.
+//!
+//! One tokio thread per connection. Bytes to send arrive on an unbounded
+//! channel and are written in order; everything that comes back -- data,
+//! stderr, the exit status, the close -- is delivered to the core thread
+//! through the callback it gave us, which must not block.
+
+use anyhow::{Context, Result};
+use russh::client::{self, Handler};
+use russh::keys::{PrivateKeyWithHashAlg, PublicKeyOrCertificate};
+use russh::ChannelMsg;
+use std::sync::Arc;
+use std::time::Duration;
+use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
+
+#[derive(Debug, Clone)]
+pub struct SshParams {
+ pub host: String,
+ pub port: u16,
+ pub user: String,
+ /// Path to an OpenSSH private key file (unencrypted for the probe).
+ pub key_path: String,
+ /// The command to exec; empty means the default proxy invocation.
+ pub remote_command: String,
+}
+
+pub enum Out {
+ Bytes(Vec<u8>),
+ Close,
+}
+
+#[derive(Debug)]
+pub enum Net {
+ Connected,
+ Data(Vec<u8>),
+ Stderr(String),
+ Exit(u32),
+ Closed(String),
+}
+
+struct Trusting;
+
+impl Handler for Trusting {
+ type Error = anyhow::Error;
+ async fn check_server_key(&mut self, _key: &PublicKeyOrCertificate) -> Result<bool> {
+ // The probe trusts any host key; the real client pins it on first
+ // use and refuses a change.
+ Ok(true)
+ }
+}
+
+const DEFAULT_COMMAND: &str = "if [ -x \"$HOME/.local/bin/thinkterm\" ]; \
+ then exec \"$HOME/.local/bin/thinkterm\" cli --prefer-mux proxy; \
+ elif command -v thinkterm >/dev/null 2>&1; \
+ then exec thinkterm cli --prefer-mux proxy; else exec wezterm cli --prefer-mux proxy; fi";
+
+/// Start the connection on its own thread. Returns the sender for bytes
+/// to write; dropping it (or sending `Out::Close`) ends the session.
+pub fn spawn(params: SshParams, deliver: Box<dyn Fn(Net) + Send>) -> UnboundedSender<Out> {
+ let (out_tx, out_rx) = unbounded_channel();
+ std::thread::Builder::new()
+ .name("thinkterm-net".into())
+ .spawn(move || {
+ let runtime = match tokio::runtime::Builder::new_current_thread()
+ .enable_all()
+ .build()
+ {
+ Ok(rt) => rt,
+ Err(err) => {
+ deliver(Net::Closed(format!("tokio runtime: {err}")));
+ return;
+ }
+ };
+ let outcome = runtime.block_on(run(params, out_rx, &deliver));
+ let reason = match outcome {
+ Ok(reason) => reason,
+ Err(err) => format!("{err:#}"),
+ };
+ deliver(Net::Closed(reason));
+ })
+ .expect("spawning the network thread");
+ out_tx
+}
+
+async fn run(
+ params: SshParams,
+ mut out_rx: UnboundedReceiver<Out>,
+ deliver: &dyn Fn(Net),
+) -> Result<String> {
+ let config = Arc::new(client::Config {
+ inactivity_timeout: None,
+ keepalive_interval: Some(Duration::from_secs(15)),
+ keepalive_max: 3,
+ ..Default::default()
+ });
+ let mut session = tokio::time::timeout(
+ Duration::from_secs(15),
+ client::connect(config, (params.host.as_str(), params.port), Trusting),
+ )
+ .await
+ .context("connecting timed out")?
+ .context("ssh transport")?;
+
+ let key = russh::keys::load_secret_key(&params.key_path, None)
+ .with_context(|| format!("loading the key {}", params.key_path))?;
+ let auth = session
+ .authenticate_publickey(
+ &params.user,
+ PrivateKeyWithHashAlg::new(Arc::new(key), None),
+ )
+ .await
+ .context("publickey auth")?;
+ if !auth.success() {
+ anyhow::bail!("the host refused the key for {}", params.user);
+ }
+
+ let mut channel = session
+ .channel_open_session()
+ .await
+ .context("opening a session channel")?;
+ let command = if params.remote_command.trim().is_empty() {
+ DEFAULT_COMMAND
+ } else {
+ params.remote_command.as_str()
+ };
+ channel.exec(true, command).await.context("exec")?;
+ deliver(Net::Connected);
+
+ loop {
+ tokio::select! {
+ out = out_rx.recv() => match out {
+ Some(Out::Bytes(bytes)) => {
+ channel.data(&bytes[..]).await.context("writing to the channel")?;
+ }
+ Some(Out::Close) | None => {
+ let _ = channel.eof().await;
+ let _ = channel.close().await;
+ let _ = session
+ .disconnect(russh::Disconnect::ByApplication, "closed", "")
+ .await;
+ return Ok("closed by the client".into());
+ }
+ },
+ msg = channel.wait() => match msg {
+ Some(ChannelMsg::Data { data }) => deliver(Net::Data(data.to_vec())),
+ Some(ChannelMsg::ExtendedData { data, .. }) => {
+ deliver(Net::Stderr(String::from_utf8_lossy(&data).to_string()))
+ }
+ Some(ChannelMsg::ExitStatus { exit_status }) => deliver(Net::Exit(exit_status)),
+ Some(ChannelMsg::Eof) => {}
+ Some(ChannelMsg::Close) | None => return Ok("the remote command ended".into()),
+ Some(_) => {}
+ },
+ }
+ }
+}
diff --git a/thinkterm-mobile/src/terminal.rs b/thinkterm-mobile/src/terminal.rs
new file mode 100644
index 00000000..bd56548a
--- /dev/null
+++ b/thinkterm-mobile/src/terminal.rs
@@ -0,0 +1,517 @@
+//! One pane, end to end: the handshake that attaches to the server's active
+//! pane, the session that keeps its lines, and the frame that turns those
+//! lines into quads through the shared emitter and glyph atlas.
+//!
+//! This is the S0.5 slice: the parts of the browser's App that one pane
+//! needs, and nothing of the rest (layout, splits, the tree, menus).
+
+use crate::host::MobileHost;
+use crate::link::SshLink;
+use anyhow::{anyhow, bail, Result};
+use codec::Pdu;
+use std::sync::atomic::AtomicUsize;
+use std::sync::Arc;
+use thinkterm_proto::{ClientId, PaneId, RenderableDimensions, TabId, WindowId};
+use thinkterm_render::pipeline::GpuTexture;
+use thinkterm_render::quad::HeapQuadAllocator;
+use thinkterm_render::vertex::Vertex;
+use thinkterm_session::host::{request, Spawner};
+use thinkterm_session::input::InputQueueFull;
+use thinkterm_session::pane::PaneSession;
+use thinkterm_web::chrome::active_pane;
+use thinkterm_web::emit;
+use thinkterm_web::fallback::FallbackBudget;
+use thinkterm_web::glyphs::GlyphCache;
+use thinkterm_web::keymap::{map_key, DomKey};
+use thinkterm_web::viewport::{max_scroll, visible_rows};
+use wezterm_color_types::LinearRgba;
+use wezterm_term::color::ColorPalette;
+use wezterm_term::{KeyModifiers, StableRowIndex, TerminalSize};
+
+pub struct Attached {
+ pub pane_id: PaneId,
+ pub tab_id: TabId,
+ pub window_id: WindowId,
+ pub workspace: String,
+ pub title: String,
+ pub dims: RenderableDimensions,
+ pub alt_screen: bool,
+ pub server_version: String,
+ pub server_id: String,
+}
+
+/// The browser's `attach()`, minus the nav rows and the native (per-pane)
+/// viewport: a phone reports one cell grid.
+pub async fn attach(link: &SshLink, size: Option<TerminalSize>, wall_ms: u64) -> Result<Attached> {
+ let version = request(
+ link,
+ Pdu::GetCodecVersion(codec::GetCodecVersion {}),
+ |pdu| match pdu {
+ Pdu::GetCodecVersionResponse(v) => Ok(v),
+ other => Err(other),
+ },
+ )
+ .await?;
+ if version.codec_vers != codec::CODEC_VERSION {
+ bail!(
+ "this app speaks protocol {} but the server speaks {}; update the server or the app",
+ codec::CODEC_VERSION,
+ version.codec_vers
+ );
+ }
+
+ let me = ClientId {
+ hostname: "ios".into(),
+ username: "mobile".into(),
+ pid: std::process::id(),
+ epoch: wall_ms,
+ id: (wall_ms as usize) ^ (std::process::id() as usize) << 8,
+ ssh_auth_sock: None,
+ };
+ link.lease_mut().me = Some(me.clone());
+ request(
+ link,
+ Pdu::SetClientId(codec::SetClientId {
+ client_id: me,
+ is_proxy: false,
+ }),
+ |pdu| match pdu {
+ Pdu::UnitResponse(_) => Ok(()),
+ other => Err(other),
+ },
+ )
+ .await?;
+
+ let panes = request(link, Pdu::ListPanes(codec::ListPanes {}), |pdu| match pdu {
+ Pdu::ListPanesResponse(p) => Ok(p),
+ other => Err(other),
+ })
+ .await?;
+ let entry = panes
+ .tabs
+ .iter()
+ .find_map(active_pane)
+ .ok_or_else(|| anyhow!("the server has no panes to show"))?;
+ {
+ let mut lease = link.lease_mut();
+ lease.tab_id = Some(entry.tab_id);
+ lease.reported = size;
+ lease.canonical_size = Some(entry.size);
+ }
+ link.report_viewport(entry.tab_id).await?;
+
+ request(
+ link,
+ Pdu::GetPaneRenderChanges(codec::GetPaneRenderChanges {
+ pane_id: entry.pane_id,
+ }),
+ |pdu| match pdu {
+ Pdu::LivenessResponse(_) | Pdu::UnitResponse(_) => Ok(()),
+ other => Err(other),
+ },
+ )
+ .await?;
+
+ let rows = entry.size.rows;
+ Ok(Attached {
+ pane_id: entry.pane_id,
+ tab_id: entry.tab_id,
+ window_id: entry.window_id,
+ workspace: entry.workspace.clone(),
+ title: entry.title.clone(),
+ dims: RenderableDimensions {
+ cols: entry.size.cols,
+ viewport_rows: rows,
+ scrollback_rows: rows,
+ physical_top: entry.physical_top,
+ scrollback_top: entry.physical_top,
+ dpi: entry.size.dpi,
+ pixel_width: entry.size.pixel_width,
+ pixel_height: entry.size.pixel_height,
+ reverse_video: false,
+ },
+ alt_screen: entry.alt_screen,
+ server_version: version.version_string,
+ server_id: version.server_id,
+ })
+}
+
+/// Nothing to come back to: the tab and the pane are both gone.
+#[derive(Debug)]
+pub struct NoPanes;
+
+impl std::fmt::Display for NoPanes {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "the server has no panes to show")
+ }
+}
+
+impl std::error::Error for NoPanes {}
+
+/// The browser's `reattach()`: the same identity on a new transport, the
+/// tab found again (or the pane's tab, or any tab), the viewport reported
+/// and the delta stream restarted.
+pub async fn reattach(
+ link: &SshLink,
+ tab_id: TabId,
+ pane_id: PaneId,
+ size: Option<TerminalSize>,
+) -> Result<codec::ListPanesResponse> {
+ let version = request(
+ link,
+ Pdu::GetCodecVersion(codec::GetCodecVersion {}),
+ |pdu| match pdu {
+ Pdu::GetCodecVersionResponse(v) => Ok(v),
+ other => Err(other),
+ },
+ )
+ .await?;
+ if version.codec_vers != codec::CODEC_VERSION {
+ bail!(
+ "this app speaks protocol {} but the server speaks {}; update the server or the app",
+ codec::CODEC_VERSION,
+ version.codec_vers
+ );
+ }
+ let me = link
+ .lease()
+ .me
+ .clone()
+ .ok_or_else(|| anyhow!("reconnecting without an identity"))?;
+ request(
+ link,
+ Pdu::SetClientId(codec::SetClientId {
+ client_id: me,
+ is_proxy: false,
+ }),
+ |pdu| match pdu {
+ Pdu::UnitResponse(_) => Ok(()),
+ other => Err(other),
+ },
+ )
+ .await?;
+ let panes = request(link, Pdu::ListPanes(codec::ListPanes {}), |pdu| match pdu {
+ Pdu::ListPanesResponse(p) => Ok(p),
+ other => Err(other),
+ })
+ .await?;
+ let tab = panes
+ .tabs
+ .iter()
+ .find(|tab| tab.window_and_tab_ids().is_some_and(|(_, id)| id == tab_id))
+ .or_else(|| panes.tabs.iter().find(|tab| contains_pane(tab, pane_id)))
+ .ok_or(NoPanes)?;
+ let (_, tab_id) = tab.window_and_tab_ids().ok_or(NoPanes)?;
+ if !contains_pane(tab, pane_id) {
+ return Err(NoPanes.into());
+ }
+ {
+ let mut lease = link.lease_mut();
+ lease.tab_id = Some(tab_id);
+ lease.tab_owner = None;
+ lease.reported = size;
+ lease.reported_viewport = None;
+ lease.fit = false;
+ }
+ link.report_viewport(tab_id).await?;
+ request(
+ link,
+ Pdu::GetPaneRenderChanges(codec::GetPaneRenderChanges { pane_id }),
+ |pdu| match pdu {
+ Pdu::LivenessResponse(_) | Pdu::UnitResponse(_) => Ok(()),
+ other => Err(other),
+ },
+ )
+ .await?;
+ Ok(panes)
+}
+
+fn contains_pane(node: &thinkterm_proto::layout::PaneNode, pane_id: PaneId) -> bool {
+ use thinkterm_proto::layout::PaneNode;
+ match node {
+ PaneNode::Empty => false,
+ PaneNode::Leaf(entry) => entry.pane_id == pane_id,
+ PaneNode::Stack(stack) => stack.panes.iter().any(|e| e.pane_id == pane_id),
+ PaneNode::Split { left, right, .. } => {
+ contains_pane(left, pane_id) || contains_pane(right, pane_id)
+ }
+ }
+}
+
+/// The grid a surface of `w`x`h` device pixels holds, or `None` when it
+/// cannot hold even one cell.
+pub fn grid_for(w: u32, h: u32, cell_w: u32, cell_h: u32) -> Option<(usize, usize)> {
+ if cell_w == 0 || cell_h == 0 || w < cell_w || h < cell_h {
+ return None;
+ }
+ Some(((w / cell_w).max(2) as usize, (h / cell_h).max(1) as usize))
+}
+
+pub struct Terminal {
+ pub glyphs: GlyphCache,
+ quads: HeapQuadAllocator,
+ vertices: Vec<Vertex>,
+ pub session: Arc<PaneSession<MobileHost>>,
+ host: Arc<MobileHost>,
+ pub pane_id: PaneId,
+ pub tab_id: TabId,
+ pub palette: ColorPalette,
+ pub cols: usize,
+ pub rows: usize,
+ pub dpi: u32,
+ scroll_from_bottom: usize,
+ /// The IME owns the keyboard while this is set: keys are dropped and
+ /// only committed text gets through.
+ pub composing: bool,
+ /// Inputs handed to the session, for the probe to count.
+ pub inputs_sent: u64,
+}
+
+impl Terminal {
+ pub fn new(
+ host: Arc<MobileHost>,
+ glyphs: GlyphCache,
+ attached: &Attached,
+ cols: usize,
+ rows: usize,
+ dpi: u32,
+ ) -> Self {
+ let images = Arc::new(thinkterm_session::Lock::new(
+ thinkterm_session::images::ImageStore::default(),
+ ));
+ let remote_tab_id = Arc::new(AtomicUsize::new(attached.tab_id));
+ let session = PaneSession::new(
+ Arc::clone(&host),
+ images,
+ thinkterm_session::SessionConfig {
+ scrollback_lines: 3500,
+ local_echo_threshold_ms: Some(100),
+ overlay_lag_indicator: false,
+ },
+ attached.pane_id,
+ remote_tab_id,
+ attached.pane_id,
+ attached.dims,
+ &attached.title,
+ attached.alt_screen,
+ );
+ Self {
+ glyphs,
+ quads: HeapQuadAllocator::default(),
+ vertices: Vec::new(),
+ session,
+ host,
+ pane_id: attached.pane_id,
+ tab_id: attached.tab_id,
+ palette: ColorPalette::default(),
+ cols,
+ rows,
+ dpi,
+ scroll_from_bottom: 0,
+ composing: false,
+ inputs_sent: 0,
+ }
+ }
+
+ pub fn cell_size(&self) -> (u32, u32) {
+ (
+ self.glyphs.metrics.cell_size.width as u32,
+ self.glyphs.metrics.cell_size.height as u32,
+ )
+ }
+
+ pub fn size(&self) -> TerminalSize {
+ let (cw, ch) = self.cell_size();
+ TerminalSize {
+ rows: self.rows,
+ cols: self.cols,
+ pixel_width: self.cols * cw as usize,
+ pixel_height: self.rows * ch as usize,
+ dpi: self.dpi,
+ }
+ }
+
+ /// The surface changed size: fit the grid to it and tell the server.
+ /// Returns whether the grid changed.
+ pub fn resize(&mut self, cols: usize, rows: usize) -> bool {
+ if (cols, rows) == (self.cols, self.rows) {
+ return false;
+ }
+ self.cols = cols;
+ self.rows = rows;
+ let size = self.size();
+ self.session.apply_local_resize(size);
+ self.host.link.lease_mut().reported = Some(size);
+ let link = self.host.link.clone();
+ let tab_id = self.tab_id;
+ self.host.spawner.spawn_detached(Box::pin(async move {
+ if let Err(err) = link.claim(tab_id).await {
+ log::warn!("fitting the tab to this screen: {err:#}");
+ }
+ }));
+ true
+ }
+
+ fn spawn_drain(&self, start: Result<bool, InputQueueFull>) {
+ match start {
+ Ok(true) => {
+ let session = Arc::clone(&self.session);
+ self.host
+ .spawner
+ .spawn_detached(Box::pin(session.drain_inputs()));
+ }
+ Ok(false) => {}
+ Err(err) => log::warn!("input refused: {err:?}"),
+ }
+ }
+
+ /// A key by its DOM name ("Enter", "ArrowUp", "a"...), as the key bar
+ /// and a hardware keyboard send them.
+ pub fn key(&mut self, name: &str, ctrl: bool, alt: bool, shift: bool) -> bool {
+ let dom = DomKey {
+ key: name,
+ code: "",
+ ctrl,
+ alt,
+ shift,
+ meta: false,
+ composing: false,
+ };
+ if self.composing {
+ return false;
+ }
+ let Some((key, mods)) = map_key(&dom) else {
+ return false;
+ };
+ let serial = codec::InputSerial::from_millis(thinkterm_session::clock::Clock::wall_millis(
+ &self.host.clock,
+ ));
+ let mods = KeyModifiers::from_bits_truncate(mods.bits());
+ self.scroll_from_bottom = 0;
+ self.inputs_sent += 1;
+ let start = self.session.key_down(serial, key, mods);
+ self.spawn_drain(start);
+ true
+ }
+
+ /// Committed text (the soft keyboard, an IME's final choice).
+ pub fn text(&mut self, text: &str) {
+ if text.is_empty() {
+ return;
+ }
+ self.scroll_from_bottom = 0;
+ self.inputs_sent += 1;
+ let start = self.session.write_bytes(text.as_bytes());
+ self.spawn_drain(start);
+ }
+
+ pub fn paste(&mut self, text: &str) {
+ self.scroll_from_bottom = 0;
+ self.inputs_sent += 1;
+ let start = self.session.paste(text);
+ self.spawn_drain(start);
+ }
+
+ /// The transport is back: every line is suspect until fetched again.
+ pub fn reconnected(&mut self) {
+ self.session.set_dead(false);
+ self.session.make_all_stale();
+ }
+
+ pub fn scroll_lines(&mut self, delta: i32) {
+ let max = max_scroll(&self.session.dimensions());
+ let next = self.scroll_from_bottom as i64 + delta as i64;
+ self.scroll_from_bottom = next.clamp(0, max as i64) as usize;
+ }
+
+ /// Everything the server pushed that concerns this pane.
+ pub fn on_push(&mut self, pdu: Pdu) -> bool {
+ match pdu {
+ Pdu::GetPaneRenderChangesResponse(delta) if delta.pane_id == self.pane_id => {
+ self.session.queue_render_delta(delta);
+ false
+ }
+ Pdu::PaneRemoved(removed) if removed.pane_id == self.pane_id => {
+ self.session.set_dead(true);
+ true
+ }
+ Pdu::DefaultPalette(codec::DefaultPalette { palette }) => {
+ self.palette = palette;
+ true
+ }
+ Pdu::SetApplicationPalette(codec::SetApplicationPalette { pane_id, palette })
+ if pane_id == self.pane_id =>
+ {
+ if let Some(palette) = palette {
+ self.palette = palette;
+ }
+ true
+ }
+ Pdu::ClientViewportState(_) | Pdu::FrontendAccessState(_) => true,
+ _ => false,
+ }
+ }
+
+ /// Build this frame's quads. Returns the vertices, the atlas they
+ /// index, and the background to clear with.
+ pub fn paint(
+ &mut self,
+ surface: (u32, u32),
+ budget: &mut FallbackBudget,
+ ) -> Result<(&[Vertex], &GpuTexture, LinearRgba)> {
+ self.glyphs.begin_frame(false);
+ self.quads.recycle();
+ let surface_f = (surface.0 as f32, surface.1 as f32);
+ let cell_w = self.glyphs.metrics.cell_size.width as f32;
+ let cell_h = self.glyphs.metrics.cell_size.height as f32;
+
+ let dims = self.session.dimensions();
+ let max = max_scroll(&dims);
+ if self.scroll_from_bottom > max {
+ self.scroll_from_bottom = max;
+ }
+ let visible = visible_rows(&dims, self.rows, self.scroll_from_bottom);
+ let (first, lines) = self.session.get_lines(visible);
+ let mut cursor = self.session.cursor_position();
+ if !self.session.has_received() {
+ cursor.y = StableRowIndex::MIN;
+ }
+ let palette = self.palette.clone();
+ let background = palette.background.to_linear();
+
+ emit::fill_rect(
+ &self.glyphs,
+ &mut self.quads,
+ 0,
+ surface_f,
+ (0.0, 0.0),
+ surface_f,
+ background,
+ None,
+ )?;
+ let origin = (0.0, 0.0);
+ let clip = (self.cols as f32 * cell_w, self.rows as f32 * cell_h);
+ for (i, line) in lines.iter().enumerate() {
+ let row = first + i as StableRowIndex;
+ let params = emit::LineParams {
+ line,
+ stable_row: row,
+ top_pixel_y: i as f32 * cell_h,
+ cursor: &cursor,
+ palette: &palette,
+ selection: 0..0,
+ focused: true,
+ reverse_video: dims.reverse_video,
+ surface: surface_f,
+ origin,
+ clip,
+ hsv: None,
+ draw_cursor: true,
+ };
+ emit::emit_line(&mut self.glyphs, &mut self.quads, budget, &params)?;
+ }
+ self.vertices.clear();
+ self.quads.extract_vertices(&mut self.vertices);
+ Ok((&self.vertices, self.glyphs.texture(), background))
+ }
+}