tui-react-0.20.0/.cargo_vcs_info.json 0000644 00000000147 00000000001 0013012 0 ustar {
"git": {
"sha1": "6cc634618e1549fcece860b7b43f5d7ee5d1d259"
},
"path_in_vcs": "tui-react"
} tui-react-0.20.0/.gitignore 0000644 0000000 0000000 00000000014 10461020230 0013563 0 ustar 0000000 0000000 /Cargo.lock
tui-react-0.20.0/CHANGELOG.md 0000644 0000000 0000000 00000007477 10461020230 0013430 0 ustar 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 0.20.0 (2023-05-11)
### Chore (BREAKING)
- switch to 'ratatui' in a fashion that leaves imports alone.
However would still be a breaking change for anyone leaving `tui` in
their dependency tree.
### Commit Statistics
- 3 commits contributed to the release.
- 241 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Merge branch 'ratatui-2' ([`948b539`](https://github.com/Byron/tui-crates/commit/948b5397c0b8317e857f79515165c04314b6838a))
- Further updates to `crossterm` and `termion` ([`3157b3b`](https://github.com/Byron/tui-crates/commit/3157b3bf392b18f0f6be7e2c04d0b8782d76314e))
- Switch to 'ratatui' in a fashion that leaves imports alone. ([`073005d`](https://github.com/Byron/tui-crates/commit/073005de8c9177248528a4cc9be58d6cee525394))
## 0.19.0 (2022-09-12)
Upgrade to tui 0.19.
### Commit Statistics
- 3 commits contributed to the release.
- 231 days passed between releases.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Release tui-react v0.19.0 ([`6296315`](https://github.com/Byron/tui-crates/commit/629631545c7137c4071df1d895dee6e547e4d149))
- Prepare changelog prior to release ([`2539f6e`](https://github.com/Byron/tui-crates/commit/2539f6e1a28d038523e342810b94770e57021cd2))
- Upgrade to tui 19 ([`1b2afad`](https://github.com/Byron/tui-crates/commit/1b2afadba7064febd0d2dffc68f82419f9a4510b))
## 0.17.0 (2022-01-23)
### New Features (BREAKING)
- upgrade to tui 0.17
### Commit Statistics
- 3 commits contributed to the release.
- 171 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Release tui-react v0.17.0 ([`4523678`](https://github.com/Byron/tui-crates/commit/4523678efbc9c876e46325682861c27ee5e7fb02))
- Add changelog ([`221474b`](https://github.com/Byron/tui-crates/commit/221474b379a2c3c2f0c45dff5471659413bb9548))
- Upgrade to tui 0.17 ([`b5dd733`](https://github.com/Byron/tui-crates/commit/b5dd73380c316d1722cc70ec4220d6ea9a7bf141))
## v0.16.0 (2021-08-04)
### Commit Statistics
- 3 commits contributed to the release over the course of 93 calendar days.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
view details
* **Uncategorized**
- Upgrade to tui 0.16 ([`907a5e5`](https://github.com/Byron/tui-crates/commit/907a5e591688732c3f88821daebc7ff8c010730b))
- Changes repository paths in tui crates manifests ([`ac5c6e6`](https://github.com/Byron/tui-crates/commit/ac5c6e62c86189a72e2305d06da176821f88b180))
- Add tui crates ([`ccb6a24`](https://github.com/Byron/tui-crates/commit/ccb6a24315a7d881e50b24e98d4720406bff16d5))
tui-react-0.20.0/Cargo.toml 0000644 00000001766 00000000001 0011020 0 ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "tui-react"
version = "0.20.0"
authors = ["Sebastian Thiel "]
description = "TUI widgets using a react-like paradigm, allowing mutable component state and render properties."
readme = "README.md"
license = "MIT"
repository = "https://github.com/Byron/tui-crates"
[dependencies.log]
version = "0.4.6"
[dependencies.tui]
version = "0.20.1"
default-features = false
package = "ratatui"
[dependencies.unicode-segmentation]
version = "1.6.0"
[dependencies.unicode-width]
version = "0.1.7"
tui-react-0.20.0/Cargo.toml.orig 0000644 0000000 0000000 00000000743 10461020230 0014473 0 ustar 0000000 0000000 [package]
name = "tui-react"
version = "0.20.0"
authors = ["Sebastian Thiel "]
edition = "2018"
repository = "https://github.com/Byron/tui-crates"
description = "TUI widgets using a react-like paradigm, allowing mutable component state and render properties."
readme = "README.md"
license = "MIT"
[dependencies]
tui = { package = "ratatui", version = "0.20.1", default-features = false }
log = "0.4.6"
unicode-segmentation = "1.6.0"
unicode-width = "0.1.7"
tui-react-0.20.0/LICENSE 0000644 0000000 0000000 00000002060 10461020230 0012603 0 ustar 0000000 0000000 MIT License
Copyright (c) 2019 Sebastian Thiel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
tui-react-0.20.0/README.md 0000644 0000000 0000000 00000004003 10461020230 0013054 0 ustar 0000000 0000000 **tui-react** is a library to enable components with state, and with properties provided per render
Please note that this crate is early in development and build for the needs of **dua**.
### How it works
It uses the TUI infrastructure Terminal, but alters it to not enforce implementing the `Widget` trait.
It provides only a single, optional, trait called `TopLevelComponent`, which makes it convenient to
draw its implementors with `Terminal::render(..)`. However, since this enforces the absence of
refernces in your state, it's probably not suitable for most.
Instead, any struct can implement `render` methods or functions, and freely write into the terminal.
That way, one can leverage everything Rust has to offer, which allows stateful components which
work in your favor. Thus, this crate does away with 'one size fits all' render implementations,
greatly adding to flexibility.
State that one wants within the component for instance could be the scoll location. Alternatively,
one can configure windows by altering their public state.
### What's the relation to TUI / Ratatui?
This project couldn't exist without TUI, and is happy to provide an alternative set of components
for use in command-line applications. Ratatui is the continuation of the tui project.
### Why `tui-react`?
I kept having a terrible feeling when managing state with tui widgets when writing **dua**, and
after trying many things, I realized what the problem actually was. It took me some time to
realize it's not possible to have stateful components in with TUI, and I admire the smarts
that went into the API design! After all, it effectively prohibited this! Amazing!
That's why I implemented my own terminal and some key components, based on the ones provided
by TUI, which can serve as standard building blocks in a stateful world.
Thus far, the experience was fantastic, and it feels much better than before. Let's see what
happens with it.
### Changelog
#### v0.4.1 - Simplify `block_width(…)` function
#### v0.2.1 - add license file to crate
tui-react-0.20.0/src/lib.rs 0000644 0000000 0000000 00000010542 10461020230 0013505 0 ustar 0000000 0000000 #![forbid(unsafe_code)]
mod list;
mod terminal;
pub use list::*;
pub use terminal::*;
use std::iter::repeat;
use tui::{self, buffer::Buffer, layout::Rect, style::Color, style::Style};
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
pub fn fill_background_to_right(mut s: String, entire_width: u16) -> String {
match (s.len(), entire_width as usize) {
(x, y) if x >= y => s,
(x, y) => {
s.extend(repeat(' ').take(y - x));
s
}
}
}
/// Helper method to quickly set the background of all cells inside the specified area.
pub fn fill_background(area: Rect, buf: &mut Buffer, color: Color) {
for y in area.top()..area.bottom() {
for x in area.left()..area.right() {
buf.get_mut(x, y).set_bg(color);
}
}
}
pub fn draw_text_with_ellipsis_nowrap(
bound: Rect,
buf: &mut Buffer,
text: impl AsRef,
style: impl Into