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 0.75 rem.
Sourcepub fn with_heading<F>(self, heading: F) -> Self
pub fn with_heading<F>(self, heading: F) -> Self
Sets the style refinement for headings, selected by heading level (1-6).
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.
Set overflow.y to Overflow::Scroll together with a max height to
scroll long code inside the block: it gets its own scrollbar, and wheel
input over it no longer scrolls an ancestor list until the code reaches
its edge.
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_inline_code_style(self, style: StyleRefinement) -> Self
pub fn with_inline_code_style(self, style: StyleRefinement) -> Self
Overrides inline code typography and its box presentation.
Supports font family, size, features, fallbacks, weight, style, color, underline and strikethrough, background, border widths/color/style, corner radii, and padding. Sizes and padding resolve pixels/rem against the window. Unspecified properties keep the existing defaults. Box layout, margin, positioning, overflow, and interaction properties are not used. Line height remains owned by the paragraph. Non-finite or non-positive font sizes are ignored. Explicit refinements also take precedence on inverted surfaces.
Sourcepub fn with_list_style(self, style: StyleRefinement) -> Self
pub fn with_list_style(self, style: StyleRefinement) -> Self
Refines the marker of a bullet or numbered list item.
Applied to the marker column after its defaults: the muted text color, a minimum width of the list indent, right-aligned text, and a right padding of 0.3 times that indent. Text properties such as color, font family, size, and weight style the bullet or number. The text color also outlines an unchecked task-list checkbox; a checked one keeps the link color. Unspecified properties keep the existing defaults, and explicit refinements also take precedence on inverted surfaces.
Sourcepub fn with_blockquote_style(self, style: StyleRefinement) -> Self
pub fn with_blockquote_style(self, style: StyleRefinement) -> Self
Refines the blockquote container.
Applied after its defaults: the muted text color, a 2px left border in the border color, and a left padding of 0.9 times the body font size. Border widths and color style the quote bar; text properties, background, padding, and corner radii style the quote and its contents. Child blocks keep properties they set explicitly, including heading and table font sizes. Unspecified properties keep the existing defaults, and explicit refinements also take precedence on inverted surfaces.
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(&self, level: u8) -> StyleRefinement
pub fn heading(&self, level: u8) -> StyleRefinement
The style refinement for a heading at level (1-6).
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.
Sourcepub fn inline_code_style(&self) -> &StyleRefinement
pub fn inline_code_style(&self) -> &StyleRefinement
Explicit inline code typography and box refinements.
Sourcepub fn list_style(&self) -> &StyleRefinement
pub fn list_style(&self) -> &StyleRefinement
Explicit list marker refinements.
Sourcepub fn blockquote_style(&self) -> &StyleRefinement
pub fn blockquote_style(&self) -> &StyleRefinement
Explicit blockquote refinements.
Trait Implementations§
Source§impl Clone for TextViewStyle
impl Clone for TextViewStyle
Source§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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().