pub struct TextViewStyle { /* private fields */ }Expand description
TextViewStyle used to customize the style for super::TextView.
The fields are private because this type crosses the gpui-base seam:
build one with the with_* methods and read it back through the accessors
of the same name, so a later field is an additive change rather than a
breaking one.
Implementations§
Source§impl TextViewStyle
impl TextViewStyle
Sourcepub fn from_theme(theme: &Theme) -> Self
pub fn from_theme(theme: &Theme) -> Self
Derives rich-text colors from Base semantic theme tokens.
Sourcepub fn with_foreground(self, color: Hsla) -> Self
pub fn with_foreground(self, color: Hsla) -> Self
Sets the default body-text color.
Sourcepub fn with_muted_foreground(self, color: Hsla) -> Self
pub fn with_muted_foreground(self, color: Hsla) -> Self
Sets the secondary text color.
Sourcepub fn with_selection(self, color: Hsla) -> Self
pub fn with_selection(self, color: Hsla) -> Self
Sets the background painted behind selected text.
Selection quads are painted under the glyphs, so this is normally a translucent wash rather than a solid fill.
Sourcepub fn with_code_background(self, color: Hsla) -> Self
pub fn with_code_background(self, color: Hsla) -> Self
Sets the background of fenced code blocks and table header rows.
Sourcepub fn with_border(self, color: Hsla) -> Self
pub fn with_border(self, color: Hsla) -> Self
Sets the color of borders and horizontal rules.
Sourcepub fn with_paragraph_gap(self, gap: Rems) -> Self
pub fn with_paragraph_gap(self, gap: Rems) -> Self
Sets the gap between paragraphs. Defaults to 1 rem.
Sourcepub fn with_heading_base_font_size(self, size: Pixels) -> Self
pub fn with_heading_base_font_size(self, size: Pixels) -> Self
Sets the base font size headings are derived from. Defaults to 14px.
Sourcepub fn with_heading_font_size<F>(self, f: F) -> Self
pub fn with_heading_font_size<F>(self, f: F) -> Self
Sets the function that resolves a heading’s font size.
The first parameter is the heading level (1-6), the second is
Self::heading_base_font_size.
Sourcepub fn with_code_block(self, style: StyleRefinement) -> Self
pub fn with_code_block(self, style: StyleRefinement) -> Self
Sets the style refinement for code blocks.
Sourcepub fn with_inline_code(self, style: HighlightStyle) -> Self
pub fn with_inline_code(self, style: HighlightStyle) -> Self
Sets the highlight style for inline code spans.
When background_color is None, the neutral code background is used,
which keeps TextViewStyle::default usable without a theme.
Sourcepub fn with_table(self, style: StyleRefinement) -> Self
pub fn with_table(self, style: StyleRefinement) -> Self
Sets the style refinement for the table container (the bordered wrapper in wrap mode, the scroll viewport in horizontal-scroll mode).
Set overflow_x: scroll on the refinement 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.
Sourcepub fn with_table_head(self, style: StyleRefinement) -> Self
pub fn with_table_head(self, style: StyleRefinement) -> Self
Sets the style refinement for the header row (the first row) of a table, applied on top of the header background and foreground.
Sourcepub fn with_table_cell(self, style: StyleRefinement) -> Self
pub fn with_table_cell(self, style: StyleRefinement) -> Self
Sets the style refinement for each table cell.
With the scroll table layout, white_space: nowrap here keeps cells on
a single line — columns then never shrink and the table scrolls as soon
as the content is wider than the frame.
Sourcepub fn with_dark(self, is_dark: bool) -> Self
pub fn with_dark(self, is_dark: bool) -> Self
Sets whether content-specific assets should use their dark variant.
Sourcepub fn foreground(&self) -> Hsla
pub fn foreground(&self) -> Hsla
The default body-text color.
Sourcepub fn muted_foreground(&self) -> Hsla
pub fn muted_foreground(&self) -> Hsla
The secondary text color.
Sourcepub fn code_background(&self) -> Hsla
pub fn code_background(&self) -> Hsla
The background of fenced code blocks and table header rows.
Sourcepub fn paragraph_gap(&self) -> Rems
pub fn paragraph_gap(&self) -> Rems
The gap between paragraphs.
Sourcepub fn heading_base_font_size(&self) -> Pixels
pub fn heading_base_font_size(&self) -> Pixels
The base font size headings are derived from.
Sourcepub fn heading_font_size(&self, level: u8) -> Option<Pixels>
pub fn heading_font_size(&self, level: u8) -> Option<Pixels>
The size this style gives a heading of level, when it resolves
heading sizes itself.
None means the caller keeps whatever size it had already derived from
Self::heading_base_font_size.
Sourcepub fn code_block(&self) -> &StyleRefinement
pub fn code_block(&self) -> &StyleRefinement
The style refinement for code blocks.
Sourcepub fn table(&self) -> &StyleRefinement
pub fn table(&self) -> &StyleRefinement
The style refinement for the table container.
Sourcepub fn table_head(&self) -> &StyleRefinement
pub fn table_head(&self) -> &StyleRefinement
The style refinement for table header rows.
Sourcepub fn table_cell(&self) -> &StyleRefinement
pub fn table_cell(&self) -> &StyleRefinement
The style refinement for table cells.
Sourcepub fn inline_code(&self) -> HighlightStyle
pub fn inline_code(&self) -> HighlightStyle
The highlight style for inline code, before the code-background
fallback in Self::inline_code_highlight applies.
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().