rhysd / tui-textarea

Simple yet powerful multi-line text editor widget for ratatui and tui-rs
https://crates.io/crates/tui-textarea
MIT License
345 stars 63 forks source link

Ratatui support #12

Closed dzfrias closed 1 year ago

dzfrias commented 1 year ago

With the release of ratatui, it would be nice to have a feature flag or release of this crate that supports it!

https://github.com/tui-rs-revival/ratatui/releases

rhysd commented 1 year ago

Yes, this should be supported. Though currently I don't have enough velocity to implement this, I'd like to work on this with higher priority when I have enough time.

rhysd commented 1 year ago

One thing I need to clarify is version of crossterm dependency.

Currently tui-textarea is directly depending on v0.25 to align with tui-rs. I'm not sure we can switch the version of crossterm crate depending on tui-rs or ratatui respectively. I need to check if Cargo allows different versions of same crate to exist in dependencies list.

rhysd commented 1 year ago

I confirmed the following change worked.

diff --git a/Cargo.toml b/Cargo.toml
index b706d9a..2d8c2c0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,16 +23,19 @@ include = [

 [features]
 default = ["crossterm"]
-crossterm = ["dep:crossterm", "tui/crossterm"]
+crossterm = ["dep:crossterm-025", "tui/crossterm"]
 termion = ["dep:termion", "tui/termion"]
 search = ["dep:regex"]
+crossterm-ratatui = ["dep:crossterm-026", "ratatui/crossterm"]

 [dependencies]
-crossterm = { version = "0.25", optional = true }
+crossterm-025 = { package = "crossterm", version = "0.25", optional = true }
 regex = { version = "1", optional = true }
 termion = { version = "1.5", optional = true }
 tui = { version = "0.19", default-features = false }
 arbitrary = { version = "1", features = ["derive"], optional = true }
+crossterm-026 = { package = "crossterm", version = "0.26", optional = true }
+ratatui = { version = "0.20.1", default-features = false }

 [[example]]
 name = "minimal"

This means

I need to check if Cargo allows different versions of same crate to exist in dependencies list.

is possible.

Now I wonder how handle the combination of (tui, ratatui) * (crossterm, termion) with features of this crate. Current idea is adding the following features separate from original crossterm and termion features.

rhysd commented 1 year ago

I'm working on this in ratatui branch

rvigo commented 1 year ago

Hi @rhysd, thanks for the ratatui support <3 Is it already available?

Just followed the instructions on README.md but got this error:

the package `X` depends on `tui-textarea`, with features: `ratatui-crossterm` but `tui-textarea` does not have these features.

Sorry if it is a silly question, I'm just not familiarized with Cargo releases

Additional Info: Cargo.toml

crossterm = "0.26.1"
tui = { package = "ratatui", version = "0.20.1" }
tui-textarea = { version = "0.2.0",  features = ["ratatui-crossterm"], default-features = false }