pub struct BlockTitle { /* private fields */ }Expand description
One styled line embedded in a block’s top border.
A title is content owned by a block, not part of its BlockStyle. Its
text carries complete styles, and its alignment and padding apply only
within the top edge between enabled side borders.
use urushi::{Align, BlockTitle, Color, StyledText, TextSpan, TextStyle};
let title = StyledText::try_from_spans([
TextSpan::new("F", TextStyle::new().foreground(Color::CYAN)),
TextSpan::from("iles"),
])
.unwrap();
let title = BlockTitle::new(title).align(Align::Center).padding(0);
assert_eq!(title.text().as_str(), "Files");Implementations§
Source§impl BlockTitle
impl BlockTitle
Sourcepub fn new(text: impl Into<StyledText>) -> Self
pub fn new(text: impl Into<StyledText>) -> Self
Creates a left-aligned title with one blank cell on each side.
§Panics
Panics when text contains a line break. A border title occupies
exactly one row and never wraps.
Sourcepub const fn align(self, align: Align) -> Self
pub const fn align(self, align: Align) -> Self
Sets the title’s alignment between the block’s enabled side borders.
Sourcepub const fn padding(self, padding: u16) -> Self
pub const fn padding(self, padding: u16) -> Self
Sets the preferred blank cells on both sides of the title.
A narrow border gives space to title text before this padding.
Sourcepub const fn text(&self) -> &StyledText
pub const fn text(&self) -> &StyledText
Returns the title’s single styled line.
Sourcepub const fn alignment(&self) -> Align
pub const fn alignment(&self) -> Align
Returns the title’s alignment between enabled side borders.
Sourcepub const fn horizontal_padding(&self) -> u16
pub const fn horizontal_padding(&self) -> u16
Returns the preferred blank cells on both sides of the title.
Trait Implementations§
Source§impl Clone for BlockTitle
impl Clone for BlockTitle
Source§fn clone(&self) -> BlockTitle
fn clone(&self) -> BlockTitle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BlockTitle
impl Debug for BlockTitle
Source§impl From<&str> for BlockTitle
impl From<&str> for BlockTitle
Source§impl From<String> for BlockTitle
impl From<String> for BlockTitle
Source§impl From<StyledText> for BlockTitle
impl From<StyledText> for BlockTitle
Source§fn from(text: StyledText) -> Self
fn from(text: StyledText) -> Self
Converts to this type from the input type.
Source§impl PartialEq for BlockTitle
impl PartialEq for BlockTitle
Source§fn eq(&self, other: &BlockTitle) -> bool
fn eq(&self, other: &BlockTitle) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for BlockTitle
impl StructuralPartialEq for BlockTitle
Auto Trait Implementations§
impl Freeze for BlockTitle
impl RefUnwindSafe for BlockTitle
impl Send for BlockTitle
impl Sync for BlockTitle
impl Unpin for BlockTitle
impl UnsafeUnpin for BlockTitle
impl UnwindSafe for BlockTitle
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
Mutably borrows from an owned value. Read more