From 49de0d6e946f2b198af88ba245a2702f5b1122c6 Mon Sep 17 00:00:00 2001 From: baskerville Date: Wed, 15 Aug 2012 23:08:22 +0200 Subject: [PATCH] Keep current setting value on syntax error --- README.mkd | 2 +- events.c | 2 +- luautils.c | 4 +++- messages.c | 2 -- settings.c | 17 +++++++++++++---- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.mkd b/README.mkd index 4ee5342..e8e5c4c 100644 --- a/README.mkd +++ b/README.mkd @@ -54,7 +54,7 @@ ## Planned Features - Directional focus movement. -- Float individual windows (it means there will be a floating layer). +- Float individual windows. - Resize and move floating windows with the keyboard. - Resize and move floating windows on a regular magnetic grid (the granularity of the grid might be related to GCD(screen\_width, screen\_height)). - Double window borders. Rationale: with single borders, it might happen that the color of the window border is too close to the color of the window content to be visible. diff --git a/events.c b/events.c index d0a6467..90dd8be 100644 --- a/events.c +++ b/events.c @@ -14,7 +14,7 @@ void handle_event(xcb_generic_event_t *evt) PUTS("received a map request\n"); break; case XCB_UNGRAB_KEY: - PUTS("ungrab key received"); + /* PUTS("ungrab key received"); */ break; case XCB_KEY_PRESS: PUTS("keypress received"); diff --git a/luautils.c b/luautils.c index dd9ceda..16195d6 100644 --- a/luautils.c +++ b/luautils.c @@ -26,8 +26,10 @@ char *string_expr(lua_State *L, char *expr, char* fallback) if (eval_expr(L, expr) == 0) { if (lua_isstring(L, -1)) result = strdup(lua_tostring(L, -1)); - else + else if (fallback != NULL) result = strdup(fallback); + else + result = NULL; lua_pop(L, 1); } return result; diff --git a/messages.c b/messages.c index 04869e8..f88cb2f 100644 --- a/messages.c +++ b/messages.c @@ -26,6 +26,4 @@ void process_message(char *msg, char *rsp) } lua_close(L); - - /* strcpy(rsp, "hello\n"); */ } diff --git a/settings.c b/settings.c index 635decf..ab8c115 100644 --- a/settings.c +++ b/settings.c @@ -1,3 +1,5 @@ +#define _BSD_SOURCE + #include #include #include @@ -73,7 +75,7 @@ void get_setting(lua_State *L, char* rsp) void set_setting(lua_State *L) { - char *name; + char *name, *backup; if (!has_table(L, "set")) return; @@ -84,12 +86,19 @@ void set_setting(lua_State *L) return; if (strcmp(name, "inner_border_width") == 0) { - inner_border_width = int_expr(L, "set.value", INNER_BORDER_WIDTH); + inner_border_width = int_expr(L, "set.value", inner_border_width); } else if (strcmp(name, "normal_border_color") == 0) { + backup = strdup(normal_border_color); free(normal_border_color); - normal_border_color = string_expr(L, "set.value", NORMAL_BORDER_COLOR); + normal_border_color = string_expr(L, "set.value", backup); } else if (strcmp(name, "inner_border_color") == 0) { + backup = strdup(inner_border_color); free(inner_border_color); - inner_border_color = string_expr(L, "set.value", INNER_BORDER_COLOR); + inner_border_color = string_expr(L, "set.value", backup); + } else if (strcmp(name, "smart_surroundings") == 0) { + smart_surroundings = bool_expr(L, "set.value", smart_surroundings); } + + if (backup != NULL) + free(backup); }