1
0
Fork 0
forked from AbleOS/ableos
ableos/sysdata/programs/adit/src/main.hb
2025-02-17 15:29:45 -06:00

71 lines
1.9 KiB
Plaintext

/*!! expected result: pretty decent notepad app
-----------------
features:
- basic keys
- holding support with DAS
- visible cursor
- l+r arrow key support
- proper insertion and deletion
- shift key support
*/
stn := @use("stn");
.{memory, log, string, math} := stn;
.{Vec2, clamp} := math
sunset := @use("lib:sunset_proto")
render := @use("lib:render")
horizon_api := @use("lib:horizon_api");
.{set_color, render_label_to_surface, Label} := horizon_api.widgets.label
rope := @use("rope.hb")
theme := @use("theme.hb");
.{Theme} := theme
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
img := @embed("sysdata:assets/wallpaper.qoi");
.{Editor} := @use("editor.hb")
main := fn(): void {
window_width := 800
window_height := 400
editor := Editor.new()
font := render.text.font_from_psf2(@bitcast(&psf), false)
if font == null {
return
}
text_1_label := Label.new_label("main := fn() : void {", window_width - editor.theme.padding)
text_2_label := Label.new_label(" log.error(\"print!\")", window_width - editor.theme.padding)
text_3_label := Label.new_label("}", window_width)
text_1_label.set_color(editor.theme.bg_color, editor.theme.fg_text_color)
text_2_label.set_color(editor.theme.bg_color, editor.theme.fg_text_color)
text_3_label.set_color(editor.theme.bg_color, editor.theme.fg_text_color)
pos_1 := Vec2(uint).(10, 1)
pos_2 := Vec2(uint).(10, 1 + 20)
pos_3 := Vec2(uint).(10, 1 + 40)
line_end := 20
editor.window.surface.clear(editor.theme.bg_color)
render_label_to_surface(editor.window.surface, text_1_label, font, pos_1)
render_label_to_surface(editor.window.surface, text_2_label, font, pos_2)
render_label_to_surface(editor.window.surface, text_3_label, font, pos_3)
loop {
// +++ Clear +++
editor.clear()
// +++ Input +++
input := memory.inb(96)
// +++ RENDER +++
if editor.line_lines editor.theme_render()
// window.surface.clear(bg_color)
editor.frame_sync()
}
}