mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
add Expr2::Str case to render
This commit is contained in:
parent
04320f95fe
commit
d42aacb506
3 changed files with 22 additions and 4 deletions
|
@ -158,11 +158,13 @@ impl Pool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_str(&self, pool_str: &PoolStr) -> &str {
|
pub fn get_str(&self, pool_str: &PoolStr) -> &str {
|
||||||
let node_ptr = unsafe { self.nodes.offset(pool_str.first_node_id.index as isize) };
|
unsafe {
|
||||||
|
let node_ptr = self.nodes.offset(pool_str.first_node_id.index as isize);
|
||||||
|
|
||||||
let node_slice: &[u8] = unsafe { &*node_ptr };
|
let node_slice: &[u8] = &*node_ptr;
|
||||||
|
|
||||||
unsafe { std::str::from_utf8_unchecked(&node_slice[0..pool_str.len as usize]) }
|
std::str::from_utf8_unchecked(&node_slice[0..pool_str.len as usize])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set<T>(&mut self, node_id: NodeId<T>, element: T) {
|
pub fn set<T>(&mut self, node_id: NodeId<T>, element: T) {
|
||||||
|
|
|
@ -300,7 +300,11 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
||||||
let region = Region::new(0, 0, 0, 0);
|
let region = Region::new(0, 0, 0, 0);
|
||||||
|
|
||||||
let (expr2, _) = crate::lang::expr::str_to_expr2(
|
let (expr2, _) = crate::lang::expr::str_to_expr2(
|
||||||
&arena, "2.0", &mut env, &mut scope, region,
|
&arena,
|
||||||
|
"\"hello\"",
|
||||||
|
&mut env,
|
||||||
|
&mut scope,
|
||||||
|
region,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,18 @@ pub fn render_expr2<'a>(
|
||||||
|
|
||||||
queue_code_text_draw(&code_text, glyph_brush);
|
queue_code_text_draw(&code_text, glyph_brush);
|
||||||
}
|
}
|
||||||
|
Expr2::Str(text) => {
|
||||||
|
let code_text = Text {
|
||||||
|
position,
|
||||||
|
area_bounds,
|
||||||
|
color: CODE_COLOR.into(),
|
||||||
|
text: env.pool.get_str(text),
|
||||||
|
size: CODE_FONT_SIZE,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
queue_code_text_draw(&code_text, glyph_brush);
|
||||||
|
}
|
||||||
rest => todo!("implement {:?} render", rest),
|
rest => todo!("implement {:?} render", rest),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue