Skip to content

Commit fc22be2

Browse files
committed
fix: lang
1 parent 9a30b24 commit fc22be2

12 files changed

Lines changed: 146 additions & 147 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ jobs:
5353
TAG="${GITHUB_REF_NAME}"
5454
VERSION="${TAG#v}"
5555
TOML_VERSION="$(python3 - <<'PY'
56-
import re
57-
import pathlib
58-
txt = pathlib.Path('gleam.toml').read_text(encoding='utf-8')
59-
m = re.search(r'^version\\s*=\\s*\"([^\"]+)\"\\s*$', txt, re.M)
60-
print(m.group(1) if m else '')
61-
PY
62-
)"
56+
import re
57+
import pathlib
58+
txt = pathlib.Path('gleam.toml').read_text(encoding='utf-8')
59+
m = re.search(r'^version\\s*=\\s*\"([^\"]+)\"\\s*$', txt, re.M)
60+
print(m.group(1) if m else '')
61+
PY
62+
)"
6363
echo "tag=$TAG version=$VERSION gleam.toml=$TOML_VERSION"
6464
test -n "$TOML_VERSION"
6565
test "$VERSION" = "$TOML_VERSION"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Gleam / Erlang build outputs
22
build/
33

4-
# Native port binaries (se generan en CI o con `make port`)
4+
# Native port binaries (generated in CI or with `make port`)
55
priv/minigui
66
priv/minigui.exe
77
priv/minigui_port
@@ -14,3 +14,4 @@ erl_crash.dump
1414
.DS_Store
1515
*.swp
1616
*.swo
17+
.vscode/

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
## v0.1.0
44

5-
- Instalación “sin toolchain”: descarga automática del port desde GitHub Releases, con cache por usuario.
6-
- Protocolo v1 con handshake (`HELLO`/`HELLO_ACK`) y `OK/ERR` por `request_id`.
5+
- Toolchain-free installation: automatic port download from GitHub Releases, with per-user cache.
6+
- v1 protocol with handshake (`HELLO`/`HELLO_ACK`) and `OK/ERR` per `request_id`.
77
- Backends:
88
- Windows: Win32 (Window + Label + TextBox + Button)
99
- Linux: GTK3 (Window + Label + TextBox + Button)
10-
- API de Gleam basada en `Result` y comandos con ACK.
11-
10+
- Gleam API based on `Result` and commands with ACK.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ port: $(PRIV_DIR)
1515
ifeq ($(UNAME_S),Linux)
1616
$(CC) -O2 -Wall -Wextra -o $(PRIV_DIR)/$(PORT_NAME) $(C_SRC) $$(pkg-config --cflags --libs gtk+-3.0) -pthread
1717
else ifeq ($(UNAME_S),Darwin)
18-
@echo "macOS: por ahora no hay backend nativo. Usa el modo headless (MINIGUI_HEADLESS=1) o implementa Cocoa."
18+
@echo "macOS: there is no native backend yet. Use headless mode (MINIGUI_HEADLESS=1) or implement Cocoa."
1919
$(CC) -O2 -Wall -Wextra -o $(PRIV_DIR)/$(PORT_NAME) $(C_SRC)
2020
else
21-
@echo "Sistema no reconocido. Compila manualmente c_src/minigui_port.c para tu plataforma."
21+
@echo "Unknown system. Compile c_src/minigui_port.c manually for your platform."
2222
endif
2323

24-
@# Compatibilidad con el nombre anterior durante desarrollo
24+
@# Compatibility with the previous name during development
2525
@if [ -f "$(PRIV_DIR)/minigui" ]; then cp -f "$(PRIV_DIR)/minigui" "$(PRIV_DIR)/minigui_port"; fi
2626

2727
gleam:

README.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,114 @@
11
# minigui
22

3-
`minigui` es una biblioteca experimental para crear interfaces gráficas desde **Gleam (target Erlang)** usando un **port externo en C** (nativo).
3+
`minigui` is an experimental library for creating graphical user interfaces from **Gleam (Erlang target)** using a native **external C port**.
44

