Packages

A gleamy app framework.

Current section

Files

Jump to
pane_gleam src pane window.gleam
Raw

src/pane/window.gleam

import gleam/json
import gleam/option.{type Option}
pub type WindowConfig {
WindowConfig(
input: String,
title: String,
width: Int,
height: Int,
icon: String,
resizable: Option(Bool),
decorations: Option(Bool),
transparent: Option(Bool),
always_on_top: Option(Bool),
maximized: Option(Bool),
min_width: Option(Int),
min_height: Option(Int),
max_width: Option(Int),
max_height: Option(Int)
)
}
@external(erlang, "ffi", "cmd")
fn cmd(command: String) -> Nil
pub fn prepare_window(config: WindowConfig) -> String {
let _prepared =
json.object([
#("input", json.string(config.input)),
#("title", json.string(config.title)),
#("width", json.int(config.width)),
#("height", json.int(config.height)),
#("icon", json.string(config.icon)),
#("resizable", json.nullable(config.resizable, of: json.bool)),
#("decorations", json.nullable(config.decorations, of: json.bool)),
#("transparent", json.nullable(config.transparent, of: json.bool)),
#("always_on_top", json.nullable(config.always_on_top, of: json.bool)),
#("maximized", json.nullable(config.maximized, of: json.bool)),
#("min_width", json.nullable(config.min_width, of: json.int)),
#("min_height", json.nullable(config.min_height, of: json.int)),
#("max_width", json.nullable(config.max_width, of: json.int)),
#("max_height", json.nullable(config.max_height, of: json.int)),
])
|> json.to_string
}
pub fn load_window(config: String) -> Nil {
cmd("./pane-webview " <> config)
}