├── .github └── workflows │ └── rust.yml ├── .gitignore ├── Cargo.toml ├── Makefile ├── README.md ├── crosstermion ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE.md ├── Makefile ├── README.md └── src │ ├── color.rs │ ├── cursor.rs │ ├── input.rs │ ├── lib.rs │ └── terminal.rs └── tui-react ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md └── src ├── lib.rs ├── list.rs └── terminal.rs /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | build-and-test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: fmt 15 | run: cargo fmt --all -- --check 16 | - name: clippy 17 | run: cargo clippy 18 | - name: tests 19 | run: make tests 20 | 21 | build-and-test-on-windows: 22 | name: Windows 23 | runs-on: windows-latest 24 | steps: 25 | - uses: actions/checkout@v1 26 | - uses: actions-rs/toolchain@v1 27 | with: 28 | profile: default 29 | toolchain: stable 30 | override: true 31 | - name: tests 32 | run: make tests-windows 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/rust 3 | # Edit at https://www.gitignore.io/?templates=rust 4 | 5 | ### Rust ### 6 | # Generated by Cargo 7 | # will have compiled files and executables 8 | /target/ 9 | 10 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 11 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 12 | Cargo.lock 13 | 14 | # These are backup files generated by rustfmt 15 | **/*.rs.bk 16 | 17 | # End of https://www.gitignore.io/api/rust 18 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["crosstermion", "tui-react"] 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY : tests build 2 | 3 | help: ## Display this help 4 | @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) 5 | 6 | ##@ Testing 7 | 8 | tests: ## Run all tests we have to assert quality 9 | cd crosstermion && make check 10 | cd tui-react && cargo check 11 | 12 | tests-windows: ## Run all tests that have a chance to work on windows 13 | cd crosstermion && make check-windows 14 | cd tui-react && cargo check 15 | 16 | ##@ Maintenance 17 | clean: ## cargo clean on all crates 18 | cargo clean 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tui-crates 2 | 3 | Various crates related to handling terminal user interfaces. 4 | 5 | # Maintenance Notes 6 | 7 | ## Upgrading TUI 8 | 9 | 1. upgrade `tui` in `tui-react`, increment minor in `tui-react` and `cargo publish`. 10 | 1. uprgade `tui` and `tui-react` in `crosstermion` and `cargo release`. 11 | 12 | 13 | ## Upgrading Crossterm 14 | 15 | You can't - it comes as tui backend and thus we need tui to upgrade to the latest crossterm first. 16 | -------------------------------------------------------------------------------- /crosstermion/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## 0.14.0 (2024-02-03) 9 | 10 | ### Chore 11 | 12 | - update ratatui to 0.26.0 13 | 14 | ### New Features (BREAKING) 15 | 16 | - update ratatui to 0.26.0 17 | 18 | ### Commit Statistics 19 | 20 | 21 | 22 | - 3 commits contributed to the release. 23 | - 38 days passed between releases. 24 | - 2 commits were understood as [conventional](https://www.conventionalcommits.org). 25 | - 0 issues like '(#ID)' were seen in commit messages 26 | 27 | ### Commit Details 28 | 29 | 30 | 31 |
view details 32 | 33 | * **Uncategorized** 34 | - Release tui-react v0.23.0, safety bump crosstermion v0.14.0 ([`c85ae46`](https://github.com/Byron/tui-crates/commit/c85ae466b18d6a97ddb45a7e2dce632d25ef971b)) 35 | - Update ratatui to 0.26.0 ([`943d49d`](https://github.com/Byron/tui-crates/commit/943d49d47c04c4ddf36b6ade8652d234d2235961)) 36 | - Update ratatui to 0.26.0 ([`ca29ee1`](https://github.com/Byron/tui-crates/commit/ca29ee1037ed9a153c3d346c231e0562ee948467)) 37 |
38 | 39 | ## 0.13.0 (2023-12-26) 40 | 41 | ### New Features (BREAKING) 42 | 43 | - upgrade to `ratatui` v0.25 44 | - Remove support for termion; use `crossterm` events directly. 45 | Also remove custom Key/Event abstractions and use the ones provided 46 | by `crossterm` instead. This is very much a breaking change, 47 | but requires only mechanical adjustments. 48 | 49 | ### Commit Statistics 50 | 51 | 52 | 53 | - 5 commits contributed to the release. 54 | - 19 days passed between releases. 55 | - 2 commits were understood as [conventional](https://www.conventionalcommits.org). 56 | - 0 issues like '(#ID)' were seen in commit messages 57 | 58 | ### Commit Details 59 | 60 | 61 | 62 |
view details 63 | 64 | * **Uncategorized** 65 | - Release crosstermion v0.13.0 ([`9555c6f`](https://github.com/Byron/tui-crates/commit/9555c6ff4b431316151ce3b81dd182d077031ab8)) 66 | - Release tui-react v0.22.0, safety bump crosstermion v0.13.0 ([`b7283a5`](https://github.com/Byron/tui-crates/commit/b7283a511abadfdbbb6cfbb2832ee1d84c06815c)) 67 | - Merge branch 'remove-termion' ([`c69813f`](https://github.com/Byron/tui-crates/commit/c69813f00e114313b206bceaa838e2fe0954f37b)) 68 | - Upgrade to `ratatui` v0.25 ([`7b49dd8`](https://github.com/Byron/tui-crates/commit/7b49dd81a3f7c209279e90c1110de00dfd6a0701)) 69 | - Remove support for termion; use `crossterm` events directly. ([`2df671a`](https://github.com/Byron/tui-crates/commit/2df671a3b4e33e3c960c91e6c10f9e8fe6c94a11)) 70 |
71 | 72 | ## 0.12.1 (2023-12-07) 73 | 74 | ### New Features 75 | 76 | - replace `ansi-term` with `ansiterm`. 77 | One is maintained, the other one is not. 78 | 79 | ### Commit Statistics 80 | 81 | 82 | 83 | - 2 commits contributed to the release. 84 | - 1 commit was understood as [conventional](https://www.conventionalcommits.org). 85 | - 0 issues like '(#ID)' were seen in commit messages 86 | 87 | ### Commit Details 88 | 89 | 90 | 91 |
view details 92 | 93 | * **Uncategorized** 94 | - Release crosstermion v0.12.1 ([`7e7a324`](https://github.com/Byron/tui-crates/commit/7e7a324e094c121508adb1514b4aa39575f539aa)) 95 | - Replace `ansi-term` with `ansiterm`. ([`5533fe6`](https://github.com/Byron/tui-crates/commit/5533fe6db074b0ba132ea01df41bde45182a4933)) 96 |
97 | 98 | ## 0.12.0 (2023-12-07) 99 | 100 | 101 | 102 | 103 | ### Chore 104 | 105 | - upgrade all packages as long as they don't break the API 106 | 107 | ### Chore (BREAKING) 108 | 109 | - upgrade `ratatui` to 0.24 and `crossterm` to v0.27. 110 | Note that these two work together, and depend on each other. 111 | 112 | ### Commit Statistics 113 | 114 | 115 | 116 | - 4 commits contributed to the release. 117 | - 210 days passed between releases. 118 | - 2 commits were understood as [conventional](https://www.conventionalcommits.org). 119 | - 0 issues like '(#ID)' were seen in commit messages 120 | 121 | ### Commit Details 122 | 123 | 124 | 125 |
view details 126 | 127 | * **Uncategorized** 128 | - Release tui-react v0.21.0, crosstermion v0.12.0, safety bump crosstermion v0.12.0 ([`942f0b9`](https://github.com/Byron/tui-crates/commit/942f0b97a4b86b91e26530cca914906645f87ac4)) 129 | - Merge branch 'upgrades' ([`c6265c8`](https://github.com/Byron/tui-crates/commit/c6265c8773829f54e4acb1106d56ef2239edcab7)) 130 | - Upgrade `ratatui` to 0.24 and `crossterm` to v0.27. ([`a371272`](https://github.com/Byron/tui-crates/commit/a371272a96da49e8db82221eaf23d3aab38514d0)) 131 | - Upgrade all packages as long as they don't break the API ([`d337c86`](https://github.com/Byron/tui-crates/commit/d337c866f48dda83166d8cafaaa97bbf24d69216)) 132 |
133 | 134 | ## 0.11.0 (2023-05-11) 135 | 136 | 137 | 138 | ### Chore (BREAKING) 139 | 140 | - switch to 'ratatui' in a fashion that leaves imports alone. 141 | However would still be a breaking change for anyone leaving `tui` in 142 | their dependency tree. 143 | 144 | ### Commit Statistics 145 | 146 | 147 | 148 | - 4 commits contributed to the release. 149 | - 241 days passed between releases. 150 | - 1 commit was understood as [conventional](https://www.conventionalcommits.org). 151 | - 0 issues like '(#ID)' were seen in commit messages 152 | 153 | ### Commit Details 154 | 155 | 156 | 157 |
view details 158 | 159 | * **Uncategorized** 160 | - Release tui-react v0.20.0, crosstermion v0.11.0, safety bump crosstermion v0.11.0 ([`6cc6346`](https://github.com/Byron/tui-crates/commit/6cc634618e1549fcece860b7b43f5d7ee5d1d259)) 161 | - Merge branch 'ratatui-2' ([`948b539`](https://github.com/Byron/tui-crates/commit/948b5397c0b8317e857f79515165c04314b6838a)) 162 | - Further updates to `crossterm` and `termion` ([`3157b3b`](https://github.com/Byron/tui-crates/commit/3157b3bf392b18f0f6be7e2c04d0b8782d76314e)) 163 | - Switch to 'ratatui' in a fashion that leaves imports alone. ([`073005d`](https://github.com/Byron/tui-crates/commit/073005de8c9177248528a4cc9be58d6cee525394)) 164 |
165 | 166 | ## 0.10.1 (2022-09-12) 167 | 168 | ### New Features 169 | 170 | - Support for reseize events via the new `input_channel()` function. 171 | Note that it only exists in blocking mode. 172 | 173 | ### Commit Statistics 174 | 175 | 176 | 177 | - 3 commits contributed to the release. 178 | - 1 commit was understood as [conventional](https://www.conventionalcommits.org). 179 | - 0 issues like '(#ID)' were seen in commit messages 180 | 181 | ### Commit Details 182 | 183 | 184 | 185 |
view details 186 | 187 | * **Uncategorized** 188 | - Release crosstermion v0.10.1 ([`b1775e8`](https://github.com/Byron/tui-crates/commit/b1775e8da35f3df4f9e10af8f95b0931c1ee8d2b)) 189 | - Support for reseize events via the new `input_channel()` function. ([`509c64c`](https://github.com/Byron/tui-crates/commit/509c64c4918d7e1fbd462de5ec3ae83bf3329785)) 190 | - Cargo fmt ([`d31a4bd`](https://github.com/Byron/tui-crates/commit/d31a4bd53dde9db3160236ac132237f76513ad12)) 191 |
192 | 193 | ## 0.10.0 (2022-09-12) 194 | 195 | Upgrade to `tui` 0.19 and `crossterm` 0.25. 196 | 197 | ### Commit Statistics 198 | 199 | 200 | 201 | - 4 commits contributed to the release. 202 | - 231 days passed between releases. 203 | - 0 commits were understood as [conventional](https://www.conventionalcommits.org). 204 | - 0 issues like '(#ID)' were seen in commit messages 205 | 206 | ### Commit Details 207 | 208 | 209 | 210 |
view details 211 | 212 | * **Uncategorized** 213 | - Release crosstermion v0.10.0 ([`420d808`](https://github.com/Byron/tui-crates/commit/420d8087f49a87985d3331a384287481d43f1217)) 214 | - Update changelog prior to release ([`7e1330d`](https://github.com/Byron/tui-crates/commit/7e1330dfc070cd8c383d8b273622709e67a0c985)) 215 | - Upgrade to crossterm 25 and tui 19 ([`ec53e20`](https://github.com/Byron/tui-crates/commit/ec53e202e7fb1809b94de0b26a010f61704c6a74)) 216 | - Allow for the Resize event to happen ([`e49a08a`](https://github.com/Byron/tui-crates/commit/e49a08a9143e9d4684ffdf387face6cdb7b24367)) 217 |
218 | 219 | ## 0.9.0 (2022-01-23) 220 | 221 | ### New Features (BREAKING) 222 | 223 | - upgrade to tui 0.17 224 | 225 | ### Commit Statistics 226 | 227 | 228 | 229 | - 4 commits contributed to the release. 230 | - 170 days passed between releases. 231 | - 1 commit was understood as [conventional](https://www.conventionalcommits.org). 232 | - 0 issues like '(#ID)' were seen in commit messages 233 | 234 | ### Commit Details 235 | 236 | 237 | 238 |
view details 239 | 240 | * **Uncategorized** 241 | - Release crosstermion v0.9.0 ([`c5fc690`](https://github.com/Byron/tui-crates/commit/c5fc69022161e0abb2dd6c1402a606381ac2cce9)) 242 | - Upgrade to tui 0.17 ([`a3223b3`](https://github.com/Byron/tui-crates/commit/a3223b3d39cb71adb1b866653ee0c984924b90ca)) 243 | - Release tui-react v0.17.0 ([`4523678`](https://github.com/Byron/tui-crates/commit/4523678efbc9c876e46325682861c27ee5e7fb02)) 244 | - Use local tui-react crate ([`9281c8e`](https://github.com/Byron/tui-crates/commit/9281c8e65226ff3a34ade7b95ef96374c9a759ea)) 245 |
246 | 247 | ## v0.8.1 (2021-08-05) 248 | 249 | ### Commit Statistics 250 | 251 | 252 | 253 | - 3 commits contributed to the release over the course of 1 calendar day. 254 | - 1 day passed between releases. 255 | - 0 commits were understood as [conventional](https://www.conventionalcommits.org). 256 | - 0 issues like '(#ID)' were seen in commit messages 257 | 258 | ### Commit Details 259 | 260 | 261 | 262 |
view details 263 | 264 | * **Uncategorized** 265 | - (cargo-release) version 0.8.1 ([`5fe230b`](https://github.com/Byron/tui-crates/commit/5fe230b6d85eaace655fad10ddac9608d2e62072)) 266 | - Fix apparently untested macr ([`c9ea9ac`](https://github.com/Byron/tui-crates/commit/c9ea9ac069ce7951252b3620052d611c925f6afd)) 267 | - Fix format ([`6323479`](https://github.com/Byron/tui-crates/commit/6323479162d69d22c55f4307be3eedd18c55f2af)) 268 |
269 | 270 | ## v0.8.0 (2021-08-04) 271 | 272 | * upgrade to TUI 0.16 and crossterm 0.20 273 | 274 | ### Commit Statistics 275 | 276 | 277 | 278 | - 5 commits contributed to the release over the course of 93 calendar days. 279 | - 0 commits were understood as [conventional](https://www.conventionalcommits.org). 280 | - 0 issues like '(#ID)' were seen in commit messages 281 | 282 | ### Commit Details 283 | 284 | 285 | 286 |
view details 287 | 288 | * **Uncategorized** 289 | - Upgrade to crossterm 0.20 ([`1d31acb`](https://github.com/Byron/tui-crates/commit/1d31acbfde475ae42ac928d0e23ff950e669e2e7)) 290 | - Make CI work on windows ([`dc0e96f`](https://github.com/Byron/tui-crates/commit/dc0e96f982bf46c8b910ca316e92357c2091559b)) 291 | - Use a workspace ([`ccc5add`](https://github.com/Byron/tui-crates/commit/ccc5add08476a1910d8d78d3bb94b70237f50958)) 292 | - Changes repository paths in tui crates manifests ([`ac5c6e6`](https://github.com/Byron/tui-crates/commit/ac5c6e62c86189a72e2305d06da176821f88b180)) 293 | - Add tui crates ([`ccb6a24`](https://github.com/Byron/tui-crates/commit/ccb6a24315a7d881e50b24e98d4720406bff16d5)) 294 |
295 | 296 | ## v0.7.0 297 | 298 | * upgrade to TUI 0.15 299 | 300 | ## v0.4.0 301 | 302 | * upgrade to TUI 0.12 303 | 304 | ## v0.3.2 305 | 306 | * Remove `futures-util` dependency in favor of `futures-lite` 307 | 308 | ## v0.2.0 309 | 310 | * remove native support for `flume` and `crossbeam-channel` for key input in favor of `std::sync::mpsc::Receiver`s :). 311 | 312 | ## v0.1.5 313 | 314 | * support for simple cursor movements 315 | * get terminal size 316 | * color support to learn if color is allowed, and dynamically disable it 317 | if `ansi_term` is used. 318 | 319 | ## v0.1.4 320 | 321 | * Fix precendence of imports in 'terminal' module. 322 | 323 | ## v0.1.3 324 | 325 | * `Key` type conversions are now always compiled when possible, as they are not mutually exclusive 326 | 327 | ## v0.1.2 328 | 329 | * Enable `flume/select` by default and allow selecting `flume/async` via the `flume-async` feature. 330 | 331 | ## v0.1.1 332 | 333 | * Add support for 'input-thread-flume' for using flume channels instead of crossbeam ones. They are 334 | smaller and there is no unsafe code either, at the expense of lack of the 'select!()` capability. 335 | 336 | ## v0.1.0 337 | 338 | Initial release. 339 | 340 | -------------------------------------------------------------------------------- /crosstermion/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crosstermion" 3 | version = "0.14.0" 4 | authors = ["Sebastian Thiel "] 5 | description = "utilities for `crossterm`, without ties to `termion`" 6 | edition = "2018" 7 | license = "MIT" 8 | repository = "https://github.com/Byron/tui-crates" 9 | readme = "README.md" 10 | include = ["src/**/*", "LICENSE.md", "README.md", "CHANGELOG.md"] 11 | 12 | [features] 13 | default = [] 14 | 15 | color = ["ansiterm"] 16 | 17 | input-async = ["futures-channel", "async-channel", "futures-lite", "futures-core" ] 18 | input-async-crossterm = ["crossterm/event-stream", "input-async"] 19 | 20 | tui-crossterm = ["tui", "tui-crossterm-backend", "crossterm"] 21 | tui-react-crossterm = ["tui-react", "tui", "tui-crossterm-backend", "crossterm"] 22 | 23 | tui-crossterm-backend = ["tui/crossterm"] 24 | 25 | 26 | [dependencies] 27 | crossterm = { version = "0.27.0", optional = true, default-features = false, features = ["events"] } 28 | futures-channel = { version = "0.3.5", optional = true, default-features = false, features = ["std", "sink"] } 29 | futures-core = { version = "0.3.5", optional = true, default-features = false } 30 | futures-lite = { version = "2.1.0", optional = true } 31 | tui = { package = "ratatui", version = "0.26.0", optional = true, default-features = false } 32 | tui-react = { version = "^0.23.2", optional = true, default-features = false, path = "../tui-react" } 33 | ansiterm = { version = "0.12.2", optional = true, default-features = false } 34 | async-channel = { version = "2.1.1", optional = true } 35 | 36 | [target."cfg(windows)".dependencies] 37 | crossterm = { version = "0.27.0", optional = true, default-features = false, features = ["windows"] } 38 | 39 | [package.metadata.docs.rs] 40 | all-features = true 41 | -------------------------------------------------------------------------------- /crosstermion/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © `2020` `Sebastian Thiel` 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /crosstermion/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY : tests build 2 | 3 | help: ## Display this help 4 | @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) 5 | 6 | ##@ Testing 7 | 8 | check: ## build features in commmon combination to be sure it all stays together 9 | #if cargo check; then false; fi 10 | $(MAKE) check-windows 11 | cargo check --features color 12 | cargo check --all-features 13 | 14 | 15 | check-windows: ## build features in commmon combination to be sure it all stays together, crossterm only 16 | cargo check --features crossterm 17 | cargo check --features crossterm,input-async 18 | cargo check --features crossterm,tui 19 | cargo check --features tui-react-crossterm 20 | cargo check --features tui-react-crossterm,input-async 21 | cargo check --features tui-crossterm 22 | cargo check --features color 23 | 24 | -------------------------------------------------------------------------------- /crosstermion/README.md: -------------------------------------------------------------------------------- 1 | 2 | Crosstermion is a utility crate to unify some types of both crates, allowing to easily build apps that use the leaner `termion` 3 | crate on unix systems, but resort to crossterm on windows systems. 4 | 5 | Currently provided facilities are: 6 | 7 | * a `Key` type an an `input_stream` (_async_) to receive key presses 8 | * an `AltenrativeRawTerminal` which marries an alternative screen with raw mode 9 | * a way to create a `tui` or `tui-react` terminal with either the crossterm or the termion backend. 10 | 11 | ### But how to do colors and styles? 12 | 13 | * **With** `tui` 14 | * When using the `tui`, you will have native cross-backend support for colors and styles. 15 | * **Without** `tui` 16 | * Use the **`color`** feature for additional utilities for colors with `ansi_term`. 17 | * Otherwise, using `ansi_term`, `colored` or `termcolor` will work as expected. 18 | 19 | ### How to build with `crossterm` on Windows and `termion` on Unix? 20 | 21 | There seems to be no easy way, as `cargo` will always build dependencies even though they are not supposed to be used on your platform. 22 | This leads to both `termion` and `crossterm` to be built, which is fatal on Windows. Thus one will have to manually select feature toggles 23 | when creating a release build, i.e. one would have to exclude all functionality that requires TUIs by default, and let the user enable 24 | the features they require. 25 | 26 | The `compile_error!(…)` macro can be useful to inform users if feature selection is required. Alternatively, assure that everything compiles 27 | even without any selected backend. 28 | 29 | Lastly, one can always give in and always compile against `crossterm`. 30 | 31 | ### Features 32 | 33 | All features work additively, but in case they are mutually exclusive, for instance 34 | in case of `tui-react` and `tui`, or `crossterm` and `termion`, the more general one will be chosen. 35 | 36 | * _mutually exclusive_ 37 | * **crossterm** 38 | * provides `Key` conversion support from `crossbeam::event::KeyEvent` and an `AlternativeRawTerminal` 39 | * provides a threaded key input channel 40 | * _additive_ 41 | * **input-async-crossterm** 42 | * adds native async capabilites to crossterm, which works without spawning an extra thread thanks to `mio`. 43 | * note that threaded key input is always supported. 44 | * **termion** 45 | * provides `Key` conversion support from `termion::event::Key` and an `AlternativeRawTerminal` 46 | * provides a threaded key input channel 47 | * _additive_ 48 | * **input-async** 49 | * Spawn a thread and provide input events via a futures Stream 50 | * note that threaded key input is always supported. 51 | * _mutually exclusive_ 52 | * _using `tui_` _(mutually exclusive)_ 53 | * **tui-termion** _implies `termion` feature_ 54 | * combines `tui` with `termion` and provides a `tui::Terminal` with `termion` backend 55 | * **tui-crossterm** _implies `crossterm` feature_ 56 | * combines `tui` with `crossterm` and provides a `tui::Terminal` with `crossterm` backend 57 | * _using `tui-react`_ _(mutually exclusive)_ 58 | * **tui-react-termion** _implies `termion` feature_ 59 | * combines `tui-react` with `crossterm` and provides a `tui::Terminal` with `crossterm` backend 60 | * **tui-react-crossterm** _implies `crossterm` feature_ 61 | * combines `tui-react` with `crossterm` and provides a `tui::Terminal` with `crossterm` backend 62 | * **color** 63 | * Add support for `ansi_term` based conditional coloring. The crate is small, to the point and allows zero-copy drawing 64 | of bytes and UTF-8 string, while supporting Windows 10 as well. 65 | * _cursor movement_ 66 | * _mutually exclusive_ 67 | * **crossterm** 68 | * Implements cursor movement with crossterm 69 | * **termion** 70 | * Implements cursor movement with termion 71 | 72 | -------------------------------------------------------------------------------- /crosstermion/src/color.rs: -------------------------------------------------------------------------------- 1 | use std::borrow::Cow; 2 | use std::ffi::OsStr; 3 | 4 | #[cfg(feature = "ansiterm")] 5 | mod _impl { 6 | use ansiterm::{ANSIGenericString, Style}; 7 | 8 | pub struct Brush { 9 | may_paint: bool, 10 | style: Option