5-
## Estado / alcance
5+
## Status / scope
66

7-
- **Windows**: backend **Win32** (ventana + label + textbox + botón).
8-
- **Linux**: backend **GTK3** (ventana + label + textbox + botón).
9-
- **macOS**: por ahora solo **modo headless** (simulado).
7+
- **Windows**: **Win32** backend (window + label + textbox + button).
8+
- **Linux**: **GTK3** backend (window + label + textbox + button).
9+
- **macOS**: for now, **headless mode** only (simulated).
1010

11-
> Nota: en Linux el binario `minigui` enlaza con GTK3, por lo que el sistema debe tener GTK3 disponible en runtime (en desktops es común; en servidores minimalistas puede requerir instalar paquetes).
11+
> Note: on Linux the `minigui` binary links against GTK3, so the system must have GTK3 available at runtime (common on desktops; on minimal servers you may need to install packages).
1212
13-
El objetivo es mantener una API pequeña y estable en Gleam, y permitir backends nativos por plataforma.
13+
The goal is to keep a small, stable API in Gleam, while enabling native per-platform backends.
1414

15-
## Releases / publicación
15+
## Releases / publishing
1616

17-
Ver el checklist: [`RELEASING.md`](./RELEASING.md)
17+
See the checklist: [`RELEASING.md`](./RELEASING.md)
1818

19-
## Instalación (Gleam Packages)
19+
## Installation (Gleam Packages)
2020

2121
```bash
2222
gleam add minigui
2323
```
2424

25-
### “Sin dependencias de build” (binario precompilado)
25+
### "Build-dependency-free" (precompiled binary)
2626

27-
Para evitar que tus usuarios tengan que instalar un compilador C o headers (`libx11-dev`, etc.), `minigui` está pensado para usar un **ejecutable precompilado** como puente (un *port*) y descargarlo automáticamente a `priv/` en el primer uso.
27+
To avoid requiring your users to install a C compiler or headers (`libx11-dev`, etc.), `minigui` is designed to use a **precompiled executable** as a bridge (a *port*) and download it automatically into `priv/` on first use.
2828

29-
Por defecto construye la URL así:
29+
By default it builds the URL like this:
3030

3131
```
3232
https://github.com/Aztekode/minigui/releases/download/v<version>/<asset>
3333
```
3434

35-
Donde `<version>` sale del `vsn` del paquete (ej. `0.1.0`) y `<asset>` depende del OS/arquitectura, por ejemplo:
35+
Where `<version>` comes from the package `vsn` (e.g. `0.1.0`) and `<asset>` depends on the OS/architecture, for example:
3636

3737
- `minigui.exe` (Windows x64)
3838
- `minigui` (Linux x64)
3939

40-
Puedes sobreescribir la base de descargas con:
40+
You can override the download base with:
4141

4242
```bash
4343
MINIGUI_RELEASE_BASE_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.0"
4444
```
4545

46-
Si prefieres un enlace exacto tipo `.../minigui.exe`, puedes fijar la URL completa:
46+
If you prefer an exact link like `.../minigui.exe`, you can set the full URL:
4747

4848
```bash
4949
MINIGUI_PORT_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.0/minigui.exe"
5050
```
5151

52-
Opciones de seguridad/cache:
52+
Security/cache options:
5353

54-
- Por defecto, `minigui` **requiere** que exista `minigui(.exe).sha256` y valida el SHA256.
55-
- `MINIGUI_REQUIRE_SHA=0`: desactiva la validación (no recomendado).
56-
- El binario se cachea por usuario (Linux: `~/.cache/minigui/<version>/`, Windows: `%LOCALAPPDATA%\\minigui\\<version>\\`).
54+
- By default, `minigui` **requires** `minigui(.exe).sha256` to exist and validates the SHA256.
55+
- `MINIGUI_REQUIRE_SHA=0`: disables validation (not recommended).
56+
- The binary is cached per user (Linux: `~/.cache/minigui/<version>/`, Windows: `%LOCALAPPDATA%\\minigui\\<version>\\`).
5757

