Prévia do scratchblocks antes de exportar, copiar para o fórum e colar

- "Exportar scratchblocks" abre uma prévia do texto (rolável) com Copiar
  (já com [scratchblocks]...[/scratchblocks]), Salvar... e Fechar.
- "Colar scratchblocks": um script copiado do fórum vira uma aba nova.
- graphics: área de transferência no contrato (tb_graphics_set_clipboard /
  tb_graphics_get_clipboard); o SDL2 usa a do sistema e o backend nulo,
  uma memória interna (testável 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:06:46 -03:00
1 parent d842890b0b
commit d9449a568e
6 files changed
+251 -11

No files matched your search

+16
View File
@@ -975,6 +975,16 @@ int main(void) {
CHECK(find("repita", R_WS, 0, &x, &y) || ws_has("repita"), "blocos importados aparecem (repita)");
if (need("Exportar", R_FLY, 0, &x, &y)) click(x, y);
if (need("Exportar scratchblocks", R_ANY, 0, &x, &y)) click(x, y);
frame(0, 0, 0, 0, 0, 0, NULL);
/* prévia: mostra o texto antes de exportar */
CHECK(find("when flag clicked", R_ANY, 0, &x, &y) && find("Copiar", R_ANY, 0, &x, &y),
"Exportar scratchblocks abre a prévia com o texto");
if (need("Copiar", R_ANY, 0, &x, &y)) click(x, y);
char* clip = tb_graphics_get_clipboard();
CHECK(clip && strstr(clip, "[scratchblocks]\nwhen flag clicked\n") && strstr(clip, "[/scratchblocks]"),
"Copiar põe o texto com [scratchblocks] na área de transferência");
free(clip);
if (need("Salvar...", R_ANY, 0, &x, &y)) click(x, y);
for (int i = 0; i < 40; i++) key(TB_KEY_BACKSPACE, 0, 0);
type(dst);
key(TB_KEY_RETURN, 0, 0);
@@ -984,6 +994,12 @@ int main(void) {
if (f) { size_t n = fread(got, 1, sizeof(got) - 1, f); got[n] = 0; fclose(f); }
CHECK(!strcmp(got, script), "Exportar scratchblocks gera o mesmo texto");
if (strcmp(got, script)) printf("---- exportado:\n%s----\n", got);
/* colar do fórum: a área de transferência vira uma aba */
tb_graphics_set_clipboard("[scratchblocks]\nwhen flag clicked\nerase all\n[/scratchblocks]\n");
if (need("Exportar", R_FLY, 0, &x, &y)) click(x, y);
if (need("Colar scratchblocks", R_ANY, 0, &x, &y)) click(x, y);
frame(0, 0, 0, 0, 0, 0, NULL);
CHECK(any_has("Importado: 1 script(s) de Colado"), "Colar scratchblocks importa da área de transferência");
remove(src); remove(dst);
}