mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-10 02:09:46 +08:00
refactor(controller): 拆分回调函数到模块化文件并添加字符串列表访问器
- 将 callbacks.c 拆分为多个按功能分类的文件(callbacks_basic.c、callbacks_nav.c、callbacks_search.c、callbacks_io.c、callbacks_sys.c) - 新增 callbacks_internal.h 提供内部辅助函数声明,减少代码重复 - 在 string_ext 模块中添加 string_list_get 和 string_list_set 安全访问器函数 - 更新 CMakeLists.txt 和 ui_utils.c 以使用新的模块结构和访问器 - 重构旨在提高代码可维护性和可读性,便于后续功能扩展
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#ifndef CALLBACKS_INTERNAL_H
|
||||
#define CALLBACKS_INTERNAL_H
|
||||
|
||||
#include <iup.h>
|
||||
#include "core/app_context.h"
|
||||
|
||||
// 内部辅助函数声明(供各 callbacks_*.c 文件共享)
|
||||
// 这些函数不对外暴露,仅在 controller 层内部使用
|
||||
|
||||
// 获取主对话框句柄
|
||||
Ihandle *get_main_dlg(void);
|
||||
|
||||
// 从对话框获取应用上下文
|
||||
AppContext *get_app_context_from_dlg(Ihandle *dlg);
|
||||
|
||||
// 获取当前活动的数据列表(根据 Tab 页切换)
|
||||
StringList *get_current_raw_data(Ihandle *dlg);
|
||||
|
||||
// 获取当前活动的列表 UI 控件
|
||||
Ihandle *get_current_list(Ihandle *dlg);
|
||||
|
||||
#endif // CALLBACKS_INTERNAL_H
|
||||
@@ -16,6 +16,12 @@ void init_string_list(StringList *list);
|
||||
void add_string_list(StringList *list, const char *str);
|
||||
void clear_string_list(StringList *list);
|
||||
|
||||
// 访问器函数 - 安全访问内部数据
|
||||
// 获取指定索引的字符串(只读),越界返回 NULL
|
||||
const char *string_list_get(const StringList *list, int index);
|
||||
// 设置指定索引的字符串(会复制新字符串并释放旧字符串),越界返回 -1,成功返回 0
|
||||
int string_list_set(StringList *list, int index, const char *str);
|
||||
|
||||
// 字符串转换函数
|
||||
char *wide_to_utf8(const wchar_t *wstr);
|
||||
wchar_t *utf8_to_wide(const char *str);
|
||||
|
||||
Reference in New Issue
Block a user