58-
> Requisito de runtime: una instalación “completa” de Erlang/OTP que incluya las aplicaciones estándar `inets` + `ssl` (normalmente ya vienen con OTP; en algunas distros Linux pueden venir en paquetes separados).
58+
> Runtime requirement: a "full" Erlang/OTP installation that includes the standard `inets` + `ssl` applications (they usually ship with OTP; on some Linux distros they may be split into separate packages).
5959
6060
## Protocolo (v1)
6161

62-
El port se abre con `open_port(..., [{packet, 2}, binary, ...])`.
62+
The port is opened with `open_port(..., [{packet, 2}, binary, ...])`.
6363

6464
- Handshake:
6565
- `0x00` `HELLO` + `u16 version`
6666
- `0xF0` `HELLO_ACK` + `u16 version` + `u32 capabilities`
6767

68-
- Comandos:
69-
- `0x10` `CREATE_WINDOW` + `u32 request_id` + título UTF-8
70-
- `0x11` `SET_LABEL` + `u32 request_id` + texto UTF-8
71-
- `0x12` `SET_TEXT` + `u32 request_id` + texto UTF-8
72-
- `0x13` `ADD_BUTTON` + `u32 request_id` + `u8 id` + etiqueta UTF-8
68+
- Commands:
69+
- `0x10` `CREATE_WINDOW` + `u32 request_id` + UTF-8 title
70+
- `0x11` `SET_LABEL` + `u32 request_id` + UTF-8 text
71+
- `0x12` `SET_TEXT` + `u32 request_id` + UTF-8 text
72+
- `0x13` `ADD_BUTTON` + `u32 request_id` + `u8 id` + UTF-8 label
7373
- `0x14` `RUN` + `u32 request_id`
7474
- `0x15` `QUIT` + `u32 request_id`
75-
- Respuestas:
75+
- Responses:
7676
- `0x70` `OK` + `u32 request_id`
77-
- `0x71` `ERR` + `u32 request_id` + mensaje UTF-8
78-
- Eventos:
77+
- `0x71` `ERR` + `u32 request_id` + UTF-8 message
78+
- Events:
7979
- `0x81` `BUTTON_CLICKED` + `u8 id`
8080
- `0x82` `CLOSED`
81-
- `0x83` `LOG` + texto UTF-8
82-
- `0x84` `TEXT_CHANGED` + texto UTF-8
81+
- `0x83` `LOG` + UTF-8 text
82+
- `0x84` `TEXT_CHANGED` + UTF-8 text
8383
- `0x85` `KEY_DOWN` + `u32 keycode`
84-
- `0x86` `ERROR` + texto UTF-8
84+
- `0x86` `ERROR` + UTF-8 text
8585

86-
## Compilar (Linux)
86+
## Build (Linux)
8787

88-
Requisitos: `gcc`, `make`, `pkg-config`, `libgtk-3-dev`, `Erlang/OTP`, `gleam`.
88+
Requirements: `gcc`, `make`, `pkg-config`, `libgtk-3-dev`, `Erlang/OTP`, `gleam`.
8989

90-
> Probado con **Gleam v1.17.0**.
90+
> Tested with **Gleam v1.17.0**.
9191
9292
```bash
9393
make port
9494
gleam build
9595
make demo
9696
```
9797

98-
Si estás en un entorno sin servidor X (CI/headless), fuerza el modo simulado:
98+
If you're in an environment without an X server (CI/headless), force simulated mode:
9999

100100
```bash
101101
MINIGUI_HEADLESS=1 make demo
102102
```
103103

104-
## Compilar (Windows)
104+
## Build (Windows)
105105

106-
1. Compila `c_src/minigui_port.c` a `priv/minigui_port.exe` (MSVC o mingw).
107-
2. Ejecuta el demo:
106+
1. Compile `c_src/minigui_port.c` to `priv/minigui_port.exe` (MSVC or mingw).
107+
2. Run the demo:
108108

