mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-31 22:25:29 -04:00
opt: allow swith vt when no config
This commit is contained in:
parent
2e02987128
commit
e82fecaab6
1 changed files with 25 additions and 22 deletions
|
|
@ -954,28 +954,6 @@ void parse_config_line(Config *config, const char *line) {
|
|||
config->key_bindings_count++;
|
||||
}
|
||||
|
||||
// 计算默认按键绑定的数量
|
||||
size_t default_key_bindings_count =
|
||||
sizeof(default_key_bindings) / sizeof(KeyBinding);
|
||||
|
||||
// 重新分配内存以容纳新的默认按键绑定
|
||||
config->key_bindings =
|
||||
realloc(config->key_bindings,
|
||||
(config->key_bindings_count + default_key_bindings_count) *
|
||||
sizeof(KeyBinding));
|
||||
if (!config->key_bindings) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 将默认按键绑定复制到配置的按键绑定数组中
|
||||
for (size_t i = 0; i < default_key_bindings_count; i++) {
|
||||
config->key_bindings[config->key_bindings_count + i] =
|
||||
default_key_bindings[i];
|
||||
}
|
||||
|
||||
// 更新按键绑定的总数
|
||||
config->key_bindings_count += default_key_bindings_count;
|
||||
|
||||
} else if (strncmp(key, "mousebind", 9) == 0) {
|
||||
config->mouse_bindings =
|
||||
realloc(config->mouse_bindings,
|
||||
|
|
@ -1324,6 +1302,30 @@ void set_value_default() {
|
|||
memcpy(config.globalcolor, globalcolor, sizeof(globalcolor));
|
||||
}
|
||||
|
||||
void set_default_key_bindings(Config *config) {
|
||||
// 计算默认按键绑定的数量
|
||||
size_t default_key_bindings_count =
|
||||
sizeof(default_key_bindings) / sizeof(KeyBinding);
|
||||
|
||||
// 重新分配内存以容纳新的默认按键绑定
|
||||
config->key_bindings =
|
||||
realloc(config->key_bindings,
|
||||
(config->key_bindings_count + default_key_bindings_count) *
|
||||
sizeof(KeyBinding));
|
||||
if (!config->key_bindings) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 将默认按键绑定复制到配置的按键绑定数组中
|
||||
for (size_t i = 0; i < default_key_bindings_count; i++) {
|
||||
config->key_bindings[config->key_bindings_count + i] =
|
||||
default_key_bindings[i];
|
||||
}
|
||||
|
||||
// 更新按键绑定的总数
|
||||
config->key_bindings_count += default_key_bindings_count;
|
||||
}
|
||||
|
||||
void parse_config(void) {
|
||||
|
||||
char filename[1024];
|
||||
|
|
@ -1369,6 +1371,7 @@ void parse_config(void) {
|
|||
|
||||
set_value_default();
|
||||
parse_config_file(&config, filename);
|
||||
set_default_key_bindings(&config);
|
||||
override_config();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue