├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── assets └── iosevka.ttf ├── bevy_example ├── Cargo.toml └── src │ └── main.rs ├── scratch ├── screen3.png ├── src ├── lib.rs └── ratagui_backend.rs └── tyorhun.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac stuff: 2 | .DS_Store 3 | 4 | # trunk output folder 5 | dist 6 | 7 | # Rust compile target directories: 8 | target 9 | target_ra 10 | target_wasm 11 | 12 | # https://github.com/lycheeverse/lychee 13 | .lycheecache 14 | Cargo.lock 15 | examples/macroquad_example/Cargo.lock 16 | examples/bevy_example/Cargo.lock 17 | examples/hello_world_web/Cargo.lock 18 | examples/hello_world_web/Cargo.lock 19 | examples/demo_web/Cargo.lock 20 | examples/colors_web/Cargo.lock 21 | /test_example 22 | /testik 23 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "ab_glyph" 7 | version = "0.2.26" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "2e53b0a3d5760cd2ba9b787ae0c6440ad18ee294ff71b05e3381c900a7d16cfd" 10 | dependencies = [ 11 | "ab_glyph_rasterizer", 12 | "owned_ttf_parser", 13 | ] 14 | 15 | [[package]] 16 | name = "ab_glyph_rasterizer" 17 | version = "0.1.8" 18 | source = "registry+https://github.com/rust-lang/crates.io-index" 19 | checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" 20 | 21 | [[package]] 22 | name = "ahash" 23 | version = "0.8.11" 24 | source = "registry+https://github.com/rust-lang/crates.io-index" 25 | checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" 26 | dependencies = [ 27 | "cfg-if", 28 | "once_cell", 29 | "version_check", 30 | "zerocopy", 31 | ] 32 | 33 | [[package]] 34 | name = "allocator-api2" 35 | version = "0.2.18" 36 | source = "registry+https://github.com/rust-lang/crates.io-index" 37 | checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" 38 | 39 | [[package]] 40 | name = "autocfg" 41 | version = "1.3.0" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" 44 | 45 | [[package]] 46 | name = "bitflags" 47 | version = "2.9.0" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" 50 | 51 | [[package]] 52 | name = "bytemuck" 53 | version = "1.23.0" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c" 56 | dependencies = [ 57 | "bytemuck_derive", 58 | ] 59 | 60 | [[package]] 61 | name = "bytemuck_derive" 62 | version = "1.9.3" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1" 65 | dependencies = [ 66 | "proc-macro2", 67 | "quote", 68 | "syn", 69 | ] 70 | 71 | [[package]] 72 | name = "cassowary" 73 | version = "0.3.0" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" 76 | 77 | [[package]] 78 | name = "castaway" 79 | version = "0.2.3" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5" 82 | dependencies = [ 83 | "rustversion", 84 | ] 85 | 86 | [[package]] 87 | name = "cfg-if" 88 | version = "1.0.0" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 91 | 92 | [[package]] 93 | name = "compact_str" 94 | version = "0.8.0" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644" 97 | dependencies = [ 98 | "castaway", 99 | "cfg-if", 100 | "itoa", 101 | "rustversion", 102 | "ryu", 103 | "static_assertions", 104 | ] 105 | 106 | [[package]] 107 | name = "cosmic-text" 108 | version = "0.14.2" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "da46a9d5a8905cc538a4a5bceb6a4510de7a51049c5588c0114efce102bcbbe8" 111 | dependencies = [ 112 | "bitflags", 113 | "fontdb", 114 | "log", 115 | "rangemap", 116 | "rustc-hash", 117 | "rustybuzz", 118 | "self_cell", 119 | "smol_str", 120 | "swash", 121 | "sys-locale", 122 | "ttf-parser 0.21.1", 123 | "unicode-bidi", 124 | "unicode-linebreak", 125 | "unicode-script", 126 | "unicode-segmentation", 127 | ] 128 | 129 | [[package]] 130 | name = "ecolor" 131 | version = "0.31.1" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "bc4feb366740ded31a004a0e4452fbf84e80ef432ecf8314c485210229672fd1" 134 | dependencies = [ 135 | "emath", 136 | ] 137 | 138 | [[package]] 139 | name = "egui" 140 | version = "0.31.1" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | checksum = "25dd34cec49ab55d85ebf70139cb1ccd29c977ef6b6ba4fe85489d6877ee9ef3" 143 | dependencies = [ 144 | "ahash", 145 | "bitflags", 146 | "emath", 147 | "epaint", 148 | "nohash-hasher", 149 | "profiling", 150 | ] 151 | 152 | [[package]] 153 | name = "egui_ratatui" 154 | version = "1.31.0" 155 | dependencies = [ 156 | "egui", 157 | "ratatui", 158 | "soft_ratatui", 159 | ] 160 | 161 | [[package]] 162 | name = "either" 163 | version = "1.12.0" 164 | source = "registry+https://github.com/rust-lang/crates.io-index" 165 | checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" 166 | 167 | [[package]] 168 | name = "emath" 169 | version = "0.31.1" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | checksum = "9e4cadcff7a5353ba72b7fea76bf2122b5ebdbc68e8155aa56dfdea90083fe1b" 172 | 173 | [[package]] 174 | name = "epaint" 175 | version = "0.31.1" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | checksum = "41fcc0f5a7c613afd2dee5e4b30c3e6acafb8ad6f0edb06068811f708a67c562" 178 | dependencies = [ 179 | "ab_glyph", 180 | "ahash", 181 | "ecolor", 182 | "emath", 183 | "nohash-hasher", 184 | "parking_lot", 185 | "profiling", 186 | ] 187 | 188 | [[package]] 189 | name = "font-types" 190 | version = "0.9.0" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "02a596f5713680923a2080d86de50fe472fb290693cf0f701187a1c8b36996b7" 193 | dependencies = [ 194 | "bytemuck", 195 | ] 196 | 197 | [[package]] 198 | name = "fontconfig-parser" 199 | version = "0.5.7" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "c1fcfcd44ca6e90c921fee9fa665d530b21ef1327a4c1a6c5250ea44b776ada7" 202 | dependencies = [ 203 | "roxmltree", 204 | ] 205 | 206 | [[package]] 207 | name = "fontdb" 208 | version = "0.16.2" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "b0299020c3ef3f60f526a4f64ab4a3d4ce116b1acbf24cdd22da0068e5d81dc3" 211 | dependencies = [ 212 | "fontconfig-parser", 213 | "log", 214 | "memmap2", 215 | "slotmap", 216 | "tinyvec", 217 | "ttf-parser 0.20.0", 218 | ] 219 | 220 | [[package]] 221 | name = "hashbrown" 222 | version = "0.14.5" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" 225 | dependencies = [ 226 | "ahash", 227 | "allocator-api2", 228 | ] 229 | 230 | [[package]] 231 | name = "heck" 232 | version = "0.5.0" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 235 | 236 | [[package]] 237 | name = "indoc" 238 | version = "2.0.5" 239 | source = "registry+https://github.com/rust-lang/crates.io-index" 240 | checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" 241 | 242 | [[package]] 243 | name = "instability" 244 | version = "0.3.2" 245 | source = "registry+https://github.com/rust-lang/crates.io-index" 246 | checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" 247 | dependencies = [ 248 | "quote", 249 | "syn", 250 | ] 251 | 252 | [[package]] 253 | name = "itertools" 254 | version = "0.12.1" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" 257 | dependencies = [ 258 | "either", 259 | ] 260 | 261 | [[package]] 262 | name = "itertools" 263 | version = "0.13.0" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" 266 | dependencies = [ 267 | "either", 268 | ] 269 | 270 | [[package]] 271 | name = "itoa" 272 | version = "1.0.11" 273 | source = "registry+https://github.com/rust-lang/crates.io-index" 274 | checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" 275 | 276 | [[package]] 277 | name = "libc" 278 | version = "0.2.155" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" 281 | 282 | [[package]] 283 | name = "libm" 284 | version = "0.2.15" 285 | source = "registry+https://github.com/rust-lang/crates.io-index" 286 | checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" 287 | 288 | [[package]] 289 | name = "lock_api" 290 | version = "0.4.12" 291 | source = "registry+https://github.com/rust-lang/crates.io-index" 292 | checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" 293 | dependencies = [ 294 | "autocfg", 295 | "scopeguard", 296 | ] 297 | 298 | [[package]] 299 | name = "log" 300 | version = "0.4.27" 301 | source = "registry+https://github.com/rust-lang/crates.io-index" 302 | checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" 303 | 304 | [[package]] 305 | name = "lru" 306 | version = "0.12.3" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" 309 | dependencies = [ 310 | "hashbrown", 311 | ] 312 | 313 | [[package]] 314 | name = "memmap2" 315 | version = "0.9.5" 316 | source = "registry+https://github.com/rust-lang/crates.io-index" 317 | checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" 318 | dependencies = [ 319 | "libc", 320 | ] 321 | 322 | [[package]] 323 | name = "nohash-hasher" 324 | version = "0.2.0" 325 | source = "registry+https://github.com/rust-lang/crates.io-index" 326 | checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" 327 | 328 | [[package]] 329 | name = "once_cell" 330 | version = "1.19.0" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 333 | 334 | [[package]] 335 | name = "owned_ttf_parser" 336 | version = "0.21.0" 337 | source = "registry+https://github.com/rust-lang/crates.io-index" 338 | checksum = "6b41438d2fc63c46c74a2203bf5ccd82c41ba04347b2fcf5754f230b167067d5" 339 | dependencies = [ 340 | "ttf-parser 0.21.1", 341 | ] 342 | 343 | [[package]] 344 | name = "parking_lot" 345 | version = "0.12.3" 346 | source = "registry+https://github.com/rust-lang/crates.io-index" 347 | checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" 348 | dependencies = [ 349 | "lock_api", 350 | "parking_lot_core", 351 | ] 352 | 353 | [[package]] 354 | name = "parking_lot_core" 355 | version = "0.9.10" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" 358 | dependencies = [ 359 | "cfg-if", 360 | "libc", 361 | "redox_syscall", 362 | "smallvec", 363 | "windows-targets", 364 | ] 365 | 366 | [[package]] 367 | name = "paste" 368 | version = "1.0.15" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 371 | 372 | [[package]] 373 | name = "proc-macro2" 374 | version = "1.0.85" 375 | source = "registry+https://github.com/rust-lang/crates.io-index" 376 | checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" 377 | dependencies = [ 378 | "unicode-ident", 379 | ] 380 | 381 | [[package]] 382 | name = "profiling" 383 | version = "1.0.16" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" 386 | 387 | [[package]] 388 | name = "quote" 389 | version = "1.0.36" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" 392 | dependencies = [ 393 | "proc-macro2", 394 | ] 395 | 396 | [[package]] 397 | name = "rangemap" 398 | version = "1.5.1" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | checksum = "f60fcc7d6849342eff22c4350c8b9a989ee8ceabc4b481253e8946b9fe83d684" 401 | 402 | [[package]] 403 | name = "ratatui" 404 | version = "0.29.0" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" 407 | dependencies = [ 408 | "bitflags", 409 | "cassowary", 410 | "compact_str", 411 | "indoc", 412 | "instability", 413 | "itertools 0.13.0", 414 | "lru", 415 | "paste", 416 | "strum", 417 | "unicode-segmentation", 418 | "unicode-truncate", 419 | "unicode-width 0.2.0", 420 | ] 421 | 422 | [[package]] 423 | name = "read-fonts" 424 | version = "0.29.0" 425 | source = "registry+https://github.com/rust-lang/crates.io-index" 426 | checksum = "5ce8e2ca6b24313587a03ca61bb74c384e2a815bd90cf2866cfc9f5fb7a11fa0" 427 | dependencies = [ 428 | "bytemuck", 429 | "font-types", 430 | ] 431 | 432 | [[package]] 433 | name = "redox_syscall" 434 | version = "0.5.1" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" 437 | dependencies = [ 438 | "bitflags", 439 | ] 440 | 441 | [[package]] 442 | name = "roxmltree" 443 | version = "0.20.0" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" 446 | 447 | [[package]] 448 | name = "rustc-hash" 449 | version = "1.1.0" 450 | source = "registry+https://github.com/rust-lang/crates.io-index" 451 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 452 | 453 | [[package]] 454 | name = "rustversion" 455 | version = "1.0.17" 456 | source = "registry+https://github.com/rust-lang/crates.io-index" 457 | checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" 458 | 459 | [[package]] 460 | name = "rustybuzz" 461 | version = "0.14.1" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "cfb9cf8877777222e4a3bc7eb247e398b56baba500c38c1c46842431adc8b55c" 464 | dependencies = [ 465 | "bitflags", 466 | "bytemuck", 467 | "libm", 468 | "smallvec", 469 | "ttf-parser 0.21.1", 470 | "unicode-bidi-mirroring", 471 | "unicode-ccc", 472 | "unicode-properties", 473 | "unicode-script", 474 | ] 475 | 476 | [[package]] 477 | name = "ryu" 478 | version = "1.0.18" 479 | source = "registry+https://github.com/rust-lang/crates.io-index" 480 | checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" 481 | 482 | [[package]] 483 | name = "scopeguard" 484 | version = "1.2.0" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 487 | 488 | [[package]] 489 | name = "self_cell" 490 | version = "1.2.0" 491 | source = "registry+https://github.com/rust-lang/crates.io-index" 492 | checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749" 493 | 494 | [[package]] 495 | name = "skrifa" 496 | version = "0.31.0" 497 | source = "registry+https://github.com/rust-lang/crates.io-index" 498 | checksum = "bbe6666ab11018ab91ff7b03f1a3b9fdbecfb610848436fefa5ce50343d3d913" 499 | dependencies = [ 500 | "bytemuck", 501 | "read-fonts", 502 | ] 503 | 504 | [[package]] 505 | name = "slotmap" 506 | version = "1.0.7" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" 509 | dependencies = [ 510 | "version_check", 511 | ] 512 | 513 | [[package]] 514 | name = "smallvec" 515 | version = "1.13.2" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 518 | 519 | [[package]] 520 | name = "smol_str" 521 | version = "0.2.2" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" 524 | 525 | [[package]] 526 | name = "soft_ratatui" 527 | version = "0.0.4" 528 | source = "registry+https://github.com/rust-lang/crates.io-index" 529 | checksum = "10021eb9e8c38ba31cd8279e6fbf89153275b29d8e867fe5aa53392a183dce2f" 530 | dependencies = [ 531 | "cosmic-text", 532 | "ratatui", 533 | ] 534 | 535 | [[package]] 536 | name = "static_assertions" 537 | version = "1.1.0" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 540 | 541 | [[package]] 542 | name = "strum" 543 | version = "0.26.3" 544 | source = "registry+https://github.com/rust-lang/crates.io-index" 545 | checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" 546 | dependencies = [ 547 | "strum_macros", 548 | ] 549 | 550 | [[package]] 551 | name = "strum_macros" 552 | version = "0.26.3" 553 | source = "registry+https://github.com/rust-lang/crates.io-index" 554 | checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" 555 | dependencies = [ 556 | "heck", 557 | "proc-macro2", 558 | "quote", 559 | "rustversion", 560 | "syn", 561 | ] 562 | 563 | [[package]] 564 | name = "swash" 565 | version = "0.2.4" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "5dce3f0af95643c855cdc449fbaa17d8c2cd08e0b00a49a6babcbe6e71667f3d" 568 | dependencies = [ 569 | "skrifa", 570 | "yazi", 571 | "zeno", 572 | ] 573 | 574 | [[package]] 575 | name = "syn" 576 | version = "2.0.66" 577 | source = "registry+https://github.com/rust-lang/crates.io-index" 578 | checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" 579 | dependencies = [ 580 | "proc-macro2", 581 | "quote", 582 | "unicode-ident", 583 | ] 584 | 585 | [[package]] 586 | name = "sys-locale" 587 | version = "0.3.2" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" 590 | dependencies = [ 591 | "libc", 592 | ] 593 | 594 | [[package]] 595 | name = "tinyvec" 596 | version = "1.9.0" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" 599 | dependencies = [ 600 | "tinyvec_macros", 601 | ] 602 | 603 | [[package]] 604 | name = "tinyvec_macros" 605 | version = "0.1.1" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 608 | 609 | [[package]] 610 | name = "ttf-parser" 611 | version = "0.20.0" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" 614 | 615 | [[package]] 616 | name = "ttf-parser" 617 | version = "0.21.1" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8" 620 | 621 | [[package]] 622 | name = "unicode-bidi" 623 | version = "0.3.18" 624 | source = "registry+https://github.com/rust-lang/crates.io-index" 625 | checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" 626 | 627 | [[package]] 628 | name = "unicode-bidi-mirroring" 629 | version = "0.2.0" 630 | source = "registry+https://github.com/rust-lang/crates.io-index" 631 | checksum = "23cb788ffebc92c5948d0e997106233eeb1d8b9512f93f41651f52b6c5f5af86" 632 | 633 | [[package]] 634 | name = "unicode-ccc" 635 | version = "0.2.0" 636 | source = "registry+https://github.com/rust-lang/crates.io-index" 637 | checksum = "1df77b101bcc4ea3d78dafc5ad7e4f58ceffe0b2b16bf446aeb50b6cb4157656" 638 | 639 | [[package]] 640 | name = "unicode-ident" 641 | version = "1.0.12" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 644 | 645 | [[package]] 646 | name = "unicode-linebreak" 647 | version = "0.1.5" 648 | source = "registry+https://github.com/rust-lang/crates.io-index" 649 | checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" 650 | 651 | [[package]] 652 | name = "unicode-properties" 653 | version = "0.1.3" 654 | source = "registry+https://github.com/rust-lang/crates.io-index" 655 | checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" 656 | 657 | [[package]] 658 | name = "unicode-script" 659 | version = "0.5.7" 660 | source = "registry+https://github.com/rust-lang/crates.io-index" 661 | checksum = "9fb421b350c9aff471779e262955939f565ec18b86c15364e6bdf0d662ca7c1f" 662 | 663 | [[package]] 664 | name = "unicode-segmentation" 665 | version = "1.11.0" 666 | source = "registry+https://github.com/rust-lang/crates.io-index" 667 | checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" 668 | 669 | [[package]] 670 | name = "unicode-truncate" 671 | version = "1.0.0" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "5a5fbabedabe362c618c714dbefda9927b5afc8e2a8102f47f081089a9019226" 674 | dependencies = [ 675 | "itertools 0.12.1", 676 | "unicode-width 0.1.13", 677 | ] 678 | 679 | [[package]] 680 | name = "unicode-width" 681 | version = "0.1.13" 682 | source = "registry+https://github.com/rust-lang/crates.io-index" 683 | checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" 684 | 685 | [[package]] 686 | name = "unicode-width" 687 | version = "0.2.0" 688 | source = "registry+https://github.com/rust-lang/crates.io-index" 689 | checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" 690 | 691 | [[package]] 692 | name = "version_check" 693 | version = "0.9.4" 694 | source = "registry+https://github.com/rust-lang/crates.io-index" 695 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 696 | 697 | [[package]] 698 | name = "windows-targets" 699 | version = "0.52.5" 700 | source = "registry+https://github.com/rust-lang/crates.io-index" 701 | checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" 702 | dependencies = [ 703 | "windows_aarch64_gnullvm", 704 | "windows_aarch64_msvc", 705 | "windows_i686_gnu", 706 | "windows_i686_gnullvm", 707 | "windows_i686_msvc", 708 | "windows_x86_64_gnu", 709 | "windows_x86_64_gnullvm", 710 | "windows_x86_64_msvc", 711 | ] 712 | 713 | [[package]] 714 | name = "windows_aarch64_gnullvm" 715 | version = "0.52.5" 716 | source = "registry+https://github.com/rust-lang/crates.io-index" 717 | checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" 718 | 719 | [[package]] 720 | name = "windows_aarch64_msvc" 721 | version = "0.52.5" 722 | source = "registry+https://github.com/rust-lang/crates.io-index" 723 | checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" 724 | 725 | [[package]] 726 | name = "windows_i686_gnu" 727 | version = "0.52.5" 728 | source = "registry+https://github.com/rust-lang/crates.io-index" 729 | checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" 730 | 731 | [[package]] 732 | name = "windows_i686_gnullvm" 733 | version = "0.52.5" 734 | source = "registry+https://github.com/rust-lang/crates.io-index" 735 | checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" 736 | 737 | [[package]] 738 | name = "windows_i686_msvc" 739 | version = "0.52.5" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" 742 | 743 | [[package]] 744 | name = "windows_x86_64_gnu" 745 | version = "0.52.5" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" 748 | 749 | [[package]] 750 | name = "windows_x86_64_gnullvm" 751 | version = "0.52.5" 752 | source = "registry+https://github.com/rust-lang/crates.io-index" 753 | checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" 754 | 755 | [[package]] 756 | name = "windows_x86_64_msvc" 757 | version = "0.52.5" 758 | source = "registry+https://github.com/rust-lang/crates.io-index" 759 | checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" 760 | 761 | [[package]] 762 | name = "yazi" 763 | version = "0.2.1" 764 | source = "registry+https://github.com/rust-lang/crates.io-index" 765 | checksum = "e01738255b5a16e78bbb83e7fbba0a1e7dd506905cfc53f4622d89015a03fbb5" 766 | 767 | [[package]] 768 | name = "zeno" 769 | version = "0.3.3" 770 | source = "registry+https://github.com/rust-lang/crates.io-index" 771 | checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" 772 | 773 | [[package]] 774 | name = "zerocopy" 775 | version = "0.7.34" 776 | source = "registry+https://github.com/rust-lang/crates.io-index" 777 | checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" 778 | dependencies = [ 779 | "zerocopy-derive", 780 | ] 781 | 782 | [[package]] 783 | name = "zerocopy-derive" 784 | version = "0.7.34" 785 | source = "registry+https://github.com/rust-lang/crates.io-index" 786 | checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" 787 | dependencies = [ 788 | "proc-macro2", 789 | "quote", 790 | "syn", 791 | ] 792 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "egui_ratatui" 3 | version = "1.31.0" 4 | authors = ["gold-silver-copper"] 5 | edition = "2024" 6 | include = ["LICENSE-APACHE", "LICENSE-MIT", "**/*.rs", "Cargo.toml"] 7 | description = "WASM ratatui with egui works with bevy and macroquad and eframe" 8 | license = "MIT OR Apache-2.0" 9 | repository = "https://github.com/gold-silver-copper/egui_ratatui" 10 | 11 | 12 | [lib] 13 | crate-type = ["cdylib", "rlib"] 14 | 15 | [dependencies] 16 | ratatui = { version = "0.29", default-features = false } 17 | egui = { version = "0.31", default-features = false } 18 | soft_ratatui = "0.0.4" 19 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # egui_ratatui : egui widget + ratatui backend (WASM) 2 | 3 | [![Crates.io](https://img.shields.io/crates/v/egui_ratatui.svg)](https://crates.io/crates/egui_ratatui) 4 | [![Documentation](https://docs.rs/egui_ratatui/badge.svg)](https://docs.rs/egui_ratatui/latest/egui_ratatui/) 5 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/bevyengine/bevy/blob/master/LICENSE) 6 | [![Downloads](https://img.shields.io/crates/d/egui_ratatui.svg)](https://crates.io/crates/egui_ratatui) + [![Downloads](https://img.shields.io/crates/d/ratframe.svg)](https://crates.io/crates/ratframe) 7 | 8 | 9 | Discord: https://discord.gg/tDBPkdgApN https://discord.gg/tDBPkdgApN 10 | 11 | 12 | Web Demo : https://gold-silver-copper.github.io/ (works best on firefox (very outdated)) 13 | 14 | 15 | See also: 16 | https://ratatui.rs/ 17 | https://github.com/emilk/egui 18 | 19 | 20 | RataguiBackend is the name of the backend/widget in code 21 | 22 | 23 | `cargo add egui_ratatui` 24 | 25 | `git clone https://github.com/gold-silver-copper/egui_ratatui.git` 26 | 27 | `cd egui_ratatui` 28 | 29 | `cd bevy_example` 30 | 31 | `cargo run --release` 32 | 33 | 34 | This repo provides the Ratagui Backend, which is also a Widget for egui. So you can have a whole ratatui terminal inside of egui. Also since egui is so WASM compatible, this means we can use this to compile ratatui to WASM ! 35 | 36 | 37 | 38 | If you would like more information about compiling to WASM please consult the relevant EGUI backend documentation: 39 | 40 | Bevy: https://bevy-cheatbook.github.io/platforms/wasm.html 41 | 42 | Macroquad: https://macroquad.rs/articles/wasm/ 43 | 44 | eframe: https://github.com/emilk/eframe_template 45 | 46 | # NOTE: While this library does provide a bevy example, bevy_egui has a slow path which prevent egui_ratatui from achieving maximum performance. This is not an issue when using eframe. For bevy, prefer to use [`soft_ratatui`](https://github.com/gold-silver-copper/soft_ratatui) directly. 47 | 48 | 49 | ![](https://github.com/gold-silver-copper/egui_ratatui/blob/main/tyorhun.gif) 50 | ![](https://github.com/gold-silver-copper/egui_ratatui/blob/main/screen3.png) 51 | -------------------------------------------------------------------------------- /assets/iosevka.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gold-silver-copper/egui_ratatui/8d5533a186ffccef6416934ca206c27721ef3b98/assets/iosevka.ttf -------------------------------------------------------------------------------- /bevy_example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bevy_example" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | bevy = "0.16" 10 | bevy_egui = "0.34.1" 11 | ratatui = { version = "0.29", default-features = false } 12 | egui_ratatui = { path = "../" } 13 | 14 | # Add the types you want support for 15 | #disable defaults features for rat frame if you do not want to import eframe 16 | # 17 | -------------------------------------------------------------------------------- /bevy_example/src/main.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use bevy_egui::{egui, EguiContextPass, EguiContexts, EguiPlugin}; 3 | use egui_ratatui::RataguiBackend; 4 | use ratatui::{ 5 | prelude::{Stylize, Terminal}, 6 | widgets::{Block, Borders, Paragraph, Wrap}, 7 | }; 8 | 9 | static FONT_DATA: &[u8] = include_bytes!("../../assets/iosevka.ttf"); 10 | fn main() { 11 | App::new() 12 | .add_plugins(DefaultPlugins) 13 | .init_resource::() 14 | .add_plugins(EguiPlugin { 15 | enable_multipass_for_primary_context: true, 16 | }) 17 | .add_systems(EguiContextPass, ui_example_system) 18 | .run(); 19 | } 20 | // Render to the terminal and to egui , both are immediate mode 21 | fn ui_example_system(mut contexts: EguiContexts, mut termres: ResMut) { 22 | termres 23 | .draw(|frame| { 24 | let area = frame.area(); 25 | let textik = format!("Hello bevy! The window area is {}", area); 26 | frame.render_widget( 27 | Paragraph::new(textik) 28 | .block(Block::new().title("Ratatui").borders(Borders::ALL)) 29 | .white() 30 | .on_blue() 31 | .wrap(Wrap { trim: false }), 32 | area, 33 | ); 34 | }) 35 | .expect("epic fail"); 36 | 37 | egui::Window::new("Hello").show(contexts.ctx_mut(), |ui| { 38 | ui.add(termres.backend_mut()); 39 | }); 40 | } 41 | 42 | #[derive(Resource, Deref, DerefMut)] 43 | struct EguiTerminal(Terminal); 44 | 45 | impl Default for EguiTerminal { 46 | fn default() -> Self { 47 | let backend = RataguiBackend::new("soft_rat", 16, FONT_DATA); 48 | //backend.set_font_size(12); 49 | Self(Terminal::new(backend).unwrap()) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /scratch: -------------------------------------------------------------------------------- 1 | Hello everyone ! I present to you my newest crate - egui_ratatui . 2 | It allows you to create Terminal User Interfaces with ratatui inside of EGUI , and is wasm compatible 3 | Previously I had made bevy_ratatui , but it was not very good , now I created a new backend for ratatui which uses egui. 4 | Thus this new crate supercedes my old bevy_ratatui crate , since now you can use bevy_egui + egui_ratatui to get a much better experience 5 | Plus performance is like 100x times better :D 6 | Check out a web demo here: https://gold-silver-copper.github.io/ 7 | (use the h j k l t keys to interact) 8 | You can find the repository here - https://github.com/gold-silver-copper/egui_ratatui 9 | 10 | 11 | 12 | 13 | Hello everyone ! I present to you version 1.1.1 of my crate - egui_ratatui. 14 | 15 | With this release I have added a good bevy example into the repo, check out the bevy_example folder 16 | 17 | It allows you to create Terminal User Interfaces with ratatui inside of EGUI , and is wasm compatible 18 | Internally the crate has fixed a few minor bugs that showed up during the process of porting all examples 19 | As well as slight performance improvements 20 | Good news: there have been ZERO changes to the user facing api, the api is extremely stable and production ready (tm) 21 | I have added a default features flag, which you can use to avoid importing eframe and web time into your project 22 | 23 | Check out an updated web demo here: https://gold-silver-copper.github.io/ 24 | (use the h j k l t keys to interact) 25 | You can find the repository here - https://github.com/gold-silver-copper/egui_ratatui 26 | 27 | 28 | Hello everyone ! I have renamed the crate 'ratframe' to 'egui_ratatui' for clarity and discoverability. 29 | I removed unneccesary code and dependencies, there are no API changes, simply rename ratframe to egui_ratatui in all cases. 30 | The old version can be found in the PRE-RENAME branch, it contains the eframe examples which I have cut from this release. 31 | This release only contains bevy and macroquad examples. Absolutely feel free to contact me with any questions. 32 | Find the new version here: 33 | 34 | https://github.com/gold-silver-copper/egui_ratatui 35 | 36 | https://crates.io/crates/egui_ratatui 37 | -------------------------------------------------------------------------------- /screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gold-silver-copper/egui_ratatui/8d5533a186ffccef6416934ca206c27721ef3b98/screen3.png -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | mod ratagui_backend; 2 | 3 | pub use ratagui_backend::RataguiBackend; 4 | -------------------------------------------------------------------------------- /src/ratagui_backend.rs: -------------------------------------------------------------------------------- 1 | //! This module provides the `RataguiBackend` implementation for the [`Backend`] trait. 2 | //! It is used in the integration tests to verify the correctness of the library. 3 | 4 | use egui::{ColorImage, Response, TextureHandle, TextureOptions, Ui, Vec2}; 5 | 6 | use ratatui::layout::Position; 7 | use soft_ratatui::SoftBackend; 8 | 9 | use std::io; 10 | 11 | use ratatui::{ 12 | backend::{Backend, WindowSize}, 13 | buffer::Cell, 14 | layout::Size, 15 | }; 16 | 17 | //use egui::Label as TerminalLine; 18 | 19 | ///The RataguiBackend is the widget+backend itself , from which you can make a ratatui terminal , 20 | /// then you can do ui.add(terminal.backend_mut()) inside an egui context 21 | /// Spawn with RataguiBackend::new() or RataguiBackend::new_with_system_fonts() 22 | /// 23 | /// For more documentation see the soft_ratatui crate 24 | /// https://github.com/gold-silver-copper/soft_ratatui 25 | /// https://docs.rs/soft_ratatui/latest/soft_ratatui/ 26 | /// 27 | 28 | pub struct RataguiBackend { 29 | soft_backend: SoftBackend, 30 | cur_size: Vec2, 31 | name: String, 32 | text_handle: Option, 33 | } 34 | impl egui::Widget for &mut RataguiBackend { 35 | fn ui(self, ui: &mut Ui) -> Response { 36 | let av_size = ui.available_size(); 37 | 38 | if self.cur_size != av_size { 39 | self.cur_size = av_size; 40 | 41 | let av_width = (av_size.x).clamp(1.0, 10000.0); 42 | let av_height = (av_size.y).clamp(1.0, 10000.0); 43 | let available_chars_width = (av_width / (self.soft_backend.char_width as f32)) as u16; 44 | 45 | let available_chars_height = 46 | (av_height / (self.soft_backend.char_height as f32)) as u16; 47 | let cur_size = self.size().expect("COULD NOT GET CURRENT BACKEND SIZE"); 48 | if (cur_size.width != available_chars_width) 49 | || (cur_size.height != available_chars_height) 50 | { 51 | self.soft_backend 52 | .resize(available_chars_width, available_chars_height); 53 | } 54 | } 55 | 56 | let texture = 57 | ui.ctx() 58 | .load_texture(&self.name, self.to_egui_image(), TextureOptions::NEAREST); 59 | self.text_handle = Some(texture.clone()); 60 | 61 | ui.image((texture.id(), texture.size_vec2())) 62 | } 63 | } 64 | 65 | impl RataguiBackend { 66 | /// Creates a new `RataguiBackend` with the specified name,font size and font data. WASM compatible. 67 | pub fn new(name: &str, font_size: u16, font_data: &[u8]) -> Self { 68 | let backend = SoftBackend::new_with_font(10, 10, font_size as i32, font_data); 69 | let name = name.to_string(); 70 | 71 | Self { 72 | soft_backend: backend, 73 | cur_size: Vec2::new(1.0, 1.0), 74 | name, 75 | 76 | text_handle: None, 77 | } 78 | } 79 | /// Creates a new `RataguiBackend` with the specified name, font size and using system fonts, this is not Web WASM compatible. 80 | pub fn new_with_system_fonts(name: &str, font_size: u16) -> Self { 81 | let backend = SoftBackend::new_with_system_fonts(10, 10, font_size as i32); 82 | let name = name.to_string(); 83 | Self { 84 | soft_backend: backend, 85 | cur_size: Vec2::new(1.0, 1.0), 86 | name, 87 | 88 | text_handle: None, 89 | } 90 | } 91 | 92 | ///Creates an Egui ColorImage from the terminal buffer. 93 | pub fn to_egui_image(&self) -> ColorImage { 94 | egui::ColorImage::from_rgb( 95 | [ 96 | self.soft_backend.get_pixmap_width(), 97 | self.soft_backend.get_pixmap_height(), 98 | ], 99 | self.soft_backend.get_pixmap_data(), 100 | ) 101 | } 102 | } 103 | 104 | impl Backend for RataguiBackend { 105 | fn draw<'a, I>(&mut self, content: I) -> io::Result<()> 106 | where 107 | I: Iterator, 108 | { 109 | self.soft_backend.draw(content) 110 | } 111 | 112 | fn hide_cursor(&mut self) -> io::Result<()> { 113 | self.soft_backend.hide_cursor() 114 | } 115 | 116 | fn show_cursor(&mut self) -> io::Result<()> { 117 | self.soft_backend.show_cursor() 118 | } 119 | 120 | fn get_cursor_position(&mut self) -> io::Result { 121 | self.soft_backend.get_cursor_position() 122 | } 123 | 124 | fn set_cursor_position>(&mut self, position: P) -> io::Result<()> { 125 | self.soft_backend.set_cursor_position(position) 126 | } 127 | 128 | fn clear(&mut self) -> io::Result<()> { 129 | self.soft_backend.clear() 130 | } 131 | 132 | fn size(&self) -> io::Result { 133 | self.soft_backend.size() 134 | } 135 | 136 | fn window_size(&mut self) -> io::Result { 137 | self.soft_backend.window_size() 138 | } 139 | 140 | fn flush(&mut self) -> io::Result<()> { 141 | self.soft_backend.flush() 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /tyorhun.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gold-silver-copper/egui_ratatui/8d5533a186ffccef6416934ca206c27721ef3b98/tyorhun.gif --------------------------------------------------------------------------------