109109
```powershell
110110
gleam build
111111
gleam run -m demo
112112
```
113113

114-
> Nota: el código Win32 está dentro de `#ifdef _WIN32`.
114+
> Note: the Win32 code is inside `#ifdef _WIN32`.

RELEASING.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# Publicación de minigui (checklist)
1+
# Releasing minigui (checklist)
22

3-
Este repositorio publica **dos cosas**:
3+
This repository publishes **two things**:
44

5-
1. **Paquete Gleam (Hex / Gleam Packages)**: código Gleam + Erlang helper.
6-
2. **Assets nativos (GitHub Releases)**: `minigui` (Linux x64) y `minigui.exe` (Windows x64) + `.sha256`.
5+
1. **Gleam package (Hex / Gleam Packages)**: Gleam code + Erlang helper.
6+
2. **Native assets (GitHub Releases)**: `minigui` (Linux x64) and `minigui.exe` (Windows x64) + `.sha256`.
77

8-
La librería descarga el port desde:
8+
The library downloads the port from:
99

1010
```
1111
https://github.com/Aztekode/minigui/releases/download/v<VERSION>/<asset>
1212
```
1313

14-
Por lo tanto, **el tag de git SIEMPRE debe ser `vX.Y.Z`** y la versión del paquete debe ser **`X.Y.Z`**.
14+
Therefore, **the git tag MUST ALWAYS be `vX.Y.Z`** and the package version must be **`X.Y.Z`**.
1515

1616
---
1717

18-
## 0) Preparación
18+
## 0) Preparation
1919

20-
- Asegúrate de que `gleam.toml` tenga la versión final `X.Y.Z`.
21-
- Actualiza `CHANGELOG.md`.
22-
- (Opcional) corre el demo en headless:
20+
- Ensure `gleam.toml` has the final version `X.Y.Z`.
21+
- Update `CHANGELOG.md`.
22+
- (Optional) run the headless demo:
2323

