summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-10-17 10:13:07 -0400
committerpommicket <pommicket@gmail.com>2023-10-17 10:13:07 -0400
commit13c10a7002fd25efc22d3f07f25f9bf693f83e89 (patch)
tree8fc2c1d5ba93d3dc0a8d05471b96d5978bffa212
parent00fd503614571387750faac33069d1f2e500d59c (diff)
sort key actions (new config system seems to be working!)
-rw-r--r--config.c9
-rw-r--r--ted-internal.h4
-rw-r--r--ted.c1
3 files changed, 10 insertions, 4 deletions
diff --git a/config.c b/config.c
index 267e2cc..34e37b9 100644
--- a/config.c
+++ b/config.c
@@ -837,10 +837,6 @@ static void config_parse_line(ConfigReader *reader, Config *cfg, char *line, FIL
}
} break;
}
- if (streq(setting_any->name, "text-size")) {
- config_set_u16(cfg, &setting_text_size_dpi_aware, (u16)roundf((float)integer * ted_get_ui_scaling(ted)));
- }
-
} break;
}
}
@@ -854,6 +850,11 @@ static int key_action_qsort_cmp_combo(const void *av, const void *bv) {
return 0;
}
+void settings_finalize(Ted *ted, Settings *settings) {
+ arr_qsort(settings->key_actions, key_action_qsort_cmp_combo);
+ settings->text_size = clamp_u16((u16)roundf((float)settings->text_size_no_dpi * ted_get_ui_scaling(ted)), TEXT_SIZE_MIN, TEXT_SIZE_MAX);
+}
+
static void config_read_file(Ted *ted, const char *cfg_path, const char ***include_stack) {
// check for, e.g. %include ted.cfg inside ted.cfg
arr_foreach_ptr(*include_stack, const char *, p_include) {
diff --git a/ted-internal.h b/ted-internal.h
index 0b53e6a..066c38c 100644
--- a/ted-internal.h
+++ b/ted-internal.h
@@ -484,6 +484,10 @@ void command_execute_ex(Ted *ted, Command c, const CommandArgument *argument, co
void config_read(Ted *ted, const char *filename);
void config_free_all(Ted *ted);
void config_merge_into(Settings *dest, const Config *src_cfg);
+/// call this after all your calls to \ref config_merge_into
+///
+/// (this sorts key actions, etc.)
+void settings_finalize(Ted *ted, Settings *settings);
bool config_applies_to(Config *cfg, const char *path, Language language);
/// higher-priority configs override lower-priority ones.
i32 config_priority(const Config *cfg);
diff --git a/ted.c b/ted.c
index 8262d4f..06c3db1 100644
--- a/ted.c
+++ b/ted.c
@@ -239,6 +239,7 @@ void ted_compute_settings(Ted *ted, const char *path, Language language, Setting
config_merge_into(settings, &ted->all_configs[*i]);
}
arr_free(applicable_configs);
+ settings_finalize(ted, settings);
}
Settings *ted_default_settings(Ted *ted) {