feat: 新增系统/用户变量分离、搜索、拖拽和清理功能

- 将单一列表拆分为系统和用户变量两个标签页
- 新增搜索框支持实时过滤路径
- 支持拖拽文件夹直接添加到列表
- 新增一键清理功能移除无效和重复路径
- 增加注册表备份机制和删除确认
- 优化界面布局和权限提示逻辑
This commit is contained in:
2026-03-16 19:58:41 +08:00
parent f21d302565
commit 39d06e20e0
15 changed files with 668 additions and 209 deletions
+20 -10
View File
@@ -4,17 +4,27 @@
#include <iup.h>
// 按钮回调
int btn_new_cb(Ihandle* self);
int btn_edit_cb(Ihandle* self);
int btn_browse_cb(Ihandle* self);
int btn_del_cb(Ihandle* self);
int btn_up_cb(Ihandle* self);
int btn_down_cb(Ihandle* self);
int btn_ok_cb(Ihandle* self);
int btn_cancel_cb(Ihandle* self);
int btn_help_cb(Ihandle* self);
int btn_new_cb(Ihandle *self);
int btn_edit_cb(Ihandle *self);
int btn_browse_cb(Ihandle *self);
int btn_del_cb(Ihandle *self);
int btn_up_cb(Ihandle *self);
int btn_down_cb(Ihandle *self);
int btn_clean_cb(Ihandle *self);
int btn_ok_cb(Ihandle *self);
int btn_cancel_cb(Ihandle *self);
int btn_help_cb(Ihandle *self);
// 搜索回调
int txt_search_cb(Ihandle *self);
// 双击回调
int list_dblclick_cb(Ihandle* self, int item, char* text);
int list_dblclick_cb(Ihandle *self, int item, char *text);
// 拖拽回调
int list_dropfiles_cb(Ihandle *self, const char *filename, int num, int x, int y);
// 键盘按键回调
int list_k_any_cb(Ihandle *self, int c);
#endif // CALLBACKS_H
+22 -2
View File
@@ -4,12 +4,15 @@
#include <iup.h>
// 注册表路径常量
#define REG_PATH L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
#define REG_PATH_SYS L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
#define REG_PATH_USER L"Environment"
#define REG_VALUE L"Path"
// 全局控件句柄声明
extern Ihandle *dlg; // 主对话框句柄
extern Ihandle *list_path; // 路径列表控件句柄
extern Ihandle *tabs_main; // 标签页容器
extern Ihandle *list_sys; // 系统变量列表
extern Ihandle *list_user; // 用户变量列表
extern Ihandle *lbl_status; // 状态标签句柄
extern Ihandle *btn_new; // 新增按钮句柄
extern Ihandle *btn_edit; // 编辑按钮句柄
@@ -17,8 +20,25 @@ extern Ihandle *btn_browse; // 浏览按钮句柄
extern Ihandle *btn_del; // 删除按钮句柄
extern Ihandle *btn_up; // 上移按钮句柄
extern Ihandle *btn_down; // 下移按钮句柄
extern Ihandle *btn_clean; // 一键清理按钮句柄
extern Ihandle *btn_ok; // 确认按钮句柄
extern Ihandle *btn_cancel; // 取消按钮句柄
extern Ihandle *btn_help; // 帮助按钮句柄
extern Ihandle *txt_search; // 搜索框
// 简单字符串列表结构,用于搜索缓存
typedef struct {
char **items;
int count;
int capacity;
} StringList;
extern StringList raw_sys_paths;
extern StringList raw_user_paths;
// 缓存操作函数声明
void init_string_list(StringList *list);
void add_string_list(StringList *list, const char *str);
void clear_string_list(StringList *list);
#endif // GLOBALS_H
+3 -3
View File
@@ -1,10 +1,10 @@
#ifndef REGISTRY_H
#define REGISTRY_H
// 从注册表加载PATH到列表控件
void load_path();
// 从注册表加载所有PATH到列表控件
void load_all_paths();
// 将列表控件中的PATH保存回注册表
void save_path();
void save_all_paths();
#endif // REGISTRY_H
+11
View File
@@ -3,6 +3,7 @@
#include <windows.h>
#include <wchar.h>
#include <iup.h>
// 宽字符转UTF-8
char* wide_to_utf8(const wchar_t* wstr);
@@ -13,7 +14,17 @@ wchar_t* utf8_to_wide(const char* str);
// 检查管理员权限
int check_admin();
// 检查路径是否有效(存在且为目录)
int is_path_valid(const char *path);
// 刷新列表样式(斑马纹)
void refresh_list_style();
void refresh_single_list_style(Ihandle *list);
// 备份注册表
void backup_registry();
// 不区分大小写的字符串查找
char *stristr(const char *haystack, const char *needle);
#endif // UTILS_H