Skip to content

Commit

Permalink
Merge pull request #83 from veeso/2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
veeso authored Oct 13, 2024
2 parents a20e8e9 + e7ac3df commit d09561b
Show file tree
Hide file tree
Showing 55 changed files with 1,415 additions and 754 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --lib --no-default-features --features derive,serialize,with-crossterm
run: cargo test --no-fail-fast --lib --no-default-features --features derive,serialize
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/crossterm-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --no-default-features --features derive,serialize,tui,crossterm
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --no-default-features --features derive,serialize,ratatui,crossterm
- name: Test
run: cargo test --no-fail-fast --lib --no-default-features --features derive,serialize,crossterm
- name: Examples
run: cargo build --all-targets --examples
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --lib --no-default-features --features derive,serialize,tui,crossterm -- -Dwarnings
- name: Clippy
run: cargo clippy --lib --no-default-features --features derive,serialize,ratatui,crossterm -- -Dwarnings
run: cargo clippy --lib --no-default-features --features derive,serialize,crossterm -- -Dwarnings
38 changes: 18 additions & 20 deletions .github/workflows/ratatui_crossterm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@ name: Ratatui-Crossterm
on: [push, pull_request]

env:
CARGO_TERM_COLOR: always
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --features derive,serialize,ratatui,crossterm --no-default-features
- name: Examples
run: cargo build --all-targets --examples
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --lib --features derive,serialize,ratatui,crossterm --no-default-features -- -Dwarnings
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Test
run: cargo test --no-fail-fast --lib --features derive,serialize,crossterm --no-default-features
- name: Examples
run: cargo build --all-targets --examples
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --lib --features derive,serialize,crossterm --no-default-features -- -Dwarnings
13 changes: 5 additions & 8 deletions .github/workflows/ratatui_termion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --no-default-features --features derive,serialize,ratatui,termion
- name: Test
run: cargo test --no-fail-fast --lib --no-default-features --features derive,serialize,termion
- name: Examples
run: cargo build --all-targets --no-default-features --features derive,serialize,ratatui,termion --examples
run: cargo build --all-targets --no-default-features --features derive,serialize,termion --examples
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --lib --no-default-features --features derive,serialize,ratatui,termion -- -Dwarnings
run: cargo clippy --lib --no-default-features --features derive,serialize,termion -- -Dwarnings
28 changes: 0 additions & 28 deletions .github/workflows/tui_crossterm.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/tui_termion.yml

This file was deleted.

29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

