Converte símbolos Unicode decorativos dos comentários para ASCII
Substitui barras de caixa (─ ═ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴), travessões (—), setas (→ ←), reticências (…), bullets (•), multiplicação (×) e guillemets (› ‹) por equivalentes ASCII. Acentos portugueses são preservados.
This commit is contained in:
1 parent
1cc0ff9d02
commit
90d47bf8a0
36 files changed
+327
-327
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_graphics.h
|
||||
* TinyBlocks - tb_graphics.h
|
||||
* Interface gráfica do TinyBlocks: janelas, entrada, desenho e texto.
|
||||
*
|
||||
* Tudo o que é gráfico passa por aqui antes de chegar a um backend concreto.
|
||||
@@ -9,15 +9,15 @@
|
||||
* - dinamicamente: tb_graphics_load_backend("build/libtinyblocks-sdl2.so");
|
||||
* (o .so exporta TINYBLOCKS_GRAPHICS_BACKEND_SYMBOL)
|
||||
* Sem escolha explícita usa o backend padrão de compilação (SDL2) ou, na
|
||||
* falta dele, o backend nulo (headless — útil para testes).
|
||||
* falta dele, o backend nulo (headless - útil para testes).
|
||||
*
|
||||
* TypeBlocks registrados por tb_graphics_get_library():
|
||||
* Graphics.Input — estado de entrada de uma janela no frame (outputs GFX_IN_*)
|
||||
* Graphics.Window — uma janela do SO que mostra uma cena (qualquer bloco com on_draw)
|
||||
* Graphics.Input - estado de entrada de uma janela no frame (outputs GFX_IN_*)
|
||||
* Graphics.Window - uma janela do SO que mostra uma cena (qualquer bloco com on_draw)
|
||||
* in: título, largura, altura, cena(block), entrada(block), principal(int)
|
||||
* Graphics.Run — roda o loop até a janela principal fechar
|
||||
* Graphics.Run - roda o loop até a janela principal fechar
|
||||
*
|
||||
* Esta library não conhece nenhum consumidor (editor, palco…): só define o
|
||||
* Esta library não conhece nenhum consumidor (editor, palco...): só define o
|
||||
* contrato e despacha para o backend. Cenas são quaisquer blocos com on_draw.
|
||||
*
|
||||
* Uso típico (host):
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
#include <tinyblocks/tb_renderable_block.h>
|
||||
|
||||
/* ── Teclas (neutras; o backend traduz as suas) ──────────────────────────── */
|
||||
/* -- Teclas (neutras; o backend traduz as suas) --- */
|
||||
enum {
|
||||
TB_KEY_NONE = 0,
|
||||
TB_KEY_ESCAPE, TB_KEY_RETURN, TB_KEY_BACKSPACE, TB_KEY_DELETE, TB_KEY_TAB,
|
||||
@@ -48,12 +48,12 @@ enum {
|
||||
TB_KEY_OTHER = 127
|
||||
};
|
||||
|
||||
/* ── Modificadores (bitmask) ─────────────────────────────────────────────── */
|
||||
/* -- Modificadores (bitmask) --- */
|
||||
#define TB_MOD_SHIFT 0x1
|
||||
#define TB_MOD_CTRL 0x2
|
||||
#define TB_MOD_ALT 0x4
|
||||
|
||||
/* ── Índices de output do bloco Graphics.Input ───────────────────────────── */
|
||||
/* -- Índices de output do bloco Graphics.Input --- */
|
||||
#define GFX_IN_MOUSE_X 0 /* real: posição X do mouse na janela */
|
||||
#define GFX_IN_MOUSE_Y 1 /* real: posição Y do mouse na janela */
|
||||
#define GFX_IN_MOUSE_L_HELD 2 /* int: botão esquerdo pressionado (estado) */
|
||||
@@ -89,7 +89,7 @@ typedef struct TinyBlocks_GfxInput {
|
||||
int mod_state;
|
||||
} TinyBlocks_GfxInput;
|
||||
|
||||
/* ── Contrato de um backend gráfico ──────────────────────────────────────── */
|
||||
/* -- Contrato de um backend gráfico --- */
|
||||
typedef struct TinyBlocks_GraphicsBackend {
|
||||
const char* name;
|
||||
bool (*init)(void); /* idempotente */
|
||||
@@ -107,7 +107,7 @@ typedef struct TinyBlocks_GraphicsBackend {
|
||||
#define TINYBLOCKS_GRAPHICS_BACKEND_SYMBOL "tinyblocks_get_graphics_backend"
|
||||
typedef const TinyBlocks_GraphicsBackend* (*TinyBlocks_GetGraphicsBackendFn)(void);
|
||||
|
||||
/* ── API ─────────────────────────────────────────────────────────────────── */
|
||||
/* -- API --- */
|
||||
TB_API const TinyBlocks_LibraryDescriptor* tb_graphics_get_library(void);
|
||||
|
||||
/* Escolhe o backend (antes de abrir a primeira janela) */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* TinyBlocks — tb_graphics.c
|
||||
* TinyBlocks - tb_graphics.c
|
||||
* Interface gráfica: escolha de backend, janelas, entrada e loop principal.
|
||||
*/
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
@@ -15,9 +15,9 @@
|
||||
#include <tb_sdl2.h>
|
||||
#endif
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
/* ===
|
||||
* Backend nulo (headless): janelas sem tela, entrada vazia, texto estimado
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
typedef struct { int w, h; } NullWin;
|
||||
|
||||
static bool null_init(void) { return true; }
|
||||
@@ -52,9 +52,9 @@ static const TinyBlocks_GraphicsBackend s_null_backend = {
|
||||
|
||||
const TinyBlocks_GraphicsBackend* tb_graphics_null_backend(void) { return &s_null_backend; }
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
/* ===
|
||||
* Escolha do backend
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
static const TinyBlocks_GraphicsBackend* s_backend = NULL;
|
||||
static bool s_backend_ready = false;
|
||||
static void* s_backend_dl = NULL;
|
||||
@@ -120,11 +120,11 @@ bool tb_graphics_load_backend(const char* so_path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
/* ===
|
||||
* Medição de texto
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
|
||||
/* Larguras de avanço da DejaVu Sans, em em, para ASCII 32..126 — estimativa
|
||||
/* Larguras de avanço da DejaVu Sans, em em, para ASCII 32..126 - estimativa
|
||||
* usada quando o backend não sabe medir (ex: backend nulo). */
|
||||
static const float s_adv[95] = {
|
||||
.318f,.401f,.460f,.838f,.636f,.950f,.780f,.275f,.390f,.390f,.500f,.838f,.318f,.361f,.318f,.337f,
|
||||
@@ -150,9 +150,9 @@ float tb_graphics_measure_text(const char* text, float font_size) {
|
||||
return b->measure_text ? b->measure_text(text, font_size) : estimate_text(text, font_size);
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
* Graphics.Input — estado de entrada de uma janela no frame
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
/* ===
|
||||
* Graphics.Input - estado de entrada de uma janela no frame
|
||||
* === */
|
||||
static const TinyBlocks_SlotDesc s_input_outs[GFX_IN_COUNT] = {
|
||||
{"mouse_x", TB_VALUE_REAL}, {"mouse_y", TB_VALUE_REAL},
|
||||
{"l_held", TB_VALUE_INTEGER}, {"r_held", TB_VALUE_INTEGER},
|
||||
@@ -206,12 +206,12 @@ static void input_push(TinyBlocks_Block* b, const TinyBlocks_GfxInput* in) {
|
||||
b->dirty = false;
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
* Graphics.Window — uma janela do SO mostrando uma cena
|
||||
/* ===
|
||||
* Graphics.Window - uma janela do SO mostrando uma cena
|
||||
* inputs: 0 título, 1 largura, 2 altura, 3 cena(block), 4 entrada(block),
|
||||
* 5 principal(int: fechar esta janela encerra o loop; padrão 1)
|
||||
* output: 0 aberta(int)
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
typedef struct { void* handle; uint64_t id; bool open; } WinState;
|
||||
|
||||
static int win_find(uint64_t id) {
|
||||
@@ -275,9 +275,9 @@ bool tb_graphics_window_is_open(TinyBlocks_Block* window) {
|
||||
return ((WinState*)window->userdata)->open;
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
/* ===
|
||||
* Loop principal
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
static void default_wait(void) {
|
||||
struct timespec ts = { 0, 16 * 1000000L };
|
||||
nanosleep(&ts, NULL);
|
||||
@@ -340,9 +340,9 @@ static void eval_run(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
tb_graphics_run(rt);
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
/* ===
|
||||
* Registro da library
|
||||
* ══════════════════════════════════════════════════════════════════════════ */
|
||||
* === */
|
||||
static bool graphics_lib_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
TinyBlocks_TypeBlock* t;
|
||||
|
||||
|
||||
Reference in new issue
Block a user