pub struct Style { /* private fields */ }Expand description
A style definition for rendering terminal content.
Style uses a builder pattern for easy chaining:
use lacquer::{Style, Border, Position, Color};
let style = Style::new()
.padding(1, 2)
.margin(0, 1)
.border(Border::Rounded)
.foreground(Color::from_hex("#F97316"))
.background(Color::from_hex("#0A0A0A"))
.bold()
.width(40)
.align(Position::Center);Implementations§
Source§impl Style
impl Style
Sourcepub const fn padding_all(self, padding: u16) -> Self
pub const fn padding_all(self, padding: u16) -> Self
Set uniform padding on all sides.
Sourcepub const fn padding(self, vertical: u16, horizontal: u16) -> Self
pub const fn padding(self, vertical: u16, horizontal: u16) -> Self
Set vertical and horizontal padding.
Sourcepub const fn padding_sides(
self,
top: u16,
right: u16,
bottom: u16,
left: u16,
) -> Self
pub const fn padding_sides( self, top: u16, right: u16, bottom: u16, left: u16, ) -> Self
Set padding for each side individually.
Sourcepub const fn padding_top(self, padding: u16) -> Self
pub const fn padding_top(self, padding: u16) -> Self
Set top padding.
Sourcepub const fn padding_right(self, padding: u16) -> Self
pub const fn padding_right(self, padding: u16) -> Self
Set right padding.
Sourcepub const fn padding_bottom(self, padding: u16) -> Self
pub const fn padding_bottom(self, padding: u16) -> Self
Set bottom padding.
Sourcepub const fn padding_left(self, padding: u16) -> Self
pub const fn padding_left(self, padding: u16) -> Self
Set left padding.
Sourcepub const fn margin_all(self, margin: u16) -> Self
pub const fn margin_all(self, margin: u16) -> Self
Set uniform margin on all sides.
Sourcepub const fn margin(self, vertical: u16, horizontal: u16) -> Self
pub const fn margin(self, vertical: u16, horizontal: u16) -> Self
Set vertical and horizontal margin.
Sourcepub const fn margin_sides(
self,
top: u16,
right: u16,
bottom: u16,
left: u16,
) -> Self
pub const fn margin_sides( self, top: u16, right: u16, bottom: u16, left: u16, ) -> Self
Set margin for each side individually.
Sourcepub const fn max_height(self, max: u16) -> Self
pub const fn max_height(self, max: u16) -> Self
Set maximum height.
Sourcepub fn border_foreground(self, color: Color) -> Self
pub fn border_foreground(self, color: Color) -> Self
Set uniform border color.
Sourcepub fn border_foreground_hex(self, hex: &str) -> Self
pub fn border_foreground_hex(self, hex: &str) -> Self
Set border color from a hex string.
Sourcepub fn foreground(self, color: Color) -> Self
pub fn foreground(self, color: Color) -> Self
Set foreground (text) color.
Accepts a Color, hex string, or RGB values.
use lacquer::{Style, Color};
let s1 = Style::new().foreground(Color::Red);
let s2 = Style::new().foreground(Color::from_hex("#F97316"));
let s3 = Style::new().foreground(Color::rgb(249, 115, 22));Sourcepub fn foreground_hex(self, hex: &str) -> Self
pub fn foreground_hex(self, hex: &str) -> Self
Set foreground color from a hex string.
Sourcepub fn background(self, color: Color) -> Self
pub fn background(self, color: Color) -> Self
Set background color.
Sourcepub fn background_hex(self, hex: &str) -> Self
pub fn background_hex(self, hex: &str) -> Self
Set background color from a hex string.
Sourcepub const fn strikethrough(self) -> Self
pub const fn strikethrough(self) -> Self
Enable strikethrough text.
Sourcepub const fn vertical_align(self, position: Position) -> Self
pub const fn vertical_align(self, position: Position) -> Self
Set vertical alignment.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)