Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 37 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ansi-to-tui"
version = "7.0.0"
version = "8.0.0-alpha.0"
authors = ["Uttarayan Mondal <[email protected]>"]
edition = "2018"
description = "A library to convert ansi color coded text into ratatui::text::Text type from ratatui library"
Expand All @@ -11,10 +11,10 @@ repository = "https://github.com/uttarayan21/ansi-to-tui"

[dependencies]
nom = "7.1"
tui = { version = "0.29", default-features = false, package = "ratatui" }
thiserror = "1.0"
ratatui-core = { version = "0.1.0-alpha", default-features = false }
simdutf8 = { version = "0.1", optional = true }
smallvec = { version = "1.10.0", features = ["const_generics"] }
thiserror = "1.0"

[dev-dependencies]
anyhow = "1.0"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

A nom parser to parse text with ANSI color codes and turn them into [`ratatui::text::Text`][Text].

For people still using [tui-rs](docs.rs/tui) use version `v2.*` for people migrating to [ratatui](docs.rs/ratatui) use version `v3.*`
I recommend switching over to ratatui since tui-rs is currently unmaintained.
For people still using [tui-rs](docs.rs/tui) use version `v2.*` for people migrating to
[ratatui](docs.rs/ratatui) use version `v3.*`+. I recommend switching over to ratatui since tui-rs
is currently unmaintained.

| Color | Supported | Examples |
| ------ | :-------: | ------------------------ |
Expand Down
2 changes: 1 addition & 1 deletion ascii/code.ascii
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
 160 │  }
 161 │ }
 162 │
 163 │ // fn span(s: &[u8]) -> IResult<&[u8], tui::text::Span> {
 163 │ // fn span(s: &[u8]) -> IResult<&[u8], ratatui::text::Span> {
 164 │ fn span(last: Style) -> impl Fn(&[u8]) -> IResult<&[u8], Span<'static>, nom::error::Error<&[u8]>> {
 165 │  move |s: &[u8]| -> IResult<&[u8], Span<'static>> {
 166 │  let mut last = last;
Expand Down
2 changes: 1 addition & 1 deletion src/code.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use tui::style::Color;
use ratatui_core::style::Color;

/// This enum stores most types of ansi escape sequences
///
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod code;
mod error;
mod parser;
pub use error::Error;
use tui::text::Text;
use ratatui_core::text::Text;

/// IntoText will convert any type that has a AsRef<[u8]> to a Text.
pub trait IntoText {
Expand Down
8 changes: 4 additions & 4 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use nom::{
sequence::{delimited, preceded, terminated, tuple},
IResult, Parser,
};
use std::str::FromStr;
use tui::{
use ratatui_core::{
style::{Color, Modifier, Style, Stylize},
text::{Line, Span, Text},
};
use std::str::FromStr;

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
enum ColorType {
Expand All @@ -37,7 +37,7 @@ struct AnsiStates {
pub style: Style,
}

impl From<AnsiStates> for tui::style::Style {
impl From<AnsiStates> for ratatui_core::style::Style {
fn from(states: AnsiStates) -> Self {
let mut style = states.style;
if states.items.is_empty() {
Expand Down Expand Up @@ -161,7 +161,7 @@ fn line_fast(style: Style) -> impl Fn(&[u8]) -> IResult<&[u8], (Line<'_>, Style)
}
}

// fn span(s: &[u8]) -> IResult<&[u8], tui::text::Span> {
// fn span(s: &[u8]) -> IResult<&[u8], ratatui::text::Span> {
fn span(last: Style) -> impl Fn(&[u8]) -> IResult<&[u8], Span<'static>, nom::error::Error<&[u8]>> {
move |s: &[u8]| -> IResult<&[u8], Span<'static>> {
let mut last = last;
Expand Down
5 changes: 2 additions & 3 deletions tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// use ansi_to_tui::{ansi_to_text, ansi_to_text_override_style};
use ansi_to_tui::IntoText;
use pretty_assertions::assert_eq;
use tui::style::Stylize;
use tui::{
style::{Color, Modifier, Style},
use ratatui_core::{
style::{Color, Modifier, Style, Stylize},
text::{Line, Span, Text},
};

Expand Down