2021-09-10 16:32:09 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
use cstr_core::{cstr, CStr};
|
|
|
|
|
2024-01-11 18:01:27 +01:00
|
|
|
use kos::{Color, Dot, Event, Size, WindowKind, WindowParams, WindowTextParams};
|
2021-09-10 16:32:09 +02:00
|
|
|
|
|
|
|
const HEADER: &CStr = cstr!("Hey Kolibri");
|
|
|
|
const MSG: &str = "Hello from Rust!";
|
|
|
|
|
|
|
|
#[inline(always)] // for some reason function removed otherwise
|
|
|
|
fn draw_window() {
|
2024-01-11 18:01:27 +01:00
|
|
|
kos::start_window_draw();
|
|
|
|
kos::define_window(
|
|
|
|
Dot { x: 50, y: 50 },
|
|
|
|
Size {
|
|
|
|
width: 300,
|
|
|
|
height: 400,
|
|
|
|
},
|
|
|
|
WindowParams {
|
|
|
|
color: Color::rgb(0xff, 0xff, 0xff),
|
|
|
|
kind: WindowKind::Themed,
|
|
|
|
title: Some(HEADER),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
kos::display_message(
|
|
|
|
Dot { x: 0, y: 10 },
|
|
|
|
WindowTextParams {
|
|
|
|
color: Color::rgb(0x66, 0x22, 0x22),
|
|
|
|
text: MSG,
|
|
|
|
bg_color: None,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
kos::end_window_draw();
|
2021-09-10 16:32:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
fn kol_main() -> ! {
|
|
|
|
draw_window();
|
|
|
|
|
2023-06-20 21:03:39 +02:00
|
|
|
while let Some(ev) = kos::fetch_event() {
|
2021-09-10 16:32:09 +02:00
|
|
|
match ev {
|
|
|
|
Event::Redraw => draw_window(),
|
2023-06-20 21:03:39 +02:00
|
|
|
Event::KeyPress => drop(kos::fetch_key()),
|
2021-09-10 16:32:09 +02:00
|
|
|
_ => break,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-20 21:03:39 +02:00
|
|
|
kos::exit();
|
2021-09-10 16:32:09 +02:00
|
|
|
}
|