Part of the Tycho graphics stack — used as the laplaceliu/tycho/plat subpackage.
// examples/.../moon.pkg
import {
"laplaceliu/tycho/plat" @plat,
}
pkgtype(kind: "executable")
supported_targets = "native"
options(overrides: [ "laplaceliu/tycho/plat/backend/native" ])let target = @plat.Target::current()
println("os=\{target.os.name()} window_system=\{target.window_system.name()}")
let win = @plat.Window::new(800, 600, "hello") // raises WindowError
let surface = win.surface() // kind + native handles| Piece | State |
|---|---|
| Target / Os / WindowSystem / SurfaceKind | done |
| Window (create / size / title / fullscreen / DPI / surface / destroy) | done |
| Event / KeyCode / Modifiers / MouseButton / CursorMode / CursorShape | done |
| Window::poll_events / mouse_pos / is_mouse_down / set_cursor_* / clipboard / wait_events | done |
| surface_extensions_for / surface_supported (capability intersection) | done (pure part; RHI wiring in M2) |
| backend/native (desktop) | done |
| backend/native (Android / iOS) | pending (M4 / M5) |
| backend/web | pending (M6) |
moon run --target native tycho/plat/smoke # prints the resolved target and opens one window
moon test --target native tycho/plat/smoke # target capability rules
moon check --target js tycho/plat # typed layer must have no native dependencypub suberror WindowError {
InitFailed
CreateFailed
}impl Show for WindowErrorpub(all) enum Event {
CloseRequested
Resized(Int, Int)
KeyDown(KeyCode, Modifiers)
KeyUp(KeyCode, Modifiers)
MouseMove(Int, Int)
MouseDown(MouseButton, Int, Int)
MouseUp(MouseButton, Int, Int)
MouseScroll(Int, Int)
FocusChanged(Bool)
TextInput(String)
ImePreedit(String)
ImePreeditClear
ImeCommit(String)
ImeCancel
TouchDown(Int, Int, Int)
TouchMove(Int, Int, Int)
TouchUp(Int, Int, Int)
SurfaceCreated
SurfaceDestroyed
AppSuspended
AppResumed
} derive(Eq, Debug)pub(all) enum KeyCode {
Escape
Return
Tab
Backspace
Space
Left
Up
Right
Down
Home
End
PageUp
PageDown
Insert
Delete
Num0
Num1
Num2
Num3
Num4
Num5
Num6
Num7
Num8
Num9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
LShift
RShift
LCtrl
RCtrl
LAlt
RAlt
Unknown(Int)
} derive(Eq, Debug)pub struct Window {
// private fields
}fn wait_events(timeout_ms : Int) -> Unitfn wait_frame() -> UnitInstall
Download zipTycho RHI — unified pure-MoonBit render hardware interface: Vulkan 1.3, Direct3D 12, Metal, and WebGPU (native + browser) drivers behind one virtual ABI