component_params/
component_params.rs1use arkham::prelude::*;
2
3fn main() {
4 App::new(root).run().expect("couldnt launch app");
5}
6
7fn root(ctx: &mut ViewContext) {
8 let size = ctx.size();
9 ctx.fill(size, Rune::new().bg(Color::DarkGrey));
10 ctx.component(Rect::new((10, 10), (20, 1)), say_hello("Alice"));
11 ctx.component(Rect::new(0, (size.width, 1)), quit_nag);
12}
13
14fn say_hello(name: &'static str) -> impl Fn(&mut ViewContext) {
15 move |ctx: &mut ViewContext| {
16 ctx.insert((0, 0), format!("Hello, {}", name));
17 }
18}
19
20fn quit_nag(ctx: &mut ViewContext) {
21 let size = ctx.size();
22 ctx.insert(
23 ((size.width / 2) - 7, 0),
24 "Press Q to Quit".to_runes().fg(Color::Red),
25 );
26}