pub struct RenderContext { /* private fields */ }Expand description
What BlockNode::render needs besides the node: the text style, code
highlighter and Markdown extensions.
Implementations§
Source§impl RenderContext
impl RenderContext
Sourcepub fn new(style: TextViewStyle) -> Self
pub fn new(style: TextViewStyle) -> Self
Creates a local rendering context without reading application globals.
The host supplies body typography through its container or
with_body_font_size.
Sourcepub fn with_code_block_highlighter<F>(self, highlighter: F) -> Self
pub fn with_code_block_highlighter<F>(self, highlighter: F) -> Self
Replaces code highlighting for this context only.
Sourcepub fn with_image_source<F>(self, resolver: F) -> Self
pub fn with_image_source<F>(self, resolver: F) -> Self
Resolves document image URIs. The host owns resource access policy.
Sourcepub fn on_link_click<F>(self, handler: F) -> Self
pub fn on_link_click<F>(self, handler: F) -> Self
Handles link activation. Without a handler, links use App::open_url.
Sourcepub fn with_link_reference(
self,
identifier: impl Into<SharedString>,
link: LinkMark,
) -> Self
pub fn with_link_reference( self, identifier: impl Into<SharedString>, link: LinkMark, ) -> Self
Registers a reference-link definition from the host’s document. Supply definitions for the entire document, including virtualized blocks.
Sourcepub fn from_app(cx: &App) -> Self
pub fn from_app(cx: &App) -> Self
The context TextView would start from: the global TextViewDefaults
style and code-block highlighter when set, else the theme’s style.
Sourcepub fn with_style(self, style: TextViewStyle) -> Self
pub fn with_style(self, style: TextViewStyle) -> Self
Replaces the text style.
Sourcepub fn with_foreground_ranges(
self,
key: u64,
ranges: Vec<(Range<usize>, Hsla)>,
) -> Self
pub fn with_foreground_ranges( self, key: u64, ranges: Vec<(Range<usize>, Hsla)>, ) -> Self
Supplies this render’s foreground ranges for a keyed paragraph leaf, including a heading or table cell. Replaces any ranges for the same key.
Ranges use the leaf’s rendered UTF-8 bytes; images and custom inline
objects occupy one U+FFFC (three bytes), as in LeafGeometry. Text
ranges are clipped to each text fragment; non-character boundaries and
empty or reversed ranges are ignored. An object’s foreground changes
only when a range covers its entire placeholder; images are unchanged.
These colors override mark and link foregrounds; later ranges win overlaps. Other mark properties and link activation are preserved. Uncovered text inherits its ordinary foreground. Colors belong to this rendering context, never the document tree: supply current theme/surface colors on each render, or omit the ranges to restore inheritance.
Sourcepub fn with_markdown_extensions(
self,
extensions: Arc<MarkdownExtensions>,
) -> Self
pub fn with_markdown_extensions( self, extensions: Arc<MarkdownExtensions>, ) -> Self
Sets the Markdown extensions that render custom nodes.
Sourcepub fn with_body_font_size(self, size: Pixels) -> Self
pub fn with_body_font_size(self, size: Pixels) -> Self
Sets the font size body text inherits, which the block gaps and heading sizes are relative to.
Sourcepub fn style(&self) -> &TextViewStyle
pub fn style(&self) -> &TextViewStyle
The text style blocks render with.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RenderContext
impl !UnwindSafe for RenderContext
impl Forget for RenderContext
impl Freeze for RenderContextwhere
*const u8 is !null: Freeze,
PhantomData<(SharedString, LinkMark)>: Freeze,
*const ArcInner<TextViewStyle> is !null: Freeze,
PhantomData<ArcInner<TextViewStyle>>: Freeze,
*const ArcInner<dyn Fn(&CodeBlock, &mut Window, &mut App) -> AnyElement + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&CodeBlock, &mut Window, &mut App) -> AnyElement + Sync + Send>>: Freeze,
*const ArcInner<dyn Fn(&CodeBlock) -> Vec<(Range<usize>, HighlightStyle)> + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&CodeBlock) -> Vec<(Range<usize>, HighlightStyle)> + Sync + Send>>: Freeze,
*const ArcInner<dyn Fn(&TableData, &mut Window, &mut App) -> AnyElement + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&TableData, &mut Window, &mut App) -> AnyElement + Sync + Send>>: Freeze,
*const ArcInner<dyn Fn(&SharedUri) -> ImageSource + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&SharedUri) -> ImageSource + Sync + Send>>: Freeze,
*const ArcInner<dyn Fn(&SharedString, &ClickEvent, &mut Window, &mut App) + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&SharedString, &ClickEvent, &mut Window, &mut App) + Sync + Send>>: Freeze,
*const ArcInner<dyn Fn(&Link, &App) -> Option<Link> + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&Link, &App) -> Option<Link> + Sync + Send>>: Freeze,
*const ArcInner<dyn Fn(&TaskToggleEvent, &mut Window, &mut App) + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&TaskToggleEvent, &mut Window, &mut App) + Sync + Send>>: Freeze,
*const ArcInner<MarkdownExtensions> is !null: Freeze,
PhantomData<ArcInner<MarkdownExtensions>>: Freeze,
*const ArcInner<StreamFadeFrame> is !null: Freeze,
PhantomData<ArcInner<StreamFadeFrame>>: Freeze,
*const ArcInner<RangeHighlightFrame> is !null: Freeze,
PhantomData<ArcInner<RangeHighlightFrame>>: Freeze,
*const ArcInner<HashMap<u64, Vec<(Range<usize>, Hsla)>>> is !null: Freeze,
PhantomData<ArcInner<HashMap<u64, Vec<(Range<usize>, Hsla)>>>>: Freeze,
*const ArcInner<Mutex<Option<RevealReport>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<Option<RevealReport>>>>: Freeze,
impl Move for RenderContext
impl Send for RenderContextwhere
RawTable<(SharedString, LinkMark)>: Send,
Arc<TextViewStyle>: Send,
Arc<dyn Fn(&CodeBlock, &mut Window, &mut App) -> AnyElement + Sync + Send>: Send,
Arc<dyn Fn(&CodeBlock) -> Vec<(Range<usize>, HighlightStyle)> + Sync + Send>: Send,
Arc<dyn Fn(&TableData, &mut Window, &mut App) -> AnyElement + Sync + Send>: Send,
Arc<dyn Fn(&SharedUri) -> ImageSource + Sync + Send>: Send,
Arc<dyn Fn(&SharedString, &ClickEvent, &mut Window, &mut App) + Sync + Send>: Send,
Arc<dyn Fn(&Link, &App) -> Option<Link> + Sync + Send>: Send,
Arc<dyn Fn(&TaskToggleEvent, &mut Window, &mut App) + Sync + Send>: Send,
Arc<MarkdownExtensions>: Send,
Arc<StreamFadeFrame>: Send,
Arc<RangeHighlightFrame>: Send,
Arc<HashMap<u64, Vec<(Range<usize>, Hsla)>>>: Send,
Arc<Mutex<Option<RevealReport>>>: Send,
impl Sync for RenderContextwhere
RawTable<(SharedString, LinkMark)>: Sync,
Arc<TextViewStyle>: Sync,
Arc<dyn Fn(&CodeBlock, &mut Window, &mut App) -> AnyElement + Sync + Send>: Sync,
Arc<dyn Fn(&CodeBlock) -> Vec<(Range<usize>, HighlightStyle)> + Sync + Send>: Sync,
Arc<dyn Fn(&TableData, &mut Window, &mut App) -> AnyElement + Sync + Send>: Sync,
Arc<dyn Fn(&SharedUri) -> ImageSource + Sync + Send>: Sync,
Arc<dyn Fn(&SharedString, &ClickEvent, &mut Window, &mut App) + Sync + Send>: Sync,
Arc<dyn Fn(&Link, &App) -> Option<Link> + Sync + Send>: Sync,
Arc<dyn Fn(&TaskToggleEvent, &mut Window, &mut App) + Sync + Send>: Sync,
Arc<MarkdownExtensions>: Sync,
Arc<StreamFadeFrame>: Sync,
Arc<RangeHighlightFrame>: Sync,
Arc<HashMap<u64, Vec<(Range<usize>, Hsla)>>>: Sync,
Arc<Mutex<Option<RevealReport>>>: Sync,
impl Unpin for RenderContextwhere
*const u8 is !null: Unpin,
&'static str: Unpin,
Arc<str>: Unpin,
Arc<TextViewStyle>: Unpin,
Arc<dyn Fn(&CodeBlock, &mut Window, &mut App) -> AnyElement + Sync + Send>: Unpin,
Arc<dyn Fn(&CodeBlock) -> Vec<(Range<usize>, HighlightStyle)> + Sync + Send>: Unpin,
Arc<dyn Fn(&TableData, &mut Window, &mut App) -> AnyElement + Sync + Send>: Unpin,
Arc<dyn Fn(&SharedUri) -> ImageSource + Sync + Send>: Unpin,
Arc<dyn Fn(&SharedString, &ClickEvent, &mut Window, &mut App) + Sync + Send>: Unpin,
Arc<dyn Fn(&Link, &App) -> Option<Link> + Sync + Send>: Unpin,
Arc<dyn Fn(&TaskToggleEvent, &mut Window, &mut App) + Sync + Send>: Unpin,
Arc<MarkdownExtensions>: Unpin,
Arc<StreamFadeFrame>: Unpin,
Arc<RangeHighlightFrame>: Unpin,
Arc<HashMap<u64, Vec<(Range<usize>, Hsla)>>>: Unpin,
Arc<Mutex<Option<RevealReport>>>: Unpin,
impl UnsafeUnpin for RenderContextwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(SharedString, LinkMark)>: UnsafeUnpin,
*const ArcInner<TextViewStyle> is !null: UnsafeUnpin,
PhantomData<ArcInner<TextViewStyle>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&CodeBlock, &mut Window, &mut App) -> AnyElement + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&CodeBlock, &mut Window, &mut App) -> AnyElement + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&CodeBlock) -> Vec<(Range<usize>, HighlightStyle)> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&CodeBlock) -> Vec<(Range<usize>, HighlightStyle)> + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&TableData, &mut Window, &mut App) -> AnyElement + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&TableData, &mut Window, &mut App) -> AnyElement + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&SharedUri) -> ImageSource + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&SharedUri) -> ImageSource + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&SharedString, &ClickEvent, &mut Window, &mut App) + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&SharedString, &ClickEvent, &mut Window, &mut App) + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&Link, &App) -> Option<Link> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&Link, &App) -> Option<Link> + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&TaskToggleEvent, &mut Window, &mut App) + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&TaskToggleEvent, &mut Window, &mut App) + Sync + Send>>: UnsafeUnpin,
*const ArcInner<MarkdownExtensions> is !null: UnsafeUnpin,
PhantomData<ArcInner<MarkdownExtensions>>: UnsafeUnpin,
*const ArcInner<StreamFadeFrame> is !null: UnsafeUnpin,
PhantomData<ArcInner<StreamFadeFrame>>: UnsafeUnpin,
*const ArcInner<RangeHighlightFrame> is !null: UnsafeUnpin,
PhantomData<ArcInner<RangeHighlightFrame>>: UnsafeUnpin,
*const ArcInner<HashMap<u64, Vec<(Range<usize>, Hsla)>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<HashMap<u64, Vec<(Range<usize>, Hsla)>>>>: UnsafeUnpin,
*const ArcInner<Mutex<Option<RevealReport>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Option<RevealReport>>>>: UnsafeUnpin,
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
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 more