diff options
author | koekeishiya <aasvi93@hotmail.com> | 2018-01-07 17:41:00 +0100 |
---|---|---|
committer | koekeishiya <aasvi93@hotmail.com> | 2018-01-07 17:41:00 +0100 |
commit | 91005ef2ff5a122fddfddd8bccda9563604f5036 (patch) | |
tree | 5ed1754916a7af47743834c3e5091ad269f68e83 /src/parse.c | |
parent | 99796390fe760a650270e9bf292b9a2a2e051282 (diff) | |
download | skhd-91005ef2ff5a122fddfddd8bccda9563604f5036.tar.gz skhd-91005ef2ff5a122fddfddd8bccda9563604f5036.zip |
#15 modal cleanup
Diffstat (limited to '')
-rw-r--r-- | src/parse.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/parse.c b/src/parse.c index 09983f8..6f3d477 100644 --- a/src/parse.c +++ b/src/parse.c @@ -15,8 +15,13 @@ internal struct mode * init_default_mode(struct parser *parser) { - struct mode *default_mode = malloc(sizeof(struct mode)); + struct mode *default_mode; + if ((default_mode = table_find(parser->mode_map, "default"))) { + return default_mode; + } + + default_mode = malloc(sizeof(struct mode)); default_mode->line = -1; default_mode->cursor = -1; default_mode->name = copy_string("default"); @@ -173,7 +178,7 @@ parse_mode(struct parser *parser, struct hotkey *hotkey) free(name); if (!mode && token_equals(identifier, "default")) { - mode = init_default_mode(parser); + mode = find_or_init_default_mode(parser); } if (!mode) { @@ -216,11 +221,7 @@ parse_hotkey(struct parser *parser) goto err; } } else { - hotkey->mode_list[hotkey->mode_count] = table_find(parser->mode_map, "default"); - if (!hotkey->mode_list[hotkey->mode_count]) { - hotkey->mode_list[hotkey->mode_count] = init_default_mode(parser); - } - hotkey->mode_count++; + hotkey->mode_list[hotkey->mode_count++] = find_or_init_default_mode(parser); } if ((found_modifier = parser_match(parser, Token_Modifier))) { @@ -267,7 +268,6 @@ parse_hotkey(struct parser *parser) } printf("}\n"); - return hotkey; err: |