Notação do fórum do Scratch (scratchblocks): exportar e importar scripts

- Nova library tinyblocks-scratchblocks: converte uma aba (TbBpTab da
  blueprint) para o texto do fórum e de volta. Blocos com equivalente no
  Scratch saem em inglês ("when flag clicked", "repeat (10)", "set [x v]
  to (0)", "if <> then ... else ... end", listas, operadores, sensores);
  os do TinyBlocks usam o rótulo em português com "::categoria". A
  importação aceita as duas formas, comentários "//", "::categoria",
  escapes e as tags [scratchblocks]. Forma, tipo dos campos e categoria
  vêm por callbacks (a library não conhece o editor).
- Editor: "Exportar scratchblocks" no menu Exportar (aba atual -> .txt);
  "Abrir" aceita .txt/.sb e cria uma aba com os scripts.
- test-scratchblocks + cenário de ida e volta no harness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-22 18:04:22 -03:00
1 parent 649ae14fb3
commit d842890b0b
11 files changed
+1255 -38

No files matched your search

+20 -6
View File
@@ -34,6 +34,7 @@ VG_DIR := $(LIBDIR)/tinyblocks-vg
SVG_DIR := $(LIBDIR)/tinyblocks-svg
JPG_DIR := $(LIBDIR)/tinyblocks-jpg
SYN_DIR := $(LIBDIR)/tinyblocks-syntax
SB_DIR := $(LIBDIR)/tinyblocks-scratchblocks
RE_DIR := $(LIBDIR)/tinyblocks-regex
MD_DIR := $(LIBDIR)/tinyblocks-markdown
OT_DIR := $(LIBDIR)/tinyblocks-opentype
@@ -89,6 +90,7 @@ BP_A := $(BP_DIR)/build/libtinyblocks-blueprint.a
API_A := $(API_DIR)/build/libtinyblocks-api.a
LIBM_A := $(LIBM_DIR)/build/libtinyblocks-libman.a
SYN_A := $(SYN_DIR)/build/libtinyblocks-syntax.a
SB_A := $(SB_DIR)/build/libtinyblocks-scratchblocks.a
LIB_LDFLAGS := -L$(ED_DIR)/build -L$(GX_DIR)/build -L$(SD_DIR)/build \
$(foreach l,$(CAT_LIBS),-L$(LIBDIR)/tinyblocks-$(l)/build) -L$(BUILD)
@@ -96,12 +98,12 @@ LIB_LDFLAGS := -L$(ED_DIR)/build -L$(GX_DIR)/build -L$(SD_DIR)/build \
editor run-editor run-sdl2 mylib vector customappearance graphics sdl2-backend test-editor \
appdir appimage run-appimage icon \
test-toml test-plugin test-blueprint test-base64 test-curves test-meta test-ppm test-bmp test-png test-image test-vg test-svg test-jpg \
test-syntax test-os test-input test-stdlib test-regex test-markdown test-opentype \
test-syntax test-os test-scratchblocks test-input test-stdlib test-regex test-markdown test-opentype \
category-libs category-sos libs \
lib-events lib-control lib-input lib-operators lib-number lib-string lib-variables lib-vector lib-appearance lib-pen lib-fs lib-os \
lib-environ \
lib-editor lib-graphics lib-sdl2 lib-python lib-mcp lib-toml \
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-regex lib-markdown lib-opentype lib-api lib-libman \
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-scratchblocks lib-regex lib-markdown lib-opentype lib-api lib-libman \
test-libman test-environ
all: static example ## Compila a biblioteca estática e o exemplo hello (padrão)
@@ -207,6 +209,9 @@ lib-jpg:
lib-syntax:
$(MAKE) -C $(SYN_DIR)
lib-scratchblocks:
$(MAKE) -C $(SB_DIR)
lib-regex:
$(MAKE) -C $(RE_DIR)
@@ -236,7 +241,7 @@ lib-mcp:
libs: static lib-events lib-control lib-operators lib-variables \
lib-appearance lib-pen lib-fs lib-os lib-input lib-number lib-string lib-vector lib-environ lib-graphics lib-sdl2 lib-toml \
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-regex lib-markdown lib-opentype lib-api lib-libman lib-editor
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-scratchblocks lib-regex lib-markdown lib-opentype lib-api lib-libman lib-editor
@echo "Libraries OK: category + graphics + sdl2 + toml + json + xml + csv + blueprint + base64 + curves + ppm + bmp + png + image + vg + svg + jpg + syntax + regex + markdown + opentype + api + libman + editor"
category-libs: static $(foreach l,$(CAT_LIBS),lib-$(l)) ## Compila as libraries de categoria (.a/.so)
@@ -281,7 +286,7 @@ $(BUILD)/editor: examples/editor/main.c static libs
-I$(JSON_DIR)/include -I$(XML_DIR)/include -I$(CSV_DIR)/include -I$(BP_DIR)/include \
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(SYN_DIR)/include \
$< -o $@ \
-Wl,--start-group $(ED_A) $(GX_A) $(SD_A) $(TOML_A) $(JSON_A) $(XML_A) $(CSV_A) $(BP_A) $(API_A) $(LIBM_A) $(SYN_A) $(CAT_A) $(LIB_A) -Wl,--end-group \
-Wl,--start-group $(ED_A) $(GX_A) $(SD_A) $(TOML_A) $(JSON_A) $(XML_A) $(CSV_A) $(BP_A) $(SB_A) $(API_A) $(LIBM_A) $(SYN_A) $(CAT_A) $(LIB_A) -Wl,--end-group \
$(SDL2_LIBS) $(SDL2TTF_LIBS) -ldl -lm -rdynamic \
'-Wl,-rpath,$$ORIGIN'
@@ -443,7 +448,7 @@ $(BUILD)/editor_harness: tests/editor_harness.c $(SRCS) \
@mkdir -p $(BUILD)
$(CC) $(CFLAGS_DBG) \
-I$(ED_DIR)/include -I$(EDITOR_SRC) -I$(ED_DIR)/internal -I$(EW_DIR)/include -I$(EIMG_DIR)/include -I$(EFILES_DIR)/include -I$(GFX_INC) $(CAT_INCS) -I$(BP_DIR)/include \
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(EN_DIR)/include -I$(TOML_DIR)/include -I$(CV_DIR)/include -I$(B64_DIR)/include -I$(PPM_DIR)/include -I$(SYN_DIR)/include \
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(EN_DIR)/include -I$(TOML_DIR)/include -I$(CV_DIR)/include -I$(B64_DIR)/include -I$(PPM_DIR)/include -I$(SYN_DIR)/include -I$(SB_DIR)/include \
$(SRCS) \
$(EDITOR_SRC)/tb_editor.c $(EDITOR_SRC)/tb_stage_widget.c \
$(EDITOR_SRC)/tb_editor_modules.c \
@@ -452,7 +457,7 @@ $(BUILD)/editor_harness: tests/editor_harness.c $(SRCS) \
$(API_DIR)/src/tb_api.c $(LIBM_DIR)/src/tb_libman.c \
$(TOML_LIB_SRCS) $(TOML_DIR)/src/tb_toml.c \
$(foreach l,$(CAT_LIBS),$(LIBDIR)/tinyblocks-$(l)/src/tb_$(l).c) \
$(CV_DIR)/src/tb_curves.c $(B64_DIR)/src/tb_base64.c $(PPM_DIR)/src/tb_ppm.c $(SYN_DIR)/src/tb_syntax.c tests/editor_harness.c -o $@ -ldl -lm -rdynamic
$(CV_DIR)/src/tb_curves.c $(B64_DIR)/src/tb_base64.c $(PPM_DIR)/src/tb_ppm.c $(SYN_DIR)/src/tb_syntax.c $(SB_DIR)/src/tb_scratchblocks.c tests/editor_harness.c -o $@ -ldl -lm -rdynamic
test-editor: $(BUILD)/editor_harness ## Roda o harness headless do editor (ASan/UBSan)
./$(BUILD)/editor_harness
@@ -620,6 +625,15 @@ $(BUILD)/os_fs_test: tests/os_fs_test.c $(FS_DIR)/src/tb_fs.c $(LIBDIR)/tinybloc
test-os: $(BUILD)/os_fs_test ## Roda o teste de tinyblocks-os + pastas do tinyblocks-fs (ASan/UBSan)
./$(BUILD)/os_fs_test
$(BUILD)/scratchblocks_test: tests/scratchblocks_test.c $(SB_DIR)/src/tb_scratchblocks.c $(BP_LIB_SRCS)
@mkdir -p $(BUILD)
$(CC) $(CFLAGS_DBG) -I$(SB_DIR)/include -I$(BP_DIR)/include \
$(SB_DIR)/src/tb_scratchblocks.c $(BP_LIB_SRCS) tests/scratchblocks_test.c \
-o $@ -Wl,--start-group $(LIB_A) -Wl,--end-group $(EXTRA_TEST_LIBS)
test-scratchblocks: $(BUILD)/scratchblocks_test static ## Roda o teste da notação scratchblocks (ASan/UBSan)
./$(BUILD)/scratchblocks_test
$(BUILD)/input_test: tests/input_test.c $(LIBDIR)/tinyblocks-input/src/tb_input.c static
@mkdir -p $(BUILD)
$(CC) $(CFLAGS_DBG) -I$(LIBDIR)/tinyblocks-input/include -I$(GFX_INC) \