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:
@@ -85,6 +85,24 @@ void add_string_list(StringList *list, const char *str)
|
||||
list->count++;
|
||||
}
|
||||
|
||||
// 获取指定索引的字符串(只读)
|
||||
const char *string_list_get(const StringList *list, int index)
|
||||
{
|
||||
if (!list || index < 0 || index >= list->count)
|
||||
return NULL;
|
||||
return list->items[index];
|
||||
}
|
||||
|
||||
// 设置指定索引的字符串(复制新字符串并释放旧字符串)
|
||||
int string_list_set(StringList *list, int index, const char *str)
|
||||
{
|
||||
if (!list || index < 0 || index >= list->count || !str)
|
||||
return -1;
|
||||
free(list->items[index]);
|
||||
list->items[index] = _strdup(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 清空字符串列表
|
||||
void clear_string_list(StringList *list)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user