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>
110 lines
3.9 KiB
C
110 lines
3.9 KiB
C
/*
|
|
* TinyBlocks - tb_editor_modules.h
|
|
* Carga dinamica das libraries privadas do editor (bundle) para permitir
|
|
* HOT RELOAD: recompile so a parte que mudou (make -C libraries/... ) e o
|
|
* editor em execucao recarrega o .so sem reiniciar.
|
|
*
|
|
* O estado da interface vive em Ed/Tab (no editor), por isso trocar o modulo
|
|
* nao perde nada: so os codigos das funcoes sao substituidos.
|
|
*/
|
|
#ifndef TB_EDITOR_MODULES_H
|
|
#define TB_EDITOR_MODULES_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <tinyblocks/tb_renderable_block.h>
|
|
#include <tb_editor_widgets.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct Ed;
|
|
struct Tab;
|
|
typedef struct Ed Ed;
|
|
typedef struct Tab Tab;
|
|
|
|
/* Visibilidade dos simbolos do editor usados pelos modulos */
|
|
#define TB_ED_API __attribute__((visibility("default")))
|
|
|
|
#define TB_ED_MODULE_MAX 8
|
|
|
|
/* API da library privada tinyblocks-editor-widgets */
|
|
typedef struct {
|
|
TbEwColor (*col_mul) (TbEwColor, float);
|
|
void (*fill_rect) (TinyBlocks_RenderableBlock*, float, float, float, float, TbEwColor);
|
|
void (*fill_rrect) (TinyBlocks_RenderableBlock*, float, float, float, float, float, TbEwColor);
|
|
void (*fill_circle) (TinyBlocks_RenderableBlock*, float, float, float, TbEwColor);
|
|
void (*stroke_rect) (TinyBlocks_RenderableBlock*, float, float, float, float, float, TbEwColor);
|
|
void (*stroke_circle)(TinyBlocks_RenderableBlock*, float, float, float, float, TbEwColor);
|
|
void (*line) (TinyBlocks_RenderableBlock*, float, float, float, float, float, TbEwColor);
|
|
void (*text_c) (TinyBlocks_RenderableBlock*, float, float, const char*, TbEwColor, float);
|
|
float (*text_width) (const char*, float);
|
|
bool (*in_rect) (float, float, float, float, float, float);
|
|
} TbEdWidgetsApi;
|
|
|
|
/* API da library privada tinyblocks-editor-image */
|
|
typedef struct {
|
|
void (*view) (Ed*, TinyBlocks_RenderableBlock*);
|
|
bool (*click) (Ed*, float, float);
|
|
void (*drag) (Ed*, float, float);
|
|
void (*release) (Ed*, float, float);
|
|
void (*load_file) (Ed*, const char*, int);
|
|
void (*save) (Ed*, const char*);
|
|
void (*ensure) (Ed*, Tab*);
|
|
void (*sel_reset) (Tab*);
|
|
void (*sel_commit)(Tab*);
|
|
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 */
|
|
void* handle;
|
|
int64_t mtime;
|
|
int ok;
|
|
} TbEdModule;
|
|
|
|
typedef struct {
|
|
TbEdModule list[TB_ED_MODULE_MAX];
|
|
TbEdWidgetsApi widgets;
|
|
int n;
|
|
TbEdImageApi image;
|
|
bool loaded;
|
|
int reloads;
|
|
char dir[512]; /* pasta dos modulos */
|
|
char info[160]; /* ultimo evento (status bar) */
|
|
} TbEdModules;
|
|
|
|
/* 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. */
|
|
bool tb_ed_modules_load(Ed* ed);
|
|
/* Verificacao barata (inotify/mtime): recarrega se algum .so mudou. */
|
|
bool tb_ed_modules_check(Ed* ed);
|
|
/* Esquece os modulos carregados (nao mexe no state do editor) */
|
|
void tb_ed_modules_clear(void);
|
|
/* Caminho de origem dos modulos (para mensagens/uso no Makefile) */
|
|
const char* tb_ed_modules_dir(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* TB_EDITOR_MODULES_H */
|