mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-06 06:46:54 -04:00
feat: set active_config in static var to handle reload
This commit is contained in:
parent
75b91d64be
commit
3749c318da
1 changed files with 11 additions and 2 deletions
|
|
@ -2943,6 +2943,8 @@ void set_default_key_bindings(Config *config) {
|
||||||
config->key_bindings_count += default_key_bindings_count;
|
config->key_bindings_count += default_key_bindings_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *active_config_path = NULL;
|
||||||
|
|
||||||
void parse_config(const char *cli_config_file) {
|
void parse_config(const char *cli_config_file) {
|
||||||
|
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
|
|
@ -2988,8 +2990,13 @@ void parse_config(const char *cli_config_file) {
|
||||||
strcpy(config.keymode, "default");
|
strcpy(config.keymode, "default");
|
||||||
|
|
||||||
create_config_keymap();
|
create_config_keymap();
|
||||||
|
|
||||||
if (cli_config_path != NULL) {
|
if (cli_config_path != NULL) {
|
||||||
|
if (active_config_path) free(active_config_path);
|
||||||
|
active_config_path = strdup(cli_config_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active_config_path != NULL) {
|
||||||
snprintf(filename, sizeof(filename), "%s", cli_config_path);
|
snprintf(filename, sizeof(filename), "%s", cli_config_path);
|
||||||
} else {
|
} else {
|
||||||
// 获取 MANGOCONFIG 环境变量
|
// 获取 MANGOCONFIG 环境变量
|
||||||
|
|
@ -3017,6 +3024,8 @@ void parse_config(const char *cli_config_file) {
|
||||||
// 使用 MANGOCONFIG 环境变量作为配置文件夹路径
|
// 使用 MANGOCONFIG 环境变量作为配置文件夹路径
|
||||||
snprintf(filename, sizeof(filename), "%s/config.conf", mangoconfig);
|
snprintf(filename, sizeof(filename), "%s/config.conf", mangoconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
active_config_path = strdup(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
set_value_default();
|
set_value_default();
|
||||||
|
|
@ -3234,7 +3243,7 @@ void reset_option(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int reload_config(const Arg *arg) {
|
int reload_config(const Arg *arg) {
|
||||||
parse_config();
|
parse_config(NULL);
|
||||||
reset_option();
|
reset_option();
|
||||||
printstatus();
|
printstatus();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue