diff options
-rw-r--r-- | buffer.c | 10 | ||||
-rw-r--r-- | config.c | 14 | ||||
-rw-r--r-- | ted.cfg | 10 | ||||
-rw-r--r-- | ted.h | 2 | ||||
-rw-r--r-- | ui.c | 4 | ||||
-rw-r--r-- | util.c | 2 |
6 files changed, 26 insertions, 16 deletions
@@ -277,13 +277,15 @@ static long context_score(const char *path, Language lang, const SettingsContext long score = 0; if (lang == context->language) { - score += 100000; + score += 10000; } if (context->path) { - int i; - for (i = 0; i < TED_PATH_MAX && path[i] == context->path[i]; ++i); - score += i; + if (path && str_has_prefix(path, context->path)) { + score += (long)strlen(context->path); + } else { + score -= 100000; + } } return score; @@ -35,7 +35,7 @@ static bool context_is_parent(const SettingsContext *parent, const SettingsConte if (parent->path) { if (!child->path) return false; - if (!str_is_prefix(parent->path, child->path)) + if (!str_has_prefix(child->path, parent->path)) return false; } return true; @@ -74,21 +74,21 @@ static u32 config_parse_key_combo(ConfigReader *cfg, char const *str) { u32 modifier = 0; // read modifier while (true) { - if (str_is_prefix(str, "Ctrl+")) { + if (str_has_prefix(str, "Ctrl+")) { if (modifier & KEY_MODIFIER_CTRL) { config_err(cfg, "Ctrl+ written twice"); return 0; } modifier |= KEY_MODIFIER_CTRL; str += strlen("Ctrl+"); - } else if (str_is_prefix(str, "Shift+")) { + } else if (str_has_prefix(str, "Shift+")) { if (modifier & KEY_MODIFIER_SHIFT) { config_err(cfg, "Shift+ written twice"); return 0; } modifier |= KEY_MODIFIER_SHIFT; str += strlen("Shift+"); - } else if (str_is_prefix(str, "Alt+")) { + } else if (str_has_prefix(str, "Alt+")) { if (modifier & KEY_MODIFIER_ALT) { config_err(cfg, "Alt+ written twice"); return 0; @@ -548,7 +548,7 @@ static void config_parse_line(ConfigReader *cfg, Settings *settings, const Confi // lines like Ctrl+Down = 10 :down u32 key_combo = config_parse_key_combo(cfg, key); KeyAction *action = &settings->key_actions[key_combo]; - llong argument = 1; + llong argument = 1; // default argument = 1 if (isdigit(*value)) { // read the argument char *endp; @@ -733,7 +733,7 @@ void config_parse(Ted *ted, ConfigPart **pparts) { --parent; if (context_is_parent(&parent->context, &part->context)) { // copy parent's settings - settings_copy(settings, parent->settings); + settings_copy(settings, &ted->all_settings[parent->settings]); break; } } @@ -741,7 +741,7 @@ void config_parse(Ted *ted, ConfigPart **pparts) { context_free(&settings->context); context_copy(&settings->context, &part->context); } - part->settings = settings; + part->settings = arr_len(ted->all_settings) - 1; arr_add(part->text, '\0'); // null termination @@ -234,7 +234,7 @@ Python = .py Tex = .tex Markdown = .md HTML = .html, .php, .xml, .xhtml, .iml -Config = .cfg +Config = .cfg, .toml Javascript = .js Java = .java Go = .go @@ -242,3 +242,11 @@ Go = .go # You can add language-specific settings like this: # [HTML.core] # tab-width = 2 + +# Or path-specific settings like this: +# [/path/to/special/project//colors] +# keyword = #f0f + +# Or both! +# [/path/to/special/project//Javascript.keyboard] +# Ctrl+J = "function() {" :insert-text @@ -196,7 +196,7 @@ typedef struct { char *file; u32 line; char *text; - Settings *settings; // only used in config_parse + u32 settings; // index into ted->all_settings. only used in config_parse } ConfigPart; // this refers to replacing prev_len characters (found in prev_text) at pos with new_len characters @@ -197,8 +197,8 @@ static int qsort_file_entry_cmp(void *search_termv, void const *av, void const * return +1; } if (search_term) { - bool a_prefix = str_is_prefix(a->name, search_term); - bool b_prefix = str_is_prefix(b->name, search_term); + bool a_prefix = str_has_prefix(a->name, search_term); + bool b_prefix = str_has_prefix(b->name, search_term); if (a_prefix && !b_prefix) { return -1; } @@ -61,7 +61,7 @@ static char32_t const *util_mem32chr_const(char32_t const *s, char32_t c, size_t return NULL; } -static bool str_is_prefix(char const *str, char const *prefix) { +static bool str_has_prefix(char const *str, char const *prefix) { return strncmp(str, prefix, strlen(prefix)) == 0; } |