Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ratatui modularized crates #47

Merged
merged 5 commits into from
Nov 27, 2024
Merged
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
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ futures = "0.3.31"
itertools = "0.13.0"
indoc = "2.0.5"
lipsum = "0.9.1"
ratatui = { version = "0.29.0", default-features = false }
ratatui-macros = "0.6.0"
ratatui = { version = "0.30.0-alpha.0", default-features = false }
ratatui-core = { version = "0.1.0-alpha.0" }
ratatui-macros = "0.7.0-alpha.0"
ratatui-widgets = { version = "0.3.0-alpha.0" }
rstest = "0.23.0"
strum = { version = "0.26.3", features = ["derive"] }
tokio = { version = "1.41.0" }
Expand All @@ -33,7 +35,7 @@ tokio = { version = "1.41.0" }
unused = "warn"

[lints.clippy]
cargo = "warn" # when this fails, investigate and disable the lint if needed, noting the reason
# cargo = "warn" # when this fails, investigate and disable the lint if needed, noting the reason
pedantic = "warn"
nursery = "warn"

Expand Down
2 changes: 1 addition & 1 deletion tui-big-text/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rust-version.workspace = true
derive_builder.workspace = true
font8x8 = "0.3.1"
itertools.workspace = true
ratatui.workspace = true
ratatui-core.workspace = true

[dev-dependencies]
color-eyre.workspace = true
Expand Down
9 changes: 8 additions & 1 deletion tui-big-text/src/big_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ use std::cmp::min;

use derive_builder::Builder;
use font8x8::UnicodeFonts;
use ratatui::{prelude::*, text::StyledGrapheme, widgets::Widget};
use ratatui_core::{
buffer::Buffer,
layout::{Alignment, Rect},
style::Style,
text::{Line, StyledGrapheme},
widgets::Widget,
};

use crate::PixelSize;

Expand Down Expand Up @@ -201,6 +207,7 @@ fn render_glyph(glyph: [u8; 8], area: Rect, buf: &mut Buffer, pixel_size: &Pixel
#[cfg(test)]
mod tests {
use super::*;
use ratatui_core::style::Stylize;

#[test]
fn build() {
Expand Down
2 changes: 1 addition & 1 deletion tui-box-text/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords.workspace = true
[dependencies]
color-eyre.workspace = true
indoc.workspace = true
ratatui.workspace = true
ratatui-core.workspace = true

[dev-dependencies]
ratatui = { workspace = true, default-features = true }
2 changes: 1 addition & 1 deletion tui-box-text/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, iter::zip, sync::LazyLock};

use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use ratatui_core::{buffer::Buffer, layout::Rect, widgets::Widget};

pub struct BoxChar(char);

Expand Down
2 changes: 1 addition & 1 deletion tui-cards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ keywords.workspace = true
color-eyre.workspace = true
indoc.workspace = true
strum.workspace = true
ratatui.workspace = true
ratatui-core.workspace = true
itertools.workspace = true

[dev-dependencies]
Expand Down
6 changes: 4 additions & 2 deletions tui-cards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
use std::iter::zip;

use indoc::indoc;
use ratatui::{
use ratatui_core::{
buffer::Buffer,
layout::Rect,
style::{Color, Stylize},
widgets::Widget,
};
Expand Down Expand Up @@ -281,7 +283,7 @@ impl Rank {
}

impl Widget for &Card {
fn render(self, area: ratatui::prelude::Rect, buf: &mut ratatui::prelude::Buffer)
fn render(self, area: Rect, buf: &mut Buffer)
where
Self: Sized,
{
Expand Down
8 changes: 4 additions & 4 deletions tui-popup/src/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ impl<'content, W: SizedWidgetRef> Popup<'content, W> {
}
}

impl SizedWidgetRef for Text<'_> {
impl SizedWidgetRef for &Text<'_> {
fn width(&self) -> usize {
self.width()
Text::width(self)
}

fn height(&self) -> usize {
self.height()
Text::height(self)
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ impl<W: SizedWidgetRef> StatefulWidgetRef for Popup<'_, W> {
.border_style(self.border_style)
.title(self.title.clone())
.style(self.style);
block.render_ref(area, buf);
Widget::render(&block, area, buf);
self.body.render_ref(block.inner(area), buf);
}
}
Expand Down
3 changes: 2 additions & 1 deletion tui-scrollview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ rust-version.workspace = true

[dependencies]
indoc.workspace = true
ratatui.workspace = true
ratatui-core.workspace = true
ratatui-widgets.workspace = true
rstest.workspace = true

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tui-scrollview/examples/scrollview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,6 @@ const CHART_DATA: [(&str, u64, Color); 3] = [

fn bars() -> BarGroup<'static> {
let data = CHART_DATA
.map(|(label, value, color)| Bar::default().label(label.into()).value(value).style(color));
.map(|(label, value, color)| Bar::default().label(label).value(value).style(color));
BarGroup::default().bars(&data)
}
9 changes: 8 additions & 1 deletion tui-scrollview/src/scroll_view.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
use ratatui::{layout::Size, prelude::*, widgets::*};
use ratatui_core::{
buffer::Buffer,
layout::Rect,
layout::Size,
widgets::{StatefulWidget, Widget},
};
use ratatui_widgets::scrollbar::{Scrollbar, ScrollbarOrientation, ScrollbarState};

use crate::ScrollViewState;

Expand Down Expand Up @@ -340,6 +346,7 @@ impl ScrollView {
#[cfg(test)]
mod tests {
use super::*;
use ratatui_core::text::Span;
use rstest::{fixture, rstest};

/// Initialize a buffer and a scroll view with a buffer size of 10x10
Expand Down
2 changes: 1 addition & 1 deletion tui-scrollview/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ratatui::layout::{Position, Size};
use ratatui_core::layout::{Position, Size};

#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)]
pub struct ScrollViewState {
Expand Down