pub struct TextViewStyle {
pub paragraph_gap: Rems,
pub heading_base_font_size: Pixels,
pub heading_font_size: Option<Arc<dyn Fn(u8, Pixels) -> Pixels + Send + Sync + 'static>>,
pub highlight_theme: Arc<HighlightTheme>,
pub code_block: StyleRefinement,
pub table: StyleRefinement,
pub table_head: StyleRefinement,
pub table_cell: StyleRefinement,
pub inline_code: HighlightStyle,
pub is_dark: bool,
}Expand description
TextViewStyle used to customize the style for super::TextView.
This is the component-level style. It is folded onto the style the active
crate::Theme already derived, so a field left at its default keeps the
themed value rather than overriding it with a neutral one.
Fields§
§paragraph_gap: RemsGap of each paragraphs, default is 1 rem.
heading_base_font_size: PixelsBase font size for headings, default is 14px.
heading_font_size: Option<Arc<dyn Fn(u8, Pixels) -> Pixels + Send + Sync + 'static>>Function to calculate heading font size based on heading level (1-6).
The first parameter is the heading level (1-6), the second parameter is the base font size.
highlight_theme: Arc<HighlightTheme>Highlight theme for code blocks. Default: HighlightTheme::default_light()
code_block: StyleRefinementThe style refinement for code blocks.
table: StyleRefinementStyle refinement applied to the table container (the bordered wrapper in wrap mode, the scroll viewport in horizontal-scroll mode).
Set overflow_x: scroll here for adaptive table layout: columns fit
their content when space allows, shrink (wrapping cell text) down to a
per-column floor when the frame is narrower, and below that the table
scrolls horizontally instead of squeezing further, e.g.
TextViewStyle::default().table({ let mut s = StyleRefinement::default(); s.overflow.x = Some(Overflow::Scroll); s }).
table_head: StyleRefinementStyle refinement applied to the header row (the first row) of a table,
on top of the table_head background and foreground from the theme.
table_cell: StyleRefinementStyle refinement applied to each table cell.
With the scroll layout, set white_space: nowrap here to keep cells
on a single line — columns then never shrink and the table scrolls as
soon as the content is wider than the frame.
inline_code: HighlightStyleThe highlight style for inline code.
Default is HighlightStyle::default(), the background_color will
fallback to cx.theme().accent, if it is None.
is_dark: boolWhether content-specific rendering should use dark-mode assets. Whether content-specific rendering should use dark-mode assets.
Implementations§
Source§impl TextViewStyle
impl TextViewStyle
Sourcepub fn paragraph_gap(self, gap: Rems) -> Self
pub fn paragraph_gap(self, gap: Rems) -> Self
Set paragraph gap, default is 1 rem.
Sourcepub fn heading_font_size<F>(self, f: F) -> Self
pub fn heading_font_size<F>(self, f: F) -> Self
Set the function that resolves a heading’s font size from its level
(1-6) and Self::heading_base_font_size.
Sourcepub fn code_block(self, style: StyleRefinement) -> Self
pub fn code_block(self, style: StyleRefinement) -> Self
Set style for code blocks.
Sourcepub fn inline_code(self, style: HighlightStyle) -> Self
pub fn inline_code(self, style: HighlightStyle) -> Self
Set style for inline code spans.
Sourcepub fn table(self, style: StyleRefinement) -> Self
pub fn table(self, style: StyleRefinement) -> Self
Set extra style for the table container.
Set overflow_x: scroll on the refinement for adaptive layout: cells
wrap as the frame narrows, and once columns reach their minimum width
the table scrolls horizontally instead of shrinking further.
Sourcepub fn table_head(self, style: StyleRefinement) -> Self
pub fn table_head(self, style: StyleRefinement) -> Self
Set extra style for the table header row.
Sourcepub fn table_cell(self, style: StyleRefinement) -> Self
pub fn table_cell(self, style: StyleRefinement) -> Self
Set extra style for each table cell.
With the scroll table layout, white_space: nowrap here keeps cells
on a single line and the table scrolls whenever the content is wider
than the frame.
Trait Implementations§
Source§impl Clone for TextViewStyle
impl Clone for TextViewStyle
Source§fn clone(&self) -> TextViewStyle
fn clone(&self) -> TextViewStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for TextViewStyle
impl Default for TextViewStyle
Auto Trait Implementations§
impl !RefUnwindSafe for TextViewStyle
impl !UnwindSafe for TextViewStyle
impl Freeze for TextViewStyle
impl Send for TextViewStyle
impl Sync for TextViewStyle
impl Unpin for TextViewStyle
impl UnsafeUnpin for TextViewStyle
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().