Compare commits
22 Commits
joshka/pus
...
release-pl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac70fe5c7b | ||
|
|
bf84c6229b | ||
|
|
3bdb9fe982 | ||
|
|
2163fd5a2c | ||
|
|
645cd55ed2 | ||
|
|
28d80365d6 | ||
|
|
c52de1a926 | ||
|
|
e338795396 | ||
|
|
f944f2fff9 | ||
|
|
58c85295ae | ||
|
|
dc4ca94e95 | ||
|
|
22610b019b | ||
|
|
c0e1b1560e | ||
|
|
55a95e67bc | ||
|
|
345f47e044 | ||
|
|
cb85c8eb4e | ||
|
|
b405a398e9 | ||
|
|
cd5c7afbac | ||
|
|
604f89a167 | ||
|
|
db40df4ed9 | ||
|
|
fae7688ed8 | ||
|
|
2c17beaee4 |
2
.github/workflows/check-semver.yml
vendored
2
.github/workflows/check-semver.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Check semver
|
||||
|
||||
64
.github/workflows/ci.yml
vendored
64
.github/workflows/ci.yml
vendored
@@ -29,15 +29,15 @@ jobs:
|
||||
name: Check Formatting
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rustfmt
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2
|
||||
with:
|
||||
tool: taplo-cli
|
||||
- run: cargo xtask format --check
|
||||
@@ -48,10 +48,10 @@ jobs:
|
||||
name: Check Typos
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: crate-ci/typos@626c4bedb751ce0b7f03262ca97ddda9a076ae1c # master
|
||||
- uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 # master
|
||||
|
||||
# Check for any disallowed dependencies in the codebase due to license / security issues.
|
||||
# See <https://github.com/EmbarkStudios/cargo-deny>
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
# Prevent sudden announcement of a new advisory from failing ci:
|
||||
continue-on-error: ${{ matrix.checks == 'advisories' }}
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: EmbarkStudios/cargo-deny-action@76cd80eb775d7bbbd2d80292136d74d39e1b4918 # v2
|
||||
@@ -81,7 +81,7 @@ jobs:
|
||||
name: Check Unused Dependencies
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: bnjbvr/cargo-machete@7959c845782fed02ee69303126d4a12d64f1db18 # v0.9.1
|
||||
@@ -100,14 +100,14 @@ jobs:
|
||||
toolchain: ["stable", "beta"]
|
||||
continue-on-error: ${{ matrix.toolchain == 'beta' }}
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
components: clippy
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- run: cargo xtask clippy
|
||||
env:
|
||||
RUSTUP_TOOLCHAIN: ${{ matrix.toolchain }}
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
name: Check Markdown
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: DavidAnson/markdownlint-cli2-action@30a0e04f1870d58f8d717450cc6134995f993c63 # v21
|
||||
@@ -132,17 +132,17 @@ jobs:
|
||||
name: Coverage Report
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: stable
|
||||
components: llvm-tools
|
||||
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2
|
||||
- uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2
|
||||
with:
|
||||
tool: cargo-llvm-cov
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- run: cargo xtask coverage
|
||||
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
|
||||
with:
|
||||
@@ -159,16 +159,16 @@ jobs:
|
||||
toolchain: ["1.86.0", "stable"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2
|
||||
- uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2
|
||||
with:
|
||||
tool: cargo-hack
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- run: cargo xtask check --all-features
|
||||
env:
|
||||
RUSTUP_TOOLCHAIN: ${{ matrix.toolchain }}
|
||||
@@ -177,14 +177,14 @@ jobs:
|
||||
name: Build No-Std
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: stable
|
||||
targets: x86_64-unknown-none
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
# This makes it easier to debug the exact versions of the dependencies
|
||||
- run: cargo tree --target x86_64-unknown-none -p ratatui-core
|
||||
- run: cargo tree --target x86_64-unknown-none -p ratatui-widgets
|
||||
@@ -200,11 +200,11 @@ jobs:
|
||||
name: Check README
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2
|
||||
with:
|
||||
tool: cargo-rdme
|
||||
- run: cargo xtask readme --check
|
||||
@@ -217,7 +217,7 @@ jobs:
|
||||
env:
|
||||
RUSTDOCFLAGS: -Dwarnings
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
@@ -226,10 +226,10 @@ jobs:
|
||||
- uses: dtolnay/install@74f735cdf643820234e37ae1c4089a08fd266d8a # master
|
||||
with:
|
||||
crate: cargo-docs-rs
|
||||
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2
|
||||
- uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2
|
||||
with:
|
||||
tool: cargo-hack
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- run: cargo xtask docs
|
||||
|
||||
# Run cargo test on the documentation of the crate. This will catch any code examples that don't
|
||||
@@ -238,16 +238,16 @@ jobs:
|
||||
name: Test Docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2
|
||||
- uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2
|
||||
with:
|
||||
tool: cargo-hack
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- run: cargo xtask test-docs
|
||||
|
||||
# Run cargo test on the libraries of the crate.
|
||||
@@ -259,16 +259,16 @@ jobs:
|
||||
matrix:
|
||||
toolchain: ["1.86.0", "stable"]
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: taiki-e/install-action@763e3324d4fd026c9bd284c504378585777a87d5 # v2
|
||||
- uses: taiki-e/install-action@50708e9ba8d7b6587a2cb575ddaa9a62e927bc06 # v2
|
||||
with:
|
||||
tool: cargo-hack
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- run: cargo xtask test-libs
|
||||
|
||||
# Run cargo test on all the backends.
|
||||
@@ -285,11 +285,11 @@ jobs:
|
||||
- os: windows-latest
|
||||
backend: termion
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2
|
||||
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
|
||||
- run: cargo xtask test-backend ${{ matrix.backend }}
|
||||
|
||||
8
.github/workflows/release-plz.yml
vendored
8
.github/workflows/release-plz.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
if: ${{ github.repository_owner == 'ratatui' }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
- uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1
|
||||
id: auth
|
||||
- name: Run release-plz
|
||||
uses: release-plz/action@d529f731ae3e89610ada96eda34e5c6ba3b12214 # v0.5
|
||||
uses: release-plz/action@487eb7b5c085a664d5c5ca05f4159bd9b591182a # v0.5
|
||||
with:
|
||||
command: release
|
||||
env:
|
||||
@@ -54,7 +54,7 @@ jobs:
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
@@ -63,7 +63,7 @@ jobs:
|
||||
with:
|
||||
toolchain: stable
|
||||
- name: Run release-plz
|
||||
uses: release-plz/action@d529f731ae3e89610ada96eda34e5c6ba3b12214 # v0.5
|
||||
uses: release-plz/action@487eb7b5c085a664d5c5ca05f4159bd9b591182a # v0.5
|
||||
with:
|
||||
command: release-pr
|
||||
env:
|
||||
|
||||
2
.github/workflows/zizmor.yml
vendored
2
.github/workflows/zizmor.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
|
||||
<!-- ignore lint rules that are often triggered by content generated from commits / git-cliff -->
|
||||
<!-- markdownlint-disable line-length no-bare-urls ul-style emphasis-style -->
|
||||
|
||||
|
||||
## [v0.30.0-beta.0](https://github.com/ratatui/ratatui/releases/tag/v0.30.0-beta.0) - 2025-10-28
|
||||
|
||||
> _"Rats don't just survive; they discover; they create. ... I mean, just look at what they do with
|
||||
|
||||
170
Cargo.lock
generated
170
Cargo.lock
generated
@@ -35,6 +35,15 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloca"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5a7d05ea6aea7e9e64d25b9156ba2fee3fdd659e34e41063cd2fc7cd020d7f4"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
@@ -587,10 +596,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "criterion"
|
||||
version = "0.7.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928"
|
||||
checksum = "4d883447757bb0ee46f233e9dc22eb84d93a9508c9b868687b274fc431d886bf"
|
||||
dependencies = [
|
||||
"alloca",
|
||||
"anes",
|
||||
"cast",
|
||||
"ciborium",
|
||||
@@ -599,6 +609,7 @@ dependencies = [
|
||||
"itertools 0.13.0",
|
||||
"num-traits",
|
||||
"oorandom",
|
||||
"page_size",
|
||||
"plotters",
|
||||
"rayon",
|
||||
"regex",
|
||||
@@ -610,9 +621,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "criterion-plot"
|
||||
version = "0.6.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338"
|
||||
checksum = "ed943f81ea2faa8dcecbbfa50164acf95d555afec96a27871663b300e387b2e4"
|
||||
dependencies = [
|
||||
"cast",
|
||||
"itertools 0.13.0",
|
||||
@@ -1041,11 +1052,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fakeit"
|
||||
version = "1.3.1"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7cee7ae5e2b85f4a54db712b29ae088b4515d27235912c8aae90eea5548512a"
|
||||
checksum = "50b022284277dcbc4858e61d87f02146c6207f5c1656dcf73e2f5a4cea570ed7"
|
||||
dependencies = [
|
||||
"libmath",
|
||||
"rand 0.9.2",
|
||||
"simplerand",
|
||||
"uuid 0.8.2",
|
||||
@@ -1137,12 +1147,6 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.31"
|
||||
@@ -1480,7 +1484,7 @@ dependencies = [
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1678,9 +1682,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "instability"
|
||||
version = "0.3.9"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "435d80800b936787d62688c927b6490e887c7ef5ff9ce922c6c6050fca75eb9a"
|
||||
checksum = "6778b0196eefee7df739db78758e5cf9b37412268bfa5650bfeed028aed20d9c"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"indoc",
|
||||
@@ -1764,9 +1768,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "kasuari"
|
||||
version = "0.4.10"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "012b421f57b19b6dca64a11f6703087faa71aaef81c6e7cae57dcf7cdf286303"
|
||||
checksum = "8fe90c1150662e858c7d5f945089b7517b0a80d8bf7ba4b1b5ffc984e7230a5b"
|
||||
dependencies = [
|
||||
"hashbrown 0.16.1",
|
||||
"portable-atomic",
|
||||
@@ -1801,20 +1805,11 @@ version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "libmath"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfd3416934a853ae80d5c3b006f632dfcbaf320300c5167e88a469e9ac214502"
|
||||
dependencies = [
|
||||
"rand 0.3.23",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "line-clipping"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9bd35dcd25f8578944c44cd75649d6487d74cf895002f6d86613164f2635b72"
|
||||
checksum = "5f4de44e98ddbf09375cbf4d17714d18f39195f4f4894e8524501726fd9a8a4a"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
]
|
||||
@@ -2104,9 +2099,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "octocrab"
|
||||
version = "0.48.0"
|
||||
version = "0.48.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03c4c16af97628682471056f83897a89e84238cc422a2af37c367acb3206a4b8"
|
||||
checksum = "c5930b376c98c438a4f4259a760cda2c198efea3b82de8f8a2aff0c00a8b7c1c"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
@@ -2139,7 +2134,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
"url",
|
||||
"web-time",
|
||||
]
|
||||
@@ -2217,6 +2212,16 @@ dependencies = [
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "page_size"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "palette"
|
||||
version = "0.7.6"
|
||||
@@ -2575,29 +2580,6 @@ version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.3.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand 0.4.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
||||
dependencies = [
|
||||
"fuchsia-cprng",
|
||||
"libc",
|
||||
"rand_core 0.3.1",
|
||||
"rdrand",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
@@ -2639,21 +2621,6 @@ dependencies = [
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
dependencies = [
|
||||
"rand_core 0.4.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
@@ -2674,7 +2641,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.30.0-beta.0"
|
||||
version = "0.30.0-beta.1"
|
||||
dependencies = [
|
||||
"color-eyre",
|
||||
"criterion",
|
||||
@@ -2699,14 +2666,14 @@ dependencies = [
|
||||
"serde_json",
|
||||
"time",
|
||||
"tokio",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-core"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"bitflags 2.10.0",
|
||||
@@ -2731,7 +2698,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-crossterm"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossterm 0.28.1",
|
||||
@@ -2744,7 +2711,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-macros"
|
||||
version = "0.7.0-beta.0"
|
||||
version = "0.7.0-beta.1"
|
||||
dependencies = [
|
||||
"ratatui-core",
|
||||
"ratatui-widgets",
|
||||
@@ -2762,7 +2729,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-termion"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
dependencies = [
|
||||
"document-features",
|
||||
"instability",
|
||||
@@ -2773,7 +2740,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-termwiz"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
dependencies = [
|
||||
"document-features",
|
||||
"ratatui",
|
||||
@@ -2784,7 +2751,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratatui-widgets"
|
||||
version = "0.3.0-beta.0"
|
||||
version = "0.3.0-beta.1"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"color-eyre",
|
||||
@@ -2826,15 +2793,6 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rdrand"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||
dependencies = [
|
||||
"rand_core 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.17"
|
||||
@@ -2985,7 +2943,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3828,7 +3786,7 @@ dependencies = [
|
||||
"tokio-util",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3847,7 +3805,7 @@ dependencies = [
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3869,16 +3827,16 @@ dependencies = [
|
||||
"color-eyre",
|
||||
"crossterm 0.29.0",
|
||||
"ratatui",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.41"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
|
||||
checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
@@ -3888,21 +3846,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-appender"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf"
|
||||
checksum = "786d480bce6247ab75f005b14ae1624ad978d3029d9113f0a22fa1ac773faeaf"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"thiserror 1.0.69",
|
||||
"thiserror 2.0.17",
|
||||
"time",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.30"
|
||||
version = "0.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
|
||||
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -3911,9 +3869,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.34"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
|
||||
checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
@@ -3925,7 +3883,7 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
|
||||
dependencies = [
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
@@ -3942,9 +3900,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.20"
|
||||
version = "0.3.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5"
|
||||
checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e"
|
||||
dependencies = [
|
||||
"matchers",
|
||||
"nu-ansi-term",
|
||||
@@ -3953,7 +3911,7 @@ dependencies = [
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
@@ -4331,7 +4289,7 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4602,7 +4560,7 @@ dependencies = [
|
||||
"clap-verbosity-flag",
|
||||
"color-eyre",
|
||||
"duct",
|
||||
"tracing 0.1.41",
|
||||
"tracing 0.1.43",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
|
||||
16
Cargo.toml
16
Cargo.toml
@@ -33,7 +33,7 @@ bitflags = "2.10"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
color-eyre = "0.6"
|
||||
compact_str = { version = "0.9", default-features = false }
|
||||
criterion = { version = "0.7", features = ["html_reports"] }
|
||||
criterion = { version = "0.8", features = ["html_reports"] }
|
||||
crossterm = "0.29"
|
||||
document-features = "0.2"
|
||||
fakeit = "1"
|
||||
@@ -50,13 +50,13 @@ palette = "0.7"
|
||||
pretty_assertions = "1"
|
||||
rand = "0.9"
|
||||
rand_chacha = "0.9"
|
||||
ratatui = { path = "ratatui", version = "0.30.0-beta.0" }
|
||||
ratatui-core = { path = "ratatui-core", version = "0.1.0-beta.0" }
|
||||
ratatui-crossterm = { path = "ratatui-crossterm", version = "0.1.0-beta.0" }
|
||||
ratatui-macros = { path = "ratatui-macros", version = "0.7.0-beta.0" }
|
||||
ratatui-termion = { path = "ratatui-termion", version = "0.1.0-beta.0" }
|
||||
ratatui-termwiz = { path = "ratatui-termwiz", version = "0.1.0-beta.0" }
|
||||
ratatui-widgets = { path = "ratatui-widgets", version = "0.3.0-beta.0" }
|
||||
ratatui = { path = "ratatui", version = "0.30.0-beta.1" }
|
||||
ratatui-core = { path = "ratatui-core", version = "0.1.0-beta.1" }
|
||||
ratatui-crossterm = { path = "ratatui-crossterm", version = "0.1.0-beta.1" }
|
||||
ratatui-macros = { path = "ratatui-macros", version = "0.7.0-beta.1" }
|
||||
ratatui-termion = { path = "ratatui-termion", version = "0.1.0-beta.1" }
|
||||
ratatui-termwiz = { path = "ratatui-termwiz", version = "0.1.0-beta.1" }
|
||||
ratatui-widgets = { path = "ratatui-widgets", version = "0.3.0-beta.1" }
|
||||
rstest = "0.26"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ratatui-core"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
description = """
|
||||
Core types and traits for the Ratatui Terminal UI library.
|
||||
Widget libraries should use this crate. Applications should use the main Ratatui crate.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#![warn(missing_docs)]
|
||||
use core::fmt;
|
||||
use core::ops::{Add, AddAssign, Sub, SubAssign};
|
||||
|
||||
use crate::layout::Rect;
|
||||
use crate::layout::{Offset, Rect};
|
||||
|
||||
/// Position in the terminal coordinate system.
|
||||
///
|
||||
@@ -23,10 +24,18 @@ use crate::layout::Rect;
|
||||
/// - [`from(Rect)`](Self::from) - Create from [`Rect`] (uses top-left corner)
|
||||
/// - [`into((u16, u16))`] - Convert to `(u16, u16)` tuple
|
||||
///
|
||||
/// # Movement
|
||||
///
|
||||
/// - [`offset`](Self::offset) - Move by an [`Offset`]
|
||||
/// - [`Add<Offset>`](core::ops::Add) and [`Sub<Offset>`](core::ops::Sub) - Shift by offsets with
|
||||
/// clamping
|
||||
/// - [`AddAssign<Offset>`](core::ops::AddAssign) and [`SubAssign<Offset>`](core::ops::SubAssign) -
|
||||
/// In-place shifting
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use ratatui_core::layout::{Position, Rect};
|
||||
/// use ratatui_core::layout::{Offset, Position, Rect};
|
||||
///
|
||||
/// // the following are all equivalent
|
||||
/// let position = Position { x: 1, y: 2 };
|
||||
@@ -36,6 +45,10 @@ use crate::layout::Rect;
|
||||
///
|
||||
/// // position can be converted back into the components when needed
|
||||
/// let (x, y) = position.into();
|
||||
///
|
||||
/// // movement by offsets
|
||||
/// let position = Position::new(5, 5) + Offset::new(2, -3);
|
||||
/// assert_eq!(position, Position::new(7, 2));
|
||||
/// ```
|
||||
///
|
||||
/// For comprehensive layout documentation and examples, see the [`layout`](crate::layout) module.
|
||||
@@ -69,6 +82,15 @@ impl Position {
|
||||
pub const fn new(x: u16, y: u16) -> Self {
|
||||
Self { x, y }
|
||||
}
|
||||
|
||||
/// Moves the position by the given offset.
|
||||
///
|
||||
/// Positive offsets move right and down, negative offsets move left and up. Values that would
|
||||
/// move the position outside the `u16` range are clamped to the nearest edge.
|
||||
#[must_use = "method returns the modified value"]
|
||||
pub fn offset(self, offset: Offset) -> Self {
|
||||
self + offset
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(u16, u16)> for Position {
|
||||
@@ -95,6 +117,68 @@ impl fmt::Display for Position {
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Offset> for Position {
|
||||
type Output = Self;
|
||||
|
||||
/// Moves the position by the given offset.
|
||||
///
|
||||
/// Values that would move the position outside the `u16` range are clamped to the nearest
|
||||
/// edge.
|
||||
fn add(self, offset: Offset) -> Self {
|
||||
let max = i32::from(u16::MAX);
|
||||
let x = i32::from(self.x).saturating_add(offset.x).clamp(0, max) as u16;
|
||||
let y = i32::from(self.y).saturating_add(offset.y).clamp(0, max) as u16;
|
||||
Self { x, y }
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Position> for Offset {
|
||||
type Output = Position;
|
||||
|
||||
/// Moves the position by the given offset.
|
||||
///
|
||||
/// Values that would move the position outside the `u16` range are clamped to the nearest
|
||||
/// edge.
|
||||
fn add(self, position: Position) -> Position {
|
||||
position + self
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<Offset> for Position {
|
||||
type Output = Self;
|
||||
|
||||
/// Moves the position by the inverse of the given offset.
|
||||
///
|
||||
/// Values that would move the position outside the `u16` range are clamped to the nearest
|
||||
/// edge.
|
||||
fn sub(self, offset: Offset) -> Self {
|
||||
let max = i32::from(u16::MAX);
|
||||
let x = i32::from(self.x).saturating_sub(offset.x).clamp(0, max) as u16;
|
||||
let y = i32::from(self.y).saturating_sub(offset.y).clamp(0, max) as u16;
|
||||
Self { x, y }
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<Offset> for Position {
|
||||
/// Moves the position in place by the given offset.
|
||||
///
|
||||
/// Values that would move the position outside the `u16` range are clamped to the nearest
|
||||
/// edge.
|
||||
fn add_assign(&mut self, offset: Offset) {
|
||||
*self = *self + offset;
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<Offset> for Position {
|
||||
/// Moves the position in place by the inverse of the given offset.
|
||||
///
|
||||
/// Values that would move the position outside the `u16` range are clamped to the nearest
|
||||
/// edge.
|
||||
fn sub_assign(&mut self, offset: Offset) {
|
||||
*self = *self - offset;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use alloc::string::ToString;
|
||||
@@ -104,15 +188,15 @@ mod tests {
|
||||
#[test]
|
||||
fn new() {
|
||||
let position = Position::new(1, 2);
|
||||
assert_eq!(position.x, 1);
|
||||
assert_eq!(position.y, 2);
|
||||
|
||||
assert_eq!(position, Position { x: 1, y: 2 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_tuple() {
|
||||
let position = Position::from((1, 2));
|
||||
assert_eq!(position.x, 1);
|
||||
assert_eq!(position.y, 2);
|
||||
|
||||
assert_eq!(position, Position { x: 1, y: 2 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -127,8 +211,8 @@ mod tests {
|
||||
fn from_rect() {
|
||||
let rect = Rect::new(1, 2, 3, 4);
|
||||
let position = Position::from(rect);
|
||||
assert_eq!(position.x, 1);
|
||||
assert_eq!(position.y, 2);
|
||||
|
||||
assert_eq!(position, Position { x: 1, y: 2 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -136,4 +220,34 @@ mod tests {
|
||||
let position = Position::new(1, 2);
|
||||
assert_eq!(position.to_string(), "(1, 2)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn offset_moves_position() {
|
||||
let position = Position::new(2, 3).offset(Offset::new(5, 7));
|
||||
|
||||
assert_eq!(position, Position::new(7, 10));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn offset_clamps_to_bounds() {
|
||||
let position = Position::new(1, 1).offset(Offset::MAX);
|
||||
|
||||
assert_eq!(position, Position::MAX);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_and_subtract_offset() {
|
||||
let position = Position::new(10, 10) + Offset::new(-3, 4) - Offset::new(5, 20);
|
||||
|
||||
assert_eq!(position, Position::new(2, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_assign_and_sub_assign_offset() {
|
||||
let mut position = Position::new(5, 5);
|
||||
position += Offset::new(2, 3);
|
||||
position -= Offset::new(10, 1);
|
||||
|
||||
assert_eq!(position, Position::new(0, 7));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -840,6 +840,16 @@ mod tests {
|
||||
assert!(!Rect::new(1, 2, 3, 4).intersects(Rect::new(5, 6, 7, 8)));
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case::corner(Rect::new(0, 0, 10, 10), Rect::new(10, 10, 20, 20))]
|
||||
#[case::edge(Rect::new(0, 0, 10, 10), Rect::new(10, 0, 20, 10))]
|
||||
#[case::no_intersect(Rect::new(0, 0, 10, 10), Rect::new(11, 11, 20, 20))]
|
||||
#[case::contains(Rect::new(0, 0, 20, 20), Rect::new(5, 5, 10, 10))]
|
||||
fn mutual_intersect(#[case] rect0: Rect, #[case] rect1: Rect) {
|
||||
assert_eq!(rect0.intersection(rect1), rect1.intersection(rect0));
|
||||
assert_eq!(rect0.intersects(rect1), rect1.intersects(rect0));
|
||||
}
|
||||
|
||||
// the bounds of this rect are x: [1..=3], y: [2..=5]
|
||||
#[rstest]
|
||||
#[case::inside_top_left(Rect::new(1, 2, 3, 4), Position { x: 1, y: 2 }, true)]
|
||||
|
||||
@@ -433,6 +433,22 @@ impl Style {
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns `true` if the style has the given modifier set.
|
||||
///
|
||||
/// ## Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use ratatui_core::style::{Modifier, Style};
|
||||
///
|
||||
/// let style = Style::default().add_modifier(Modifier::BOLD | Modifier::ITALIC);
|
||||
/// assert!(style.has_modifier(Modifier::BOLD));
|
||||
/// assert!(style.has_modifier(Modifier::ITALIC));
|
||||
/// assert!(!style.has_modifier(Modifier::UNDERLINED));
|
||||
/// ```
|
||||
pub const fn has_modifier(self, modifier: Modifier) -> bool {
|
||||
self.add_modifier.contains(modifier) && !self.sub_modifier.contains(modifier)
|
||||
}
|
||||
|
||||
/// Results in a combined style that is equivalent to applying the two individual styles to
|
||||
/// a style one after the other.
|
||||
///
|
||||
@@ -812,6 +828,28 @@ mod tests {
|
||||
assert_eq!(ALL, ALL_SHORT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn has_modifier_checks() {
|
||||
// basic presence
|
||||
let style = Style::new().add_modifier(Modifier::BOLD | Modifier::ITALIC);
|
||||
assert!(style.has_modifier(Modifier::BOLD));
|
||||
assert!(style.has_modifier(Modifier::ITALIC));
|
||||
assert!(!style.has_modifier(Modifier::UNDERLINED));
|
||||
|
||||
// removal prevents the modifier from being reported as present
|
||||
let style = Style::new()
|
||||
.add_modifier(Modifier::BOLD | Modifier::ITALIC)
|
||||
.remove_modifier(Modifier::ITALIC);
|
||||
assert!(style.has_modifier(Modifier::BOLD));
|
||||
assert!(!style.has_modifier(Modifier::ITALIC));
|
||||
|
||||
// patching with a style that removes a modifier clears it
|
||||
let style = Style::new().add_modifier(Modifier::BOLD | Modifier::ITALIC);
|
||||
let patched = style.patch(Style::new().remove_modifier(Modifier::ITALIC));
|
||||
assert!(patched.has_modifier(Modifier::BOLD));
|
||||
assert!(!patched.has_modifier(Modifier::ITALIC));
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(Style::new().black(), Color::Black)]
|
||||
#[case(Style::new().red(), Color::Red)]
|
||||
|
||||
@@ -72,7 +72,7 @@ fn outer() {
|
||||
#[test]
|
||||
fn offset() {
|
||||
let base = Rect::new(2, 2, 5, 3);
|
||||
let moved = base.offset(Offset { x: 4, y: 2 });
|
||||
let moved = base + Offset::new(4, 2);
|
||||
|
||||
let mut buf = Buffer::empty(Rect::new(0, 0, 15, 10));
|
||||
Filled { symbol: "░" }.render(base, &mut buf);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ratatui-crossterm"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
description = "Crossterm backend for the Ratatui Terminal UI library."
|
||||
documentation = "https://docs.rs/ratatui-crossterm"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ratatui-macros"
|
||||
version = "0.7.0-beta.0"
|
||||
version = "0.7.0-beta.1"
|
||||
description = "Macros for Ratatui"
|
||||
edition.workspace = true
|
||||
authors = ["The Ratatui Developers"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ratatui-termion"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
description = "Termion backend for the Ratatui Terminal UI library."
|
||||
documentation = "https://docs.rs/ratatui-termion"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ratatui-termwiz"
|
||||
version = "0.1.0-beta.0"
|
||||
version = "0.1.0-beta.1"
|
||||
description = "Termwiz backend for the Ratatui Terminal UI library."
|
||||
documentation = "https://docs.rs/ratatui-termwiz"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "ratatui-widgets"
|
||||
# Note that this started at 0.3.0 as there was a previous crate using the name `ratatui-widgets`.
|
||||
# <https://github.com/joshka/ratatui-widgets/issues/46>
|
||||
version = "0.3.0-beta.0"
|
||||
version = "0.3.0-beta.1"
|
||||
description = "A collection of Ratatui widgets for building terminal user interfaces using Ratatui."
|
||||
documentation = "https://docs.rs/ratatui-widgets"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -1951,18 +1951,18 @@ mod tests {
|
||||
let mut offset = Offset::ZERO;
|
||||
for (border_type_1, border_type_2) in iproduct!(border_types, border_types) {
|
||||
let title = format!("{border_type_1} + {border_type_2}");
|
||||
let title_area = Rect::new(0, 0, 43, 1).offset(offset);
|
||||
let title_area = Rect::new(0, 0, 43, 1) + offset;
|
||||
title.render(title_area, &mut buffer);
|
||||
offset.y += 1;
|
||||
for (rect_1, rect_2) in rects {
|
||||
Block::bordered()
|
||||
.border_type(border_type_1)
|
||||
.merge_borders(strategy)
|
||||
.render(rect_1.offset(offset), &mut buffer);
|
||||
.render(rect_1 + offset, &mut buffer);
|
||||
Block::bordered()
|
||||
.border_type(border_type_2)
|
||||
.merge_borders(strategy)
|
||||
.render(rect_2.offset(offset), &mut buffer);
|
||||
.render(rect_2 + offset, &mut buffer);
|
||||
}
|
||||
offset.y += 9;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "ratatui"
|
||||
description = "A library that's all about cooking up terminal user interfaces"
|
||||
version = "0.30.0-beta.0"
|
||||
version = "0.30.0-beta.1"
|
||||
authors.workspace = true
|
||||
documentation.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
Reference in New Issue
Block a user