Skip to content

Window Package

window is an independently versioned official package. Git installs build it from source and require SDL2 development files; it is not bundled into the Kelvra runtime.

const window = @import("github.com/kelvralang/window")
const win window.Window =
window.create("Demo", 800i64, 600i64)
window.clear(win)
window.present(win)
window.close(win)

The current API creates windows hidden by default. Visible manual demos call window.show(win) explicitly.

const evt window.Event? = window.pollEvent(win)
if (evt != null) {
print(window.eventKind(evt))
}

Current input/event helpers include:

  • pollEvent(win) -> Event?
  • eventKind(evt) -> str
  • eventKeyCode(evt) -> i64
  • isKeyDown(win, keyCode) -> bool
  • mouseX(win) -> i64
  • mouseY(win) -> i64
  • KEY_SPACE
  • KEY_ESCAPE

The package already exposes a small immediate-mode drawing surface:

window.clearRgb(win, 32i64, 64i64, 96i64)
window.fillRect(win, 8i64, 8i64, 24i64, 24i64, 255i64, 0i64, 0i64)
window.drawText(win, 8i64, 40i64, "Score: 12", 2i64, 255i64, 255i64, 255i64)
window.present(win)
window.delay(1i64)

drawText uses a built-in bitmap monospace font, accepts printable ASCII, supports \n for multi-line text, and clips against the window surface. The scale argument must be at least 1.

That is enough for the rectangle-rendered Flappy Bird demo with an in-window score HUD in examples/flappy_bird.kel.

Manual examples:

  • examples/window_open.kel
  • examples/window_events.kel
  • examples/flappy_bird.kel

Headless test coverage:

  • tests/sample_kelvra_window.kel
  • tests/sample_kelvra_window_render.kel

Installing Window from Git requires CMake, a C++17 compiler, and SDL2 development files. The Kelvra runtime itself does not require SDL2.

Window’s tag workflow builds target-specific convenience archives and attaches checksums to a GitHub Release. KELVRA does not consume GitHub Release archives as prebuilt dependencies. To offer prebuilt installation, publish each prepared target bundle to a configured registry:

Terminal window
kelvra publish --registry official --signing-key ./keys/release.toml .
kelvra publish --registry official --target linux-arm64-gnu \
--native-artifact-dir ./dist/linux-arm64-gnu \
--signing-key ./keys/release.toml .

The registry service URL, credentials, and signing key are deployment secrets; they are not stored in the package repository.