Comentários: separadores com no máximo "---"

Trechos com quatro ou mais hífens dentro de comentários viram "---"
(strings não mudam).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-23 07:24:19 -03:00
1 parent 374b445a8f
commit 80bd330766
40 files changed
+137 -137

No files matched your search

+2 -2
View File
@@ -43,7 +43,7 @@ static const char* path_basename(const char* p) {
return s ? s + 1 : p;
}
/* -- Modulos de codigo (bundle) e watcher de arquivos ------------------- */
/* -- Modulos de codigo (bundle) e watcher de arquivos --- */
typedef struct {
char name[64];
@@ -416,7 +416,7 @@ bool tb_api_reload(int idx) {
return tb_api_load(path) >= 0;
}
/* -- Descoberta de libraries no disco ---------------------------------- */
/* -- Descoberta de libraries no disco --- */
static bool try_path(const char* dir, const char* file, char* out, size_t cap) {
if (!dir || !dir[0]) return false;
+2 -2
View File
@@ -88,7 +88,7 @@ char* tb_base64_decode_str(const char* s, size_t* out_len) {
return (char*)tb_base64_decode(s, out_len);
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_encode(TinyBlocks_Block* self, TinyBlocks* rt) {
@@ -105,7 +105,7 @@ static void eval_decode(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------ */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
@@ -545,7 +545,7 @@ static TinyBlocks_JsonValue* blueprint_csv_tree(const TbBlueprint* bp) {
return arr;
}
/* -- Formatos (TbBpFormat) ------------------------------------------------ */
/* -- Formatos (TbBpFormat) --- */
static char* buf_take(Buf* b) {
if (!b->p) { b->p = (char*)malloc(1); if (b->p) b->p[0] = 0; }
+1 -1
View File
@@ -121,7 +121,7 @@ bool tb_bmp_save(const TinyBlocks_Image* img, const char* path) {
return ok;
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static TinyBlocks_Image* in_img(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
@@ -12,7 +12,7 @@ static void eval_noop(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Fluxos ------------------------------------------------------------------
/* -- Fluxos ---
* step: 0 = entrando, 1 = vai testar/entrar na volta, 2 = a volta acabou
* (pausa um quadro, como no Scratch, e testa de novo). */
@@ -53,7 +53,7 @@ static const TinyBlocks_FlowClass s_forever = { 1, { NULL }, true, forever_n
static const TinyBlocks_FlowClass s_if = { 1, { NULL }, false, if_next, NULL };
static const TinyBlocks_FlowClass s_if_else = { 2, { "senão" }, false, if_else_next, NULL };
/* -- Registro ------------------------------------------------------------- */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+5 -5
View File
@@ -40,7 +40,7 @@ static void push_point(TinyBlocks_JsonValue* arr, double x, double y) {
tb_json_release(pt);
}
/* -- Curvas -------------------------------------------------------------- */
/* -- Curvas --- */
TinyBlocks_JsonValue* tb_curves_line(double x0, double y0, double x1, double y1,
int steps) {
@@ -104,7 +104,7 @@ TinyBlocks_JsonValue* tb_curves_circle(double cx, double cy, double r, int steps
return tb_curves_arc(cx, cy, r, 0.0, 360.0, steps);
}
/* -- Leitura ------------------------------------------------------------- */
/* -- Leitura --- */
int tb_curves_count(const TinyBlocks_JsonValue* pts) {
if (!pts || tb_json_kind(pts) != TB_JSON_ARRAY) return 0;
@@ -128,7 +128,7 @@ bool tb_curves_point(const TinyBlocks_JsonValue* pts, int i, double* x, double*
return ok;
}
/* -- Helpers de entrada -------------------------------------------------- */
/* -- Helpers de entrada --- */
static int64_t in_int(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
@@ -149,7 +149,7 @@ static void out_pts(TinyBlocks_Block* self, TinyBlocks_JsonValue* pts) {
self->dirty = false;
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_line(TinyBlocks_Block* self, TinyBlocks* rt) {
out_pts(self, tb_curves_line(tb_block_input_number(self,rt,0, 0), tb_block_input_number(self,rt,1, 0),
@@ -195,7 +195,7 @@ static void eval_pointy(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------ */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
@@ -19,7 +19,7 @@
#include <tb_editor_internal.h>
#include "tb_editor_files.h"
/* -- Geometria ------------------------------------------------------------ */
/* -- Geometria --- */
#define FD_HEAD_H 46
#define FD_BAR_H 44
#define FD_SIDE_W 196
@@ -87,7 +87,7 @@ static void fd_layout(Ed* ed, FdL* L) {
L->cancel_x = L->ok_x - 10.f - FD_BTN_W;
}
/* -- Utilidades ----------------------------------------------------------- */
/* -- Utilidades --- */
static unsigned fd_now_ms(void) {
struct timespec ts;
@@ -213,7 +213,7 @@ static void fd_time_str(char* out, size_t cap, long long t) {
strftime(out, cap, "%d/%m/%Y %H:%M", &tmv);
}
/* -- Listagem ------------------------------------------------------------- */
/* -- Listagem --- */
static int fd_cmp(const void* a, const void* b) {
const FileEnt* x = a;
@@ -346,7 +346,7 @@ static void fd_places(Ed* ed) {
fd_add_place(F, "Raiz do sistema", "/");
}
/* -- Trilha da pasta atual (segmentos clicaveis) ------------------------- */
/* -- Trilha da pasta atual (segmentos clicaveis) --- */
#define FD_MAX_CRUMBS 48
typedef struct {
int n, first; /* segmentos; primeiro visivel */
@@ -400,7 +400,7 @@ static void fd_crumbs(Ed* ed, const FdL* L, FdCrumbs* K) {
}
}
/* -- Acoes ---------------------------------------------------------------- */
/* -- Acoes --- */
static void fd_ensure_visible(Ed* ed) {
FileDlg* F = &ed->fdlg;
@@ -549,7 +549,7 @@ void tb_editor_files_open(Ed* ed, int mode, const char* def) {
fd_ensure_visible(ed);
}
/* -- Desenho -------------------------------------------------------------- */
/* -- Desenho --- */
static void fd_icon_folder(TinyBlocks_RenderableBlock* rb, float x, float y, bool dim) {
Col c = COL_FD_FOLDER, d = COL_FD_FOLDER_DARK;
@@ -797,7 +797,7 @@ void tb_editor_files_view(Ed* ed, TinyBlocks_RenderableBlock* rb) {
}
}
/* -- Entrada -------------------------------------------------------------- */
/* -- Entrada --- */
static void fd_rescan_keep(Ed* ed) {
FileDlg* F = &ed->fdlg;
@@ -53,7 +53,7 @@ static const Col IMG_PALETTE[12] = {
{0.55f,0.38f,0.24f,1.f}, {0.60f,0.60f,0.60f,1.f}
};
/* Cor: HSV (roda de matiz + quadrado saturacao/valor) ------------------- */
/* Cor: HSV (roda de matiz + quadrado saturacao/valor) --- */
static Col img_hsv_col(float h, float sat, float v) {
float c = v * sat;
float hp = h / 60.f;
@@ -95,7 +95,7 @@ static void img_hsv_apply(Tab* T) {
T->img_swatch = -1;
}
/* Geometria -------------------------------------------------------------
/* Geometria ---
* Layout (como no Krita): ferramentas na coluna da esquerda, tela no meio e
* na direita uma coluna com a roda de cores em cima e as camadas embaixo. */
#define IMG_TOOL_W 54 /* coluna de ferramentas (esquerda) */
@@ -248,7 +248,7 @@ static void img_side_btn(Ed* ed, int which, float* x, float* y, float* w, float*
(void)ed;
}
/* Camadas --------------------------------------------------------------- */
/* Camadas --- */
#define IMG_THUMB_W 40
#define IMG_THUMB_H 30
/* Miniatura da camada (cacheada por revisao) - como no painel do Scratch */
@@ -383,7 +383,7 @@ static bool img_layer_add(Ed* ed, Tab* T, int kind, const char* src, const char*
return true;
}
/* Desenho --------------------------------------------------------------- */
/* Desenho --- */
static bool img_pixel_at(Ed* ed, Tab* T, float mx, float my, int* px, int* py) {
float dx, dy, dw, dh;
img_view(ed, T, &dx, &dy, &dw, &dh);
@@ -514,9 +514,9 @@ static void img_flatten(Tab* T, TinyBlocks_Image* dst) {
}
}
/* Miniatura do documento (cache; reconstruida so quando algo muda) -------- */
/* Miniatura do documento (cache; reconstruida so quando algo muda) --- */
/* Selecao: mover / redimensionar pixels ---------------------------------- */
/* Selecao: mover / redimensionar pixels --- */
void tb_editor_image_sel_reset(Tab* T) {
if (T->img_sel.buf) { tb_image_release(T->img_sel.buf); T->img_sel.buf = NULL; }
memset(&T->img_sel, 0, sizeof(T->img_sel));
@@ -606,7 +606,7 @@ static void img_sel_resize(Tab* T, int hnd, int px, int py) {
if (S->h < 1) S->h = 1;
}
/* Undo ------------------------------------------------------------------ */
/* Undo --- */
static void img_undo_push(Tab* T) {
ImgLayer* L = img_active(T);
if (!L || !L->img) return;
@@ -636,7 +636,7 @@ static void img_undo_do(Tab* T) {
T->img_rev++;
}
/* Icones das ferramentas ------------------------------------------------ */
/* Icones das ferramentas --- */
static void img_draw_icon(TinyBlocks_RenderableBlock* rb, int tool, float cx, float cy, Col c) {
switch (tool) {
case IT_SEL:
@@ -672,7 +672,7 @@ static void img_draw_icon(TinyBlocks_RenderableBlock* rb, int tool, float cx, fl
}
}
/* Render ---------------------------------------------------------------- */
/* Render --- */
void tb_editor_image_view(Ed* ed, TinyBlocks_RenderableBlock* rb) {
Tab* T = &CT;
img_ensure(ed, T);
@@ -805,7 +805,7 @@ void tb_editor_image_view(Ed* ed, TinyBlocks_RenderableBlock* rb) {
labels[i], enabled ? COL_TEXT : COL_TEXT_DIM, FS_UI - 1);
}
/* ---- widget novo: slider de zoom ---- */
/* --- widget novo: slider de zoom --- */
{
float sx, sy, sw, sh;
img_zoom_slider(ed, &sx, &sy, &sw, &sh);
@@ -907,7 +907,7 @@ void tb_editor_image_view(Ed* ed, TinyBlocks_RenderableBlock* rb) {
rb_text_c(rb, px + IMG_PAD, img_pal_y(ed) + 4 * 30 + 6, inf, COL_TEXT, FS_UI);
}
/* ---- camadas: embaixo da roda de cores (como no Krita) ---- */
/* --- camadas: embaixo da roda de cores (como no Krita) --- */
rb_line(rb, px + IMG_PAD, img_layers_title_y(ed) - 14,
px + IMG_RIGHT_W - IMG_PAD, img_layers_title_y(ed) - 14, 1.f, COL_PAINT_LINE);
rb_text_c(rb, px + IMG_PAD, img_layers_title_y(ed), "Camadas", COL_TEXT_DIM, 11.f);
@@ -957,7 +957,7 @@ void tb_editor_image_view(Ed* ed, TinyBlocks_RenderableBlock* rb) {
}
}
/* Entrada --------------------------------------------------------------- */
/* Entrada --- */
static void img_clear_layer(Tab* T) {
ImgLayer* L = img_active(T);
if (!L || !L->img) return;
@@ -51,7 +51,7 @@ static char s_dir[512] = "";
const char* tb_ed_modules_dir(void) { return s_dir; }
/* -- utilidades ---------------------------------------------------------- */
/* -- utilidades --- */
static bool file_exists(const char* p) {
struct stat st;
@@ -157,7 +157,7 @@ static bool resolve_files(void) {
return ok;
}
/* -- carga --------------------------------------------------------------- */
/* -- carga --- */
bool tb_ed_modules_load(Ed* ed) {
if (!tb_api_runtime()) tb_api_init(ed->rt);
@@ -26,7 +26,7 @@ static EnvPair s_env[ENV_MAX];
static int s_env_n = 0;
static char s_err[256] = "";
/* -- Store --------------------------------------------------------------- */
/* -- Store --- */
static char* dup_str(const char* s) {
if (!s) s = "";
@@ -200,7 +200,7 @@ const char* tb_environ_env_path(void) {
return (e && e[0]) ? e : "";
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_get(TinyBlocks_Block* self, TinyBlocks* rt) {
@@ -223,7 +223,7 @@ static void eval_unset(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------ */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+5 -5
View File
@@ -11,7 +11,7 @@
#include <tinyblocks/tinyblocks.h>
#include "tb_errors.h"
/* -- Saidas --------------------------------------------------------------- */
/* -- Saidas --- */
/* Toma a referencia de r */
static void out_result(TinyBlocks_Block* self, TinyBlocks_Result* r) {
@@ -25,7 +25,7 @@ static void out_bool(TinyBlocks_Block* self, bool b) {
self->dirty = false;
}
/* -- Blocos: resultados --------------------------------------------------- */
/* -- Blocos: resultados --- */
/* "tente obter (x)": avalia x (o tipo tem lazy_inputs); erro vira Erro(msg),
valor vira Ok(valor) */
@@ -102,7 +102,7 @@ static void eval_message(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Blocos: tratamento --------------------------------------------------- */
/* -- Blocos: tratamento --- */
/* "lance o erro [msg]" (raise / panic!) */
static void eval_raise(TinyBlocks_Block* self, TinyBlocks* rt) {
@@ -124,7 +124,7 @@ static void eval_nop(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Fluxos: tente / se der erro / finalmente -------------------------------
/* -- Fluxos: tente / se der erro / finalmente ---
* step: 0 entrando, 1 no "tente", 2 no "se der erro", 3 no "finalmente". */
static void catch_enter(TinyBlocks_Flow* f, const char* msg) {
@@ -182,7 +182,7 @@ static const TinyBlocks_FlowClass s_try_catch = {
static const TinyBlocks_FlowClass s_try = {
3, { "se der erro", "finalmente" }, false, try_next, try_error };
/* -- Registro ------------------------------------------------------------- */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+2 -2
View File
@@ -108,7 +108,7 @@ static void eval_close(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Pastas --------------------------------------------------------------- */
/* -- Pastas --- */
static int cmp_name(const void* a, const void* b) {
return strcasecmp(*(char* const*)a, *(char* const*)b);
@@ -206,7 +206,7 @@ static void eval_exists(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------ */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+4 -4
View File
@@ -77,7 +77,7 @@ TinyBlocks_Image* tb_imglib_scale(const TinyBlocks_Image* img,
return out;
}
/* -- Helpers de entrada -------------------------------------------------- */
/* -- Helpers de entrada --- */
static TinyBlocks_Image* in_img(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
@@ -92,7 +92,7 @@ static void out_img(TinyBlocks_Block* self, TinyBlocks_Image* img) {
self->dirty = false;
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_new(TinyBlocks_Block* self, TinyBlocks* rt) {
int w = (int)tb_block_input_number(self, rt, 0, 0), h = (int)tb_block_input_number(self, rt, 1, 0);
@@ -155,7 +155,7 @@ static void eval_save(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Conversoes ---------------------------------------------------------- */
/* -- Conversoes --- */
#define IMG_MAX_PIXELS (4096 * 4096)
@@ -304,7 +304,7 @@ static void eval_to_text(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------ */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+4 -4
View File
@@ -22,7 +22,7 @@
#include <tb_graphics.h>
#include "tb_input_lib.h"
/* -- Nomes de tecla ------------------------------------------------------- */
/* -- Nomes de tecla --- */
typedef struct { const char* name; int key; } KeyName;
@@ -89,7 +89,7 @@ TB_API const char* tb_input_key_name(int key) {
return "";
}
/* -- Entradas/saidas ------------------------------------------------------ */
/* -- Entradas/saidas --- */
@@ -117,7 +117,7 @@ static void out_bool(TinyBlocks_Block* self, bool b) {
self->dirty = false;
}
/* -- Blocos --------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_mouse_x(TinyBlocks_Block* self, TinyBlocks* rt) { (void)rt; out_num(self, roundf(tb_input_mouse_x())); }
static void eval_mouse_y(TinyBlocks_Block* self, TinyBlocks* rt) { (void)rt; out_num(self, roundf(tb_input_mouse_y())); }
@@ -172,7 +172,7 @@ static void eval_reset_timer(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------- */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+1 -1
View File
@@ -129,7 +129,7 @@ bool tb_jpg_save(const TinyBlocks_Image* img, const char* path, int quality) {
return ok;
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static TinyBlocks_Image* in_img(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
@@ -10,7 +10,7 @@
TB_API const TinyBlocks_LibraryDescriptor* tb_markdown_get_library(void);
/* -- API C (resultados com malloc; libere com free) ---------------------- */
/* -- API C (resultados com malloc; libere com free) --- */
TB_API char* tb_markdown_to_html(const char* md);
TB_API char* tb_markdown_to_xml(const char* md);
TB_API char* tb_markdown_to_svg(const char* md);
@@ -18,7 +18,7 @@
static char s_err[160] = "";
const char* tb_markdown_last_error(void) { return s_err; }
/* ---------------------------------------------------------------- Buffer */
/* --- Buffer */
typedef struct { char* p; size_t n, cap; } Buf;
static bool b_res(Buf* b, size_t extra) {
if (b->n + extra + 1 <= b->cap) return true;
@@ -49,7 +49,7 @@ static void b_esc(Buf* b, const char* s, size_t n) {
}
}
/* ----------------------------------------------------------------- Blocos */
/* --- Blocos */
typedef enum { BLK_H, BLK_P, BLK_LI, BLK_CODE, BLK_QUOTE, BLK_HR } BlkKind;
typedef struct {
BlkKind kind;
@@ -208,7 +208,7 @@ static Doc* parse(const char* md) {
return d;
}
/* ---------------------------------------------------------------- Inline */
/* --- Inline */
/* Serializa inline markdown para HTML (xml=false) ou XML (xml=true). */
static void inline_out(Buf* b, const char* s, bool xml) {
const char* bold0 = xml ? "<bold>" : "<strong>";
@@ -276,7 +276,7 @@ static void inline_out(Buf* b, const char* s, bool xml) {
}
}
/* ------------------------------------------------------------------ HTML */
/* --- HTML */
char* tb_markdown_to_html(const char* md) {
s_err[0] = 0;
Doc* d = parse(md);
@@ -320,7 +320,7 @@ char* tb_markdown_to_html(const char* md) {
return b.p;
}
/* ------------------------------------------------------------------- XML */
/* --- XML */
char* tb_markdown_to_xml(const char* md) {
s_err[0] = 0;
Doc* d = parse(md);
@@ -367,7 +367,7 @@ char* tb_markdown_to_xml(const char* md) {
return b.p;
}
/* ------------------------------------------------------------------- SVG */
/* --- SVG */
char* tb_markdown_to_svg_opts(const char* md, int width, int font_size) {
s_err[0] = 0;
if (width < 80) width = 640;
@@ -470,7 +470,7 @@ char* tb_markdown_to_svg_opts(const char* md, int width, int font_size) {
char* tb_markdown_to_svg(const char* md) { return tb_markdown_to_svg_opts(md, 640, 16); }
/* ---------------------------------------------------------------- Blocos */
/* --- Blocos */
static void eval_html(TinyBlocks_Block* self, TinyBlocks* rt) {
char* s = tb_markdown_to_html(tb_block_input_text(self, rt, 0));
tb_block_set_output(self, 0, tb_value_text(s ? s : "")); free(s); self->dirty = false;
+5 -5
View File
@@ -26,7 +26,7 @@
#endif
#define DEG (M_PI / 180.0)
/* -- API ------------------------------------------------------------------ */
/* -- API --- */
TB_API double tb_number_round_to(double x, int places) {
if (places < 0) places = 0;
@@ -60,7 +60,7 @@ TB_API void tb_number_format(double x, int places, char* out, size_t cap) {
}
}
/* -- Entradas/saidas ------------------------------------------------------ */
/* -- Entradas/saidas --- */
/* Inteiro quando o resultado for exato (e couber), senao real */
@@ -80,7 +80,7 @@ static void out_bool(TinyBlocks_Block* self, bool b) {
/* trigonometria: corta o ruido de ponto flutuante (sen 180 = 0, nao 1e-16) */
static double trig(double x) { return tb_number_round_to(x, 10); }
/* -- Blocos --------------------------------------------------------------- */
/* -- Blocos --- */
#define N(i) tb_block_input_number(self, rt, (i), 0)
@@ -147,7 +147,7 @@ static void eval_is_int(TinyBlocks_Block* self, TinyBlocks* rt) {
out_bool(self, isfinite(x) && x == floor(x));
}
/* -- Conversoes ----------------------------------------------------------- */
/* -- Conversoes --- */
/* Texto -> numero: o mesmo do core (espacos nas pontas, virgula decimal) */
TB_API bool tb_number_parse(const char* s, double* out) {
@@ -201,7 +201,7 @@ static void eval_from_base(TinyBlocks_Block* self, TinyBlocks* rt) {
out_num(self, (double)r);
}
/* -- Registro ------------------------------------------------------------- */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
@@ -16,7 +16,7 @@
TB_API const TinyBlocks_LibraryDescriptor* tb_opentype_get_library(void);
/* -- API C --------------------------------------------------------------- */
/* -- API C --- */
/* Carrega uma fonte; devolve um handle (>0) ou 0 em erro. */
TB_API int tb_opentype_load(const char* path);
@@ -294,7 +294,7 @@ const char* tb_opentype_default_font(void) {
return NULL;
}
/* ---------------------------------------------------------------- Blocos */
/* --- Blocos */
static void eval_load(TinyBlocks_Block* self, TinyBlocks* rt) {
int h = tb_opentype_load(tb_block_input_text(self, rt, 0));
+3 -3
View File
@@ -22,7 +22,7 @@ static void copy(char* out, size_t cap, const char* s) {
snprintf(out, cap, "%s", s ? s : "");
}
/* -- Consultas ------------------------------------------------------------ */
/* -- Consultas --- */
TB_API void tb_os_name(char* out, size_t cap) {
#if defined(__APPLE__)
@@ -104,7 +104,7 @@ TB_API long long tb_os_uptime_s(void) {
return (long long)up;
}
/* -- Blocos --------------------------------------------------------------- */
/* -- Blocos --- */
static void out_text(TinyBlocks_Block* self, void (*fn)(char*, size_t)) {
char buf[512];
@@ -170,7 +170,7 @@ static void eval_is(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------- */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+1 -1
View File
@@ -72,7 +72,7 @@ bool tb_png_save(const TinyBlocks_Image* img, const char* path) {
return ok;
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static TinyBlocks_Image* in_img(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
+3 -3
View File
@@ -110,7 +110,7 @@ bool tb_ppm_save(const TinyBlocks_Image* img, const char* path) {
return ok;
}
/* -- Helpers de entrada -------------------------------------------------- */
/* -- Helpers de entrada --- */
static TinyBlocks_Image* in_img(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
@@ -123,7 +123,7 @@ static uint8_t clamp8(double v) {
return (uint8_t)(v + 0.5);
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_load(TinyBlocks_Block* self, TinyBlocks* rt) {
TinyBlocks_Image* img = tb_ppm_load(tb_block_input_text(self, rt, 0));
@@ -186,7 +186,7 @@ static void eval_getpixel(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Registro ------------------------------------------------------------ */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
@@ -10,7 +10,7 @@
TB_API const TinyBlocks_LibraryDescriptor* tb_regex_get_library(void);
/* -- API C --------------------------------------------------------------- */
/* -- API C --- */
/* Verdadeiro se o padrao casa em algum ponto do texto. */
TB_API bool tb_regex_test(const char* text, const char* pattern);
+2 -2
View File
@@ -107,7 +107,7 @@ int tb_regex_count(const char* text, const char* pattern) {
return count;
}
/* --- Expansao do substituto -------------------------------------------- */
/* --- Expansao do substituto --- */
typedef struct { char* p; size_t n, cap; } Buf;
static bool b_res(Buf* b, size_t extra) {
if (b->n + extra + 1 <= b->cap) return true;
@@ -210,7 +210,7 @@ void tb_regex_free_list(char** list) {
free(list);
}
/* ---------------------------------------------------------------- Blocos */
/* --- Blocos */
static void eval_test(TinyBlocks_Block* self, TinyBlocks* rt) {
bool ok = tb_regex_test(tb_block_input_text(self, rt, 0), tb_block_input_text(self, rt, 1));
@@ -21,7 +21,7 @@
#include "tb_scratchblocks.h"
/* -- Modelos internos (ingles do Scratch 3) ------------------------------- */
/* -- Modelos internos (ingles do Scratch 3) --- */
/* forma: h chapeu, s comando, c C, C se/senao, e sempre, r repórter, b booleano */
typedef struct { const char* type; const char* text; char shape; bool import_only; } Tpl;
@@ -88,7 +88,7 @@ static const Tpl s_builtin[] = {
};
#define BUILTIN_N ((int)(sizeof(s_builtin) / sizeof(s_builtin[0])))
/* -- Texto dinamico -------------------------------------------------------- */
/* -- Texto dinamico --- */
typedef struct { char* p; size_t n, cap; } Sb;
static void sb_add(Sb* b, const char* s, size_t n) {
@@ -114,7 +114,7 @@ static void sb_esc(Sb* b, const char* s) {
}
}
/* -- Tokens ---------------------------------------------------------------- */
/* -- Tokens --- */
enum { T_WORD, T_ROUND, T_SQUARE, T_ANGLE }; /* palavra, ( ), [ ], < > */
#define TOK_MAX 40
#define TOK_TEXT 256
@@ -228,7 +228,7 @@ static void strip_category(char* s) {
}
}
/* -- Modelos (internos + rotulos do chamador) ------------------------------ */
/* -- Modelos (internos + rotulos do chamador) --- */
typedef struct {
const char* type;
char shape;
@@ -347,7 +347,7 @@ static bool model_match(const Model* m, const Tok* t, int n) {
static bool shape_is_stmt(char s) { return s == 's' || s == 'h' || s == 'c' || s == 'C' || s == 'e'; }
/* -- Exportar -------------------------------------------------------------- */
/* -- Exportar --- */
static bool is_literal(const char* type) { return strncmp(type, "Literal.", 8) == 0; }
static int block_shape(const Models* M, const char* type) {
@@ -530,7 +530,7 @@ char* tb_scratchblocks_export(const TbBpTab* tab, const TbSbContext* cx) {
return out.p;
}
/* -- Importar -------------------------------------------------------------- */
/* -- Importar --- */
typedef struct {
const Models* M;
TbBpTab* tab;
+6 -6
View File
@@ -22,7 +22,7 @@
#define STR_MAX_OUT (1u << 20) /* teto de 1 MB para "repita" */
/* -- UTF-8 ---------------------------------------------------------------- */
/* -- UTF-8 --- */
static size_t u8_len(unsigned char c) {
if (c < 0x80) return 1;
@@ -77,7 +77,7 @@ static size_t u8_count(const char* s, size_t nbytes) {
return n;
}
/* -- API ------------------------------------------------------------------ */
/* -- API --- */
TB_API size_t tb_string_length(const char* s) {
return u8_count(s, strlen(s));
@@ -156,7 +156,7 @@ TB_API bool tb_string_is_number(const char* s) {
return *e == 0;
}
/* -- Entradas ------------------------------------------------------------- */
/* -- Entradas --- */
/* Texto da entrada i (numeros viram texto). Fica valido ate o proximo uso. */
@@ -174,7 +174,7 @@ static void out_bool(TinyBlocks_Block* self, bool b) {
#define TXT(i) tb_block_input_text(self, rt, (i))
/* -- Blocos --------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_upper(TinyBlocks_Block* self, TinyBlocks* rt) { out_owned(self, tb_string_upper(TXT(0))); }
static void eval_lower(TinyBlocks_Block* self, TinyBlocks* rt) { out_owned(self, tb_string_lower(TXT(0))); }
@@ -285,7 +285,7 @@ static void eval_isempty(TinyBlocks_Block* self, TinyBlocks* rt) {
free(t);
}
/* -- Conversoes ----------------------------------------------------------- */
/* -- Conversoes --- */
/* "texto de (x)": cada tipo de valor sabe virar texto (classe do valor) */
static void eval_from(TinyBlocks_Block* self, TinyBlocks* rt) {
@@ -330,7 +330,7 @@ static void eval_from_code(TinyBlocks_Block* self, TinyBlocks* rt) {
out_owned(self, dup_n(buf, n));
}
/* -- Registro ------------------------------------------------------------- */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+5 -5
View File
@@ -23,7 +23,7 @@
static char s_err[200] = "";
const char* tb_svg_last_error(void) { return s_err; }
/* -- Utilitarios de parsing ---------------------------------------------- */
/* -- Utilitarios de parsing --- */
static void skip_ws(const char** p) {
while (**p && (isspace((unsigned char)**p) || **p == ',')) (*p)++;
@@ -109,7 +109,7 @@ static bool parse_color(const char* s, float* r, float* g, float* b, float* a) {
return false;
}
/* -- Cotas de imagens embutidas ------------------------------------------ */
/* -- Cotas de imagens embutidas --- */
typedef struct { double x, y, w, h; TinyBlocks_Image* img; } SvgImg;
#define SVG_MAX_IMGS 16
@@ -157,7 +157,7 @@ static TinyBlocks_Image* decode_data_uri(const char* uri) {
return img;
}
/* -- Parsing de shapes ---------------------------------------------------- */
/* -- Parsing de shapes --- */
typedef struct { double* xy; int n, cap; } Pts;
@@ -288,7 +288,7 @@ static void parse_path(TinyBlocks_VectorData* v, const char* d, bool do_fill, bo
pts_free(&poly);
}
/* -- Parse principal ------------------------------------------------------ */
/* -- Parse principal --- */
static TinyBlocks_VectorData* svg_parse_internal(const char* svg, int* out_w, int* out_h,
SvgImg* imgs, int* img_n) {
@@ -451,7 +451,7 @@ TinyBlocks_Image* tb_svg_render(const char* svg, int w, int h) {
return im;
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_parse(TinyBlocks_Block* self, TinyBlocks* rt) {
@@ -19,7 +19,7 @@
TB_API const TinyBlocks_LibraryDescriptor* tb_syntax_get_library(void);
/* -- API C --------------------------------------------------------------- */
/* -- API C --- */
/* Realca `text` como `lang` e devolve XML (malloc; libere com free). */
TB_API char* tb_syntax_highlight(const char* text, const char* lang);
+7 -7
View File
@@ -17,7 +17,7 @@
static char s_err[160] = "";
const char* tb_syntax_last_error(void) { return s_err; }
/* ---------------------------------------------------------------- Buffer */
/* --- Buffer */
typedef struct { char* p; size_t n, cap; } Buf;
static bool b_reserve(Buf* b, size_t extra) {
@@ -46,7 +46,7 @@ static void b_esc(Buf* b, const char* s, size_t n) {
}
}
/* ------------------------------------------------------------- Token tip */
/* --- Token tip */
typedef enum { T_PLAIN, T_KW, T_TYPE, T_STR, T_NUM, T_CMT, T_PRE,
T_FN, T_OP, T_PUNC, T_ID } TK;
@@ -96,7 +96,7 @@ const char* tb_syntax_type_color(const char* type) {
return tk_color(T_PLAIN);
}
/* ------------------------------------------------------------ Linguagens */
/* --- Linguagens */
typedef struct {
const char* name;
const char* aliases; /* separados por espaco */
@@ -218,7 +218,7 @@ static bool word_in(const char* list, const char* w, size_t n) {
return false;
}
/* -------------------------------------------------------------- Emissao */
/* --- Emissao */
static bool emit(Buf* b, TK k, const char* s, size_t n, bool inline_mode) {
(void)inline_mode;
if (n == 0) return true;
@@ -232,7 +232,7 @@ static bool emit(Buf* b, TK k, const char* s, size_t n, bool inline_mode) {
return true;
}
/* --------------------------------------------------------- Tokenizadores */
/* --- Tokenizadores */
static bool is_id_start(int c) { return isalpha(c) || c == '_'; }
static bool is_id_char(int c) { return isalnum(c) || c == '_'; }
static bool is_op(int c) {
@@ -386,7 +386,7 @@ static void tok_md(Buf* b, const char* s, bool inline_mode) {
}
}
/* ---------------------------------------------------------------- Render */
/* --- Render */
char* tb_syntax_highlight_inline(const char* text, const char* lang) {
s_err[0] = 0;
if (!text) text = "";
@@ -435,7 +435,7 @@ char* tb_syntax_highlight(const char* text, const char* lang) {
return b.p;
}
/* ---------------------------------------------------------------- Blocos */
/* --- Blocos */
static void eval_highlight(TinyBlocks_Block* self, TinyBlocks* rt) {
char* x = tb_syntax_highlight(tb_block_input_text(self, rt, 0), tb_block_input_text(self, rt, 1));
+1 -1
View File
@@ -355,7 +355,7 @@ void toml_free(TomlDoc* doc) {
free(doc);
}
/* -- Navegacao ----------------------------------------------------------- */
/* -- Navegacao --- */
const TomlValue* toml_table_get(const TomlValue* table, const char* key) {
TomlKeyVal* kv = table_find(table, key);
+6 -6
View File
@@ -26,7 +26,7 @@
#define LIST_MAX_RANGE 100000
/* -- Itens ---------------------------------------------------------------- */
/* -- Itens --- */
static bool text_number(const char* s, double* out) {
while (isspace((unsigned char)*s)) s++;
@@ -101,7 +101,7 @@ static bool item_equal(const TinyBlocks_JsonValue* a, const TinyBlocks_JsonValue
return strcasecmp(sa, sb) == 0;
}
/* -- Listas --------------------------------------------------------------- */
/* -- Listas --- */
static void push_owned(TinyBlocks_JsonValue* arr, TinyBlocks_JsonValue* item) {
if (!item) return;
@@ -163,7 +163,7 @@ static TinyBlocks_JsonValue* list_copy(const TinyBlocks_JsonValue* src, uint32_t
return arr;
}
/* -- Entradas/saidas ------------------------------------------------------ */
/* -- Entradas/saidas --- */
static TinyBlocks_JsonValue* in_list(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
return tb_vector_from_value(tb_block_get_input(self, rt, i));
@@ -188,7 +188,7 @@ static void out_int(TinyBlocks_Block* self, long long n) {
self->dirty = false;
}
/* -- Blocos --------------------------------------------------------------- */
/* -- Blocos --- */
static void eval_empty(TinyBlocks_Block* self, TinyBlocks* rt) {
(void)rt;
@@ -409,7 +409,7 @@ static void eval_sum(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
}
/* -- Listas com nome (comandos que mudam a lista, como no Scratch) -------- */
/* -- Listas com nome (comandos que mudam a lista, como no Scratch) --- */
#define NAMED_MAX 64
typedef struct { char name[64]; TinyBlocks_JsonValue* arr; } NamedList;
@@ -554,7 +554,7 @@ static void eval_from(TinyBlocks_Block* self, TinyBlocks* rt) {
out_list(self, tb_vector_from_value(v));
}
/* -- Registro ------------------------------------------------------------- */
/* -- Registro --- */
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
const TinyBlocks_SlotDesc* in, uint32_t ni,
+2 -2
View File
@@ -156,7 +156,7 @@ TinyBlocks_Image* tb_vg_render(const TinyBlocks_VectorData* v, int w, int h, flo
return im;
}
/* -- Helpers de construcao ------------------------------------------------ */
/* -- Helpers de construcao --- */
TinyBlocks_VectorData* tb_vg_new(void) { return tb_vector_data_create(); }
@@ -196,7 +196,7 @@ bool tb_vg_polygon(TinyBlocks_VectorData* v, const double* xy, int n, bool close
return tb_vector_fill(v, r, g, b, a);
}
/* -- Blocos -------------------------------------------------------------- */
/* -- Blocos --- */
static TinyBlocks_VectorData* in_vec(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
TinyBlocks_Value v = tb_block_get_input(self, rt, i);