From fd444a620d41352c98df85e2afaee7bc05311f8b Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 5 May 2024 22:50:38 -0400 Subject: [PATCH] Create an example UI and event handler --- Cargo.lock | 488 ++++++++++++++++++++++++++++------- Cargo.toml | 1 + editor-challenge/Cargo.toml | 14 + editor-challenge/src/main.rs | 110 ++++++++ 4 files changed, 524 insertions(+), 89 deletions(-) create mode 100644 editor-challenge/Cargo.toml create mode 100644 editor-challenge/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 4118f22..e54657d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,23 +68,24 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" @@ -184,7 +185,7 @@ dependencies = [ "cfg-if", "concurrent-queue", "futures-lite 1.13.0", - "log 0.4.20", + "log 0.4.21", "parking", "polling 2.8.0", "rustix 0.37.27", @@ -249,7 +250,7 @@ dependencies = [ "futures-lite 1.13.0", "gloo-timers", "kv-log-macro", - "log 0.4.20", + "log 0.4.21", "memchr", "once_cell", "pin-project-lite", @@ -307,7 +308,7 @@ dependencies = [ "base64ct", "clap", "cool_asserts", - "serde 1.0.193", + "serde 1.0.200", "sha2", "sqlx", "thiserror", @@ -400,7 +401,7 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" dependencies = [ - "serde 1.0.193", + "serde 1.0.200", ] [[package]] @@ -483,6 +484,12 @@ dependencies = [ "system-deps", ] +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + [[package]] name = "cc" version = "1.0.83" @@ -512,7 +519,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" name = "changeset" version = "0.1.0" dependencies = [ - "uuid 1.6.1", + "uuid 1.8.0", ] [[package]] @@ -525,7 +532,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "serde 1.0.193", + "serde 1.0.200", "wasm-bindgen", "windows-targets 0.48.5", ] @@ -539,7 +546,7 @@ dependencies = [ "chrono", "chrono-tz-build", "phf 0.11.2", - "serde 1.0.193", + "serde 1.0.200", ] [[package]] @@ -629,7 +636,7 @@ version = "0.1.0" dependencies = [ "config-derive", "cool_asserts", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "thiserror", ] @@ -767,6 +774,57 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossterm" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c36c10130df424b2f3552fcc2ddcd9b28a27b1e54b358b45874f88d1ca6888c" +dependencies = [ + "bitflags 1.3.2", + "crossterm_winapi 0.7.0", + "lazy_static", + "libc", + "mio 0.7.14", + "parking_lot 0.11.2", + "serde 1.0.200", + "signal-hook 0.1.17", + "winapi", +] + +[[package]] +name = "crossterm" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +dependencies = [ + "bitflags 1.3.2", + "crossterm_winapi 0.9.1", + "libc", + "mio 0.8.10", + "parking_lot 0.12.1", + "signal-hook 0.3.17", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da8964ace4d3e4a044fd027919b2237000b24315a37c916f61809f1ff2140b9" +dependencies = [ + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -813,7 +871,7 @@ dependencies = [ "libadwaita", "memorycache", "reqwest", - "serde 1.0.193", + "serde 1.0.200", "serde_derive", "serde_json", "tokio", @@ -876,7 +934,7 @@ checksum = "2517b0555262aeeda0d107a40ecfbbcf185921180ffb4acf316ebe0887467e26" dependencies = [ "generic-array 0.11.2", "num-traits", - "serde 1.0.193", + "serde 1.0.200", "typenum", ] @@ -888,7 +946,7 @@ checksum = "a0b0a86c5d31c93238ff4b694fa31f3acdf67440770dc314c57d90e433914397" dependencies = [ "generic-array 0.14.7", "num-traits", - "serde 1.0.193", + "serde 1.0.200", "typenum", ] @@ -909,13 +967,36 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dtt" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b2dd9ee2d76888dc4c17d6da74629fa11b3cb1e8094fdc159b7f8ff259fc88" +dependencies = [ + "regex", + "serde 1.0.200", + "time 0.3.31", +] + +[[package]] +name = "editor-challenge" +version = "0.1.0" +dependencies = [ + "anyhow", + "crossterm 0.19.0", + "serde 1.0.200", + "serde_yml", + "thiserror", + "tui", +] + [[package]] name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" dependencies = [ - "serde 1.0.193", + "serde 1.0.200", ] [[package]] @@ -925,7 +1006,7 @@ dependencies = [ "chrono", "chrono-tz", "dimensioned 0.7.0", - "serde 1.0.193", + "serde 1.0.200", "serde_derive", "serde_json", "tempfile", @@ -942,6 +1023,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log 0.4.21", + "regex", +] + [[package]] name = "env_logger" version = "0.10.1" @@ -950,11 +1041,24 @@ checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", - "log 0.4.20", + "log 0.4.21", "regex", "termcolor", ] +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log 0.4.21", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1059,6 +1163,12 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "figlet-rs" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4742a071cd9694fc86f9fa1a08fa3e53d40cc899d7ee532295da2d085639fbc5" + [[package]] name = "file-service" version = "0.2.0" @@ -1075,12 +1185,12 @@ dependencies = [ "hex-string", "http 0.2.11", "image 0.23.14", - "log 0.4.20", + "log 0.4.21", "logger", "mime 0.3.17", "mime_guess 2.0.4", "pretty_env_logger", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "sha2", "tempdir", @@ -1230,7 +1340,7 @@ dependencies = [ "chrono-tz", "dimensioned 0.8.0", "emseries", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "tempfile", ] @@ -1291,7 +1401,7 @@ checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot", + "parking_lot 0.12.1", ] [[package]] @@ -1609,7 +1719,7 @@ dependencies = [ "glib-build-tools 0.16.3", "gtk4", "libadwaita", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "tokio", ] @@ -1880,6 +1990,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "http" version = "0.2.11" @@ -2046,7 +2167,7 @@ name = "ifc" version = "0.1.0" dependencies = [ "chrono", - "serde 1.0.193", + "serde 1.0.200", "thiserror", ] @@ -2096,9 +2217,9 @@ checksum = "0cfe9645a18782869361d9c8732246be7b410ad4e919d3609ebabdac00ba12c3" [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -2176,6 +2297,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.12.0" @@ -2187,9 +2314,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jpeg-decoder" @@ -2224,7 +2351,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" dependencies = [ - "log 0.4.20", + "log 0.4.21", ] [[package]] @@ -2303,6 +2430,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libyml" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1303532258de1fbe263b4daaaba0e17e3d502b8de57b7845928b92398fb4afd1" + [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -2331,14 +2464,14 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" dependencies = [ - "log 0.4.20", + "log 0.4.21", ] [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" dependencies = [ "value-bag", ] @@ -2354,6 +2487,12 @@ dependencies = [ "time 0.1.45", ] +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matches" version = "0.1.10" @@ -2391,7 +2530,7 @@ version = "0.1.0" dependencies = [ "chrono", "futures", - "serde 1.0.193", + "serde 1.0.200", "serde_derive", "tokio", ] @@ -2468,6 +2607,19 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +dependencies = [ + "libc", + "log 0.4.21", + "miow", + "ntapi", + "winapi", +] + [[package]] name = "mio" version = "0.8.10" @@ -2475,10 +2627,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", + "log 0.4.21", "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + [[package]] name = "modifier" version = "0.1.0" @@ -2496,7 +2658,7 @@ dependencies = [ "futures-util", "http 0.2.11", "httparse", - "log 0.4.20", + "log 0.4.21", "memchr", "mime 0.3.17", "spin 0.9.8", @@ -2521,7 +2683,7 @@ checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ "lazy_static", "libc", - "log 0.4.20", + "log 0.4.21", "openssl", "openssl-probe", "openssl-sys", @@ -2566,6 +2728,15 @@ dependencies = [ "nom", ] +[[package]] +name = "ntapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +dependencies = [ + "winapi", +] + [[package]] name = "num-bigint-dig" version = "0.8.4" @@ -2663,9 +2834,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.61" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -2694,13 +2865,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] -name = "openssl-sys" -version = "0.9.97" +name = "openssl-src" +version = "300.2.3+3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" +checksum = "5cff92b6f71555b61bb9315f7c64da3ca43d87531622120fea0195fc761b4843" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -2716,7 +2897,7 @@ dependencies = [ "cool_asserts", "grid", "nary_tree", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "sgf", "thiserror", @@ -2774,6 +2955,17 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -2781,7 +2973,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", ] [[package]] @@ -2792,7 +2998,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "smallvec", "windows-targets 0.48.5", ] @@ -3025,7 +3231,7 @@ dependencies = [ "cfg-if", "concurrent-queue", "libc", - "log 0.4.20", + "log 0.4.21", "pin-project-lite", "windows-sys 0.48.0", ] @@ -3062,8 +3268,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" dependencies = [ - "env_logger", - "log 0.4.20", + "env_logger 0.10.1", + "log 0.4.21", ] [[package]] @@ -3360,6 +3566,15 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -3425,13 +3640,13 @@ dependencies = [ "hyper-tls", "ipnet", "js-sys", - "log 0.4.20", + "log 0.4.21", "mime 0.3.17", "native-tls", "once_cell", "percent-encoding 2.3.1", "pin-project-lite", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "serde_urlencoded", "system-configuration", @@ -3452,6 +3667,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "rlg" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e02c717e23f67b23032a4acb01cf63534d6259938d592e6d2451c02f09fc368" +dependencies = [ + "dtt", + "hostname", + "serde_json", + "tokio", + "vrd", +] + [[package]] name = "rsa" version = "0.9.6" @@ -3543,9 +3771,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "safemem" @@ -3640,18 +3868,18 @@ checksum = "34b623917345a631dc9608d5194cc206b3fe6c3554cd1c75b937e55e285254af" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", @@ -3660,13 +3888,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", - "serde 1.0.193", + "serde 1.0.200", ] [[package]] @@ -3675,7 +3903,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ - "serde 1.0.193", + "serde 1.0.200", ] [[package]] @@ -3687,7 +3915,27 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde 1.0.193", + "serde 1.0.200", +] + +[[package]] +name = "serde_yml" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b48f444c502b161ee70dafc567a48336c0a05139e586758dc40ef528d511d235" +dependencies = [ + "dtt", + "env_logger 0.11.3", + "figlet-rs", + "indexmap", + "itoa", + "libyml", + "log 0.4.21", + "openssl", + "rlg", + "ryu", + "serde 1.0.200", + "uuid 1.8.0", ] [[package]] @@ -3698,7 +3946,7 @@ dependencies = [ "cool_asserts", "nary_tree", "nom", - "serde 1.0.193", + "serde 1.0.200", "thiserror", "typeshare", "uuid 0.8.2", @@ -3726,6 +3974,38 @@ dependencies = [ "digest", ] +[[package]] +name = "signal-hook" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" +dependencies = [ + "libc", + "mio 0.7.14", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +dependencies = [ + "libc", + "mio 0.8.10", + "signal-hook 0.3.17", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3876,12 +4156,12 @@ dependencies = [ "hashlink", "hex", "indexmap", - "log 0.4.20", + "log 0.4.21", "memchr", "once_cell", "paste", "percent-encoding 2.3.1", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "sha2", "smallvec", @@ -3920,7 +4200,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "sha2", "sqlx-core", @@ -3956,14 +4236,14 @@ dependencies = [ "hkdf", "hmac", "itoa", - "log 0.4.20", + "log 0.4.21", "md-5", "memchr", "once_cell", "percent-encoding 2.3.1", "rand 0.8.5", "rsa", - "serde 1.0.193", + "serde 1.0.200", "sha1", "sha2", "smallvec", @@ -3996,12 +4276,12 @@ dependencies = [ "hmac", "home", "itoa", - "log 0.4.20", + "log 0.4.21", "md-5", "memchr", "once_cell", "rand 0.8.5", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "sha1", "sha2", @@ -4027,9 +4307,9 @@ dependencies = [ "futures-intrusive", "futures-util", "libsqlite3-sys", - "log 0.4.20", + "log 0.4.21", "percent-encoding 2.3.1", - "serde 1.0.193", + "serde 1.0.200", "sqlx-core", "tracing", "url 2.5.0", @@ -4139,7 +4419,7 @@ checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall", + "redox_syscall 0.4.1", "rustix 0.38.28", "windows-sys 0.48.0", ] @@ -4215,7 +4495,7 @@ dependencies = [ "deranged", "itoa", "powerfmt", - "serde 1.0.193", + "serde 1.0.200", "time-core", "time-macros", ] @@ -4269,16 +4549,16 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", "libc", - "mio", + "mio 0.8.10", "num_cpus", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2 0.5.5", @@ -4325,7 +4605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", - "log 0.4.20", + "log 0.4.21", "tokio", "tungstenite", ] @@ -4350,7 +4630,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ - "serde 1.0.193", + "serde 1.0.200", "serde_spanned", "toml_datetime", "toml_edit 0.20.2", @@ -4362,7 +4642,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ - "serde 1.0.193", + "serde 1.0.200", ] [[package]] @@ -4383,7 +4663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap", - "serde 1.0.193", + "serde 1.0.200", "serde_spanned", "toml_datetime", "winnow", @@ -4401,7 +4681,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log 0.4.20", + "log 0.4.21", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4443,6 +4723,20 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tui" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" +dependencies = [ + "bitflags 1.3.2", + "cassowary", + "crossterm 0.25.0", + "serde 1.0.200", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "tungstenite" version = "0.20.1" @@ -4454,7 +4748,7 @@ dependencies = [ "data-encoding", "http 0.2.11", "httparse", - "log 0.4.20", + "log 0.4.21", "rand 0.8.5", "sha1", "thiserror", @@ -4499,7 +4793,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f44d1a2f454cb35fbe05b218c410792697e76bd868f48d3a418f2cd1a7d527d6" dependencies = [ "chrono", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "typeshare-annotation", ] @@ -4583,6 +4877,12 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +[[package]] +name = "unicode-width" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" + [[package]] name = "unicode_categories" version = "0.1.1" @@ -4655,14 +4955,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ "getrandom", - "serde 1.0.193", + "serde 1.0.200", ] [[package]] name = "uuid" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom", ] @@ -4703,12 +5003,22 @@ version = "0.1.0" dependencies = [ "authdb", "http 1.0.0", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "tokio", "warp", ] +[[package]] +name = "vrd" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee1067b8d17481f5be71b59d11c329e955ffe36348907e0a4a41b619682bb4af" +dependencies = [ + "rand 0.8.5", + "serde 1.0.200", +] + [[package]] name = "wait-timeout" version = "0.2.0" @@ -4745,7 +5055,7 @@ dependencies = [ "headers", "http 0.2.11", "hyper 0.14.28", - "log 0.4.20", + "log 0.4.21", "mime 0.3.17", "mime_guess 2.0.4", "multer", @@ -4753,7 +5063,7 @@ dependencies = [ "pin-project", "rustls-pemfile", "scoped-tls", - "serde 1.0.193", + "serde 1.0.200", "serde_json", "serde_urlencoded", "tokio", @@ -4793,7 +5103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", - "log 0.4.20", + "log 0.4.21", "once_cell", "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 538b62b..a930038 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ members = [ "coordinates", "cyberpunk-splash", "dashboard", + "editor-challenge", "emseries", "file-service", "fitnesstrax/core", diff --git a/editor-challenge/Cargo.toml b/editor-challenge/Cargo.toml new file mode 100644 index 0000000..1f3a98d --- /dev/null +++ b/editor-challenge/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "editor-challenge" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = { version = "1" } +crossterm = { version = "0.19", features = [ "serde" ] } +serde = { version = "1", features = [ "derive" ] } +serde_yml = { version = "*" } +thiserror = { version = "1" } +tui = { version = "0.19", default-features = false, features = [ "crossterm", "serde" ] } diff --git a/editor-challenge/src/main.rs b/editor-challenge/src/main.rs new file mode 100644 index 0000000..db55133 --- /dev/null +++ b/editor-challenge/src/main.rs @@ -0,0 +1,110 @@ +use crossterm::{event::{self, KeyCode, KeyEvent}, terminal::{disable_raw_mode, enable_raw_mode}}; +use std::{io::{self, Read}, sync::mpsc, thread, time::{Duration, Instant}}; +use tui::{ + backend::CrosstermBackend, layout::{Alignment, Constraint, Direction, Layout}, style::{Color, Style}, widgets::{Block, BorderType, Borders, Paragraph}, Terminal +}; + +const TITLE: &str = "Editor Challenge"; +const COPYRIGHT: &str = "Editor Challenge, (c) Savanni D'Gerinel - all rights reserved"; +const TICK_RATE_MS: u64 = 200; + +fn render(terminal: &mut Terminal) -> Result<(), anyhow::Error> +where + T: tui::backend::Backend, +{ + terminal.draw(|rect| { + let size = rect.size(); + let chunks = Layout::default() + .direction(Direction::Vertical) + .margin(2) + .constraints( + [ + Constraint::Length(3), + Constraint::Min(2), + Constraint::Length(3), + ] + .as_ref(), + ) + .split(size); + + let title = Paragraph::new(TITLE) + .style(Style::default().fg(Color::LightCyan)) + .alignment(Alignment::Center) + .block( + Block::default() + .borders(Borders::ALL) + .style(Style::default().fg(Color::White)) + .title("Copyright") + .border_type(BorderType::Plain), + ); + rect.render_widget(title, chunks[0]); + + let cp = Paragraph::new(COPYRIGHT) + .style(Style::default().fg(Color::LightCyan)) + .alignment(Alignment::Center) + .block( + Block::default() + .borders(Borders::ALL) + .style(Style::default().fg(Color::White)) + .title("Copyright") + .border_type(BorderType::Plain), + ); + rect.render_widget(cp, chunks[2]); + })?; + Ok(()) +} + +enum Event { + Input(I), + Tick, +} + +fn handle_input(tx: mpsc::Sender>, tick_rate: Duration) { + let mut last_tick = Instant::now(); + loop { + let timeout = tick_rate.checked_sub(last_tick.elapsed()) + .unwrap_or_else(|| Duration::from_secs(0)); + + if event::poll(timeout).expect("poll works") { + if let event::Event::Key(key) = event::read().expect("can read events") { + tx.send(Event::Input(key)).expect("can send events"); + } + } + + if last_tick.elapsed() >= tick_rate { + if let Ok(_) = tx.send(Event::Tick) { + last_tick = Instant::now(); + } + } + } +} + +fn main() -> Result<(), anyhow::Error> { + let (tx, rx) = mpsc::channel(); + + let tick_rate = Duration::from_millis(TICK_RATE_MS); + thread::spawn(move || { + handle_input(tx, tick_rate); + }); + + enable_raw_mode()?; + + let stdout = io::stdout(); + let backend = CrosstermBackend::new(stdout); + let mut terminal = Terminal::new(backend)?; + let _ = terminal.clear()?; + + loop { + render(&mut terminal)?; + + let event = rx.recv()?; + + match event { + Event::Input(KeyEvent{ code, .. }) if code == KeyCode::Char('q') => { + disable_raw_mode()?; + return Ok(()); + } + _ => {}, + } + } +}