editor: explorador de arquivos (tinyblocks-editor-files) para Abrir/Salvar
Nova library privada do bundle do editor (dlopen + hot reload) com um diálogo modal no lugar da barra de caminho: locais, trilha clicável, lista filtrada por extensão, campo de nome e confirmação ao substituir. - start_path() abre o explorador em todos os modos (projeto, exportar, imagem, código, .so); sem o módulo volta para a barra de caminho. - O switch do Enter virou path_commit(), usado pelos dois caminhos. - Estado em ed->fdlg para sobreviver à recarga do módulo. - Empacotado no AppImage; 6 cenários novos no harness headless. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
adf5d2cd12
commit
f0abc7593a
13 files changed
+1286
-46
No files matched your search
@@ -27,6 +27,7 @@
|
||||
#include <tb_syntax.h>
|
||||
#include <tb_editor_widgets.h>
|
||||
#include <tb_editor_image.h>
|
||||
#include <tb_editor_files.h>
|
||||
#include "../internal/tb_editor_modules.h"
|
||||
|
||||
#ifndef TB_EW_UNUSED
|
||||
@@ -482,6 +483,40 @@ enum { CM_DUPLICATE, CM_DELETE, CM_EDIT_DEF, CM_CLEANUP, CM_NEW_COMPOSITE,
|
||||
enum { PM_NONE, PM_LIB, PM_LOAD, PM_SAVE, PM_EXP_JSON, PM_EXP_XML, PM_EXP_CSV,
|
||||
PM_IMGLOAD, PM_IMSAVE, PM_IMADDR, PM_IMADDV, PM_CODELOAD, PM_CODESAVE };
|
||||
|
||||
/* Explorador de arquivos (library privada tinyblocks-editor-files).
|
||||
O estado vive aqui para sobreviver ao hot reload do modulo. */
|
||||
#define FD_PLACES 8
|
||||
typedef struct {
|
||||
char name[256];
|
||||
int is_dir; /* 0 = arquivo, 1 = pasta, 2 = ".." (pasta pai) */
|
||||
long long size;
|
||||
long long mtime;
|
||||
} FileEnt;
|
||||
|
||||
typedef struct {
|
||||
bool open;
|
||||
int mode; /* PM_* a executar ao confirmar */
|
||||
bool save; /* dialogo de salvar (pede substituir) */
|
||||
bool confirm; /* "ja existe, substituir?" visivel */
|
||||
bool all_files; /* ignora o filtro de extensoes */
|
||||
bool show_hidden;
|
||||
char dir[1024]; /* pasta atual (lembrada entre aberturas) */
|
||||
char name[256]; /* campo "Nome" */
|
||||
char def_name[256]; /* nome sugerido (volta apos entrar numa pasta) */
|
||||
char filter[96]; /* ".json .xml" - vazio = todos */
|
||||
char title[64];
|
||||
char ok_label[24];
|
||||
char err[192];
|
||||
FileEnt* ents; /* listagem (alocada pelo modulo) */
|
||||
int n, cap;
|
||||
int sel, scroll;
|
||||
int last_click_i;
|
||||
unsigned last_click_ms;
|
||||
char place_path[FD_PLACES][512];
|
||||
char place_label[FD_PLACES][40];
|
||||
int place_n;
|
||||
} FileDlg;
|
||||
|
||||
/* Formatos de exportacao */
|
||||
enum { EX_JSON, EX_XML, EX_CSV };
|
||||
|
||||
@@ -580,6 +615,7 @@ typedef struct Ed {
|
||||
char path_input_buf[512];
|
||||
int path_input_len;
|
||||
int path_mode; /* PM_* - o que fazer no Enter */
|
||||
FileDlg fdlg; /* explorador de arquivos (Abrir/Salvar) */
|
||||
|
||||
/* Gestor de libraries (tinyblocks-libman); a UI e desenhada aqui */
|
||||
bool libman_open;
|
||||
@@ -670,6 +706,8 @@ TB_ED_API void clip_set(Ed* ed, TinyBlocks_RenderableBlock* rb, float x, float y
|
||||
TB_ED_API void clip_clear(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
TB_ED_API void clip_restore(Ed* ed, TinyBlocks_RenderableBlock* rb);
|
||||
TB_ED_API void start_path(Ed* ed, int mode, const char* def);
|
||||
/* Executa a acao do modo PM_* sobre o caminho escolhido (barra ou explorador) */
|
||||
TB_ED_API void path_commit(Ed* ed, int mode, const char* path);
|
||||
|
||||
/* Aba de imagem: library privada carregada por dlopen (hot reload).
|
||||
As chamadas passam pela tabela tb_ed_img, entao trocar o .so em execucao
|
||||
@@ -699,6 +737,25 @@ TB_ED_API void start_path(Ed* ed, int mode, const char* def);
|
||||
# define image_zoom tb_ed_img.zoom
|
||||
#endif
|
||||
|
||||
/* Explorador de arquivos: library privada carregada por dlopen */
|
||||
#ifdef TB_EDITOR_FILES_BUILD
|
||||
# define files_open tb_editor_files_open
|
||||
# define files_close tb_editor_files_close
|
||||
# define files_view tb_editor_files_view
|
||||
# define files_click tb_editor_files_click
|
||||
# define files_key tb_editor_files_key
|
||||
# define files_text tb_editor_files_text
|
||||
# define files_scroll tb_editor_files_scroll
|
||||
#else
|
||||
# define files_open tb_ed_files.open
|
||||
# define files_close tb_ed_files.close
|
||||
# define files_view tb_ed_files.view
|
||||
# define files_click tb_ed_files.click
|
||||
# define files_key tb_ed_files.key
|
||||
# define files_text tb_ed_files.text
|
||||
# define files_scroll tb_ed_files.scroll
|
||||
#endif
|
||||
|
||||
/* Configuracoes (settings) - UI desenhada pelo editor */
|
||||
void settings_show(Ed* ed);
|
||||
void settings_click(Ed* ed, float mx, float my);
|
||||
|
||||
@@ -57,6 +57,17 @@ typedef struct {
|
||||
void (*zoom) (Ed*, float, float, int); /* roda do mouse = zoom */
|
||||
} TbEdImageApi;
|
||||
|
||||
/* API da library privada tinyblocks-editor-files (explorador de arquivos) */
|
||||
typedef struct {
|
||||
void (*open) (Ed*, int, const char*);
|
||||
void (*close) (Ed*);
|
||||
void (*view) (Ed*, TinyBlocks_RenderableBlock*);
|
||||
bool (*click) (Ed*, float, float);
|
||||
void (*key) (Ed*, int, bool);
|
||||
void (*text) (Ed*, const char*);
|
||||
void (*scroll)(Ed*, float);
|
||||
} TbEdFilesApi;
|
||||
|
||||
typedef struct {
|
||||
const char* name; /* tinyblocks-editor-image */
|
||||
const char* file; /* libtinyblocks-editor-image.so */
|
||||
@@ -79,6 +90,7 @@ typedef struct {
|
||||
/* Tabelas vivas: o editor chama por aqui, entao a troca e instantanea */
|
||||
TB_ED_API extern TbEdImageApi tb_ed_img;
|
||||
TB_ED_API extern TbEdWidgetsApi tb_ed_w;
|
||||
TB_ED_API extern TbEdFilesApi tb_ed_files;
|
||||
|
||||
/* Carrega (ou recarrega) os modulos. Sempre que um .so muda de mtime
|
||||
recarrega todos os modulos, na ordem. Retorna true se algo foi carregado. */
|
||||
|
||||
Reference in new issue
Block a user