pub struct LineGauge<'a> { /* private fields */ }Expand description
A compact widget to display a progress bar over a single thin line.
This can be useful to indicate the progression of a task, like a download.
A LineGauge renders a thin line filled according to the value given to LineGauge::ratio.
Unlike Gauge, only the width can be defined by the rendering Rect. The
height is always 1.
The associated label is always left-aligned. If not set with LineGauge::label, the label is
the percentage of the bar filled.
You can also set the symbols used to draw the bar with LineGauge::line_set.
To style the gauge line use LineGauge::filled_style and LineGauge::unfilled_style which
let you pick a color for foreground (i.e. line) and background of the filled and unfilled part
of gauge respectively.
§Examples:
use ratatui::{
style::{Style, Stylize},
symbols,
widgets::{Block, LineGauge},
};
LineGauge::default()
.block(Block::bordered().title("Progress"))
.filled_style(Style::new().white().on_black().bold())
.line_set(symbols::line::THICK)
.ratio(0.4);§See also
Gaugefor bigger, higher precision and more configurable progress bar
Implementations§
Source§impl<'a> LineGauge<'a>
impl<'a> LineGauge<'a>
Sourcepub fn ratio(self, ratio: f64) -> Self
pub fn ratio(self, ratio: f64) -> Self
Sets the bar progression from a ratio (float).
ratio is the ratio between filled bar over empty bar (i.e. 3/4 completion is 0.75).
This is more easily seen as a floating point percentage (e.g. 42% = 0.42).
§Panics
This method panics if ratio is not between 0 and 1 inclusively.
Sourcepub const fn line_set(self, set: Set) -> Self
pub const fn line_set(self, set: Set) -> Self
Sets the characters to use for the line.
§See also
See symbols::line::Set for more information. Predefined sets are also available, see
NORMAL, DOUBLE and
THICK.
Sourcepub fn label<T>(self, label: T) -> Self
pub fn label<T>(self, label: T) -> Self
Sets the label to display.
With LineGauge, labels are only on the left, see Gauge for a centered label.
If the label is not defined, it is the percentage filled.
Sourcepub fn style<S: Into<Style>>(self, style: S) -> Self
pub fn style<S: Into<Style>>(self, style: S) -> Self
Sets the widget style.
style accepts any type that is convertible to Style (e.g. Style, Color, or
your own type that implements Into<Style>).
This will style everything except the bar itself, so basically the block (if any) and background.
Sourcepub fn gauge_style<S: Into<Style>>(self, style: S) -> Self
👎Deprecated since 0.27.0: You should use LineGauge::filled_style instead.
pub fn gauge_style<S: Into<Style>>(self, style: S) -> Self
LineGauge::filled_style instead.Sets the style of the bar.
style accepts any type that is convertible to Style (e.g. Style, Color, or
your own type that implements Into<Style>).
Sourcepub fn filled_style<S: Into<Style>>(self, style: S) -> Self
pub fn filled_style<S: Into<Style>>(self, style: S) -> Self
Sets the style of filled part of the bar.
style accepts any type that is convertible to Style (e.g. Style, Color, or
your own type that implements Into<Style>).
Sourcepub fn unfilled_style<S: Into<Style>>(self, style: S) -> Self
pub fn unfilled_style<S: Into<Style>>(self, style: S) -> Self
Sets the style of the unfilled part of the bar.
style accepts any type that is convertible to Style (e.g. Style, Color, or
your own type that implements Into<Style>).
Trait Implementations§
Source§impl WidgetRef for LineGauge<'_>
impl WidgetRef for LineGauge<'_>
Source§fn render_ref(&self, area: Rect, buf: &mut Buffer)
fn render_ref(&self, area: Rect, buf: &mut Buffer)
impl<'a> StructuralPartialEq for LineGauge<'a>
Auto Trait Implementations§
impl<'a> Freeze for LineGauge<'a>
impl<'a> RefUnwindSafe for LineGauge<'a>
impl<'a> Send for LineGauge<'a>
impl<'a> Sync for LineGauge<'a>
impl<'a> Unpin for LineGauge<'a>
impl<'a> UnwindSafe for LineGauge<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'a, T, U> Stylize<'a, T> for Uwhere
U: Styled<Item = T>,
impl<'a, T, U> Stylize<'a, T> for Uwhere
U: Styled<Item = T>,
fn bg<C>(self, color: C) -> T
fn fg<C>(self, color: C) -> T
fn add_modifier(self, modifier: Modifier) -> T
fn remove_modifier(self, modifier: Modifier) -> T
fn reset(self) -> T
Source§fn on_magenta(self) -> T
fn on_magenta(self) -> T
magenta.Source§fn on_dark_gray(self) -> T
fn on_dark_gray(self) -> T
dark_gray.Source§fn on_light_red(self) -> T
fn on_light_red(self) -> T
light_red.Source§fn light_green(self) -> T
fn light_green(self) -> T
light_green.Source§fn on_light_green(self) -> T
fn on_light_green(self) -> T
light_green.Source§fn light_yellow(self) -> T
fn light_yellow(self) -> T
light_yellow.Source§fn on_light_yellow(self) -> T
fn on_light_yellow(self) -> T
light_yellow.Source§fn light_blue(self) -> T
fn light_blue(self) -> T
light_blue.Source§fn on_light_blue(self) -> T
fn on_light_blue(self) -> T
light_blue.Source§fn light_magenta(self) -> T
fn light_magenta(self) -> T
light_magenta.Source§fn on_light_magenta(self) -> T
fn on_light_magenta(self) -> T
light_magenta.Source§fn light_cyan(self) -> T
fn light_cyan(self) -> T
light_cyan.Source§fn on_light_cyan(self) -> T
fn on_light_cyan(self) -> T
light_cyan.Source§fn not_italic(self) -> T
fn not_italic(self) -> T
ITALIC modifier.Source§fn underlined(self) -> T
fn underlined(self) -> T
UNDERLINED modifier.Source§fn not_underlined(self) -> T
fn not_underlined(self) -> T
UNDERLINED modifier.Source§fn slow_blink(self) -> T
fn slow_blink(self) -> T
SLOW_BLINK modifier.Source§fn not_slow_blink(self) -> T
fn not_slow_blink(self) -> T
SLOW_BLINK modifier.Source§fn rapid_blink(self) -> T
fn rapid_blink(self) -> T
RAPID_BLINK modifier.Source§fn not_rapid_blink(self) -> T
fn not_rapid_blink(self) -> T
RAPID_BLINK modifier.Source§fn not_reversed(self) -> T
fn not_reversed(self) -> T
REVERSED modifier.HIDDEN modifier.HIDDEN modifier.Source§fn crossed_out(self) -> T
fn crossed_out(self) -> T
CROSSED_OUT modifier.Source§fn not_crossed_out(self) -> T
fn not_crossed_out(self) -> T
CROSSED_OUT modifier.