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