mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
fix: Broken script in documentation
This commit is contained in:
parent
2a918bc7ba
commit
83413fdd2b
1 changed files with 8 additions and 7 deletions
|
|
@ -13,30 +13,31 @@ Applications reside entirely in the `src/userland/` directory. Create a new file
|
||||||
// src/userland/gui/hello.c
|
// src/userland/gui/hello.c
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <libui.h>
|
#include <libui.h>
|
||||||
|
#include <syscall.h>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
// Attempt to open a 300x200 window
|
// Attempt to open a 300x200 window
|
||||||
int wid = ui_create_window("My Custom App", 300, 200, 0);
|
ui_window_t wid = ui_window_create("My Custom App", 100, 100, 300, 200);
|
||||||
if (wid < 0) {
|
if (wid < 0) {
|
||||||
printf("Error creating window!\n");
|
printf("Error creating window!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write text in center
|
// Write text in center
|
||||||
ui_draw_string(wid, "Hello, BoredOS!!", 50, 90, 0xFFFFFFFF);
|
ui_draw_string(wid, 50, 90, "Hello, BoredOS!!", 0xFFFFFFFF);
|
||||||
|
|
||||||
// Commit drawing to screen
|
// Commit drawing to screen
|
||||||
ui_swap_buffers(wid);
|
ui_mark_dirty(wid, 0, 0, 300, 200);
|
||||||
|
|
||||||
ui_event_t event;
|
gui_event_t event;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (ui_poll_event(&event)) {
|
if (ui_get_event(wid, &event)) {
|
||||||
if (event.window_id == wid && event.type == UI_EVENT_WINDOW_CLOSE) {
|
if (event.type == GUI_EVENT_CLOSE) {
|
||||||
break; // Exit loop if 'X' is clicked
|
break; // Exit loop if 'X' is clicked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall1(SYSTEM_CMD_YIELD, 0);
|
sys_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; // Returning 0 smoothly exits the process via crt0.asm
|
return 0; // Returning 0 smoothly exits the process via crt0.asm
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue