mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-13 00:17:11 +00:00
cleanup doc links
This commit is contained in:
parent
62a9eeb242
commit
3137ee35f9
25 changed files with 132 additions and 138 deletions
|
@ -40,6 +40,10 @@ unstable-widget-ref = ["ratatui-core/unstable-widget-ref"]
|
|||
## See [Issue 293](https://github.com/ratatui/ratatui/issues/293) for more details.
|
||||
unstable-rendered-line-info = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[dependencies]
|
||||
bitflags.workspace = true
|
||||
itertools.workspace = true
|
||||
|
|
|
@ -191,7 +191,7 @@ impl<'a> BarChart<'a> {
|
|||
/// It is also possible to set individually the style of each [`Bar`].
|
||||
/// In this case the default style will be patched by the individual style
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn bar_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.bar_style = style.into();
|
||||
|
@ -200,8 +200,8 @@ impl<'a> BarChart<'a> {
|
|||
|
||||
/// Set the width of the displayed bars.
|
||||
///
|
||||
/// For [`Horizontal`](crate::layout::Direction::Horizontal) bars this becomes the height of
|
||||
/// the bar.
|
||||
/// For [`Horizontal`](ratatui_core::layout::Direction::Horizontal) bars this becomes the height
|
||||
/// of the bar.
|
||||
///
|
||||
/// If not set, this defaults to `1`.
|
||||
/// The bar label also uses this value as its width.
|
||||
|
@ -236,9 +236,9 @@ impl<'a> BarChart<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
/// The [`bar::Set`](crate::symbols::bar::Set) to use for displaying the bars.
|
||||
/// The [`bar::Set`](ratatui_core::symbols::bar::Set) to use for displaying the bars.
|
||||
///
|
||||
/// If not set, the default is [`bar::NINE_LEVELS`](crate::symbols::bar::NINE_LEVELS).
|
||||
/// If not set, the default is [`bar::NINE_LEVELS`](ratatui_core::symbols::bar::NINE_LEVELS).
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn bar_set(mut self, bar_set: symbols::bar::Set) -> Self {
|
||||
self.bar_set = bar_set;
|
||||
|
@ -257,7 +257,7 @@ impl<'a> BarChart<'a> {
|
|||
///
|
||||
/// [`Bar::value_style`] to set the value style individually.
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn value_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.value_style = style.into();
|
||||
|
@ -276,7 +276,7 @@ impl<'a> BarChart<'a> {
|
|||
///
|
||||
/// [`Bar::label`] to set the label style individually.
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn label_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.label_style = style.into();
|
||||
|
@ -297,7 +297,7 @@ impl<'a> BarChart<'a> {
|
|||
///
|
||||
/// The style will be applied to everything that isn't styled (borders, bars, labels, ...).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
@ -306,7 +306,7 @@ impl<'a> BarChart<'a> {
|
|||
|
||||
/// Set the direction of the bars.
|
||||
///
|
||||
/// [`Vertical`](crate::layout::Direction::Vertical) bars are the default.
|
||||
/// [`Vertical`](ratatui_core::layout::Direction::Vertical) bars are the default.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use ratatui_core::{buffer::Buffer, layout::Rect, style::Style, text::Line, widgets::Widget};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
/// A bar to be shown by the [`BarChart`](crate::widgets::BarChart) widget.
|
||||
/// A bar to be shown by the [`BarChart`](crate::barchart::BarChart) widget.
|
||||
///
|
||||
/// Here is an explanation of a `Bar`'s components.
|
||||
/// ```plain
|
||||
|
@ -59,11 +59,11 @@ impl<'a> Bar<'a> {
|
|||
|
||||
/// Set the label of the bar.
|
||||
///
|
||||
/// For [`Vertical`](crate::layout::Direction::Vertical) bars,
|
||||
/// For [`Vertical`](ratatui_core::layout::Direction::Vertical) bars,
|
||||
/// display the label **under** the bar.
|
||||
/// For [`Horizontal`](crate::layout::Direction::Horizontal) bars,
|
||||
/// For [`Horizontal`](ratatui_core::layout::Direction::Horizontal) bars,
|
||||
/// display the label **in** the bar.
|
||||
/// See [`BarChart::direction`](crate::widgets::BarChart::direction) to set the direction.
|
||||
/// See [`BarChart::direction`](crate::barchart::BarChart::direction) to set the direction.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn label(mut self, label: Line<'a>) -> Self {
|
||||
self.label = Some(label);
|
||||
|
@ -77,7 +77,7 @@ impl<'a> Bar<'a> {
|
|||
///
|
||||
/// This will apply to every non-styled element. It can be seen and used as a default value.
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
@ -93,7 +93,7 @@ impl<'a> Bar<'a> {
|
|||
///
|
||||
/// [`Bar::value`] to set the value.
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn value_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.value_style = style.into();
|
||||
|
|
|
@ -24,7 +24,7 @@ use crate::borders::{BorderType, Borders};
|
|||
mod padding;
|
||||
pub mod title;
|
||||
|
||||
/// Base widget to be used to display a box border around all [upper level ones](crate::widgets).
|
||||
/// Base widget to be used to display a box border around all other built-in widgets.
|
||||
///
|
||||
/// The borders can be configured with [`Block::borders`] and others. A block can have multiple
|
||||
/// [`Title`] using [`Block::title`]. It can also be [styled](Block::style) and
|
||||
|
@ -172,8 +172,8 @@ impl<'a> Block<'a> {
|
|||
/// space is calculated based on the full width of the block, rather than the leftover width.
|
||||
///
|
||||
/// You can provide any type that can be converted into [`Title`] including: strings, string
|
||||
/// slices (`&str`), borrowed strings (`Cow<str>`), [spans](crate::text::Span), or vectors of
|
||||
/// [spans](crate::text::Span) (`Vec<Span>`).
|
||||
/// slices (`&str`), borrowed strings (`Cow<str>`), [spans](ratatui_core::text::Span), or
|
||||
/// vectors of [spans](ratatui_core::text::Span) (`Vec<Span>`).
|
||||
///
|
||||
/// By default, the titles will avoid being rendered in the corners of the block but will align
|
||||
/// against the left or right edge of the block if there is no border on that edge. The
|
||||
|
@ -247,8 +247,8 @@ impl<'a> Block<'a> {
|
|||
/// Adds a title to the top of the block.
|
||||
///
|
||||
/// You can provide any type that can be converted into [`Line`] including: strings, string
|
||||
/// slices (`&str`), borrowed strings (`Cow<str>`), [spans](crate::text::Span), or vectors of
|
||||
/// [spans](crate::text::Span) (`Vec<Span>`).
|
||||
/// slices (`&str`), borrowed strings (`Cow<str>`), [spans](ratatui_core::text::Span), or
|
||||
/// vectors of [spans](ratatui_core::text::Span) (`Vec<Span>`).
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -276,8 +276,8 @@ impl<'a> Block<'a> {
|
|||
/// Adds a title to the bottom of the block.
|
||||
///
|
||||
/// You can provide any type that can be converted into [`Line`] including: strings, string
|
||||
/// slices (`&str`), borrowed strings (`Cow<str>`), [spans](crate::text::Span), or vectors of
|
||||
/// [spans](crate::text::Span) (`Vec<Span>`).
|
||||
/// slices (`&str`), borrowed strings (`Cow<str>`), [spans](ratatui_core::text::Span), or
|
||||
/// vectors of [spans](ratatui_core::text::Span) (`Vec<Span>`).
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -313,7 +313,7 @@ impl<'a> Block<'a> {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn title_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.titles_style = style.into();
|
||||
|
@ -389,7 +389,7 @@ impl<'a> Block<'a> {
|
|||
/// Block::bordered().border_style(Style::new().blue());
|
||||
/// ```
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn border_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.border_style = style.into();
|
||||
|
@ -432,8 +432,8 @@ impl<'a> Block<'a> {
|
|||
/// .style(Style::new().white().not_bold()); // will be white, and italic
|
||||
/// ```
|
||||
///
|
||||
/// [`Paragraph`]: crate::widgets::Paragraph
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Paragraph`]: crate::paragraph::Paragraph
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
@ -484,7 +484,7 @@ impl<'a> Block<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the symbols used to display the border as a [`crate::symbols::border::Set`].
|
||||
/// Sets the symbols used to display the border as a [`ratatui_core::symbols::border::Set`].
|
||||
///
|
||||
/// Setting this overwrites any [`border_type`](Block::border_type) that was set.
|
||||
///
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
/// Padding::symmetric(5, 6);
|
||||
/// ```
|
||||
///
|
||||
/// [`Block`]: crate::widgets::Block
|
||||
/// [`padding`]: crate::widgets::Block::padding
|
||||
/// [`Block`]: crate::block::Block
|
||||
/// [`padding`]: crate::block::Block::padding
|
||||
/// [CSS padding]: https://developer.mozilla.org/en-US/docs/Web/CSS/padding
|
||||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub struct Padding {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! This module holds the [`Title`] element and its related configuration types.
|
||||
//! A title is a piece of [`Block`](crate::widgets::Block) configuration.
|
||||
//! A title is a piece of [`Block`](crate::block::Block) configuration.
|
||||
|
||||
use ratatui_core::{layout::Alignment, text::Line};
|
||||
use strum::{Display, EnumString};
|
||||
|
||||
/// A [`Block`](crate::widgets::Block) title.
|
||||
/// A [`Block`](crate::block::Block) title.
|
||||
///
|
||||
/// It can be aligned (see [`Alignment`]) and positioned (see [`Position`]).
|
||||
///
|
||||
|
@ -16,8 +16,8 @@ use strum::{Display, EnumString};
|
|||
/// <https://github.com/ratatui/ratatui/issues/738>.
|
||||
///
|
||||
/// Use [`Line`] instead, when the position is not defined as part of the title. When a specific
|
||||
/// position is needed, use [`Block::title_top`](crate::widgets::Block::title_top) or
|
||||
/// [`Block::title_bottom`](crate::widgets::Block::title_bottom) instead.
|
||||
/// position is needed, use [`Block::title_top`](crate::block::Block::title_top) or
|
||||
/// [`Block::title_bottom`](crate::block::Block::title_bottom) instead.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -28,14 +28,14 @@ use strum::{Display, EnumString};
|
|||
/// Title::from("Title");
|
||||
/// ```
|
||||
///
|
||||
/// Blue title on a white background (via [`Stylize`](crate::style::Stylize) trait).
|
||||
/// Blue title on a white background (via [`Stylize`](ratatui_core::style::Stylize) trait).
|
||||
/// ```
|
||||
/// use ratatui::{style::Stylize, widgets::block::Title};
|
||||
///
|
||||
/// Title::from("Title".blue().on_white());
|
||||
/// ```
|
||||
///
|
||||
/// Title with multiple styles (see [`Line`] and [`Stylize`](crate::style::Stylize)).
|
||||
/// Title with multiple styles (see [`Line`] and [`Stylize`](ratatui_core::style::Stylize)).
|
||||
/// ```
|
||||
/// use ratatui::{style::Stylize, text::Line, widgets::block::Title};
|
||||
///
|
||||
|
@ -63,19 +63,19 @@ pub struct Title<'a> {
|
|||
/// Title alignment
|
||||
///
|
||||
/// If [`None`], defaults to the alignment defined with
|
||||
/// [`Block::title_alignment`](crate::widgets::Block::title_alignment) in the associated
|
||||
/// [`Block`](crate::widgets::Block).
|
||||
/// [`Block::title_alignment`](crate::block::Block::title_alignment) in the associated
|
||||
/// [`Block`](crate::block::Block).
|
||||
pub alignment: Option<Alignment>,
|
||||
|
||||
/// Title position
|
||||
///
|
||||
/// If [`None`], defaults to the position defined with
|
||||
/// [`Block::title_position`](crate::widgets::Block::title_position) in the associated
|
||||
/// [`Block`](crate::widgets::Block).
|
||||
/// [`Block::title_position`](crate::block::Block::title_position) in the associated
|
||||
/// [`Block`](crate::block::Block).
|
||||
pub position: Option<Position>,
|
||||
}
|
||||
|
||||
/// Defines the [title](crate::widgets::block::Title) position.
|
||||
/// Defines the [title](crate::block::Title) position.
|
||||
///
|
||||
/// The title can be positioned on top or at the bottom of the block.
|
||||
/// Defaults to [`Position::Top`].
|
||||
|
|
|
@ -24,9 +24,9 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
/// The type of border of a [`Block`].
|
||||
/// The type of border of a [`Block`](crate::block::Block).
|
||||
///
|
||||
/// See the [`borders`](Block::borders) method of `Block` to configure its borders.
|
||||
/// See the [`borders`](crate::block::Block::borders) method of `Block` to configure its borders.
|
||||
#[derive(Debug, Default, Display, EnumString, Clone, Copy, Eq, PartialEq, Hash)]
|
||||
pub enum BorderType {
|
||||
/// A plain, simple border.
|
||||
|
@ -150,7 +150,7 @@ impl fmt::Debug for Borders {
|
|||
/// and RIGHT.
|
||||
///
|
||||
/// When used with NONE you should consider omitting this completely. For ALL you should consider
|
||||
/// [`Block::bordered()`](crate::widgets::Block::bordered) instead.
|
||||
/// [`Block::bordered()`](crate::block::Block::bordered) instead.
|
||||
///
|
||||
/// ## Examples
|
||||
///
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<'a, DS: DateStyler> Monthly<'a, DS> {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn show_surrounding<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.show_surrounding = Some(style.into());
|
||||
|
@ -66,7 +66,7 @@ impl<'a, DS: DateStyler> Monthly<'a, DS> {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn show_weekdays_header<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.show_weekday = Some(style.into());
|
||||
|
@ -78,7 +78,7 @@ impl<'a, DS: DateStyler> Monthly<'a, DS> {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn show_month_header<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.show_month = Some(style.into());
|
||||
|
@ -90,7 +90,7 @@ impl<'a, DS: DateStyler> Monthly<'a, DS> {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn default_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.default_style = style.into();
|
||||
|
@ -217,7 +217,7 @@ impl CalendarEventStore {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
pub fn today<S: Into<Style>>(style: S) -> Self {
|
||||
let mut res = Self::default();
|
||||
res.add(
|
||||
|
@ -234,7 +234,7 @@ impl CalendarEventStore {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
pub fn add<S: Into<Style>>(&mut self, date: Date, style: S) {
|
||||
// to simplify style nonsense, last write wins
|
||||
let _ = self.0.insert(date, style.into());
|
||||
|
|
|
@ -439,9 +439,7 @@ impl<'a, 'b> From<&'a mut Context<'b>> for Painter<'a, 'b> {
|
|||
/// Holds the state of the [`Canvas`] when painting to it.
|
||||
///
|
||||
/// This is used by the [`Canvas`] widget to draw shapes on the grid. It can be useful to think of
|
||||
/// this as similar to the [`Frame`] struct that is used to draw widgets on the terminal.
|
||||
///
|
||||
/// [`Frame`]: crate::Frame
|
||||
/// this as similar to the `Frame` struct that is used to draw widgets on the terminal.
|
||||
#[derive(Debug)]
|
||||
pub struct Context<'a> {
|
||||
x_bounds: [f64; 2],
|
||||
|
@ -530,7 +528,7 @@ impl<'a> Context<'a> {
|
|||
/// Note that the text is always printed on top of the canvas and is **not** affected by the
|
||||
/// layers.
|
||||
///
|
||||
/// [`Text`]: crate::text::Text
|
||||
/// [`Text`]: ratatui_core::text::Text
|
||||
pub fn print<T>(&mut self, x: f64, y: f64, line: T)
|
||||
where
|
||||
T: Into<TextLine<'a>>,
|
||||
|
@ -711,10 +709,10 @@ where
|
|||
/// cell. This allows for more flexibility than the `BrailleGrid` which only supports a single
|
||||
/// foreground color for each 2x4 dots cell.
|
||||
///
|
||||
/// [`Braille`]: crate::symbols::Marker::Braille
|
||||
/// [`HalfBlock`]: crate::symbols::Marker::HalfBlock
|
||||
/// [`Dot`]: crate::symbols::Marker::Dot
|
||||
/// [`Block`]: crate::symbols::Marker::Block
|
||||
/// [`Braille`]: ratatui_core::symbols::Marker::Braille
|
||||
/// [`HalfBlock`]: ratatui_core::symbols::Marker::HalfBlock
|
||||
/// [`Dot`]: ratatui_core::symbols::Marker::Dot
|
||||
/// [`Block`]: ratatui_core::symbols::Marker::Block
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -20,7 +20,7 @@ pub enum MapResolution {
|
|||
///
|
||||
/// Contains about 5000 points, you likely want to use [`Marker::Braille`] with this.
|
||||
///
|
||||
/// [`Marker::Braille`]: (crate::symbols::Marker::Braille)
|
||||
/// [`Marker::Braille`]: (ratatui_core::symbols::Marker::Braille)
|
||||
High,
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use ratatui_core::style::Color;
|
|||
|
||||
use crate::canvas::{Line, Painter, Shape};
|
||||
|
||||
/// A rectangle to draw on a [`Canvas`](crate::widgets::canvas::Canvas)
|
||||
/// A rectangle to draw on a [`Canvas`](crate::canvas::Canvas)
|
||||
///
|
||||
/// Sizes used here are **not** in terminal cell. This is much more similar to the
|
||||
/// mathematic coordinate system.
|
||||
|
|
|
@ -127,8 +127,8 @@ impl<'a> Axis<'a> {
|
|||
///
|
||||
/// # Example
|
||||
///
|
||||
/// [`Axis`] also implements [`Stylize`](crate::style::Stylize) which mean you can style it
|
||||
/// like so
|
||||
/// [`Axis`] also implements [`Stylize`](ratatui_core::style::Stylize) which mean you can style
|
||||
/// it like so
|
||||
///
|
||||
/// ```rust
|
||||
/// use ratatui::{style::Stylize, widgets::Axis};
|
||||
|
@ -411,8 +411,8 @@ impl<'a> Dataset<'a> {
|
|||
///
|
||||
/// # Example
|
||||
///
|
||||
/// [`Dataset`] also implements [`Stylize`](crate::style::Stylize) which mean you can style it
|
||||
/// like so
|
||||
/// [`Dataset`] also implements [`Stylize`](ratatui_core::style::Stylize) which mean you can
|
||||
/// style it like so
|
||||
///
|
||||
/// ```rust
|
||||
/// use ratatui::{style::Stylize, widgets::Dataset};
|
||||
|
|
|
@ -8,7 +8,7 @@ use ratatui_core::{
|
|||
/// A widget to clear/reset a certain area to allow overdrawing (e.g. for popups).
|
||||
///
|
||||
/// This widget **cannot be used to clear the terminal on the first render** as `ratatui` assumes
|
||||
/// the render area is empty. Use [`crate::Terminal::clear`] instead.
|
||||
/// the render area is empty. Use `Terminal::clear` instead.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
//!
|
||||
//! # License
|
||||
//!
|
||||
//! This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
//! This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.
|
||||
pub mod barchart;
|
||||
pub mod block;
|
||||
pub mod borders;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//! The [`List`] widget is used to display a list of items and allows selecting one or multiple
|
||||
//! items.
|
||||
pub use self::{item::ListItem, state::ListState};
|
||||
|
||||
use ratatui_core::style::{Style, Styled};
|
||||
use strum::{Display, EnumString};
|
||||
|
||||
pub use self::{item::ListItem, state::ListState};
|
||||
use crate::{block::Block, table::HighlightSpacing};
|
||||
|
||||
mod item;
|
||||
|
@ -19,13 +18,10 @@ mod state;
|
|||
/// the item's height is automatically determined. A `List` can also be put in reverse order (i.e.
|
||||
/// *bottom to top*) whereas a [`Table`] cannot.
|
||||
///
|
||||
/// [`Table`]: crate::widgets::Table
|
||||
/// [`Table`]: crate::table::Table
|
||||
///
|
||||
/// List items can be aligned using [`Text::alignment`], for more details see [`ListItem`].
|
||||
///
|
||||
/// [`List`] implements [`Widget`] and so it can be drawn using
|
||||
/// [`Frame::render_widget`](crate::terminal::Frame::render_widget).
|
||||
///
|
||||
/// [`List`] is also a [`StatefulWidget`], which means you can use it with [`ListState`] to allow
|
||||
/// the user to [scroll] through items and [select] one of them.
|
||||
///
|
||||
|
@ -101,12 +97,12 @@ mod state;
|
|||
/// (0..5).map(|i| format!("Item{i}")).collect::<List>();
|
||||
/// ```
|
||||
///
|
||||
/// [`ListState`]: crate::widgets::list::ListState
|
||||
/// [scroll]: crate::widgets::list::ListState::offset
|
||||
/// [select]: crate::widgets::list::ListState::select
|
||||
/// [`Text::alignment`]: crate::text::Text::alignment
|
||||
/// [`StatefulWidget`]: crate::widgets::StatefulWidget
|
||||
/// [`Widget`]: crate::widgets::Widget
|
||||
/// [`ListState`]: crate::list::ListState
|
||||
/// [scroll]: crate::list::ListState::offset
|
||||
/// [select]: crate::list::ListState::select
|
||||
/// [`Text::alignment`]: ratatui_core::text::Text::alignment
|
||||
/// [`StatefulWidget`]: ratatui_core::widgets::StatefulWidget
|
||||
/// [`Widget`]: ratatui_core::widgets::Widget
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, Default)]
|
||||
pub struct List<'a> {
|
||||
/// An optional block to wrap the widget in
|
||||
|
@ -184,7 +180,7 @@ impl<'a> List<'a> {
|
|||
/// let filled_list = empty_list.items(["Item 1"]);
|
||||
/// ```
|
||||
///
|
||||
/// [`Text`]: crate::text::Text
|
||||
/// [`Text`]: ratatui_core::text::Text
|
||||
pub fn new<T>(items: T) -> Self
|
||||
where
|
||||
T: IntoIterator,
|
||||
|
@ -214,7 +210,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::default().items(["Item 1", "Item 2"]);
|
||||
/// ```
|
||||
///
|
||||
/// [`Text`]: crate::text::Text
|
||||
/// [`Text`]: ratatui_core::text::Text
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn items<T>(mut self, items: T) -> Self
|
||||
where
|
||||
|
@ -271,7 +267,7 @@ impl<'a> List<'a> {
|
|||
/// `List` also implements the [`Styled`] trait, which means you can use style shorthands from
|
||||
/// the [`Stylize`] trait to set the style of the widget more concisely.
|
||||
///
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
///
|
||||
/// ```rust
|
||||
/// use ratatui::{style::Stylize, widgets::List};
|
||||
|
@ -280,7 +276,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).red().italic();
|
||||
/// ```
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
@ -330,7 +326,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).highlight_style(Style::new().red().italic());
|
||||
/// ```
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn highlight_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.highlight_style = style.into();
|
||||
|
|
|
@ -63,10 +63,10 @@ use ratatui_core::{style::Style, text::Text};
|
|||
/// ListItem::new(Text::from("foo").right_aligned());
|
||||
/// ```
|
||||
///
|
||||
/// [`List`]: crate::widgets::List
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Line`]: crate::text::Line
|
||||
/// [`Line::alignment`]: crate::text::Line::alignment
|
||||
/// [`List`]: crate::list::List
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
/// [`Line`]: ratatui_core::text::Line
|
||||
/// [`Line::alignment`]: ratatui_core::text::Line::alignment
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct ListItem<'a> {
|
||||
pub(crate) content: Text<'a>,
|
||||
|
@ -107,8 +107,8 @@ impl<'a> ListItem<'a> {
|
|||
///
|
||||
/// # See also
|
||||
///
|
||||
/// - [`List::new`](crate::widgets::List::new) to create a list of items that can be converted
|
||||
/// to [`ListItem`]
|
||||
/// - [`List::new`](super::List::new) to create a list of items that can be converted to
|
||||
/// [`ListItem`]
|
||||
pub fn new<T>(content: T) -> Self
|
||||
where
|
||||
T: Into<Text<'a>>,
|
||||
|
@ -140,7 +140,7 @@ impl<'a> ListItem<'a> {
|
|||
/// ```
|
||||
///
|
||||
/// `ListItem` also implements the [`Styled`] trait, which means you can use style shorthands
|
||||
/// from the [`Stylize`](crate::style::Stylize) trait to set the style of the widget more
|
||||
/// from the [`Stylize`](ratatui_core::style::Stylize) trait to set the style of the widget more
|
||||
/// concisely.
|
||||
///
|
||||
/// ```rust
|
||||
|
@ -149,9 +149,9 @@ impl<'a> ListItem<'a> {
|
|||
/// let item = ListItem::new("Item 1").red().italic();
|
||||
/// ```
|
||||
///
|
||||
/// [`Styled`]: crate::style::Styled
|
||||
/// [`ListState`]: crate::widgets::list::ListState
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Styled`]: ratatui_core::style::Styled
|
||||
/// [`ListState`]: crate::list::ListState
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/// This state can be used to scroll through items and select one. When the list is rendered as a
|
||||
/// stateful widget, the selected item will be highlighted and the list will be shifted to ensure
|
||||
/// that the selected item is visible. This will modify the [`ListState`] object passed to the
|
||||
/// [`Frame::render_stateful_widget`](crate::terminal::Frame::render_stateful_widget) method.
|
||||
/// `Frame::render_stateful_widget` method.
|
||||
///
|
||||
/// The state consists of two fields:
|
||||
/// - [`offset`]: the index of the first item to be displayed
|
||||
|
@ -41,7 +41,7 @@
|
|||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// [`List`]: crate::widgets::List
|
||||
/// [`List`]: super::List
|
||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ListState {
|
||||
|
|
|
@ -86,7 +86,7 @@ const fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Align
|
|||
/// .wrap(Wrap { trim: true });
|
||||
/// ```
|
||||
///
|
||||
/// [`Span`]: crate::text::Span
|
||||
/// [`Span`]: ratatui_core::text::Span
|
||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct Paragraph<'a> {
|
||||
/// A block to wrap the widget in
|
||||
|
@ -213,7 +213,7 @@ impl<'a> Paragraph<'a> {
|
|||
/// let paragraph = Paragraph::new("Hello, world!").style(Style::new().red().on_white());
|
||||
/// ```
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
|
|
@ -266,7 +266,7 @@ impl<'a> Scrollbar<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn thumb_style<S: Into<Style>>(mut self, thumb_style: S) -> Self {
|
||||
self.thumb_style = thumb_style.into();
|
||||
|
@ -293,7 +293,7 @@ impl<'a> Scrollbar<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn track_style<S: Into<Style>>(mut self, track_style: S) -> Self {
|
||||
self.track_style = track_style.into();
|
||||
|
@ -320,7 +320,7 @@ impl<'a> Scrollbar<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn begin_style<S: Into<Style>>(mut self, begin_style: S) -> Self {
|
||||
self.begin_style = begin_style.into();
|
||||
|
@ -347,7 +347,7 @@ impl<'a> Scrollbar<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn end_style<S: Into<Style>>(mut self, end_style: S) -> Self {
|
||||
self.end_style = end_style.into();
|
||||
|
@ -402,7 +402,7 @@ impl<'a> Scrollbar<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
let style = style.into();
|
||||
|
|
|
@ -24,8 +24,8 @@ use crate::block::{Block, BlockExt};
|
|||
/// of `None` is interpreted an as the _absence_ of a value.
|
||||
///
|
||||
/// `Sparkline` can be styled either using [`Sparkline::style`] or preferably using the methods
|
||||
/// provided by the [`Stylize`](crate::style::Stylize) trait. The style may be set for the entire
|
||||
/// widget or for individual bars by setting individual [`SparklineBar::style`].
|
||||
/// provided by the [`Stylize`](ratatui_core::style::Stylize) trait. The style may be set for the
|
||||
/// entire widget or for individual bars by setting individual [`SparklineBar::style`].
|
||||
///
|
||||
/// The bars are rendered using a set of symbols. The default set is [`symbols::bar::NINE_LEVELS`].
|
||||
/// You can change the set using [`Sparkline::bar_set`].
|
||||
|
@ -111,7 +111,7 @@ impl<'a> Sparkline<'a> {
|
|||
///
|
||||
/// The foreground corresponds to the bars while the background is everything else.
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
@ -127,7 +127,7 @@ impl<'a> Sparkline<'a> {
|
|||
///
|
||||
/// The foreground corresponds to the bars while the background is everything else.
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn absent_value_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.absent_value_style = style.into();
|
||||
|
@ -271,7 +271,7 @@ impl SparklineBar {
|
|||
/// style. If set, the style of the bar will be the style of the sparkline combined with
|
||||
/// the style of the bar.
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Option<Style>>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
|
|
@ -10,9 +10,8 @@ use ratatui_core::{
|
|||
widgets::{StatefulWidget, StatefulWidgetRef, Widget, WidgetRef},
|
||||
};
|
||||
|
||||
use crate::block::{Block, BlockExt};
|
||||
|
||||
pub use self::{cell::Cell, highlight_spacing::HighlightSpacing, row::Row, state::TableState};
|
||||
use crate::block::{Block, BlockExt};
|
||||
|
||||
mod cell;
|
||||
mod highlight_spacing;
|
||||
|
@ -31,7 +30,7 @@ mod state;
|
|||
/// Make sure to call the [`Table::widths`] method, otherwise the columns will all have a width of 0
|
||||
/// and thus not be visible.
|
||||
///
|
||||
/// [`Table`] implements [`Widget`] and so it can be drawn using [`Frame::render_widget`].
|
||||
/// [`Table`] implements [`Widget`] and so it can be drawn using `Frame::render_widget`.
|
||||
///
|
||||
/// [`Table`] is also a [`StatefulWidget`], which means you can use it with [`TableState`] to allow
|
||||
/// the user to scroll through the rows and select one of them. When rendering a [`Table`] with a
|
||||
|
@ -237,9 +236,7 @@ mod state;
|
|||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// [`Frame::render_widget`]: crate::Frame::render_widget
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Cell`]: super::Cell
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct Table<'a> {
|
||||
/// Data to display in each row
|
||||
|
@ -549,8 +546,8 @@ impl<'a> Table<'a> {
|
|||
/// let table = Table::new(rows, widths).red().italic();
|
||||
/// ```
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
@ -581,7 +578,7 @@ impl<'a> Table<'a> {
|
|||
/// let table = Table::new(rows, widths).highlight_style(Style::new().red().italic());
|
||||
/// ```
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
#[deprecated(note = "use `Table::row_highlight_style` instead")]
|
||||
pub fn highlight_style<S: Into<Style>>(self, highlight_style: S) -> Self {
|
||||
|
@ -606,7 +603,7 @@ impl<'a> Table<'a> {
|
|||
/// # let widths = [Constraint::Length(5), Constraint::Length(5)];
|
||||
/// let table = Table::new(rows, widths).row_highlight_style(Style::new().red().italic());
|
||||
/// ```
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn row_highlight_style<S: Into<Style>>(mut self, highlight_style: S) -> Self {
|
||||
self.row_highlight_style = highlight_style.into();
|
||||
|
@ -631,7 +628,7 @@ impl<'a> Table<'a> {
|
|||
/// # let widths = [Constraint::Length(5), Constraint::Length(5)];
|
||||
/// let table = Table::new(rows, widths).column_highlight_style(Style::new().red().italic());
|
||||
/// ```
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn column_highlight_style<S: Into<Style>>(mut self, highlight_style: S) -> Self {
|
||||
self.column_highlight_style = highlight_style.into();
|
||||
|
@ -656,7 +653,7 @@ impl<'a> Table<'a> {
|
|||
/// # let widths = [Constraint::Length(5), Constraint::Length(5)];
|
||||
/// let table = Table::new(rows, widths).cell_highlight_style(Style::new().red().italic());
|
||||
/// ```
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn cell_highlight_style<S: Into<Style>>(mut self, highlight_style: S) -> Self {
|
||||
self.cell_highlight_style = highlight_style.into();
|
||||
|
@ -1291,7 +1288,6 @@ mod tests {
|
|||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
use crate::table::{Row, Table, TableState};
|
||||
|
||||
#[fixture]
|
||||
|
@ -1366,9 +1362,10 @@ mod tests {
|
|||
|
||||
#[cfg(test)]
|
||||
mod render {
|
||||
use super::*;
|
||||
use ratatui_core::layout::Alignment;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn render_empty_area() {
|
||||
let mut buf = Buffer::empty(Rect::new(0, 0, 15, 3));
|
||||
|
|
|
@ -47,9 +47,9 @@ use ratatui_core::{
|
|||
/// Cell::new("Cell 1").red().italic();
|
||||
/// ```
|
||||
///
|
||||
/// [`Row`]: crate::widgets::Row
|
||||
/// [`Table`]: crate::widgets::Table
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Row`]: super::Row
|
||||
/// [`Table`]: super::Table
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct Cell<'a> {
|
||||
content: Text<'a>,
|
||||
|
@ -150,9 +150,9 @@ impl<'a> Cell<'a> {
|
|||
/// Cell::new("Cell 1").red().italic();
|
||||
/// ```
|
||||
///
|
||||
/// [`Row`]: crate::widgets::Row
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Row`]: super::Row
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
|
|
@ -67,9 +67,9 @@ use super::Cell;
|
|||
/// Row::new(cells).red().italic();
|
||||
/// ```
|
||||
///
|
||||
/// [`Table`]: crate::widgets::Table
|
||||
/// [`Text`]: crate::text::Text
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Table`]: super::Table
|
||||
/// [`Text`]: ratatui_core::text::Text
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct Row<'a> {
|
||||
pub(crate) cells: Vec<Cell<'a>>,
|
||||
|
@ -231,9 +231,9 @@ impl<'a> Row<'a> {
|
|||
/// let row = Row::new(cells).red().italic();
|
||||
/// ```
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Stylize`]: crate::style::Stylize
|
||||
/// [`Text`]: crate::text::Text
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
/// [`Stylize`]: ratatui_core::style::Stylize
|
||||
/// [`Text`]: ratatui_core::text::Text
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/// This state can be used to scroll through the rows and select one of them. When the table is
|
||||
/// rendered as a stateful widget, the selected row, column and cell will be highlighted and the
|
||||
/// table will be shifted to ensure that the selected row is visible. This will modify the
|
||||
/// [`TableState`] object passed to the [`Frame::render_stateful_widget`] method.
|
||||
/// [`TableState`] object passed to the `Frame::render_stateful_widget` method.
|
||||
///
|
||||
/// The state consists of two fields:
|
||||
/// - [`offset`]: the index of the first row to be displayed
|
||||
|
@ -50,9 +50,8 @@
|
|||
/// Note that if [`Table::widths`] is not called before rendering, the rendered columns will have
|
||||
/// equal width.
|
||||
///
|
||||
/// [`Table`]: crate::widgets::Table
|
||||
/// [`Table::widths`]: crate::widgets::Table::widths
|
||||
/// [`Frame::render_stateful_widget`]: crate::Frame::render_stateful_widget
|
||||
/// [`Table`]: super::Table
|
||||
/// [`Table::widths`]: crate::table::Table::widths
|
||||
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct TableState {
|
||||
|
|
|
@ -230,7 +230,7 @@ impl<'a> Tabs<'a> {
|
|||
/// More precise style can be applied to the titles by styling the ones given to [`Tabs::new`].
|
||||
/// The selected tab can be styled differently using [`Tabs::highlight_style`].
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
|
@ -245,7 +245,7 @@ impl<'a> Tabs<'a> {
|
|||
/// Highlighted tab can be selected with [`Tabs::select`].
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
///
|
||||
/// [`Color`]: crate::style::Color
|
||||
/// [`Color`]: ratatui_core::style::Color
|
||||
pub fn highlight_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.highlight_style = style.into();
|
||||
self
|
||||
|
|
Loading…
Reference in a new issue