mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-10 10:19:47 +08:00
e777b26879
修复JSON导入时转义字符处理不完整的问题,添加对\b、\f等控制字符的转义 改进备份目录创建逻辑,使用SHCreateDirectoryExW递归创建目录 修复内存分配失败处理,避免空指针解引用 修正选项卡标题设置位置,从Dialog改为Tabs控件 增强导入功能,支持TXT文件导入时选择目标变量类型 优化清理无效路径算法,使用标记数组减少内存移动 修复宽字符环境变量设置,使用_wputenv_s替代putenv 添加导入数据初始化,防止未初始化内存访问 改进文件属性检查,使用宽字符API支持Unicode路径
82 lines
2.3 KiB
C
82 lines
2.3 KiB
C
#include "controller/callbacks.h"
|
|
#include "controller/callbacks_internal.h"
|
|
#include "core/app_context.h"
|
|
#include "core/lua_config.h"
|
|
#include "utils/string_ext.h"
|
|
#include "utils/safe_string.h"
|
|
#include "utils/ui_constants.h"
|
|
#include "ui/ui_utils.h"
|
|
#include <string.h>
|
|
#include <windows.h>
|
|
|
|
// 搜索回调
|
|
int txt_search_cb(Ihandle *self)
|
|
{
|
|
Ihandle *dlg = IupGetDialog(self);
|
|
char *filter = IupGetAttribute(self, "VALUE");
|
|
if (!filter)
|
|
return IUP_DEFAULT;
|
|
|
|
Ihandle *current_list = get_current_list(dlg);
|
|
StringList *raw_data = get_current_raw_data(dlg);
|
|
|
|
IupSetAttribute(current_list, "REMOVEITEM", "ALL");
|
|
|
|
int count = 0;
|
|
for (int i = 0; i < raw_data->count; i++)
|
|
{
|
|
const char *item = string_list_get(raw_data, i);
|
|
if (strlen(filter) == 0 || stristr(item, filter) != NULL)
|
|
{
|
|
count++;
|
|
IupSetAttributeId(current_list, "", count, item);
|
|
}
|
|
}
|
|
|
|
IupSetInt(current_list, "COUNT", count);
|
|
refresh_single_list_style(current_list);
|
|
|
|
return IUP_DEFAULT;
|
|
}
|
|
|
|
// 拖拽回调
|
|
int list_dropfiles_cb(Ihandle *self, const char *filename, int num, int x, int y)
|
|
{
|
|
Ihandle *dlg = IupGetDialog(self);
|
|
Ihandle *current_list = self;
|
|
AppContext *ctx = get_app_context_from_dlg(dlg);
|
|
if (!ctx)
|
|
return IUP_DEFAULT;
|
|
|
|
StringList *raw_data = NULL;
|
|
if (self == IupGetDialogChild(dlg, CTRL_LIST_SYS))
|
|
raw_data = &ctx->sys_paths;
|
|
else if (self == IupGetDialogChild(dlg, CTRL_LIST_USER))
|
|
raw_data = &ctx->user_paths;
|
|
else
|
|
return IUP_DEFAULT;
|
|
|
|
wchar_t *wfilename = utf8_to_wide(filename);
|
|
DWORD attr = wfilename ? GetFileAttributesW(wfilename) : INVALID_FILE_ATTRIBUTES;
|
|
free(wfilename);
|
|
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
|
|
{
|
|
Ihandle *txt_search = IupGetDialogChild(dlg, CTRL_TXT_SEARCH);
|
|
if (txt_search)
|
|
IupSetAttribute(txt_search, "VALUE", "");
|
|
|
|
add_string_list(raw_data, filename);
|
|
sync_string_list_to_ui(current_list, raw_data);
|
|
|
|
IupSetInt(current_list, "VALUE", raw_data->count);
|
|
}
|
|
else
|
|
{
|
|
Ihandle *lbl_status = IupGetDialogChild(dlg, CTRL_LBL_STATUS);
|
|
if (lbl_status)
|
|
IupSetAttribute(lbl_status, "TITLE", lua_config_get_string("status", "drag_folder_only"));
|
|
}
|
|
|
|
return IUP_DEFAULT;
|
|
}
|