- [Changelog](#changelog)
- [2.0.0](#200)
- [1.9.2](#192)
- [1.9.1](#191)
- [1.9.0](#190)
Expand Down Expand Up @@ -35,6 +36,34 @@

---

## 2.0.0

Released on 13/10/2024

- Dropped support for `tui-rs`. Tui-rs was deprecated a long time ago, so it doesn't really makes sense to keep supporting it.
- Added new methods for `TerminalBridge`
- `init`: Initialize a terminal with reasonable defaults for most applications.
- Raw mode is enabled
- Alternate screen buffer enabled
- A panic hook is installed that restores the terminal before panicking. Ensure that this method is called after any other panic hooks that may be installed to ensure that the terminal is.
- `restore`: Restore the terminal to its original state
- `set_panic_hook`: Sets a panic hook that restores the terminal before panicking.
- Added `draw` to `TerminalBridge`
- `CmdResult::Custom(&'static str)` changed to `CmdResult::Custom(&'static str, State)`
- Added new `subclause_and!(Id::Foo, Id::Bar, Id::Baz)` and `subclause_or!(Id::Foo, Id::Bar, Id::Baz)` macros.
- Removed `InputListener`. Now use `CrosstermInputListener` or `TermionInputListener`.
- Added Event handling for Mouse Events
- Added `Mouse` in `SubEventClause`.
- Bump `ratatui` version to `0.28`
- Dont enable `MouseCapture` by default
- Add function `enable_mouse_capture` and `disable_mouse_capture` to `TerminalBridge`
- **Max poll for ports**:
- Add `Port::set_max_poll` to set the amount a `Port` is polled in a single `Port::should_poll`.
- Add `EventListenerCfg::port` to add a manually constructed `Port`
- Previous `EventListenerCfg::port` has been renamed to `EventListenerCfg::add_port`

Huge thanks to [hasezoey](https://github.com/hasezoey) for the contributions.

## 1.9.2

Released on 04/03/2023
Expand Down
36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tuirealm"
version = "1.9.2"
version = "2.0.0"
authors = ["Christian Visintin"]
edition = "2021"
categories = ["command-line-utilities"]
Expand All @@ -14,37 +14,37 @@ readme = "README.md"
repository = "https://github.com/veeso/tui-realm"

[dependencies]
bitflags = "2.4"
crossterm = { version = "0.27", optional = true }
bitflags = "2"
crossterm = { version = "0.28", optional = true }
lazy-regex = "3"
ratatui = { version = "0.26", default-features = false, optional = true }
ratatui = { version = "0.28", default-features = false }
serde = { version = "^1", features = ["derive"], optional = true }
termion = { version = "^2", optional = true }
thiserror = "^1.0.0"
tui = { version = "0.19", default-features = false, optional = true }
tuirealm_derive = { version = "^1.0.0", optional = true }
termion = { version = "^4", optional = true }
thiserror = "1"
tuirealm_derive = { version = "2", optional = true }

[dev-dependencies]
pretty_assertions = "^1"
toml = "^0.8"
tempfile = "^3"

[features]
default = ["derive", "ratatui", "crossterm"]
derive = ["tuirealm_derive"]
serialize = ["serde", "bitflags/serde"]
tui = ["dep:tui"]
crossterm = ["dep:crossterm", "tui?/crossterm", "ratatui?/crossterm"]
termion = ["dep:termion", "tui?/termion", "ratatui?/termion"]
ratatui = ["dep:ratatui"]
# deprecated aliases for broken out backend and UI library features
with-crossterm = ["tui", "crossterm"]
with-termion = ["tui", "termion"]
default = ["derive", "crossterm"]
derive = ["dep:tuirealm_derive"]
serialize = ["dep:serde", "bitflags/serde"]
crossterm = ["dep:crossterm", "ratatui/crossterm"]
termion = ["dep:termion", "ratatui/termion"]

[[example]]
name = "demo"
path = "examples/demo/demo.rs"
required-features = ["crossterm"]

[[example]]
name = "user-events"
path = "examples/user_events/user_events.rs"
required-features = ["crossterm"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
42 changes: 11 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</p>

<p align="center">Developed by <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
<p align="center">Current version: 1.9.2 (04/03/2024)</p>
<p align="center">Current version: 2.0.0 (13/10/2024)</p>

<p align="center">
<a href="https://opensource.org/licenses/MIT"
Expand Down Expand Up @@ -54,16 +54,6 @@
src="https://github.com/veeso/tui-realm/actions/workflows/ratatui_termion.yml/badge.svg"
alt="Ratatui-Termion CI"
/></a>
<a href="https://github.com/veeso/tui-realm/actions/workflows/tui_crossterm.yml"
><img
src="https://github.com/veeso/tui-realm/actions/workflows/tui_crossterm.yml/badge.svg"
alt="Tui-Crossterm CI"
/></a>
<a href="https://github.com/veeso/tui-realm/actions/workflows/tui_termion.yml"
><img
src="https://github.com/veeso/tui-realm/actions/workflows/tui_termion.yml/badge.svg"
alt="Termion CI"
/></a>
<a href="https://github.com/veeso/tui-realm/actions/workflows/crossterm-windows.yml"
><img
src="https://github.com/veeso/tui-realm/actions/workflows/crossterm-windows.yml/badge.svg"
Expand Down Expand Up @@ -105,9 +95,9 @@

## About tui-realm 👑

tui-realm is a **framework** for [tui](https://github.com/fdehau/tui-rs) and [ratatui](https://github.com/ratatui-org/ratatui) to simplify the implementation of terminal user interfaces adding the possibility to work with re-usable components with properties and states, as you'd do in React. But that's not all: the components communicate with the ui engine via a system based on **Messages** and **Events**, providing you with the possibility to implement `update` routines as happens in Elm. In addition, the components are organized inside the **View**, which manages mounting/umounting, focus and event forwarding for you.
tui-realm is a **framework** for **[ratatui](https://github.com/ratatui-org/ratatui)** to simplify the implementation of terminal user interfaces adding the possibility to work with re-usable components with properties and states, as you'd do in React. But that's not all: the components communicate with the ui engine via a system based on **Messages** and **Events**, providing you with the possibility to implement `update` routines as happens in Elm. In addition, the components are organized inside the **View**, which manages mounting/umounting, focus and event forwarding for you.

And that also explains the reason of the name: Realm stands for React and Elm.
And that also explains the reason of the name: **Realm stands for React and Elm**.

tui-realm also comes with a standard library of components, which can be added to your dependencies, that you may find very useful. Don't worry, they are optional if you don't want to use them 😉, just follow the guide in [get started](#get-started-).

Expand Down Expand Up @@ -136,51 +126,41 @@ See tui-realm in action in the [Example](#run-examples-) or if you want to read
If you want the default features, just add tuirealm 1.x version:

```toml
tuirealm = "^1.9.0"
tuirealm = "2"
```

otherwise you can specify the features you want to add:

```toml
tuirealm = { version = "^1.9.0", default-features = false, features = [ "derive", "serialize", "termion" ] }
tuirealm = { version = "2", default-features = false, features = [ "derive", "serialize", "termion" ] }
```

Supported features are:

- `derive` (*default*): add the `#[derive(MockComponent)]` proc macro to automatically implement `MockComponent` for `Component`. [Read more](https://github.com/veeso/tuirealm_derive).
- `serialize`: add the serialize/deserialize trait implementation for `KeyEvent` and `Key`.
- `tui`: use the [tui-rs](https://github.com/fdehau/tui-rs) terminal UI library
- `ratatui`: use the [ratatui](https://github.com/ratatui-org/ratatui) terminal UI library
- `crossterm`: use the [crossterm](https://github.com/crossterm-rs/crossterm) terminal backend
- `termion`: use the [termion](https://github.com/redox-os/termion) terminal backend

Deprecated feature flags:

- `with-crossterm`
- `with-termion`

> ⚠️ You can enable only one backend at the time and at least one must be enabled in order to build.
> ❗ You don't need tui as a dependency, since you can access to tui types via `use tuirealm::tui::`
#### Enabling other backends ⚠️

This library supports two backends: `crossterm` and `termion`, and two high
level terminal TUI libraries: `tui` and `ratatui`. Whenever you explicitly
declare any of the TUI library or backend feature sets you should disable the
crate's default features.

> You can never have more than one backend and one UI library enabled at the same time
> The two features can co-exist, even if it doesn't make too much sense.
Example using the termion backend:
Example using crossterm:

```toml
tuirealm = { version = "^1.9.0", default-features = false, features = [ "termion", "derive", "tui" ] }
tuirealm = { version = "2", default-features = false, features = [ "derive", "crossterm" ]}
```

Example using the ratatui UI library:
Example using the termion backend:

```toml
tuirealm = { version = "^1.9.0", default-features = false, features = [ "ratatui", "derive", "crossterm" ]}
tuirealm = { version = "2", default-features = false, features = [ "derive", "termion" ] }
```

### Create a tui-realm application 🪂
Expand All @@ -191,7 +171,7 @@ View how to implement a tui-realm application in the [related guide](/docs/en/ge

Still confused about how tui-realm works? Don't worry, try with the examples:

- [demo](/examples/demo.rs): a simple application which shows how tui-realm works
- [demo](/examples/demo/demo.rs): a simple application which shows how tui-realm works

```sh
cargo run --example demo
Expand Down
Loading

0 comments on commit d09561b

Please sign in to comment.