summaryrefslogtreecommitdiff
path: root/ted.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-11-03 14:48:51 -0400
committerpommicket <pommicket@gmail.com>2022-11-03 14:48:51 -0400
commit809ce7cdc95cd602223333b53761735238b5b48a (patch)
tree59f2ddd7cfcad5deae31761284518829297c470f /ted.c
parent609cdb6f0cc9f6f5d86366fbf60364f463cba551 (diff)
custom bg-shader
Diffstat (limited to 'ted.c')
-rw-r--r--ted.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/ted.c b/ted.c
index 2d19a02..5d82198 100644
--- a/ted.c
+++ b/ted.c
@@ -49,7 +49,21 @@ static void *ted_realloc(Ted *ted, void *p, size_t new_size) {
}
Settings *ted_active_settings(Ted *ted) {
- return ted->active_buffer ? buffer_settings(ted->active_buffer) : ted->default_settings;
+ if (ted->active_buffer)
+ return buffer_settings(ted->active_buffer);
+ Settings *settings = ted->default_settings;
+ int settings_score = 0;
+ arr_foreach_ptr(ted->all_settings, Settings, s) {
+ const SettingsContext *c = &s->context;
+ if (c->language != 0) continue;
+ if (!c->path || !str_has_prefix(ted->cwd, c->path)) continue;
+ int score = (int)strlen(c->path);
+ if (score > settings_score) {
+ settings = s;
+ settings_score = score;
+ }
+ }
+ return settings;
}
u32 ted_color(Ted *ted, ColorSetting color) {