Skip to main content

CodeView

Struct CodeView 

Source
pub struct CodeView { /* private fields */ }
Expand description

A lv-tui Component that renders syntax-highlighted code.

Implementations§

Source§

impl CodeView

Source

pub fn new(code: &str, language: &str) -> Self

Examples found in repository?
examples/highlight_demo.rs (line 18)
18    fn new() -> Self { Self { view: CodeView::new(CODE, "rust") } }

Trait Implementations§

Source§

impl Component for CodeView

Source§

fn render(&self, cx: &mut RenderCx<'_>)

渲染组件内容
Source§

fn measure(&self, _c: Constraint, _cx: &mut MeasureCx) -> Size

测量组件在给定约束下的自适应尺寸 Read more
Source§

fn event(&mut self, event: &Event, cx: &mut EventCx<'_>)

处理事件(可选实现)
Source§

fn layout(&mut self, rect: Rect, _cx: &mut LayoutCx<'_>)

布局回调——组件在此计算子节点 rect 并调用 child.layout() Read more
Source§

fn focusable(&self) -> bool

是否可聚焦(Tab 导航会跳过不可聚焦的组件)
Source§

fn style(&self) -> Style

返回组件样式(可选实现)
Source§

fn mount(&mut self, _cx: &mut EventCx<'_>)

首次挂载(初始化后调用)
Source§

fn unmount(&mut self, _cx: &mut EventCx<'_>)

从树卸载(退出前调用)
Source§

fn update(&mut self, _cx: &mut EventCx<'_>)

每次事件分发前调用
Source§

fn type_name(&self) -> &str

组件类型名(用于样式表类型选择器匹配)
Source§

fn id(&self) -> Option<&str>

组件 ID(用于样式表 #id 选择器匹配)
Source§

fn class(&self) -> Option<&str>

组件 class(用于样式表 .class 选择器匹配)
Source§

fn for_each_child(&self, _f: &mut dyn FnMut(&Node))

遍历子节点(为焦点系统等提供统一的树遍历接口)
Source§

fn for_each_child_mut(&mut self, _f: &mut dyn FnMut(&mut Node))

遍历子节点(可变版本)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.