├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md └── src ├── event.rs ├── main.rs └── view.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "arc-swap" 5 | version = "0.4.3" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | 8 | [[package]] 9 | name = "array-macro" 10 | version = "1.0.4" 11 | source = "registry+https://github.com/rust-lang/crates.io-index" 12 | 13 | [[package]] 14 | name = "autocfg" 15 | version = "0.1.6" 16 | source = "registry+https://github.com/rust-lang/crates.io-index" 17 | 18 | [[package]] 19 | name = "c2-chacha" 20 | version = "0.2.2" 21 | source = "registry+https://github.com/rust-lang/crates.io-index" 22 | dependencies = [ 23 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 24 | "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", 25 | ] 26 | 27 | [[package]] 28 | name = "cc" 29 | version = "1.0.46" 30 | source = "registry+https://github.com/rust-lang/crates.io-index" 31 | 32 | [[package]] 33 | name = "cfg-if" 34 | version = "0.1.10" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | 37 | [[package]] 38 | name = "chrono" 39 | version = "0.4.9" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | dependencies = [ 42 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 43 | "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 44 | "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 45 | "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", 46 | ] 47 | 48 | [[package]] 49 | name = "crossbeam-channel" 50 | version = "0.3.9" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | dependencies = [ 53 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", 54 | ] 55 | 56 | [[package]] 57 | name = "crossbeam-utils" 58 | version = "0.6.6" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | dependencies = [ 61 | "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 62 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 63 | ] 64 | 65 | [[package]] 66 | name = "cursive" 67 | version = "0.13.0" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | dependencies = [ 70 | "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 71 | "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "enum-map 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", 74 | "enumset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 75 | "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", 76 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 77 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 78 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 79 | "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 80 | "ncurses 5.99.0 (registry+https://github.com/rust-lang/crates.io-index)", 81 | "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 82 | "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 83 | "signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 84 | "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 85 | "toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", 86 | "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 87 | "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 88 | "xi-unicode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 89 | ] 90 | 91 | [[package]] 92 | name = "darling" 93 | version = "0.10.1" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | dependencies = [ 96 | "darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", 97 | "darling_macro 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", 98 | ] 99 | 100 | [[package]] 101 | name = "darling_core" 102 | version = "0.10.1" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | dependencies = [ 105 | "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 106 | "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 107 | "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 108 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 109 | "strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", 110 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 111 | ] 112 | 113 | [[package]] 114 | name = "darling_macro" 115 | version = "0.10.1" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | dependencies = [ 118 | "darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", 119 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 120 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 121 | ] 122 | 123 | [[package]] 124 | name = "enum-map" 125 | version = "0.6.1" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | dependencies = [ 128 | "array-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 129 | "enum-map-derive 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 130 | ] 131 | 132 | [[package]] 133 | name = "enum-map-derive" 134 | version = "0.4.3" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | dependencies = [ 137 | "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 138 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 139 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 140 | ] 141 | 142 | [[package]] 143 | name = "enumset" 144 | version = "0.4.4" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | dependencies = [ 147 | "enumset_derive 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 148 | "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 149 | ] 150 | 151 | [[package]] 152 | name = "enumset_derive" 153 | version = "0.4.3" 154 | source = "registry+https://github.com/rust-lang/crates.io-index" 155 | dependencies = [ 156 | "darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", 157 | "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 158 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 159 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 160 | ] 161 | 162 | [[package]] 163 | name = "fnv" 164 | version = "1.0.6" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | 167 | [[package]] 168 | name = "getrandom" 169 | version = "0.1.12" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | dependencies = [ 172 | "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 173 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 174 | "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 175 | ] 176 | 177 | [[package]] 178 | name = "hashbrown" 179 | version = "0.5.0" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | 182 | [[package]] 183 | name = "ident_case" 184 | version = "1.0.1" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | 187 | [[package]] 188 | name = "kernel32-sys" 189 | version = "0.2.2" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | dependencies = [ 192 | "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 193 | "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 194 | ] 195 | 196 | [[package]] 197 | name = "lazy_static" 198 | version = "1.4.0" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | 201 | [[package]] 202 | name = "libc" 203 | version = "0.2.65" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | 206 | [[package]] 207 | name = "log" 208 | version = "0.4.8" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | dependencies = [ 211 | "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 212 | ] 213 | 214 | [[package]] 215 | name = "maplit" 216 | version = "1.0.2" 217 | source = "registry+https://github.com/rust-lang/crates.io-index" 218 | 219 | [[package]] 220 | name = "ncurses" 221 | version = "5.99.0" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | dependencies = [ 224 | "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", 225 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 226 | "pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", 227 | ] 228 | 229 | [[package]] 230 | name = "num" 231 | version = "0.2.0" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | dependencies = [ 234 | "num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 235 | "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 236 | "num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", 237 | "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 238 | "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 239 | ] 240 | 241 | [[package]] 242 | name = "num-complex" 243 | version = "0.2.3" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | dependencies = [ 246 | "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 247 | "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 248 | ] 249 | 250 | [[package]] 251 | name = "num-integer" 252 | version = "0.1.41" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | dependencies = [ 255 | "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 256 | "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 257 | ] 258 | 259 | [[package]] 260 | name = "num-iter" 261 | version = "0.1.39" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | dependencies = [ 264 | "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 265 | "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 266 | "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 267 | ] 268 | 269 | [[package]] 270 | name = "num-rational" 271 | version = "0.2.2" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | dependencies = [ 274 | "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 275 | "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 276 | "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 277 | ] 278 | 279 | [[package]] 280 | name = "num-traits" 281 | version = "0.2.8" 282 | source = "registry+https://github.com/rust-lang/crates.io-index" 283 | dependencies = [ 284 | "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 285 | ] 286 | 287 | [[package]] 288 | name = "numtoa" 289 | version = "0.1.0" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | 292 | [[package]] 293 | name = "owning_ref" 294 | version = "0.4.0" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | dependencies = [ 297 | "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 298 | ] 299 | 300 | [[package]] 301 | name = "pkg-config" 302 | version = "0.3.16" 303 | source = "registry+https://github.com/rust-lang/crates.io-index" 304 | 305 | [[package]] 306 | name = "ppv-lite86" 307 | version = "0.2.5" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | 310 | [[package]] 311 | name = "proc-macro2" 312 | version = "1.0.5" 313 | source = "registry+https://github.com/rust-lang/crates.io-index" 314 | dependencies = [ 315 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 316 | ] 317 | 318 | [[package]] 319 | name = "quote" 320 | version = "1.0.2" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | dependencies = [ 323 | "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 324 | ] 325 | 326 | [[package]] 327 | name = "rand" 328 | version = "0.7.2" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | dependencies = [ 331 | "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", 332 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 333 | "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 334 | "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 335 | "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 336 | ] 337 | 338 | [[package]] 339 | name = "rand_chacha" 340 | version = "0.2.1" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | dependencies = [ 343 | "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 344 | "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 345 | ] 346 | 347 | [[package]] 348 | name = "rand_core" 349 | version = "0.5.1" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | dependencies = [ 352 | "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", 353 | ] 354 | 355 | [[package]] 356 | name = "rand_hc" 357 | version = "0.2.0" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | dependencies = [ 360 | "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 361 | ] 362 | 363 | [[package]] 364 | name = "redox_syscall" 365 | version = "0.1.56" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | 368 | [[package]] 369 | name = "redox_termios" 370 | version = "0.1.1" 371 | source = "registry+https://github.com/rust-lang/crates.io-index" 372 | dependencies = [ 373 | "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", 374 | ] 375 | 376 | [[package]] 377 | name = "rustmatrix" 378 | version = "0.1.0" 379 | dependencies = [ 380 | "cursive 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", 381 | "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", 382 | "termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", 383 | ] 384 | 385 | [[package]] 386 | name = "serde" 387 | version = "1.0.101" 388 | source = "registry+https://github.com/rust-lang/crates.io-index" 389 | 390 | [[package]] 391 | name = "signal-hook" 392 | version = "0.1.10" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | dependencies = [ 395 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 396 | "signal-hook-registry 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 397 | ] 398 | 399 | [[package]] 400 | name = "signal-hook-registry" 401 | version = "1.1.1" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | dependencies = [ 404 | "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 405 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 406 | ] 407 | 408 | [[package]] 409 | name = "stable_deref_trait" 410 | version = "1.1.1" 411 | source = "registry+https://github.com/rust-lang/crates.io-index" 412 | 413 | [[package]] 414 | name = "strsim" 415 | version = "0.9.2" 416 | source = "registry+https://github.com/rust-lang/crates.io-index" 417 | 418 | [[package]] 419 | name = "syn" 420 | version = "1.0.5" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | dependencies = [ 423 | "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 424 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 425 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 426 | ] 427 | 428 | [[package]] 429 | name = "term_size" 430 | version = "0.3.1" 431 | source = "registry+https://github.com/rust-lang/crates.io-index" 432 | dependencies = [ 433 | "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 434 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 435 | "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 436 | ] 437 | 438 | [[package]] 439 | name = "termion" 440 | version = "1.5.3" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | dependencies = [ 443 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 444 | "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 445 | "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", 446 | "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 447 | ] 448 | 449 | [[package]] 450 | name = "time" 451 | version = "0.1.42" 452 | source = "registry+https://github.com/rust-lang/crates.io-index" 453 | dependencies = [ 454 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 455 | "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", 456 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 457 | ] 458 | 459 | [[package]] 460 | name = "toml" 461 | version = "0.5.3" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | dependencies = [ 464 | "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 465 | ] 466 | 467 | [[package]] 468 | name = "unicode-segmentation" 469 | version = "1.3.0" 470 | source = "registry+https://github.com/rust-lang/crates.io-index" 471 | 472 | [[package]] 473 | name = "unicode-width" 474 | version = "0.1.6" 475 | source = "registry+https://github.com/rust-lang/crates.io-index" 476 | 477 | [[package]] 478 | name = "unicode-xid" 479 | version = "0.2.0" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | 482 | [[package]] 483 | name = "wasi" 484 | version = "0.7.0" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | 487 | [[package]] 488 | name = "winapi" 489 | version = "0.2.8" 490 | source = "registry+https://github.com/rust-lang/crates.io-index" 491 | 492 | [[package]] 493 | name = "winapi" 494 | version = "0.3.8" 495 | source = "registry+https://github.com/rust-lang/crates.io-index" 496 | dependencies = [ 497 | "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 498 | "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 499 | ] 500 | 501 | [[package]] 502 | name = "winapi-build" 503 | version = "0.1.1" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | 506 | [[package]] 507 | name = "winapi-i686-pc-windows-gnu" 508 | version = "0.4.0" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | 511 | [[package]] 512 | name = "winapi-x86_64-pc-windows-gnu" 513 | version = "0.4.0" 514 | source = "registry+https://github.com/rust-lang/crates.io-index" 515 | 516 | [[package]] 517 | name = "xi-unicode" 518 | version = "0.2.0" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | 521 | [metadata] 522 | "checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" 523 | "checksum array-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7d034edd76d4e7adc314c95400941dedc89bd4337d565bf87f6b69d3b20dc4de" 524 | "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" 525 | "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" 526 | "checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" 527 | "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 528 | "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" 529 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" 530 | "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" 531 | "checksum cursive 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6261747aa936aab19fc4ac3a2c1a8eee8fb5862ba96fb1e524ee56cb520d9caf" 532 | "checksum darling 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe629a532efad5526454efb0700f86d5ad7ff001acb37e431c8bf017a432a8e" 533 | "checksum darling_core 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee54512bec54b41cf2337a22ddfadb53c7d4c738494dc2a186d7b037ad683b85" 534 | "checksum darling_macro 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cd3e432e52c0810b72898296a69d66b1d78d1517dff6cde7a130557a55a62c1" 535 | "checksum enum-map 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "75eb4afb8170adb4120b13700c1af58c3137cd72e4c56e282045af5c29ab5329" 536 | "checksum enum-map-derive 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e57001dfb2532f5a103ff869656887fae9a8defa7d236f3e39d2ee86ed629ad7" 537 | "checksum enumset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "57b811aef4ff1cc938f13bbec348f0ecbfc2bb565b7ab90161c9f0b2805edc8a" 538 | "checksum enumset_derive 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b184c2d0714bbeeb6440481a19c78530aa210654d99529f13d2f860a1b447598" 539 | "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" 540 | "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" 541 | "checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" 542 | "checksum ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 543 | "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 544 | "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 545 | "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" 546 | "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 547 | "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" 548 | "checksum ncurses 5.99.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15699bee2f37e9f8828c7b35b2bc70d13846db453f2d507713b758fabe536b82" 549 | "checksum num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf4825417e1e1406b3782a8ce92f4d53f26ec055e3622e1881ca8e9f5f9e08db" 550 | "checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc" 551 | "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" 552 | "checksum num-iter 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e" 553 | "checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454" 554 | "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" 555 | "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" 556 | "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" 557 | "checksum pkg-config 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "72d5370d90f49f70bd033c3d75e87fc529fbfff9d6f7cccef07d6170079d91ea" 558 | "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" 559 | "checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" 560 | "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" 561 | "checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" 562 | "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" 563 | "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 564 | "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 565 | "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" 566 | "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" 567 | "checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" 568 | "checksum signal-hook 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4f61c4d59f3aaa9f61bba6450a9b80ba48362fd7d651689e7a10c453b1f6dc68" 569 | "checksum signal-hook-registry 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1797d48f38f91643908bb14e35e79928f9f4b3cefb2420a564dde0991b4358dc" 570 | "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 571 | "checksum strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "032c03039aae92b350aad2e3779c352e104d919cb192ba2fabbd7b831ce4f0f6" 572 | "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" 573 | "checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" 574 | "checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" 575 | "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" 576 | "checksum toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7aabe75941d914b72bf3e5d3932ed92ce0664d49d8432305a8b547c37227724" 577 | "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" 578 | "checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" 579 | "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" 580 | "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" 581 | "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 582 | "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" 583 | "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" 584 | "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 585 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 586 | "checksum xi-unicode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7395cdb9d0a6219fa0ea77d08c946adf9c1984c72fcd443ace30365f3daadef7" 587 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustmatrix" 3 | version = "0.1.0" 4 | authors = ["meagnehouser "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | cursive = "0.13" 11 | rand = "0.7.2" 12 | termion = "1.5.3" 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rustmatrix 2 | Cli application to simulate the display from "The Matrix" in terminal. Based on CMatrix and UniMatrix. 3 | 4 | rustmatrix 5 | -------------------------------------------------------------------------------- /src/event.rs: -------------------------------------------------------------------------------- 1 | use std::io; 2 | use std::sync::mpsc; 3 | use std::thread; 4 | use std::time::Duration; 5 | 6 | use termion::event::Key; 7 | use termion::input::TermRead; 8 | 9 | pub enum Event { 10 | Tick, 11 | Exit, 12 | } 13 | 14 | pub struct Events { 15 | rx: mpsc::Receiver, 16 | _input_handle: thread::JoinHandle<()>, 17 | _tick_handle: thread::JoinHandle<()>, 18 | } 19 | 20 | impl Events { 21 | pub fn new(tick_rate: u64) -> Events { 22 | let (tx, rx) = mpsc::channel(); 23 | let input_handle = { 24 | let tx = tx.clone(); 25 | thread::spawn(move || { 26 | let stdin = io::stdin(); 27 | for evt in stdin.keys() { 28 | if let Ok(Key::Ctrl('c')) = evt { 29 | tx.send(Event::Exit).unwrap(); 30 | }; 31 | } 32 | }) 33 | }; 34 | let tick_handle = { 35 | let tx = tx.clone(); 36 | thread::spawn(move || loop { 37 | tx.send(Event::Tick).unwrap(); 38 | thread::sleep(Duration::from_millis(tick_rate)) 39 | }) 40 | }; 41 | 42 | Events { 43 | rx, 44 | _input_handle: input_handle, 45 | _tick_handle: tick_handle, 46 | } 47 | } 48 | 49 | pub fn next(&self) -> Result { 50 | self.rx.recv() 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod event; 2 | mod view; 3 | 4 | use crate::event::{Event, Events}; 5 | use crate::view::MatrixApp; 6 | 7 | fn main() { 8 | let events = Events::new(250); 9 | let mut app = MatrixApp::new(); 10 | 11 | loop { 12 | match events.next().unwrap() { 13 | Event::Tick => { 14 | app.on_tick(); 15 | } 16 | Event::Exit => break, 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/view.rs: -------------------------------------------------------------------------------- 1 | use rand::prelude::*; 2 | use std::cell::RefCell; 3 | use std::collections::VecDeque; 4 | use std::io::{stdout, Stdout, Write}; 5 | use std::mem; 6 | use termion; 7 | use termion::raw::{IntoRawMode, RawTerminal}; 8 | 9 | const CHARS: &str = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNMヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン1234567890-=*_+|:<>"; 10 | 11 | enum ColorType { 12 | White, 13 | Normal, 14 | } 15 | 16 | enum Character { 17 | Char { 18 | char: char, 19 | bold: bool, 20 | color_type: ColorType, 21 | }, 22 | Blank, 23 | } 24 | 25 | enum NodeType { 26 | Eraser, 27 | Writer { white: bool, rng: ThreadRng }, 28 | } 29 | 30 | impl NodeType { 31 | fn choice_char(&mut self) -> Character { 32 | match self { 33 | NodeType::Writer { white, ref mut rng } => { 34 | let chars: Vec = String::from(CHARS).chars().collect(); 35 | let char = chars.choose(rng).unwrap().to_owned(); 36 | let bold = rng.gen(); 37 | let color_type = if *white { 38 | ColorType::White 39 | } else { 40 | ColorType::Normal 41 | }; 42 | Character::Char { 43 | char, 44 | bold, 45 | color_type, 46 | } 47 | } 48 | NodeType::Eraser => Character::Blank, 49 | } 50 | } 51 | } 52 | 53 | struct Node { 54 | node_type: NodeType, 55 | y: u16, 56 | previous_char: Character, 57 | char: Character, 58 | } 59 | 60 | impl Node { 61 | fn new(mut node_type: NodeType) -> Node { 62 | let y = 1; 63 | let char = node_type.choice_char(); 64 | Node { 65 | node_type, 66 | y, 67 | previous_char: Character::Blank, 68 | char, 69 | } 70 | } 71 | 72 | fn update(&mut self) { 73 | self.y += 1; 74 | let next_char = self.node_type.choice_char(); 75 | self.previous_char = mem::replace(&mut self.char, next_char); 76 | } 77 | } 78 | 79 | struct Column { 80 | row_count: u16, 81 | wait_time: u16, 82 | rng: ThreadRng, 83 | nodes: VecDeque, 84 | is_drawing: bool, 85 | } 86 | 87 | impl Column { 88 | fn new(row_count: u16) -> Column { 89 | let mut rng = thread_rng(); 90 | let wait_time = rng.gen_range(0, row_count); 91 | Column { 92 | row_count, 93 | wait_time, 94 | rng, 95 | nodes: VecDeque::new(), 96 | is_drawing: false, 97 | } 98 | } 99 | 100 | fn spawn_node(&mut self) -> Node { 101 | let max_range = self.row_count - 3; 102 | let start_delay = self.rng.gen_range(1, max_range); 103 | self.wait_time = start_delay; 104 | 105 | self.is_drawing = !self.is_drawing; 106 | if self.is_drawing { 107 | let white: bool = self.rng.gen(); 108 | Node::new(NodeType::Writer { 109 | white, 110 | rng: thread_rng(), 111 | }) 112 | } else { 113 | Node::new(NodeType::Eraser) 114 | } 115 | } 116 | 117 | fn update(&mut self) { 118 | for node in self.nodes.iter_mut() { 119 | node.update(); 120 | } 121 | 122 | if self.wait_time == 0 { 123 | let node = self.spawn_node(); 124 | self.nodes.push_back(node); 125 | } else { 126 | self.wait_time -= 1; 127 | } 128 | 129 | if let Some(node) = self.nodes.front() { 130 | if node.y > self.row_count { 131 | self.nodes.pop_front(); 132 | } 133 | } 134 | } 135 | } 136 | 137 | pub struct MatrixApp { 138 | columns: Vec, 139 | stdout: RefCell>, 140 | } 141 | 142 | impl MatrixApp { 143 | pub fn new() -> MatrixApp { 144 | let (size_x, size_y) = termion::terminal_size().unwrap(); 145 | let mut stdout = stdout().into_raw_mode().unwrap(); 146 | write!(stdout, "{}{}", termion::clear::All, termion::cursor::Hide).unwrap(); 147 | let column_count = size_x / 2; 148 | 149 | let columns = (0..column_count).map(|_| Column::new(size_y)).collect(); 150 | 151 | MatrixApp { 152 | columns, 153 | stdout: RefCell::new(stdout), 154 | } 155 | } 156 | 157 | fn update(&mut self) { 158 | for column in self.columns.iter_mut() { 159 | column.update(); 160 | } 161 | } 162 | 163 | fn draw(&self) { 164 | for (x, column) in self.columns.iter().enumerate() { 165 | for node in column.nodes.iter() { 166 | write!( 167 | self.stdout.borrow_mut(), 168 | "{}", 169 | termion::cursor::Goto((x * 2) as u16, node.y) 170 | ) 171 | .unwrap(); 172 | 173 | match &node.char { 174 | Character::Char { 175 | char, 176 | bold, 177 | color_type, 178 | } => { 179 | match color_type { 180 | ColorType::White => { 181 | self.set_white_char_style(); 182 | } 183 | ColorType::Normal => { 184 | self.set_normal_char_style(*bold); 185 | } 186 | }; 187 | write!( 188 | self.stdout.borrow_mut(), 189 | "{}{}", 190 | char, 191 | termion::style::Reset 192 | ) 193 | .unwrap(); 194 | } 195 | Character::Blank => { 196 | write!(self.stdout.borrow_mut(), " ").unwrap(); 197 | } 198 | } 199 | 200 | if node.y == 1 { 201 | continue; 202 | } 203 | 204 | if let Character::Char { 205 | char, 206 | bold, 207 | color_type: ColorType::White, 208 | } = &node.char 209 | { 210 | self.set_normal_char_style(*bold); 211 | write!( 212 | self.stdout.borrow_mut(), 213 | "{}{}{}", 214 | termion::cursor::Goto((x * 2) as u16, (node.y - 1) as u16), 215 | char, 216 | termion::style::Reset 217 | ) 218 | .unwrap(); 219 | } 220 | } 221 | } 222 | self.stdout.borrow_mut().flush().unwrap(); 223 | } 224 | 225 | fn set_normal_char_style(&self, bold: bool) { 226 | if bold { 227 | write!(self.stdout.borrow_mut(), "{}", termion::style::Bold,).unwrap(); 228 | } 229 | 230 | write!( 231 | self.stdout.borrow_mut(), 232 | "{}", 233 | termion::color::Fg(termion::color::Green) 234 | ) 235 | .unwrap(); 236 | } 237 | 238 | fn set_white_char_style(&self) { 239 | write!( 240 | self.stdout.borrow_mut(), 241 | "{}{}", 242 | termion::style::Bold, 243 | termion::color::Fg(termion::color::White) 244 | ) 245 | .unwrap(); 246 | } 247 | 248 | pub fn on_tick(&mut self) { 249 | self.update(); 250 | self.draw(); 251 | } 252 | } 253 | 254 | impl Drop for MatrixApp { 255 | fn drop(&mut self) { 256 | write!(self.stdout.borrow_mut(), "{}", termion::cursor::Show).unwrap(); 257 | } 258 | } 259 | --------------------------------------------------------------------------------