2424
```bash
2525
make port
@@ -28,9 +28,9 @@ MINIGUI_HEADLESS=1 gleam run -m demo
2828

2929
---
3030

31-
## 1) Crear tag y release (assets nativos)
31+
## 1) Create tag and release (native assets)
3232

33-
1. Commit de la versión:
33+
1. Commit the version:
3434

3535
```bash
3636
git add -A
@@ -44,21 +44,20 @@ git tag vX.Y.Z
4444
git push origin main --tags
4545
```
4646

47-
3. GitHub Actions ejecutará el workflow `release.yml` y adjuntará:
47+
3. GitHub Actions will run the `release.yml` workflow and attach:
4848
- `minigui` + `minigui.sha256`
4949
- `minigui.exe` + `minigui.exe.sha256`
5050

51-
> Nota: el workflow falla si el tag `vX.Y.Z` no coincide con la versión `X.Y.Z` en `gleam.toml`.
51+
> Note: the workflow fails if the `vX.Y.Z` tag does not match the `X.Y.Z` version in `gleam.toml`.
5252
5353
---
5454

55-
## 2) Publicar el paquete en Hex / Gleam Packages
55+
## 2) Publish the package to Hex / Gleam Packages
5656

57-
En la máquina donde tengas configuradas credenciales de Hex:
57+
On the machine where you have Hex credentials configured:
5858

5959
```bash
6060
gleam publish
6161
```
6262

63-
Si vas a usar CI para publicar, tendrás que configurar el token correspondiente (no se incluye en este repo).
64-
63+
If you are going to use CI to publish, you will need to configure the corresponding token (not included in this repo).

c_src/minigui_port.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
// minigui_port.c (protocolo v1)
2-
// Port externo para Erlang/Gleam usando {packet, 2}.
1+
// minigui_port.c (protocol v1)
2+
// External port for Erlang/Gleam using {packet, 2}.
33
//
44
// Handshake:
55
// HELLO 0x00 + u16 version
66
// HELLO_ACK 0xF0 + u16 version + u32 capabilities
77
//
8-
// Comandos (todos incluyen request_id u32 big-endian):
8+
// Commands (all include request_id u32 big-endian):
99
// CREATE_WINDOW 0x10 + u32 req + title utf-8
1010
// SET_LABEL 0x11 + u32 req + text utf-8
1111
// SET_TEXT 0x12 + u32 req + text utf-8
1212
// ADD_BUTTON 0x13 + u32 req + u8 id + label utf-8
1313
// RUN 0x14 + u32 req
1414
// QUIT 0x15 + u32 req
1515
//
16-
// Respuestas:
16+
// Responses:
1717
// OK 0x70 + u32 req
1818
// ERR 0x71 + u32 req + msg utf-8
1919
//
20-
// Eventos:
20+
// Events:
2121
// BUTTON_CLICKED 0x81 + u8 id
2222
// CLOSED 0x82
2323
// LOG 0x83 + msg utf-8
@@ -42,7 +42,7 @@
4242

4343
#define PROTOCOL_VERSION 1
4444

45-
// ---------- salida thread-safe ----------
45+
// ---------- thread-safe output ----------
4646
#ifdef _WIN32
4747
static CRITICAL_SECTION g_out_lock;
4848
static void out_lock_init(void) { InitializeCriticalSection(&g_out_lock); }
@@ -148,7 +148,7 @@ static void send_key_down(uint32_t keycode) {
148148
send_packet(buf, (uint16_t)sizeof(buf));
149149
}
150150

151-
// ---------- lectura ----------
151+
// ---------- read ----------
152152
static int read_exact(uint8_t* out, size_t len) {
153153
size_t got = 0;
154154
while (got < len) {
@@ -195,7 +195,7 @@ static int is_headless_forced(void) {
195195
return v && (strcmp(v, "1") == 0 || strcmp(v, "true") == 0 || strcmp(v, "TRUE") == 0);
196196
}
197197

198-
// ---------- estado compartido ----------
198+
// ---------- shared state ----------
199199
typedef struct {
200200
char* title;
201201
char* label;
@@ -350,7 +350,7 @@ static void ui_start(gui_state_t* st) {
350350
if (st->ui_started) return;
351351
st->ui_started = 1;
352352
if (is_headless_forced()) {
353-
send_log("minigui_port: modo headless (windows).");
353+
send_log("minigui_port: headless mode (windows).");
354354
Sleep(300);
355355
send_text_changed(st->text ? st->text : "");
356356
Sleep(300);
@@ -407,7 +407,7 @@ static void* ui_thread_proc(void* param) {
407407
g_state = (gui_state_t*)param;
408408

409409
if (is_headless_forced()) {
410-
send_log("minigui_port: modo headless (linux).");
410+
send_log("minigui_port: headless mode (linux).");
411411
struct timespec ts = {0, 300 * 1000 * 1000};
412412
nanosleep(&ts, NULL);
413413
send_text_changed(g_state->text ? g_state->text : "");
@@ -499,7 +499,7 @@ int main(void) {
499499

500500
if (cmd == 0x00) { // HELLO
501501
if (len < 3) {
502-
send_error_event("HELLO inválido");
502+
send_error_event("invalid HELLO");
503503
} else {
504504
uint16_t ver = read_u16be(buf + 1);
505505
if (ver != PROTOCOL_VERSION) {
@@ -559,7 +559,7 @@ int main(void) {
559559
}
560560
case 0x13: { // ADD_BUTTON
561561
if (payload_len < 1) {
562-
send_err(req, "ADD_BUTTON inválido");
562+
send_err(req, "invalid ADD_BUTTON");
563563
break;
564564
}
565565
st.button_id = payload[0];
@@ -586,7 +586,7 @@ int main(void) {
586586
break;
587587
}
588588
default:
589-
send_err(req, "comando desconocido");
589+
send_err(req, "unknown command");
590590
break;
591591
}
592592

0 commit comments

Comments
 (0)