Initial public release of Warp.
Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
use crate::{
|
||||
extract_block,
|
||||
render::model::{BlockItem, RenderState, viewport::ViewportItem},
|
||||
};
|
||||
|
||||
use super::{RenderableBlock, paint::RenderContext};
|
||||
|
||||
pub struct RenderableTextBlock {
|
||||
viewport_item: ViewportItem,
|
||||
}
|
||||
|
||||
impl RenderableTextBlock {
|
||||
pub fn new(viewport_item: ViewportItem) -> Self {
|
||||
Self { viewport_item }
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderableBlock for RenderableTextBlock {
|
||||
fn viewport_item(&self) -> &ViewportItem {
|
||||
&self.viewport_item
|
||||
}
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
_model: &RenderState,
|
||||
_ctx: &mut warpui::LayoutContext,
|
||||
_app: &warpui::AppContext,
|
||||
) {
|
||||
}
|
||||
|
||||
fn paint(&mut self, model: &RenderState, ctx: &mut RenderContext, _app: &warpui::AppContext) {
|
||||
let content = model.content();
|
||||
let text_block = extract_block!(
|
||||
self.viewport_item,
|
||||
content,
|
||||
(block, BlockItem::TextBlock { paragraph_block }) => block.text_block(paragraph_block)
|
||||
);
|
||||
|
||||
let paragraph_styles = &model.styles().base_text;
|
||||
for paragraph in text_block.paragraphs() {
|
||||
ctx.draw_paragraph(¶graph, paragraph_styles, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user