refactor: Devide lib.rs into modules

This commit is contained in:
2024-01-12 11:39:38 +03:00
parent 994ae2f392
commit c6351affe3
9 changed files with 171 additions and 162 deletions

View File

@@ -3,15 +3,18 @@
use cstr_core::{cstr, CStr};
use kos::{Color, Dot, Event, Size, WindowKind, WindowParams, WindowTextParams};
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};
const HEADER: &CStr = cstr!("Hey Kolibri");
const MSG: &str = "Hello from Rust!";
const MSG: &CStr = cstr!("Hello from Rust!");
#[inline(always)] // for some reason function removed otherwise
fn draw_window() {
kos::start_window_draw();
kos::define_window(
start_window_draw();
define_window(
Dot { x: 50, y: 50 },
Size {
width: 300,
@@ -23,28 +26,21 @@ fn draw_window() {
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();
display_message(Dot { x: 0, y: 10 }, Color::rgb(0x66, 0x22, 0x22), MSG, None);
end_window_draw();
}
#[no_mangle]
fn kol_main() -> ! {
draw_window();
while let Some(ev) = kos::fetch_event() {
while let Some(ev) = fetch_event() {
match ev {
Event::Redraw => draw_window(),
Event::KeyPress => drop(kos::fetch_key()),
Event::KeyPress => drop(fetch_key()),
_ => break,
}
}
kos::exit();
exit();
}