Files
Serendipity 485d16a180 feat(tooltip): 添加环境变量展开预览悬停提示
- 新增 expand_env_vars 函数,调用 ExpandEnvironmentStringsA 展开 %VAR%
- sync_string_list_to_ui 中对含 % 的路径设置 ITEMTIP 属性
- 鼠标悬停时显示展开后的完整路径

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 23:45:58 +08:00

38 lines
1.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef STRING_EXT_H
#define STRING_EXT_H
#include <wchar.h>
// 简单字符串列表结构
typedef struct
{
char **items;
int count;
int capacity;
} StringList;
// 字符串列表
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);
char *stristr(const char *haystack, const char *needle);
// 检查字符串列表中是否存在指定路径(不区分大小写)
int string_list_contains(const StringList *list, const char *str);
// 展开环境变量(如 %JAVA_HOME%\bin → C:\Java\bin
// 返回 malloc 分配的字符串,调用者负责释放;无变量返回 NULL
char *expand_env_vars(const char *path);
#endif // STRING_EXT_H