ratatui-termwiz-0.1.0/.cargo_vcs_info.json0000644000000001550000000000100142030ustar { "git": { "sha1": "0a2a7c0363a4806b0cf05c1915bf7cdd438f756c" }, "path_in_vcs": "ratatui-termwiz" }ratatui-termwiz-0.1.0/Cargo.lock0000644000001027020000000000100121570ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "allocator-api2" version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anyhow" version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "atomic" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" dependencies = [ "bytemuck", ] [[package]] name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bit-set" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" dependencies = [ "serde_core", ] [[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] [[package]] name = "bumpalo" version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytemuck" version = "1.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" [[package]] name = "castaway" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" dependencies = [ "rustversion", ] [[package]] name = "cfg-if" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "cfg_aliases" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "compact_str" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb1325a1cece981e8a296ab8f0f9b63ae357bd0784a9faaf548cc7b480707a" dependencies = [ "castaway", "cfg-if", "itoa", "rustversion", "ryu", "static_assertions", ] [[package]] name = "cpufeatures" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] [[package]] name = "crypto-common" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", ] [[package]] name = "csscolorparser" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" dependencies = [ "lab", "phf", ] [[package]] name = "deltae" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", ] [[package]] name = "document-features" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" dependencies = [ "litrs", ] [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "euclid" version = "0.22.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad9cdb4b747e485a12abb0e6566612956c7a1bafa3bdb8d682c5b6d403589e48" dependencies = [ "num-traits", ] [[package]] name = "fancy-regex" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" dependencies = [ "bit-set", "regex", ] [[package]] name = "filedescriptor" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d" dependencies = [ "libc", "thiserror 1.0.69", "winapi", ] [[package]] name = "finl_unicode" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94c970b525906eb37d3940083aa65b95e481fc1857d467d13374e1d925cfc163" [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-macro" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "futures-task" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-macro", "futures-task", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "generic-array" version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", ] [[package]] name = "getrandom" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "libc", "r-efi", "wasi", ] [[package]] name = "glob" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "hashbrown" version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" [[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", "foldhash", ] [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "indexmap" version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", "hashbrown 0.15.5", ] [[package]] name = "indoc" version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" dependencies = [ "rustversion", ] [[package]] name = "itertools" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] [[package]] name = "itertools" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] [[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", ] [[package]] name = "kasuari" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fe90c1150662e858c7d5f945089b7517b0a80d8bf7ba4b1b5ffc984e7230a5b" dependencies = [ "hashbrown 0.16.1", "thiserror 2.0.17", ] [[package]] name = "lab" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f" [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "litrs" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" [[package]] name = "log" version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru" version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96051b46fc183dc9cd4a223960ef37b9af631b55191852a8274bfef064cda20f" dependencies = [ "hashbrown 0.16.1", ] [[package]] name = "mac_address" version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303" dependencies = [ "nix", "winapi", ] [[package]] name = "memchr" version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "memmem" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" [[package]] name = "memoffset" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] [[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nix" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.10.0", "cfg-if", "cfg_aliases", "libc", "memoffset", ] [[package]] name = "nom" version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", ] [[package]] name = "num-derive" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "ordered-float" version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" dependencies = [ "num-traits", ] [[package]] name = "pest" version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" dependencies = [ "memchr", "thiserror 2.0.17", "ucd-trie", ] [[package]] name = "pest_derive" version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" dependencies = [ "pest", "pest_generator", ] [[package]] name = "pest_generator" version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "pest_meta" version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" dependencies = [ "pest", "sha2", ] [[package]] name = "phf" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_macros", "phf_shared", ] [[package]] name = "phf_codegen" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" dependencies = [ "phf_generator", "phf_shared", ] [[package]] name = "phf_generator" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", "rand", ] [[package]] name = "phf_macros" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" dependencies = [ "phf_generator", "phf_shared", "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "phf_shared" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ "siphasher", ] [[package]] name = "pin-project-lite" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro-crate" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "rand_core", ] [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "ratatui-core" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ef8dea09a92caaf73bff7adb70b76162e5937524058a7e5bff37869cbbec293" dependencies = [ "bitflags 2.10.0", "compact_str", "hashbrown 0.16.1", "indoc", "itertools 0.14.0", "kasuari", "lru", "strum", "thiserror 2.0.17", "unicode-segmentation", "unicode-truncate", "unicode-width", ] [[package]] name = "ratatui-termwiz" version = "0.1.0" dependencies = [ "document-features", "ratatui-core", "rstest", "termwiz", ] [[package]] name = "regex" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relative-path" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" [[package]] name = "rstest" version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5a3193c063baaa2a95a33f03035c8a72b83d97a54916055ba22d35ed3839d49" dependencies = [ "futures-timer", "futures-util", "rstest_macros", ] [[package]] name = "rstest_macros" version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c845311f0ff7951c5506121a9ad75aec44d083c31583b2ea5a30bcb0b0abba0" dependencies = [ "cfg-if", "glob", "proc-macro-crate", "proc-macro2", "quote", "regex", "relative-path", "rustc_version", "syn 2.0.106", "unicode-ident", ] [[package]] name = "rustc_version" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustversion" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "semver" version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ "serde_core", "serde_derive", ] [[package]] name = "serde_core" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "sha2" version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", "digest", ] [[package]] name = "signal-hook" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" dependencies = [ "libc", "signal-hook-registry", ] [[package]] name = "signal-hook-registry" version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" dependencies = [ "libc", ] [[package]] name = "siphasher" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "slab" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ "heck", "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "syn" version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "terminfo" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4ea810f0692f9f51b382fff5893887bb4580f5fa246fde546e0b13e7fcee662" dependencies = [ "fnv", "nom", "phf", "phf_codegen", ] [[package]] name = "termios" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" dependencies = [ "libc", ] [[package]] name = "termwiz" version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4676b37242ccbd1aabf56edb093a4827dc49086c0ffd764a5705899e0f35f8f7" dependencies = [ "anyhow", "base64", "bitflags 2.10.0", "fancy-regex", "filedescriptor", "finl_unicode", "fixedbitset", "hex", "lazy_static", "libc", "log", "memmem", "nix", "num-derive", "num-traits", "ordered-float", "pest", "pest_derive", "phf", "serde", "sha2", "signal-hook", "siphasher", "terminfo", "termios", "thiserror 1.0.69", "ucd-trie", "unicode-segmentation", "vtparse", "wezterm-bidi", "wezterm-blob-leases", "wezterm-color-types", "wezterm-dynamic", "wezterm-input-types", "winapi", ] [[package]] name = "thiserror" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl 1.0.69", ] [[package]] name = "thiserror" version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ "thiserror-impl 2.0.17", ] [[package]] name = "thiserror-impl" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "thiserror-impl" version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", "syn 2.0.106", ] [[package]] name = "toml_datetime" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" [[package]] name = "toml_edit" version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", "toml_datetime", "winnow", ] [[package]] name = "typenum" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "ucd-trie" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-segmentation" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-truncate" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fbf03860ff438702f3910ca5f28f8dac63c1c11e7efb5012b8b175493606330" dependencies = [ "itertools 0.13.0", "unicode-segmentation", "unicode-width", ] [[package]] name = "unicode-width" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" dependencies = [ "atomic", "getrandom", "js-sys", "serde", "wasm-bindgen", ] [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vtparse" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d9b2acfb050df409c972a37d3b8e08cdea3bddb0c09db9d53137e504cfabed0" dependencies = [ "utf8parse", ] [[package]] name = "wasi" version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] [[package]] name = "wasm-bindgen" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", "syn 2.0.106", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", "syn 2.0.106", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" dependencies = [ "unicode-ident", ] [[package]] name = "wezterm-bidi" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c0a6e355560527dd2d1cf7890652f4f09bb3433b6aadade4c9b5ed76de5f3ec" dependencies = [ "log", "wezterm-dynamic", ] [[package]] name = "wezterm-blob-leases" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7" dependencies = [ "getrandom", "mac_address", "serde", "sha2", "thiserror 1.0.69", "uuid", ] [[package]] name = "wezterm-color-types" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7de81ef35c9010270d63772bebef2f2d6d1f2d20a983d27505ac850b8c4b4296" dependencies = [ "csscolorparser", "deltae", "lazy_static", "serde", "wezterm-dynamic", ] [[package]] name = "wezterm-dynamic" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f2ab60e120fd6eaa68d9567f3226e876684639d22a4219b313ff69ec0ccd5ac" dependencies = [ "log", "ordered-float", "strsim", "thiserror 1.0.69", "wezterm-dynamic-derive", ] [[package]] name = "wezterm-dynamic-derive" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c0cf2d539c645b448eaffec9ec494b8b19bd5077d9e58cb1ae7efece8d575b" dependencies = [ "proc-macro2", "quote", "syn 1.0.109", ] [[package]] name = "wezterm-input-types" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e" dependencies = [ "bitflags 1.3.2", "euclid", "lazy_static", "serde", "wezterm-dynamic", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winnow" version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" dependencies = [ "memchr", ] [[package]] name = "wit-bindgen-rt" version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags 2.10.0", ] ratatui-termwiz-0.1.0/Cargo.toml0000644000000053410000000000100122030ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2024" rust-version = "1.86.0" name = "ratatui-termwiz" version = "0.1.0" authors = [ "Florian Dehau ", "The Ratatui Developers", ] build = false exclude = [ "assets/*", ".github", "Makefile.toml", "CONTRIBUTING.md", "*.log", "tags", ] autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "Termwiz backend for the Ratatui Terminal UI library." homepage = "https://ratatui.rs" documentation = "https://docs.rs/ratatui-termwiz" readme = "README.md" keywords = [ "tui", "terminal", "dashboard", ] categories = ["command-line-interface"] license = "MIT" repository = "https://github.com/ratatui/ratatui" resolver = "2" [package.metadata.docs.rs] all-features = true cargo-args = [ "-Zunstable-options", "-Zrustdoc-scrape-examples", ] rustdoc-args = [ "--cfg", "docsrs", ] [features] default = [] scrolling-regions = ["ratatui-core/scrolling-regions"] serde = ["termwiz/use_serde"] underline-color = ["ratatui-core/underline-color"] [lib] name = "ratatui_termwiz" path = "src/lib.rs" [dependencies.document-features] version = "0.2" optional = true [dependencies.ratatui-core] version = "0.1.0" [dependencies.termwiz] version = "0.23" [dev-dependencies.rstest] version = "0.26" [lints.clippy] as_underscore = "warn" cast_possible_truncation = "allow" cast_possible_wrap = "allow" cast_precision_loss = "allow" cast_sign_loss = "allow" deref_by_slicing = "warn" else_if_without_else = "warn" empty_line_after_doc_comments = "warn" equatable_if_let = "warn" fn_to_numeric_cast_any = "warn" format_push_string = "warn" implicit_clone = "warn" map_err_ignore = "warn" missing_const_for_fn = "warn" missing_errors_doc = "allow" missing_panics_doc = "allow" mixed_read_write_in_expression = "warn" mod_module_files = "warn" module_inception = "allow" module_name_repetitions = "allow" must_use_candidate = "allow" needless_pass_by_ref_mut = "warn" needless_raw_strings = "warn" or_fun_call = "warn" redundant_type_annotations = "warn" rest_pat_in_fully_bound_structs = "warn" string_lit_chars_any = "warn" string_slice = "warn" unnecessary_self_imports = "warn" use_self = "warn" [lints.clippy.pedantic] level = "warn" priority = -1 [lints.rust] unsafe_code = "forbid" ratatui-termwiz-0.1.0/Cargo.toml.orig000064400000000000000000000023711046102023000156640ustar 00000000000000[package] name = "ratatui-termwiz" version = "0.1.0" description = "Termwiz backend for the Ratatui Terminal UI library." documentation = "https://docs.rs/ratatui-termwiz" readme = "README.md" authors.workspace = true repository.workspace = true homepage.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true exclude.workspace = true edition.workspace = true rust-version.workspace = true [package.metadata.docs.rs] all-features = true cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] rustdoc-args = ["--cfg", "docsrs"] [features] default = [] ## Enables serde for termwiz dependency serde = ["termwiz/use_serde"] ## Enables the backend code that sets the underline color. ## Underline color is not supported on Windows 7. underline-color = ["ratatui-core/underline-color"] ## Use terminal scrolling regions to make Terminal::insert_before less prone to flickering. scrolling-regions = ["ratatui-core/scrolling-regions"] [dependencies] document-features = { workspace = true, optional = true } ratatui-core = { workspace = true } termwiz.workspace = true [dev-dependencies] ratatui = { path = "../ratatui", features = ["termwiz"], default-features = false } rstest.workspace = true [lints] workspace = true ratatui-termwiz-0.1.0/README.md000064400000000000000000000021601046102023000142500ustar 00000000000000# Ratatui-termwiz This module provides the [`TermwizBackend`] implementation for the [`Backend`] trait. It uses the [Termwiz] crate to interact with the terminal. [`Backend`]: trait.Backend.html [Termwiz]: https://crates.io/crates/termwiz ## Crate Organization `ratatui-termwiz` is part of the Ratatui workspace that was modularized in version 0.30.0. This crate provides the [Termwiz] backend implementation for Ratatui. **When to use `ratatui-termwiz`:** - You need fine-grained control over dependencies - Building a widget library that needs backend functionality - You want to use only the Termwiz backend without other backends - You need Termwiz's advanced terminal capabilities **When to use the main [`ratatui`] crate:** - Building applications (recommended - includes termwiz backend when enabled) - You want the convenience of having everything available For detailed information about the workspace organization, see [ARCHITECTURE.md]. [`ratatui`]: https://crates.io/crates/ratatui [ARCHITECTURE.md]: https://github.com/ratatui/ratatui/blob/main/ARCHITECTURE.md ratatui-termwiz-0.1.0/src/lib.rs000064400000000000000000000750351046102023000147070ustar 00000000000000// show the feature flags in the generated documentation #![cfg_attr(docsrs, feature(doc_cfg))] #![doc( html_logo_url = "https://raw.githubusercontent.com/ratatui/ratatui/main/assets/logo.png", html_favicon_url = "https://raw.githubusercontent.com/ratatui/ratatui/main/assets/favicon.ico" )] #![warn(missing_docs)] //! This module provides the [`TermwizBackend`] implementation for the [`Backend`] trait. It uses //! the [Termwiz] crate to interact with the terminal. //! //! [`Backend`]: trait.Backend.html //! [Termwiz]: https://crates.io/crates/termwiz //! //! # Crate Organization //! //! `ratatui-termwiz` is part of the Ratatui workspace that was modularized in version 0.30.0. //! This crate provides the [Termwiz] backend implementation for Ratatui. //! //! **When to use `ratatui-termwiz`:** //! //! - You need fine-grained control over dependencies //! - Building a widget library that needs backend functionality //! - You want to use only the Termwiz backend without other backends //! - You need Termwiz's advanced terminal capabilities //! //! **When to use the main [`ratatui`] crate:** //! //! - Building applications (recommended - includes termwiz backend when enabled) //! - You want the convenience of having everything available //! //! For detailed information about the workspace organization, see [ARCHITECTURE.md]. //! //! [`ratatui`]: https://crates.io/crates/ratatui //! [ARCHITECTURE.md]: https://github.com/ratatui/ratatui/blob/main/ARCHITECTURE.md #![cfg_attr(feature = "document-features", doc = "\n## Features")] #![cfg_attr(feature = "document-features", doc = document_features::document_features!())] use std::error::Error; use std::io; use ratatui_core::backend::{Backend, ClearType, WindowSize}; use ratatui_core::buffer::Cell; use ratatui_core::layout::{Position, Size}; use ratatui_core::style::{Color, Modifier, Style}; pub use termwiz; use termwiz::caps::Capabilities; use termwiz::cell::{AttributeChange, Blink, CellAttributes, Intensity, Underline}; use termwiz::color::{AnsiColor, ColorAttribute, ColorSpec, LinearRgba, RgbColor, SrgbaTuple}; use termwiz::surface::{Change, CursorVisibility, Position as TermwizPosition}; use termwiz::terminal::buffered::BufferedTerminal; use termwiz::terminal::{ScreenSize, SystemTerminal, Terminal}; /// A [`Backend`] implementation that uses [Termwiz] to render to the terminal. /// /// The `TermwizBackend` struct is a wrapper around a [`BufferedTerminal`], which is used to send /// commands to the terminal. It provides methods for drawing content, manipulating the cursor, and /// clearing the terminal screen. /// /// Most applications should not call the methods on `TermwizBackend` directly, but will instead /// use the [`Terminal`] struct, which provides a more ergonomic interface. /// /// This backend automatically enables raw mode and switches to the alternate screen when it is /// created using the [`TermwizBackend::new`] method (and disables raw mode and returns to the main /// screen when dropped). Use the [`TermwizBackend::with_buffered_terminal`] to create a new /// instance with a custom [`BufferedTerminal`] if this is not desired. /// /// # Example /// /// ```rust,no_run /// use ratatui::Terminal; /// use ratatui::backend::TermwizBackend; /// /// let backend = TermwizBackend::new()?; /// let mut terminal = Terminal::new(backend)?; /// /// terminal.clear()?; /// terminal.draw(|frame| { /// // -- snip -- /// })?; /// # std::result::Result::Ok::<(), Box>(()) /// ``` /// /// See the the [Examples] directory for more examples. See the [`backend`] module documentation /// for more details on raw mode and alternate screen. /// /// [`backend`]: ratatui_core::backend /// [`Terminal`]: https://docs.rs/ratatui/latest/ratatui/struct.Terminal.html /// [`BufferedTerminal`]: termwiz::terminal::buffered::BufferedTerminal /// [Termwiz]: https://crates.io/crates/termwiz /// [Examples]: https://github.com/ratatui/ratatui/tree/main/ratatui/examples/README.md pub struct TermwizBackend { buffered_terminal: BufferedTerminal, } impl TermwizBackend { /// Creates a new Termwiz backend instance. /// /// The backend will automatically enable raw mode and enter the alternate screen. /// /// # Errors /// /// Returns an error if unable to do any of the following: /// - query the terminal capabilities. /// - enter raw mode. /// - enter the alternate screen. /// - create the system or buffered terminal. /// /// # Example /// /// ```rust,no_run /// use ratatui::backend::TermwizBackend; /// /// let backend = TermwizBackend::new()?; /// # Ok::<(), Box>(()) /// ``` pub fn new() -> Result> { let mut buffered_terminal = BufferedTerminal::new(SystemTerminal::new(Capabilities::new_from_env()?)?)?; buffered_terminal.terminal().set_raw_mode()?; buffered_terminal.terminal().enter_alternate_screen()?; Ok(Self { buffered_terminal }) } /// Creates a new Termwiz backend instance with the given buffered terminal. pub const fn with_buffered_terminal(instance: BufferedTerminal) -> Self { Self { buffered_terminal: instance, } } /// Returns a reference to the buffered terminal used by the backend. pub const fn buffered_terminal(&self) -> &BufferedTerminal { &self.buffered_terminal } /// Returns a mutable reference to the buffered terminal used by the backend. pub const fn buffered_terminal_mut(&mut self) -> &mut BufferedTerminal { &mut self.buffered_terminal } } impl Backend for TermwizBackend { type Error = io::Error; fn draw<'a, I>(&mut self, content: I) -> io::Result<()> where I: Iterator, { for (x, y, cell) in content { self.buffered_terminal.add_changes(vec![ Change::CursorPosition { x: TermwizPosition::Absolute(x as usize), y: TermwizPosition::Absolute(y as usize), }, Change::Attribute(AttributeChange::Foreground(cell.fg.into_termwiz())), Change::Attribute(AttributeChange::Background(cell.bg.into_termwiz())), ]); self.buffered_terminal .add_change(Change::Attribute(AttributeChange::Intensity( if cell.modifier.contains(Modifier::BOLD) { Intensity::Bold } else if cell.modifier.contains(Modifier::DIM) { Intensity::Half } else { Intensity::Normal }, ))); self.buffered_terminal .add_change(Change::Attribute(AttributeChange::Italic( cell.modifier.contains(Modifier::ITALIC), ))); self.buffered_terminal .add_change(Change::Attribute(AttributeChange::Underline( if cell.modifier.contains(Modifier::UNDERLINED) { Underline::Single } else { Underline::None }, ))); self.buffered_terminal .add_change(Change::Attribute(AttributeChange::Reverse( cell.modifier.contains(Modifier::REVERSED), ))); self.buffered_terminal .add_change(Change::Attribute(AttributeChange::Invisible( cell.modifier.contains(Modifier::HIDDEN), ))); self.buffered_terminal .add_change(Change::Attribute(AttributeChange::StrikeThrough( cell.modifier.contains(Modifier::CROSSED_OUT), ))); self.buffered_terminal .add_change(Change::Attribute(AttributeChange::Blink( if cell.modifier.contains(Modifier::SLOW_BLINK) { Blink::Slow } else if cell.modifier.contains(Modifier::RAPID_BLINK) { Blink::Rapid } else { Blink::None }, ))); self.buffered_terminal.add_change(cell.symbol()); } Ok(()) } fn hide_cursor(&mut self) -> io::Result<()> { self.buffered_terminal .add_change(Change::CursorVisibility(CursorVisibility::Hidden)); Ok(()) } fn show_cursor(&mut self) -> io::Result<()> { self.buffered_terminal .add_change(Change::CursorVisibility(CursorVisibility::Visible)); Ok(()) } fn get_cursor_position(&mut self) -> io::Result { let (x, y) = self.buffered_terminal.cursor_position(); Ok(Position::new(x as u16, y as u16)) } fn set_cursor_position>(&mut self, position: P) -> io::Result<()> { let Position { x, y } = position.into(); self.buffered_terminal.add_change(Change::CursorPosition { x: TermwizPosition::Absolute(x as usize), y: TermwizPosition::Absolute(y as usize), }); Ok(()) } fn clear(&mut self) -> io::Result<()> { self.buffered_terminal .add_change(Change::ClearScreen(termwiz::color::ColorAttribute::Default)); Ok(()) } fn clear_region(&mut self, clear_type: ClearType) -> io::Result<()> { match clear_type { ClearType::All => self.clear(), ClearType::AfterCursor | ClearType::BeforeCursor | ClearType::CurrentLine | ClearType::UntilNewLine => Err(io::Error::other(format!( "clear_type [{clear_type:?}] not supported with this backend" ))), } } fn size(&self) -> io::Result { let (cols, rows) = self.buffered_terminal.dimensions(); Ok(Size::new(u16_max(cols), u16_max(rows))) } fn window_size(&mut self) -> io::Result { let ScreenSize { cols, rows, xpixel, ypixel, } = self .buffered_terminal .terminal() .get_screen_size() .map_err(io::Error::other)?; Ok(WindowSize { columns_rows: Size { width: u16_max(cols), height: u16_max(rows), }, pixels: Size { width: u16_max(xpixel), height: u16_max(ypixel), }, }) } fn flush(&mut self) -> io::Result<()> { self.buffered_terminal.flush().map_err(io::Error::other)?; Ok(()) } #[cfg(feature = "scrolling-regions")] fn scroll_region_up(&mut self, region: std::ops::Range, amount: u16) -> io::Result<()> { // termwiz doesn't have a command to just set the scrolling region. Instead, setting the // scrolling region and scrolling are combined. However, this has the side-effect of // leaving the scrolling region set. To reset the scrolling region, termwiz advises one to // make a scrolling-region scroll command that contains the entire screen, but scrolls by 0 // lines. See [`Change::ScrollRegionUp`] for more details. let (_, rows) = self.buffered_terminal.dimensions(); self.buffered_terminal.add_changes(vec![ Change::ScrollRegionUp { first_row: region.start as usize, region_size: region.len(), scroll_count: amount as usize, }, Change::ScrollRegionUp { first_row: 0, region_size: rows, scroll_count: 0, }, ]); Ok(()) } #[cfg(feature = "scrolling-regions")] fn scroll_region_down(&mut self, region: std::ops::Range, amount: u16) -> io::Result<()> { // termwiz doesn't have a command to just set the scrolling region. Instead, setting the // scrolling region and scrolling are combined. However, this has the side-effect of // leaving the scrolling region set. To reset the scrolling region, termwiz advises one to // make a scrolling-region scroll command that contains the entire screen, but scrolls by 0 // lines. See [`Change::ScrollRegionDown`] for more details. let (_, rows) = self.buffered_terminal.dimensions(); self.buffered_terminal.add_changes(vec![ Change::ScrollRegionDown { first_row: region.start as usize, region_size: region.len(), scroll_count: amount as usize, }, Change::ScrollRegionDown { first_row: 0, region_size: rows, scroll_count: 0, }, ]); Ok(()) } } /// A trait for converting types from Termwiz to Ratatui. /// /// This trait replaces the `From` trait for converting types from Termwiz to Ratatui. It is /// necessary because the `From` trait is not implemented for types defined in external crates. pub trait FromTermwiz { /// Converts the given Termwiz type to the Ratatui type. fn from_termwiz(termwiz: T) -> Self; } /// A trait for converting types from Ratatui to Termwiz. /// /// This trait replaces the `Into` trait for converting types from Ratatui to Termwiz. It is /// necessary because the `Into` trait is not implemented for types defined in external crates. pub trait IntoTermwiz { /// Converts the given Ratatui type to the Termwiz type. fn into_termwiz(self) -> T; } /// A replacement for the `Into` trait for converting types from Ratatui to Termwiz. /// /// This trait is necessary because the `Into` trait is not implemented for types defined in /// external crates. /// /// A blanket implementation is provided for all types that implement `FromTermwiz`. /// /// This trait is private to the module as it would otherwise conflict with the other backend /// modules. It is mainly used to avoid rewriting all the `.into()` calls in this module. trait IntoRatatui { fn into_ratatui(self) -> R; } impl> IntoRatatui for C { fn into_ratatui(self) -> R { R::from_termwiz(self) } } impl FromTermwiz for Style { fn from_termwiz(value: CellAttributes) -> Self { let mut style = Self::new() .add_modifier(value.intensity().into_ratatui()) .add_modifier(value.underline().into_ratatui()) .add_modifier(value.blink().into_ratatui()); if value.italic() { style.add_modifier |= Modifier::ITALIC; } if value.reverse() { style.add_modifier |= Modifier::REVERSED; } if value.strikethrough() { style.add_modifier |= Modifier::CROSSED_OUT; } if value.invisible() { style.add_modifier |= Modifier::HIDDEN; } style.fg = Some(value.foreground().into_ratatui()); style.bg = Some(value.background().into_ratatui()); #[cfg(feature = "underline-color")] { style.underline_color = Some(value.underline_color().into_ratatui()); } style } } impl FromTermwiz for Modifier { fn from_termwiz(value: Intensity) -> Self { match value { Intensity::Normal => Self::empty(), Intensity::Bold => Self::BOLD, Intensity::Half => Self::DIM, } } } impl FromTermwiz for Modifier { fn from_termwiz(value: Underline) -> Self { match value { Underline::None => Self::empty(), _ => Self::UNDERLINED, } } } impl FromTermwiz for Modifier { fn from_termwiz(value: Blink) -> Self { match value { Blink::None => Self::empty(), Blink::Slow => Self::SLOW_BLINK, Blink::Rapid => Self::RAPID_BLINK, } } } impl IntoTermwiz for Color { fn into_termwiz(self) -> ColorAttribute { match self { Self::Reset => ColorAttribute::Default, Self::Black => AnsiColor::Black.into(), Self::DarkGray => AnsiColor::Grey.into(), Self::Gray => AnsiColor::Silver.into(), Self::Red => AnsiColor::Maroon.into(), Self::LightRed => AnsiColor::Red.into(), Self::Green => AnsiColor::Green.into(), Self::LightGreen => AnsiColor::Lime.into(), Self::Yellow => AnsiColor::Olive.into(), Self::LightYellow => AnsiColor::Yellow.into(), Self::Magenta => AnsiColor::Purple.into(), Self::LightMagenta => AnsiColor::Fuchsia.into(), Self::Cyan => AnsiColor::Teal.into(), Self::LightCyan => AnsiColor::Aqua.into(), Self::White => AnsiColor::White.into(), Self::Blue => AnsiColor::Navy.into(), Self::LightBlue => AnsiColor::Blue.into(), Self::Indexed(i) => ColorAttribute::PaletteIndex(i), Self::Rgb(r, g, b) => { ColorAttribute::TrueColorWithDefaultFallback(SrgbaTuple::from((r, g, b))) } } } } impl FromTermwiz for Color { fn from_termwiz(value: AnsiColor) -> Self { match value { AnsiColor::Black => Self::Black, AnsiColor::Grey => Self::DarkGray, AnsiColor::Silver => Self::Gray, AnsiColor::Maroon => Self::Red, AnsiColor::Red => Self::LightRed, AnsiColor::Green => Self::Green, AnsiColor::Lime => Self::LightGreen, AnsiColor::Olive => Self::Yellow, AnsiColor::Yellow => Self::LightYellow, AnsiColor::Purple => Self::Magenta, AnsiColor::Fuchsia => Self::LightMagenta, AnsiColor::Teal => Self::Cyan, AnsiColor::Aqua => Self::LightCyan, AnsiColor::White => Self::White, AnsiColor::Navy => Self::Blue, AnsiColor::Blue => Self::LightBlue, } } } impl FromTermwiz for Color { fn from_termwiz(value: ColorAttribute) -> Self { match value { ColorAttribute::TrueColorWithDefaultFallback(srgba) | ColorAttribute::TrueColorWithPaletteFallback(srgba, _) => srgba.into_ratatui(), ColorAttribute::PaletteIndex(i) => Self::Indexed(i), ColorAttribute::Default => Self::Reset, } } } impl FromTermwiz for Color { fn from_termwiz(value: ColorSpec) -> Self { match value { ColorSpec::Default => Self::Reset, ColorSpec::PaletteIndex(i) => Self::Indexed(i), ColorSpec::TrueColor(srgba) => srgba.into_ratatui(), } } } impl FromTermwiz for Color { fn from_termwiz(value: SrgbaTuple) -> Self { let (r, g, b, _) = value.to_srgb_u8(); Self::Rgb(r, g, b) } } impl FromTermwiz for Color { fn from_termwiz(value: RgbColor) -> Self { let (r, g, b) = value.to_tuple_rgb8(); Self::Rgb(r, g, b) } } impl FromTermwiz for Color { fn from_termwiz(value: LinearRgba) -> Self { value.to_srgb().into_ratatui() } } #[inline] fn u16_max(i: usize) -> u16 { u16::try_from(i).unwrap_or(u16::MAX) } #[cfg(test)] mod tests { use super::*; mod into_color { use Color as C; use super::*; #[test] fn from_linear_rgba() { // full black + opaque assert_eq!( C::from_termwiz(LinearRgba(0., 0., 0., 1.)), Color::Rgb(0, 0, 0) ); // full black + transparent assert_eq!( C::from_termwiz(LinearRgba(0., 0., 0., 0.)), Color::Rgb(0, 0, 0) ); // full white + opaque assert_eq!( C::from_termwiz(LinearRgba(1., 1., 1., 1.)), C::Rgb(254, 254, 254) ); // full white + transparent assert_eq!( C::from_termwiz(LinearRgba(1., 1., 1., 0.)), C::Rgb(254, 254, 254) ); // full red assert_eq!( C::from_termwiz(LinearRgba(1., 0., 0., 1.)), C::Rgb(254, 0, 0) ); // full green assert_eq!( C::from_termwiz(LinearRgba(0., 1., 0., 1.)), C::Rgb(0, 254, 0) ); // full blue assert_eq!( C::from_termwiz(LinearRgba(0., 0., 1., 1.)), C::Rgb(0, 0, 254) ); // See https://stackoverflow.com/questions/12524623/what-are-the-practical-differences-when-working-with-colors-in-a-linear-vs-a-no // for an explanation // half red assert_eq!( C::from_termwiz(LinearRgba(0.214, 0., 0., 1.)), C::Rgb(127, 0, 0) ); // half green assert_eq!( C::from_termwiz(LinearRgba(0., 0.214, 0., 1.)), C::Rgb(0, 127, 0) ); // half blue assert_eq!( C::from_termwiz(LinearRgba(0., 0., 0.214, 1.)), C::Rgb(0, 0, 127) ); } #[test] fn from_srgba() { // full black + opaque assert_eq!( C::from_termwiz(SrgbaTuple(0., 0., 0., 1.)), Color::Rgb(0, 0, 0) ); // full black + transparent assert_eq!( C::from_termwiz(SrgbaTuple(0., 0., 0., 0.)), Color::Rgb(0, 0, 0) ); // full white + opaque assert_eq!( C::from_termwiz(SrgbaTuple(1., 1., 1., 1.)), C::Rgb(255, 255, 255) ); // full white + transparent assert_eq!( C::from_termwiz(SrgbaTuple(1., 1., 1., 0.)), C::Rgb(255, 255, 255) ); // full red assert_eq!( C::from_termwiz(SrgbaTuple(1., 0., 0., 1.)), C::Rgb(255, 0, 0) ); // full green assert_eq!( C::from_termwiz(SrgbaTuple(0., 1., 0., 1.)), C::Rgb(0, 255, 0) ); // full blue assert_eq!( C::from_termwiz(SrgbaTuple(0., 0., 1., 1.)), C::Rgb(0, 0, 255) ); // half red assert_eq!( C::from_termwiz(SrgbaTuple(0.5, 0., 0., 1.)), C::Rgb(127, 0, 0) ); // half green assert_eq!( C::from_termwiz(SrgbaTuple(0., 0.5, 0., 1.)), C::Rgb(0, 127, 0) ); // half blue assert_eq!( C::from_termwiz(SrgbaTuple(0., 0., 0.5, 1.)), C::Rgb(0, 0, 127) ); } #[test] fn from_rgbcolor() { // full black assert_eq!( C::from_termwiz(RgbColor::new_8bpc(0, 0, 0)), Color::Rgb(0, 0, 0) ); // full white assert_eq!( C::from_termwiz(RgbColor::new_8bpc(255, 255, 255)), C::Rgb(255, 255, 255) ); // full red assert_eq!( C::from_termwiz(RgbColor::new_8bpc(255, 0, 0)), C::Rgb(255, 0, 0) ); // full green assert_eq!( C::from_termwiz(RgbColor::new_8bpc(0, 255, 0)), C::Rgb(0, 255, 0) ); // full blue assert_eq!( C::from_termwiz(RgbColor::new_8bpc(0, 0, 255)), C::Rgb(0, 0, 255) ); // half red assert_eq!( C::from_termwiz(RgbColor::new_8bpc(127, 0, 0)), C::Rgb(127, 0, 0) ); // half green assert_eq!( C::from_termwiz(RgbColor::new_8bpc(0, 127, 0)), C::Rgb(0, 127, 0) ); // half blue assert_eq!( C::from_termwiz(RgbColor::new_8bpc(0, 0, 127)), C::Rgb(0, 0, 127) ); } #[test] fn from_colorspec() { assert_eq!(C::from_termwiz(ColorSpec::Default), C::Reset); assert_eq!(C::from_termwiz(ColorSpec::PaletteIndex(33)), C::Indexed(33)); assert_eq!( C::from_termwiz(ColorSpec::TrueColor(SrgbaTuple(0., 0., 0., 1.))), C::Rgb(0, 0, 0) ); } #[test] fn from_colorattribute() { assert_eq!(C::from_termwiz(ColorAttribute::Default), C::Reset); assert_eq!( C::from_termwiz(ColorAttribute::PaletteIndex(32)), C::Indexed(32) ); assert_eq!( C::from_termwiz(ColorAttribute::TrueColorWithDefaultFallback(SrgbaTuple( 0., 0., 0., 1. ))), C::Rgb(0, 0, 0) ); assert_eq!( C::from_termwiz(ColorAttribute::TrueColorWithPaletteFallback( SrgbaTuple(0., 0., 0., 1.), 31 )), C::Rgb(0, 0, 0) ); } #[test] fn from_ansicolor() { assert_eq!(C::from_termwiz(AnsiColor::Black), Color::Black); assert_eq!(C::from_termwiz(AnsiColor::Grey), Color::DarkGray); assert_eq!(C::from_termwiz(AnsiColor::Silver), Color::Gray); assert_eq!(C::from_termwiz(AnsiColor::Maroon), Color::Red); assert_eq!(C::from_termwiz(AnsiColor::Red), Color::LightRed); assert_eq!(C::from_termwiz(AnsiColor::Green), Color::Green); assert_eq!(C::from_termwiz(AnsiColor::Lime), Color::LightGreen); assert_eq!(C::from_termwiz(AnsiColor::Olive), Color::Yellow); assert_eq!(C::from_termwiz(AnsiColor::Yellow), Color::LightYellow); assert_eq!(C::from_termwiz(AnsiColor::Purple), Color::Magenta); assert_eq!(C::from_termwiz(AnsiColor::Fuchsia), Color::LightMagenta); assert_eq!(C::from_termwiz(AnsiColor::Teal), Color::Cyan); assert_eq!(C::from_termwiz(AnsiColor::Aqua), Color::LightCyan); assert_eq!(C::from_termwiz(AnsiColor::White), Color::White); assert_eq!(C::from_termwiz(AnsiColor::Navy), Color::Blue); assert_eq!(C::from_termwiz(AnsiColor::Blue), Color::LightBlue); } } mod into_modifier { use super::*; #[test] fn from_intensity() { assert_eq!(Modifier::from_termwiz(Intensity::Normal), Modifier::empty()); assert_eq!(Modifier::from_termwiz(Intensity::Bold), Modifier::BOLD); assert_eq!(Modifier::from_termwiz(Intensity::Half), Modifier::DIM); } #[test] fn from_underline() { assert_eq!(Modifier::from_termwiz(Underline::None), Modifier::empty()); assert_eq!( Modifier::from_termwiz(Underline::Single), Modifier::UNDERLINED ); assert_eq!( Modifier::from_termwiz(Underline::Double), Modifier::UNDERLINED ); assert_eq!( Modifier::from_termwiz(Underline::Curly), Modifier::UNDERLINED ); assert_eq!( Modifier::from_termwiz(Underline::Dashed), Modifier::UNDERLINED ); assert_eq!( Modifier::from_termwiz(Underline::Dotted), Modifier::UNDERLINED ); } #[test] fn from_blink() { assert_eq!(Modifier::from_termwiz(Blink::None), Modifier::empty()); assert_eq!(Modifier::from_termwiz(Blink::Slow), Modifier::SLOW_BLINK); assert_eq!(Modifier::from_termwiz(Blink::Rapid), Modifier::RAPID_BLINK); } } #[test] fn from_cell_attribute_for_style() { #[cfg(feature = "underline-color")] const STYLE: Style = Style::new() .underline_color(Color::Reset) .fg(Color::Reset) .bg(Color::Reset); #[cfg(not(feature = "underline-color"))] const STYLE: Style = Style::new().fg(Color::Reset).bg(Color::Reset); // default assert_eq!(Style::from_termwiz(CellAttributes::default()), STYLE); // foreground color assert_eq!( Style::from_termwiz( CellAttributes::default() .set_foreground(ColorAttribute::PaletteIndex(31)) .to_owned() ), STYLE.fg(Color::Indexed(31)) ); // background color assert_eq!( Style::from_termwiz( CellAttributes::default() .set_background(ColorAttribute::PaletteIndex(31)) .to_owned() ), STYLE.bg(Color::Indexed(31)) ); // underlined assert_eq!( Style::from_termwiz( CellAttributes::default() .set_underline(Underline::Single) .to_owned() ), STYLE.underlined() ); // blink assert_eq!( Style::from_termwiz(CellAttributes::default().set_blink(Blink::Slow).to_owned()), STYLE.slow_blink() ); // intensity assert_eq!( Style::from_termwiz( CellAttributes::default() .set_intensity(Intensity::Bold) .to_owned() ), STYLE.bold() ); // italic assert_eq!( Style::from_termwiz(CellAttributes::default().set_italic(true).to_owned()), STYLE.italic() ); // reversed assert_eq!( Style::from_termwiz(CellAttributes::default().set_reverse(true).to_owned()), STYLE.reversed() ); // strikethrough assert_eq!( Style::from_termwiz(CellAttributes::default().set_strikethrough(true).to_owned()), STYLE.crossed_out() ); // hidden assert_eq!( Style::from_termwiz(CellAttributes::default().set_invisible(true).to_owned()), STYLE.hidden() ); // underline color #[cfg(feature = "underline-color")] assert_eq!( Style::from_termwiz( CellAttributes::default() .set_underline_color(AnsiColor::Red) .to_owned() ), STYLE.underline_color(Color::Indexed(9)) ); } }