component_functions/
component_functions.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)), hello_world);
11 ctx.component(Rect::new(0, (size.width, 1)), quit_nag);
12}
13
14fn hello_world(ctx: &mut ViewContext) {
15 ctx.insert(0, "Hello World");
16}
17
18fn quit_nag(ctx: &mut ViewContext) {
19 let size = ctx.size();
20 ctx.insert(
21 ((size.width / 2) - 7, 0),
22 "Press Q to Quit".to_runes().fg(Color::Red),
23 );
24}