diff options
author | Blaž Hrastnik | 2020-05-28 08:47:35 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-05-28 08:47:35 +0000 |
commit | 6905ff03c29c9fc020a6333adf9e9d5004c3f3c5 (patch) | |
tree | 39b0a23ccafce90cc7c767cee5859c75666fd3d6 | |
parent | 1984410ac998ac5561f4a3de87d3d125f2f61178 (diff) |
Start swapping from termwiz to crossterm + async.
-rw-r--r-- | Cargo.lock | 684 | ||||
-rw-r--r-- | helix-core/src/state.rs | 6 | ||||
-rw-r--r-- | helix-core/src/transaction.rs | 33 | ||||
-rw-r--r-- | helix-term/Cargo.toml | 17 | ||||
-rw-r--r-- | helix-term/src/line.rs | 172 | ||||
-rw-r--r-- | helix-term/src/main.rs | 8 |
6 files changed, 443 insertions, 477 deletions
@@ -1,15 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "aho-corasick" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" -dependencies = [ - "memchr", -] - -[[package]] name = "anyhow" version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -39,9 +30,9 @@ checksum = "e742194e0f43fc932bcb801708c2b279d3ec8f527e3acda05a6a9f342c5ef764" dependencies = [ "argh_shared", "heck", - "proc-macro2 1.0.13", - "quote 1.0.6", - "syn 1.0.22", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -51,16 +42,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1ba68f4276a778591e36a0c348a269888f3a177c8d2054969389e3b59611ff5" [[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.1" +name = "async-task" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" [[package]] name = "autocfg" @@ -69,108 +54,127 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] -name = "base64" -version = "0.10.1" +name = "bitflags" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] -name = "base64" -version = "0.11.0" +name = "cc" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" [[package]] -name = "bitflags" -version = "1.2.1" +name = "cfg-if" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" [[package]] -name = "blake2b_simd" -version = "0.5.10" +name = "cloudabi" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", + "bitflags", ] [[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "cassowary" -version = "0.3.0" +name = "crossbeam" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" +checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" +dependencies = [ + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] [[package]] -name = "cfg-if" -version = "0.1.9" +name = "crossbeam-channel" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +checksum = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061" +dependencies = [ + "crossbeam-utils", + "maybe-uninit", +] [[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "crossbeam-deque" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", + "maybe-uninit", +] [[package]] -name = "crossbeam-utils" -version = "0.7.2" +name = "crossbeam-epoch" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ "autocfg", "cfg-if", + "crossbeam-utils", "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", ] [[package]] -name = "dirs" -version = "2.0.2" +name = "crossbeam-queue" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" dependencies = [ "cfg-if", - "dirs-sys", + "crossbeam-utils", ] [[package]] -name = "dirs-sys" -version = "0.3.4" +name = "crossbeam-utils" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ + "autocfg", "cfg-if", - "libc", - "redox_users", - "winapi", + "lazy_static", ] [[package]] -name = "filedescriptor" -version = "0.7.1" +name = "crossterm" +version = "0.17.4" +source = "git+https://github.com/crossterm-rs/crossterm?branch=mio-update#4ab507dfc41a32dec0d8249f599b02c3a78a83f7" dependencies = [ - "anyhow", + "bitflags", + "crossterm_winapi", + "futures", + "lazy_static", "libc", + "mio", + "parking_lot", + "signal-hook", "winapi", ] [[package]] -name = "fnv" -version = "1.0.7" +name = "crossterm_winapi" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "057b7146d02fb50175fd7dbe5158f6097f33d02831f43b4ee8ae4ddf67b68f5c" +dependencies = [ + "winapi", +] [[package]] name = "futf" @@ -183,14 +187,98 @@ dependencies = [ ] [[package]] -name = "getrandom" -version = "0.1.14" +name = "futures" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" dependencies = [ - "cfg-if", - "libc", - "wasi", + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" + +[[package]] +name = "futures-executor" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" + +[[package]] +name = "futures-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" + +[[package]] +name = "futures-task" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-util" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", ] [[package]] @@ -208,7 +296,7 @@ version = "0.1.0" dependencies = [ "anyhow", "ropey", - "smallvec 1.4.0", + "smallvec", "tendril", ] @@ -218,8 +306,21 @@ version = "0.1.0" dependencies = [ "anyhow", "argh", + "crossterm", + "futures", "helix-core", - "termwiz", + "num_cpus", + "piper", + "smol", +] + +[[package]] +name = "hermit-abi" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" +dependencies = [ + "libc", ] [[package]] @@ -235,6 +336,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" [[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + +[[package]] name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -262,256 +372,199 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] -name = "memmem" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" - -[[package]] -name = "new_debug_unreachable" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - -[[package]] -name = "nom" -version = "5.1.1" +name = "memoffset" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6" -dependencies = [ - "memchr", - "version_check", -] - -[[package]] -name = "num-derive" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eafd0b45c5537c3ba526f79d3e75120036502bebacbb3f3220914067ce39dbf2" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" dependencies = [ "autocfg", ] [[package]] -name = "ordered-float" -version = "1.0.2" +name = "mio" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" +checksum = "6e9971bc8349a361217a8f2a41f5d011274686bd4436465ba51730921039d7fb" dependencies = [ - "num-traits", + "lazy_static", + "libc", + "log", + "miow", + "ntapi", + "winapi", ] [[package]] -name = "phf" -version = "0.8.0" +name = "miow" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +checksum = "22dfdd1d51b2639a5abd17ed07005c3af05fb7a2a3b1a1d0d7af1000a520c1c7" dependencies = [ - "phf_shared", + "socket2", + "winapi", ] [[package]] -name = "phf_codegen" -version = "0.8.0" +name = "new_debug_unreachable" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" -dependencies = [ - "phf_generator", - "phf_shared", -] +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] -name = "phf_generator" -version = "0.8.0" +name = "nix" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" dependencies = [ - "phf_shared", - "rand", + "bitflags", + "cc", + "cfg-if", + "libc", + "void", ] [[package]] -name = "phf_shared" -version = "0.8.0" +name = "ntapi" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" dependencies = [ - "siphasher", + "winapi", ] [[package]] -name = "ppv-lite86" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" - -[[package]] -name = "proc-macro2" -version = "0.4.30" +name = "num_cpus" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ - "unicode-xid 0.1.0", + "hermit-abi", + "libc", ] [[package]] -name = "proc-macro2" -version = "1.0.13" +name = "once_cell" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53f5ffe53a6b28e37c9c1ce74893477864d64f74778a93a4beb43c8fa167f639" -dependencies = [ - "unicode-xid 0.2.0", -] +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" [[package]] -name = "quote" -version = "0.6.13" +name = "parking_lot" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ - "proc-macro2 0.4.30", + "lock_api", + "parking_lot_core", ] [[package]] -name = "quote" -version = "1.0.6" +name = "parking_lot_core" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ - "proc-macro2 1.0.13", + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "smallvec", + "winapi", ] [[package]] -name = "rand" -version = "0.7.3" +name = "pin-project" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "edc93aeee735e60ecb40cf740eb319ff23eab1c5748abfdb5c180e4ce49f7791" dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", - "rand_pcg", + "pin-project-internal", ] [[package]] -name = "rand_chacha" -version = "0.2.2" +name = "pin-project-internal" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40" dependencies = [ - "ppv-lite86", - "rand_core", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "rand_core" -version = "0.5.1" +name = "pin-utils" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "rand_hc" -version = "0.2.0" +name = "piper" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +checksum = "6b0deb65f46e873ba8aa7c6a8dbe3f23cb1bf59c339a81a1d56361dde4d66ac8" dependencies = [ - "rand_core", + "crossbeam-utils", + "futures-io", + "futures-sink", + "futures-util", ] [[package]] -name = "rand_pcg" -version = "0.2.1" +name = "proc-macro-hack" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core", -] +checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" [[package]] -name = "redox_syscall" -version = "0.1.56" +name = "proc-macro-nested" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" [[package]] -name = "redox_users" -version = "0.3.4" +name = "proc-macro2" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" +checksum = "53f5ffe53a6b28e37c9c1ce74893477864d64f74778a93a4beb43c8fa167f639" dependencies = [ - "getrandom", - "redox_syscall", - "rust-argon2", + "unicode-xid", ] [[package]] -name = "regex" -version = "1.3.7" +name = "quote" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" +checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", + "proc-macro2", ] [[package]] -name = "regex-syntax" -version = "0.6.17" +name = "redox_syscall" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] name = "ropey" version = "1.1.0" source = "git+https://github.com/cessen/ropey#083c34949274ef9800267e6bc64b76a45e401807" dependencies = [ - "smallvec 1.4.0", + "smallvec", ] [[package]] -name = "rust-argon2" -version = "0.7.0" +name = "scoped-tls-hkt" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" -dependencies = [ - "base64 0.11.0", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] +checksum = "c2e9d7eaddb227e8fbaaa71136ae0e1e913ca159b86c7da82f3e8f0044ad3a63" [[package]] -name = "semver-parser" -version = "0.7.0" +name = "scopeguard" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "signal-hook" @@ -520,6 +573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ff2db2112d6c761e12522c65f7768548bd6e8cd23d2a9dae162520626629bd6" dependencies = [ "libc", + "mio", "signal-hook-registry", ] @@ -534,35 +588,46 @@ dependencies = [ ] [[package]] -name = "siphasher" -version = "0.3.3" +name = "slab" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "0.6.13" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] +checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] -name = "smallvec" -version = "1.4.0" +name = "smol" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" +checksum = "686c634ad1873fffef6aed20f180eede424fbf3bb31802394c90fd7335a661b7" +dependencies = [ + "async-task", + "crossbeam", + "futures-io", + "futures-util", + "nix", + "once_cell", + "piper", + "scoped-tls-hkt", + "slab", + "socket2", + "wepoll-binding", +] [[package]] -name = "syn" -version = "0.15.44" +name = "socket2" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", + "cfg-if", + "libc", + "redox_syscall", + "winapi", ] [[package]] @@ -571,9 +636,9 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1425de3c33b0941002740a420b1a906a350b88d08b82b2c8a01035a3f9447bac" dependencies = [ - "proc-macro2 1.0.13", - "quote 1.0.6", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -587,85 +652,12 @@ dependencies = [ ] [[package]] -name = "terminfo" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76971977e6121664ec1b960d1313aacfa75642adc93b9d4d53b247bd4cb1747e" -dependencies = [ - "dirs", - "fnv", - "nom", - "phf", - "phf_codegen", -] - -[[package]] -name = "termios" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0fcee7b24a25675de40d5bb4de6e41b0df07bc9856295e7e2b3a3600c400c2" -dependencies = [ - "libc", -] - -[[package]] -name = "termwiz" -version = "0.9.0" -dependencies = [ - "anyhow", - "base64 0.10.1", - "bitflags", - "cassowary", - "filedescriptor", - "fnv", - "lazy_static", - "libc", - "log", - "memmem", - "num-derive", - "num-traits", - "ordered-float", - "regex", - "semver", - "signal-hook", - "smallvec 0.6.13", - "terminfo", - "termios", - "unicode-segmentation", - "unicode-width", - "vtparse", - "winapi", - "xi-unicode", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] name = "unicode-segmentation" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" [[package]] -name = "unicode-width" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -678,29 +670,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] -name = "utf8parse" -version = "0.1.1" +name = "void" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8772a4ccbb4e89959023bc5b7cb8623a795caa7092d99f3aa9501b9484d4557d" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] -name = "version_check" -version = "0.9.1" +name = "wepoll-binding" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" - -[[package]] -name = "vtparse" -version = "0.2.2" +checksum = "374fff4ff9701ff8b6ad0d14bacd3156c44063632d8c136186ff5967d48999a7" dependencies = [ - "utf8parse", + "bitflags", + "wepoll-sys", ] [[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +name = "wepoll-sys" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "9082a777aed991f6769e2b654aa0cb29f1c3d615daf009829b07b66c7aff6a24" +dependencies = [ + "cc", +] [[package]] name = "winapi" @@ -723,9 +715,3 @@ 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 = "xi-unicode" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7395cdb9d0a6219fa0ea77d08c946adf9c1984c72fcd443ace30365f3daadef7" diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs index b4a3f2f0..22de6ca7 100644 --- a/helix-core/src/state.rs +++ b/helix-core/src/state.rs @@ -18,7 +18,11 @@ impl State { // TODO: buf/selection accessors - // update/transact + // update/transact: + // update(desc) => transaction ? transaction.doc() for applied doc + // transaction.apply(doc) + // doc.transact(fn -> ... end) + // replaceSelection (transaction that replaces selection) // changeByRange // changes diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs index 8da01c09..f3bb40fa 100644 --- a/helix-core/src/transaction.rs +++ b/helix-core/src/transaction.rs @@ -1,19 +1,3 @@ -// pub struct Change { -// from: usize, -// to: usize, -// insert: Option<String>, -// } - -// 40 bytes (8 + 24 + 8) -> strings are really big 24 as String, 16 as &str -// pub struct Change { -// /// old extent -// old_extent: usize, -// /// inserted text, new extent equal to insert length -// insert: Option<String>, -// /// distance from the previous change -// distance: usize, -// } - use crate::{Buffer, Rope, Selection, Tendril}; // TODO: divided into three different operations, I sort of like having just @@ -33,11 +17,11 @@ pub enum Change { Insert(Tendril), } -impl Change { - pub fn new(from: usize, to: usize, insert: Option<Tendril>) { - // old_extent, new_extent, insert - } -} +// impl Change { +// pub fn new(from: usize, to: usize, insert: Option<Tendril>) { +// // old_extent, new_extent, insert +// } +// } #[derive(Copy, Clone, PartialEq, Eq)] pub enum Assoc { @@ -46,13 +30,8 @@ pub enum Assoc { } // ChangeSpec = Change | ChangeSet | Vec<Change> -// ChangeDesc as a ChangeSet without text: can't be applied, cheaper to store. -// ChangeSet = ChangeDesc with Text #[derive(Debug)] pub struct ChangeSet { - // basically Vec<ChangeDesc> where ChangeDesc = (current len, replacement len?) - // (0, n>0) for insertion, (n>0, 0) for deletion, (>0, >0) for replacement - // sections: Vec<(usize, isize)>, changes: Vec<Change>, /// The required document length. Will refuse to apply changes unless it matches. len: usize, @@ -341,6 +320,8 @@ pub struct Transaction { // scroll_into_view } +impl Transaction {} + #[cfg(test)] mod test { use super::*; diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index ea4d5b55..0ab6209e 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -10,13 +10,22 @@ edition = "2018" name = "hx" path = "src/main.rs" -# [[bin]] -# name = "line" -# path = "src/line.rs" +[[bin]] +name = "line" +path = "src/line.rs" [dependencies] # termwiz = { git = "https://github.com/wez/wezterm", features = ["widgets"] } -termwiz = { path = "../../wezterm/termwiz", default-features = false, features = ["widgets"] } +# termwiz = { path = "../../wezterm/termwiz", default-features = false, features = ["widgets"] } + anyhow = "1.0.31" argh = "0.1.3" helix-core = { path = "../helix-core" } +# crossterm = { version = "0.17.5", features = ["event-stream"] } +crossterm = { git = "https://github.com/crossterm-rs/crossterm", branch = "mio-update", features = ["event-stream"] } + +futures = { version = "0.3.5", default-features = false, features = ["std"] } +# futures-timer = "3.0.2" +smol = "0.1.10" +num_cpus = "1.13.0" +piper = "0.1.2" diff --git a/helix-term/src/line.rs b/helix-term/src/line.rs index 90fb5e6f..58d4c9d8 100644 --- a/helix-term/src/line.rs +++ b/helix-term/src/line.rs @@ -1,111 +1,97 @@ -use termwiz::cell::AttributeChange; -use termwiz::color::{AnsiColor, ColorAttribute, RgbColor}; -use termwiz::lineedit::*; +//! Demonstrates how to read events asynchronously with async-std. +//! +//! cargo run --features="event-stream" --example event-stream-async-std -#[derive(Default)] -struct Host { - history: BasicHistory, -} +use std::{ + io::{stdout, Write}, + time::Duration, +}; -impl LineEditorHost for Host { - // Render the prompt with a darkslateblue background color if - // the terminal supports true color, otherwise render it with - // a navy blue ansi color. - fn render_prompt(&self, prompt: &str) -> Vec<OutputElement> { - vec![ - OutputElement::Attribute(AttributeChange::Background( - ColorAttribute::TrueColorWithPaletteFallback( - RgbColor::from_named("darkslateblue").unwrap(), - AnsiColor::Navy.into(), - ), - )), - OutputElement::Text(prompt.to_owned()), - ] - } +use futures::{future::FutureExt, select, StreamExt}; +use smol::Timer; +// use futures_timer::Delay; - fn history(&mut self) -> &mut dyn History { - &mut self.history - } +use crossterm::{ + cursor::position, + event::{DisableMouseCapture, EnableMouseCapture, Event, EventStream, KeyCode}, + execute, + terminal::{disable_raw_mode, enable_raw_mode}, + Result, +}; + +const HELP: &str = r#"EventStream based on futures::Stream with async-std + - Keyboard, mouse and terminal resize events enabled + - Prints "." every second if there's no event + - Hit "c" to print current cursor position + - Use Esc to quit +"#; + +async fn print_events() { + let mut reader = EventStream::new(); - /// Demo of the completion API for words starting with "h" or "he" - fn complete(&self, line: &str, cursor_position: usize) -> Vec<CompletionCandidate> { - let mut candidates = vec![]; - if let Some((range, word)) = word_at_cursor(line, cursor_position) { - let words = &["hello", "help", "he-man"]; - - for w in words { - if w.starts_with(word) { - candidates.push(CompletionCandidate { - range: range.clone(), - text: w.to_string(), - }); + loop { + let mut delay = Timer::after(Duration::from_millis(1_000)).fuse(); + let mut event = reader.next().fuse(); + + select! { + _ = delay => { println!(".\r"); }, + maybe_event = event => { + match maybe_event { + Some(Ok(event)) => { + println!("Event::{:?}\r", event); + + if event == Event::Key(KeyCode::Char('c').into()) { + println!("Cursor position: {:?}\r", position()); + } + + if event == Event::Key(KeyCode::Esc.into()) { + break; + } + } + Some(Err(e)) => println!("Error: {:?}\r", e), + None => break, } } - } - candidates + }; } } -/// This is a conceptually simple function that computes the bounds -/// of the whitespace delimited word at the specified cursor position -/// in the supplied line string. -/// It returns the range and the corresponding slice out of the line. -/// This function is sufficient for example purposes; in a real application -/// the equivalent function would need to be aware of quoting and other -/// application specific context. -fn word_at_cursor(line: &str, cursor_position: usize) -> Option<(std::ops::Range<usize>, &str)> { - let char_indices: Vec<(usize, char)> = line.char_indices().collect(); - if char_indices.is_empty() { - return None; - } - let char_position = char_indices - .iter() - .position(|(idx, _)| *idx == cursor_position) - .unwrap_or(char_indices.len()); - - // Look back until we find whitespace - let mut start_position = char_position; - while start_position > 0 - && start_position <= char_indices.len() - && !char_indices[start_position - 1].1.is_whitespace() - { - start_position -= 1; - } +fn main() -> Result<()> { + println!("{}", HELP); - // Look forwards until we find whitespace - let mut end_position = char_position; - while end_position < char_indices.len() && !char_indices[end_position].1.is_whitespace() { - end_position += 1; - } + enable_raw_mode()?; + + let mut stdout = stdout(); + execute!(stdout, EnableMouseCapture)?; + + use std::thread; + + // Same number of threads as there are CPU cores. + let num_threads = num_cpus::get().max(1); - if end_position > start_position { - let range = char_indices[start_position].0 - ..char_indices - .get(end_position) - .map(|c| c.0 + 1) - .unwrap_or(line.len()); - Some((range.clone(), &line[range])) - } else { - None + // A channel that sends the shutdown signal. + let (s, r) = piper::chan::<()>(0); + let mut threads = Vec::new(); + + // Create an executor thread pool. + for _ in 0..num_threads { + // Spawn an executor thread that waits for the shutdown signal. + let r = r.clone(); + threads.push(thread::spawn(move || smol::run(r.recv()))); } -} -fn main() -> anyhow::Result<()> { - println!("Type `exit` to quit this example, or start a word with `h` and press Tab."); - let mut terminal = line_editor_terminal()?; - let mut editor = LineEditor::new(&mut terminal); + // No need to `run()`, now we can just block on the main future. + smol::block_on(print_events()); - let mut host = Host::default(); - loop { - if let Some(line) = editor.read_line(&mut host)? { - println!("read line: {:?}", line); - if line == "exit" { - break; - } + // Send a shutdown signal. + drop(s); - host.history().add(&line); - } + // Wait for threads to finish. + for t in threads { + t.join().unwrap(); } - Ok(()) + execute!(stdout, DisableMouseCapture)?; + + disable_raw_mode() } diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 9dfa3767..aaa83a86 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -1,6 +1,6 @@ -mod editor; +// mod editor; -use editor::Editor; +// use editor::Editor; use argh::FromArgs; use std::{env, path::PathBuf}; @@ -16,9 +16,9 @@ pub struct Args { fn main() -> Result<(), Error> { let args: Args = argh::from_env(); - let mut editor = Editor::new(args)?; + // let mut editor = Editor::new(args)?; - editor.run()?; + // editor.run()?; Ok(()) } |